use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class ManufOrderServiceImpl method updateStockMoveFromManufOrder.
@Override
public void updateStockMoveFromManufOrder(List<StockMoveLine> stockMoveLineList, StockMove stockMove) throws AxelorException {
if (stockMoveLineList == null) {
return;
}
// add missing lines in stock move
stockMoveLineList.stream().filter(stockMoveLine -> stockMoveLine.getStockMove() == null).forEach(stockMove::addStockMoveLineListItem);
// remove lines in stock move removed in manuf order
if (stockMove.getStockMoveLineList() != null) {
stockMove.getStockMoveLineList().removeIf(stockMoveLine -> !stockMoveLineList.contains(stockMoveLine));
}
StockMoveService stockMoveService = Beans.get(StockMoveService.class);
// update stock location by cancelling then planning stock move.
stockMoveService.cancel(stockMove);
stockMoveService.plan(stockMove);
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class ManufOrderStockMoveService method createNewProducedStockMoveLineList.
/**
* Clear the produced list and create a new one with the right quantity.
*
* @param manufOrder
* @param qtyToUpdate
*/
public void createNewProducedStockMoveLineList(ManufOrder manufOrder, BigDecimal qtyToUpdate) throws AxelorException {
Optional<StockMove> stockMoveOpt = getPlannedStockMove(manufOrder.getOutStockMoveList());
if (!stockMoveOpt.isPresent()) {
return;
}
StockMove stockMove = stockMoveOpt.get();
stockMoveService.cancel(stockMove);
// clear all lists
manufOrder.getProducedStockMoveLineList().removeIf(stockMoveLine -> stockMoveLine.getStockMove().getStatusSelect() == StockMoveRepository.STATUS_CANCELED);
stockMove.clearStockMoveLineList();
// create a new list
for (ProdProduct prodProduct : manufOrder.getToProduceProdProductList()) {
BigDecimal qty = getFractionQty(manufOrder, prodProduct, qtyToUpdate);
BigDecimal productCostPrice = prodProduct.getProduct() != null ? (BigDecimal) productCompanyService.get(prodProduct.getProduct(), "costPrice", manufOrder.getCompany()) : BigDecimal.ZERO;
_createStockMoveLine(prodProduct, stockMove, StockMoveLineService.TYPE_OUT_PRODUCTIONS, qty, productCostPrice);
// Update produced StockMoveLineList with created stock move lines
stockMove.getStockMoveLineList().stream().filter(stockMoveLine1 -> !manufOrder.getProducedStockMoveLineList().contains(stockMoveLine1)).forEach(manufOrder::addProducedStockMoveLineListItem);
}
stockMoveService.plan(stockMove);
}
use of com.axelor.apps.stock.db.StockMoveLine 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.stock.db.StockMoveLine 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.stock.db.StockMoveLine 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);
}
Aggregations