Search in sources :

Example 21 with StockMoveLine

use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.

the class StockMoveServiceImpl method copyPlannedStockMovLines.

protected void copyPlannedStockMovLines(StockMove stockMove) {
    List<StockMoveLine> stockMoveLineList = MoreObjects.firstNonNull(stockMove.getStockMoveLineList(), Collections.emptyList());
    stockMove.clearPlannedStockMoveLineList();
    stockMoveLineList.forEach(stockMoveLine -> {
        StockMoveLine copy = stockMoveLineRepo.copy(stockMoveLine, false);
        copy.setArchived(true);
        stockMove.addPlannedStockMoveLineListItem(copy);
    });
}
Also used : StockMoveLine(com.axelor.apps.stock.db.StockMoveLine)

Example 22 with StockMoveLine

use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.

the class StockMoveServiceImpl method copyAndSplitStockMove.

@Override
public Optional<StockMove> copyAndSplitStockMove(StockMove stockMove, List<StockMoveLine> stockMoveLines) throws AxelorException {
    stockMoveLines = MoreObjects.firstNonNull(stockMoveLines, Collections.emptyList());
    StockMove newStockMove = stockMoveRepo.copy(stockMove, false);
    // In copy OriginTypeSelect set null.
    newStockMove.setOriginTypeSelect(stockMove.getOriginTypeSelect());
    newStockMove.setOriginId(stockMove.getOriginId());
    newStockMove.setOrigin(stockMove.getOrigin());
    for (StockMoveLine stockMoveLine : stockMoveLines) {
        if (stockMoveLine.getQty().compareTo(stockMoveLine.getRealQty()) > 0) {
            StockMoveLine newStockMoveLine = copySplittedStockMoveLine(stockMoveLine);
            newStockMove.addStockMoveLineListItem(newStockMoveLine);
        }
    }
    if (ObjectUtils.isEmpty(newStockMove.getStockMoveLineList())) {
        return Optional.empty();
    }
    newStockMove.setRealDate(null);
    newStockMove.setStockMoveSeq(stockMoveToolService.getSequenceStockMove(newStockMove.getTypeSelect(), newStockMove.getCompany()));
    newStockMove.setName(stockMoveToolService.computeName(newStockMove, newStockMove.getStockMoveSeq() + " " + I18n.get(IExceptionMessage.STOCK_MOVE_7) + " " + stockMove.getStockMoveSeq() + " )"));
    newStockMove.setExTaxTotal(stockMoveToolService.compute(newStockMove));
    plan(newStockMove);
    newStockMove.setStockMoveOrigin(stockMove);
    stockMoveRepo.save(newStockMove);
    stockMove.setBackorderId(newStockMove.getId());
    return Optional.of(newStockMove);
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine)

Example 23 with StockMoveLine

use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.

the class StockMoveServiceImpl method updateProductNetMass.

@Override
@Transactional
public void updateProductNetMass(StockMove stockMove) throws AxelorException {
    if (stockMove.getStockMoveLineList() != null) {
        for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
            if (stockMoveLine.getProduct() != null) {
                Product product = productRepository.find(stockMoveLine.getProduct().getId());
                stockMoveLine.setNetMass(product.getNetMass());
                stockMoveLineRepo.save(stockMoveLine);
            }
        }
    }
}
Also used : StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product) Transactional(com.google.inject.persist.Transactional)

Example 24 with StockMoveLine

use of com.axelor.apps.stock.db.StockMoveLine 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 25 with StockMoveLine

use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.

the class StockMoveLineController method splitStockMoveLineByTrackingNumber.

public void splitStockMoveLineByTrackingNumber(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    if (context.get("trackingNumbers") == null) {
        response.setAlert(I18n.get(IExceptionMessage.TRACK_NUMBER_WIZARD_NO_RECORD_ADDED_ERROR));
    } else {
        @SuppressWarnings("unchecked") LinkedHashMap<String, Object> stockMoveLineMap = (LinkedHashMap<String, Object>) context.get("_stockMoveLine");
        Integer stockMoveLineId = (Integer) stockMoveLineMap.get("id");
        StockMoveLine stockMoveLine = Beans.get(StockMoveLineRepository.class).find(new Long(stockMoveLineId));
        @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> trackingNumbers = (ArrayList<LinkedHashMap<String, Object>>) context.get("trackingNumbers");
        Beans.get(StockMoveLineService.class).splitStockMoveLineByTrackingNumber(stockMoveLine, trackingNumbers);
        response.setCanClose(true);
    }
}
Also used : Context(com.axelor.rpc.Context) StockMoveLineService(com.axelor.apps.stock.service.StockMoveLineService) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) StockMoveLineRepository(com.axelor.apps.stock.db.repo.StockMoveLineRepository)

Aggregations

StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)121 BigDecimal (java.math.BigDecimal)59 StockMove (com.axelor.apps.stock.db.StockMove)44 AxelorException (com.axelor.exception.AxelorException)41 Product (com.axelor.apps.base.db.Product)33 Transactional (com.google.inject.persist.Transactional)31 ArrayList (java.util.ArrayList)28 List (java.util.List)18 Company (com.axelor.apps.base.db.Company)16 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)16 StockLocation (com.axelor.apps.stock.db.StockLocation)14 StockMoveLineService (com.axelor.apps.stock.service.StockMoveLineService)14 Unit (com.axelor.apps.base.db.Unit)13 Beans (com.axelor.inject.Beans)13 ProdProduct (com.axelor.apps.production.db.ProdProduct)12 StockMoveService (com.axelor.apps.stock.service.StockMoveService)12 I18n (com.axelor.i18n.I18n)12 Inject (com.google.inject.Inject)12 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)10 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)10