Search in sources :

Example 16 with StockMove

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());
}
Also used : Context(com.axelor.rpc.Context) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) Wizard(com.axelor.apps.base.db.Wizard)

Example 17 with StockMove

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);
    }
}
Also used : StockMoveLineService(com.axelor.apps.stock.service.StockMoveLineService) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 18 with StockMove

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);
}
Also used : Company(com.axelor.apps.base.db.Company) IExceptionMessage(com.axelor.apps.production.exceptions.IExceptionMessage) ProductRepository(com.axelor.apps.base.db.repo.ProductRepository) ReservedQtyService(com.axelor.apps.supplychain.service.ReservedQtyService) Inject(com.google.inject.Inject) LocalDateTime(java.time.LocalDateTime) LoggerFactory(org.slf4j.LoggerFactory) StockMoveService(com.axelor.apps.stock.service.StockMoveService) ProductCompanyService(com.axelor.apps.base.service.ProductCompanyService) Transactional(com.google.inject.persist.Transactional) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) StockLocation(com.axelor.apps.stock.db.StockLocation) CollectionUtils(org.apache.commons.collections.CollectionUtils) I18n(com.axelor.i18n.I18n) StockMoveLineService(com.axelor.apps.stock.service.StockMoveLineService) ProdProcess(com.axelor.apps.production.db.ProdProcess) ProdProduct(com.axelor.apps.production.db.ProdProduct) RoundingMode(java.math.RoundingMode) Logger(org.slf4j.Logger) StockConfig(com.axelor.apps.stock.db.StockConfig) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) MethodHandles(java.lang.invoke.MethodHandles) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) OperationOrder(com.axelor.apps.production.db.OperationOrder) OperationOrderRepository(com.axelor.apps.production.db.repo.OperationOrderRepository) StockConfigProductionService(com.axelor.apps.production.service.config.StockConfigProductionService) SupplyChainConfig(com.axelor.apps.supplychain.db.SupplyChainConfig) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) List(java.util.List) Beans(com.axelor.inject.Beans) ManufOrder(com.axelor.apps.production.db.ManufOrder) LocalDate(java.time.LocalDate) Optional(java.util.Optional) ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) OperationOrderStockMoveService(com.axelor.apps.production.service.operationorder.OperationOrderStockMoveService) SupplyChainConfigService(com.axelor.apps.supplychain.service.config.SupplyChainConfigService) StockMove(com.axelor.apps.stock.db.StockMove) ProdProduct(com.axelor.apps.production.db.ProdProduct) BigDecimal(java.math.BigDecimal)

Example 19 with 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);
    }
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove)

Example 20 with 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());
}
Also used : AxelorException(com.axelor.exception.AxelorException) StockMove(com.axelor.apps.stock.db.StockMove) ProductionOrderService(com.axelor.apps.production.service.productionorder.ProductionOrderService) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) Transactional(com.google.inject.persist.Transactional)

Aggregations

StockMove (com.axelor.apps.stock.db.StockMove)129 AxelorException (com.axelor.exception.AxelorException)57 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)50 ArrayList (java.util.ArrayList)36 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)33 Transactional (com.google.inject.persist.Transactional)32 StockMoveService (com.axelor.apps.stock.service.StockMoveService)31 BigDecimal (java.math.BigDecimal)30 List (java.util.List)25 Company (com.axelor.apps.base.db.Company)23 Map (java.util.Map)21 Product (com.axelor.apps.base.db.Product)19 Invoice (com.axelor.apps.account.db.Invoice)18 StockLocation (com.axelor.apps.stock.db.StockLocation)18 Beans (com.axelor.inject.Beans)17 Optional (java.util.Optional)16 StockMoveLineService (com.axelor.apps.stock.service.StockMoveLineService)15 I18n (com.axelor.i18n.I18n)15 Inject (com.google.inject.Inject)14 HashMap (java.util.HashMap)14