use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.
the class StockMoveLineController method openTrackNumberWizard.
public void openTrackNumberWizard(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
StockMoveLine stockMoveLine = context.asType(StockMoveLine.class);
StockMove stockMove = null;
if (context.getParent() != null && context.getParent().get("_model").equals("com.axelor.apps.stock.db.StockMove")) {
stockMove = context.getParent().asType(StockMove.class);
} else if (stockMoveLine.getStockMove() != null && stockMoveLine.getStockMove().getId() != null) {
stockMove = Beans.get(StockMoveRepository.class).find(stockMoveLine.getStockMove().getId());
}
boolean _hasWarranty = false, _isPerishable = false;
if (stockMoveLine.getProduct() != null) {
_hasWarranty = stockMoveLine.getProduct().getHasWarranty();
_isPerishable = stockMoveLine.getProduct().getIsPerishable();
}
response.setView(ActionView.define(I18n.get(IExceptionMessage.TRACK_NUMBER_WIZARD_TITLE)).model(Wizard.class.getName()).add("form", "stock-move-line-track-number-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("width", "large").param("popup-save", "false").context("_stockMove", stockMove).context("_stockMoveLine", stockMoveLine).context("_hasWarranty", _hasWarranty).context("_isPerishable", _isPerishable).map());
}
use of com.axelor.apps.stock.db.StockMove 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.StockMove 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.StockMove in project axelor-open-suite by axelor.
the class ManufOrderStockMoveService method finish.
public void finish(ManufOrder manufOrder) throws AxelorException {
// clear empty stock move
manufOrder.getInStockMoveList().removeIf(stockMove -> CollectionUtils.isEmpty(stockMove.getStockMoveLineList()));
manufOrder.getOutStockMoveList().removeIf(stockMove -> CollectionUtils.isEmpty(stockMove.getStockMoveLineList()));
// finish remaining stock move
for (StockMove stockMove : manufOrder.getInStockMoveList()) {
this.finishStockMove(stockMove);
}
for (StockMove stockMove : manufOrder.getOutStockMoveList()) {
updateRealPrice(manufOrder, stockMove);
this.finishStockMove(stockMove);
}
}
use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.
the class ManufOrderWorkflowService method start.
@Transactional(rollbackOn = { Exception.class })
public void start(ManufOrder manufOrder) throws AxelorException {
if (manufOrder.getBillOfMaterial().getStatusSelect() != BillOfMaterialRepository.STATUS_APPLICABLE || manufOrder.getProdProcess().getStatusSelect() != ProdProcessRepository.STATUS_APPLICABLE) {
throw new AxelorException(manufOrder, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.CHECK_BOM_AND_PROD_PROCESS));
}
manufOrder.setRealStartDateT(Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
int beforeOrAfterConfig = manufOrder.getProdProcess().getStockMoveRealizeOrderSelect();
if (beforeOrAfterConfig == ProductionConfigRepository.REALIZE_START) {
for (StockMove stockMove : manufOrder.getInStockMoveList()) {
manufOrderStockMoveService.finishStockMove(stockMove);
}
}
manufOrder.setStatusSelect(ManufOrderRepository.STATUS_IN_PROGRESS);
manufOrderRepo.save(manufOrder);
Beans.get(ProductionOrderService.class).updateStatus(manufOrder.getProductionOrderSet());
}
Aggregations