use of com.axelor.apps.production.db.ProdProduct in project axelor-open-suite by axelor.
the class ManufOrderStockMoveService method createToProduceStockMove.
public void createToProduceStockMove(ManufOrder manufOrder) throws AxelorException {
Company company = manufOrder.getCompany();
if (manufOrder.getToProduceProdProductList() != null && company != null) {
StockMove stockMove = this._createToProduceStockMove(manufOrder, company);
for (ProdProduct prodProduct : manufOrder.getToProduceProdProductList()) {
BigDecimal productCostPrice = prodProduct.getProduct() != null ? (BigDecimal) productCompanyService.get(prodProduct.getProduct(), "costPrice", manufOrder.getCompany()) : BigDecimal.ZERO;
this._createStockMoveLine(prodProduct, stockMove, StockMoveLineService.TYPE_OUT_PRODUCTIONS, prodProduct.getQty(), productCostPrice);
}
if (stockMove.getStockMoveLineList() != null && !stockMove.getStockMoveLineList().isEmpty()) {
stockMoveService.plan(stockMove);
manufOrder.addOutStockMoveListItem(stockMove);
}
if (stockMove.getStockMoveLineList() != null) {
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
manufOrder.addProducedStockMoveLineListItem(stockMoveLine);
}
}
}
}
use of com.axelor.apps.production.db.ProdProduct in project axelor-open-suite by axelor.
the class ManufOrderStockMoveService method createToConsumeStockMove.
public void createToConsumeStockMove(ManufOrder manufOrder) throws AxelorException {
Company company = manufOrder.getCompany();
SupplyChainConfig supplyChainConfig = supplyChainConfigService.getSupplyChainConfig(company);
if (manufOrder.getToConsumeProdProductList() != null && company != null) {
StockMove stockMove = this._createToConsumeStockMove(manufOrder, company);
for (ProdProduct prodProduct : manufOrder.getToConsumeProdProductList()) {
this._createStockMoveLine(prodProduct, stockMove, StockMoveLineService.TYPE_IN_PRODUCTIONS);
}
if (stockMove.getStockMoveLineList() != null && !stockMove.getStockMoveLineList().isEmpty()) {
stockMoveService.plan(stockMove);
if (supplyChainConfig.getAutoRequestReservedQtyOnManufOrder()) {
requestStockReservation(stockMove);
}
manufOrder.addInStockMoveListItem(stockMove);
}
// case where we had to split tracked stock move lines
if (stockMove.getStockMoveLineList() != null) {
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
manufOrder.addConsumedStockMoveLineListItem(stockMoveLine);
}
}
}
}
use of com.axelor.apps.production.db.ProdProduct in project axelor-open-suite by axelor.
the class OperationOrderServiceImpl method createToConsumeProdProductList.
@Override
public void createToConsumeProdProductList(OperationOrder operationOrder) {
BigDecimal manufOrderQty = operationOrder.getManufOrder().getQty();
BigDecimal bomQty = operationOrder.getManufOrder().getBillOfMaterial().getQty();
ProdProcessLine prodProcessLine = operationOrder.getProdProcessLine();
if (prodProcessLine.getToConsumeProdProductList() != null) {
for (ProdProduct prodProduct : prodProcessLine.getToConsumeProdProductList()) {
BigDecimal qty = Beans.get(ManufOrderService.class).computeToConsumeProdProductLineQuantity(bomQty, manufOrderQty, prodProduct.getQty());
operationOrder.addToConsumeProdProductListItem(new ProdProduct(prodProduct.getProduct(), qty, prodProduct.getUnit()));
}
}
}
use of com.axelor.apps.production.db.ProdProduct in project axelor-open-suite by axelor.
the class OperationOrderStockMoveService method createNewConsumedStockMoveLineList.
/**
* Clear the consumed list and create a new one with the right quantity.
*
* @param operationOrder
* @param qtyToUpdate
*/
public void createNewConsumedStockMoveLineList(OperationOrder operationOrder, BigDecimal qtyToUpdate) throws AxelorException {
ManufOrderStockMoveService manufOrderStockMoveService = Beans.get(ManufOrderStockMoveService.class);
// find planned stock move
Optional<StockMove> stockMoveOpt = manufOrderStockMoveService.getPlannedStockMove(operationOrder.getInStockMoveList());
if (!stockMoveOpt.isPresent()) {
return;
}
StockMove stockMove = stockMoveOpt.get();
stockMoveService.cancel(stockMove);
// clear all lists from planned lines
operationOrder.getConsumedStockMoveLineList().removeIf(stockMoveLine -> stockMoveLine.getStockMove().getStatusSelect() == StockMoveRepository.STATUS_CANCELED);
stockMove.clearStockMoveLineList();
// create a new list
for (ProdProduct prodProduct : operationOrder.getToConsumeProdProductList()) {
BigDecimal qty = manufOrderStockMoveService.getFractionQty(operationOrder.getManufOrder(), prodProduct, qtyToUpdate);
manufOrderStockMoveService._createStockMoveLine(prodProduct, stockMove, StockMoveLineService.TYPE_IN_PRODUCTIONS, qty);
// Update consumed StockMoveLineList with created stock move lines
stockMove.getStockMoveLineList().stream().filter(stockMoveLine1 -> !operationOrder.getConsumedStockMoveLineList().contains(stockMoveLine1)).forEach(operationOrder::addConsumedStockMoveLineListItem);
}
stockMoveService.plan(stockMove);
}
use of com.axelor.apps.production.db.ProdProduct in project axelor-open-suite by axelor.
the class ManufOrderController method multiLevelManufOrderOnLoad.
/**
* Called from manuf order form, on clicking "Multi-level planning" button.
*
* @param request
* @param response
*/
public void multiLevelManufOrderOnLoad(ActionRequest request, ActionResponse response) {
try {
Long moId = Long.valueOf(request.getContext().get("id").toString());
ManufOrder mo = Beans.get(ManufOrderRepository.class).find(moId);
boolean showOnlyMissingQty = request.getContext().get("_showOnlyMissingQty") != null && Boolean.parseBoolean(request.getContext().get("_showOnlyMissingQty").toString());
ProdProductProductionRepository prodProductProductionRepository = Beans.get(ProdProductProductionRepository.class);
List<ProdProduct> prodProducts = mo.getToConsumeProdProductList().stream().filter(prodProduct -> prodProduct.getProduct().getProductSubTypeSelect() == ProductRepository.PRODUCT_SUB_TYPE_FINISHED_PRODUCT || prodProduct.getProduct().getProductSubTypeSelect() == ProductRepository.PRODUCT_SUB_TYPE_SEMI_FINISHED_PRODUCT).filter(prodProduct -> !showOnlyMissingQty || prodProductProductionRepository.computeMissingQty(prodProduct.getProduct().getId(), prodProduct.getQty(), moId).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
response.setValue("$components", prodProducts);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations