use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveLineController method setAvailableStatus.
public void setAvailableStatus(ActionRequest request, ActionResponse response) {
StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
Beans.get(StockMoveLineService.class).setAvailableStatus(stockMoveLine);
response.setValue("availableStatus", stockMoveLine.getAvailableStatus());
response.setValue("availableStatusSelect", stockMoveLine.getAvailableStatusSelect());
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveLineController method setProductInfo.
public void setProductInfo(ActionRequest request, ActionResponse response) {
StockMoveLine stockMoveLine;
try {
stockMoveLine = request.getContext().asType(StockMoveLine.class);
StockMove stockMove = stockMoveLine.getStockMove();
if (stockMove == null) {
stockMove = request.getContext().getParent().asType(StockMove.class);
}
if (stockMoveLine.getProduct() == null) {
stockMoveLine = new StockMoveLine();
response.setValues(Mapper.toMap(stockMoveLine));
return;
}
Beans.get(StockMoveLineService.class).setProductInfo(stockMove, stockMoveLine, stockMove.getCompany());
response.setValues(stockMoveLine);
} catch (Exception e) {
stockMoveLine = new StockMoveLine();
response.setValues(Mapper.toMap(stockMoveLine));
TraceBackService.trace(response, e, ResponseMessageType.INFORMATION);
}
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class ManufOrderStockMoveService method createNewConsumedStockMoveLineList.
/**
* Clear the consumed list and create a new one with the right quantity.
*
* @param manufOrder
* @param qtyToUpdate
*/
public void createNewConsumedStockMoveLineList(ManufOrder manufOrder, BigDecimal qtyToUpdate) throws AxelorException {
// find planned stock move
Optional<StockMove> stockMoveOpt = getPlannedStockMove(manufOrder.getInStockMoveList());
if (!stockMoveOpt.isPresent()) {
return;
}
StockMove stockMove = stockMoveOpt.get();
stockMoveService.cancel(stockMove);
// clear all lists from planned lines
manufOrder.getConsumedStockMoveLineList().removeIf(stockMoveLine -> stockMoveLine.getStockMove().getStatusSelect() == StockMoveRepository.STATUS_CANCELED);
stockMove.clearStockMoveLineList();
// create a new list
for (ProdProduct prodProduct : manufOrder.getToConsumeProdProductList()) {
BigDecimal qty = getFractionQty(manufOrder, prodProduct, qtyToUpdate);
_createStockMoveLine(prodProduct, stockMove, StockMoveLineService.TYPE_IN_PRODUCTIONS, qty);
// Update consumed StockMoveLineList with created stock move lines
stockMove.getStockMoveLineList().stream().filter(stockMoveLine1 -> !manufOrder.getConsumedStockMoveLineList().contains(stockMoveLine1)).forEach(manufOrder::addConsumedStockMoveLineListItem);
}
stockMoveService.plan(stockMove);
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class OperationOrderServiceImpl method updateConsumedStockMoveFromOperationOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public void updateConsumedStockMoveFromOperationOrder(OperationOrder operationOrder) throws AxelorException {
this.updateDiffProdProductList(operationOrder);
List<StockMoveLine> consumedStockMoveLineList = operationOrder.getConsumedStockMoveLineList();
if (consumedStockMoveLineList == null) {
return;
}
Optional<StockMove> stockMoveOpt = operationOrder.getInStockMoveList().stream().filter(stockMove -> stockMove.getStatusSelect() == StockMoveRepository.STATUS_PLANNED).findFirst();
StockMove stockMove;
if (stockMoveOpt.isPresent()) {
stockMove = stockMoveOpt.get();
} else {
stockMove = Beans.get(ManufOrderStockMoveService.class)._createToConsumeStockMove(operationOrder.getManufOrder(), operationOrder.getManufOrder().getCompany());
operationOrder.addInStockMoveListItem(stockMove);
Beans.get(StockMoveService.class).plan(stockMove);
}
Beans.get(ManufOrderService.class).updateStockMoveFromManufOrder(consumedStockMoveLineList, stockMove);
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class OperationOrderStockMoveService method createToConsumeStockMove.
public void createToConsumeStockMove(OperationOrder operationOrder) throws AxelorException {
Company company = operationOrder.getManufOrder().getCompany();
if (operationOrder.getToConsumeProdProductList() != null && company != null) {
StockMove stockMove = this._createToConsumeStockMove(operationOrder, company);
stockMove.setOriginId(operationOrder.getId());
stockMove.setOriginTypeSelect(StockMoveRepository.ORIGIN_OPERATION_ORDER);
stockMove.setOrigin(operationOrder.getOperationName());
for (ProdProduct prodProduct : operationOrder.getToConsumeProdProductList()) {
StockMoveLine stockMoveLine = this._createStockMoveLine(prodProduct, stockMove);
}
if (stockMove.getStockMoveLineList() != null && !stockMove.getStockMoveLineList().isEmpty()) {
stockMoveService.plan(stockMove);
operationOrder.addInStockMoveListItem(stockMove);
}
// case where we had to split tracked stock move lines
if (stockMove.getStockMoveLineList() != null) {
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
operationOrder.addConsumedStockMoveLineListItem(stockMoveLine);
}
}
}
}
Aggregations