Search in sources :

Example 6 with LogisticalFormLine

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

the class LogisticalFormServiceImpl method getNextParcelPalletNumber.

@Override
public int getNextParcelPalletNumber(LogisticalForm logisticalForm, int typeSelect) {
    int highest = 0;
    Set<Integer> parcelPalletNumberSet = new HashSet<>();
    if (logisticalForm.getLogisticalFormLineList() != null) {
        for (LogisticalFormLine logisticalFormLine : logisticalForm.getLogisticalFormLineList()) {
            if (logisticalFormLine.getTypeSelect() == typeSelect && logisticalFormLine.getParcelPalletNumber() != null) {
                parcelPalletNumberSet.add(logisticalFormLine.getParcelPalletNumber());
                if (logisticalFormLine.getParcelPalletNumber() > highest) {
                    highest = logisticalFormLine.getParcelPalletNumber();
                }
            }
        }
    }
    for (int i = 1; i < highest; ++i) {
        if (!parcelPalletNumberSet.contains(i)) {
            return i;
        }
    }
    return highest + 1;
}
Also used : LogisticalFormLine(com.axelor.apps.stock.db.LogisticalFormLine) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 7 with LogisticalFormLine

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

the class LogisticalFormLineController method setQty.

public void setQty(ActionRequest request, ActionResponse response) {
    try {
        LogisticalFormLine logisticalFormLine = getLogisticalFormLine(request);
        if (logisticalFormLine.getQty() == null) {
            BigDecimal qty = Beans.get(LogisticalFormLineService.class).getUnspreadQty(logisticalFormLine);
            response.setValue("qty", qty);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : LogisticalFormLineService(com.axelor.apps.stock.service.LogisticalFormLineService) LogisticalFormLine(com.axelor.apps.stock.db.LogisticalFormLine) BigDecimal(java.math.BigDecimal)

Example 8 with LogisticalFormLine

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

the class LogisticalFormLineController method initParcelPallet.

public void initParcelPallet(ActionRequest request, ActionResponse response) {
    try {
        LogisticalFormLine logisticalFormLine = getLogisticalFormLine(request);
        Beans.get(LogisticalFormLineService.class).initParcelPallet(logisticalFormLine);
        response.setValue("parcelPalletNumber", logisticalFormLine.getParcelPalletNumber());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : LogisticalFormLineService(com.axelor.apps.stock.service.LogisticalFormLineService) LogisticalFormLine(com.axelor.apps.stock.db.LogisticalFormLine)

Example 9 with LogisticalFormLine

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

the class LogisticalFormSupplychainServiceImpl method createLogisticalFormLine.

@Override
protected LogisticalFormLine createLogisticalFormLine(LogisticalForm logisticalForm, StockMoveLine stockMoveLine, BigDecimal qty) {
    LogisticalFormLine logisticalFormLine = super.createLogisticalFormLine(logisticalForm, stockMoveLine, qty);
    if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
        return logisticalFormLine;
    }
    StockMove stockMove = logisticalFormLine.getStockMoveLine() != null ? logisticalFormLine.getStockMoveLine().getStockMove() : null;
    if (stockMove != null && stockMove.getOriginId() != null && stockMove.getOriginId() != 0 && stockMove.getOriginTypeSelect().equals(StockMoveRepository.ORIGIN_SALE_ORDER)) {
        logisticalFormLine.setSaleOrder(Beans.get(SaleOrderRepository.class).find(stockMove.getOriginId()));
    }
    return logisticalFormLine;
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove) LogisticalFormLine(com.axelor.apps.stock.db.LogisticalFormLine)

Example 10 with LogisticalFormLine

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

the class LogisticalFormLineServiceImpl method getStockMoveLineDomain.

@Override
public String getStockMoveLineDomain(LogisticalFormLine logisticalFormLine) {
    long partnerId = 0;
    List<String> domainList = new ArrayList<>();
    LogisticalForm logisticalForm = logisticalFormLine.getLogisticalForm();
    if (logisticalForm != null) {
        Partner deliverToCustomerPartner = logisticalForm.getDeliverToCustomerPartner();
        if (deliverToCustomerPartner != null) {
            partnerId = deliverToCustomerPartner.getId();
        }
    }
    domainList.add(String.format("self.stockMove.partner.id = %d", partnerId));
    domainList.add(String.format("self.stockMove.typeSelect = %d", StockMoveRepository.TYPE_OUTGOING));
    domainList.add(String.format("self.stockMove.statusSelect in (%d, %d)", StockMoveRepository.STATUS_PLANNED, StockMoveRepository.STATUS_REALIZED));
    domainList.add("self.realQty > 0");
    domainList.add("COALESCE(self.stockMove.fullySpreadOverLogisticalFormsFlag, FALSE) = FALSE");
    if (logisticalForm.getStockLocation() != null) {
        domainList.add(String.format("self.stockMove.fromStockLocation.id = %d", logisticalForm.getStockLocation().getId()));
    }
    List<StockMoveLine> fullySpreadStockMoveLineList = Beans.get(LogisticalFormService.class).getFullySpreadStockMoveLineList(logisticalForm);
    if (!fullySpreadStockMoveLineList.isEmpty()) {
        String idListString = StringTool.getIdListString(fullySpreadStockMoveLineList);
        domainList.add(String.format("self.id NOT IN (%s)", idListString));
    }
    return domainList.stream().map(domain -> String.format("(%s)", domain)).collect(Collectors.joining(" AND "));
}
Also used : StringTool(com.axelor.apps.tool.StringTool) LogisticalForm(com.axelor.apps.stock.db.LogisticalForm) LogisticalFormLine(com.axelor.apps.stock.db.LogisticalFormLine) IExceptionMessage(com.axelor.apps.stock.exception.IExceptionMessage) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Strings(com.google.common.base.Strings) BigDecimal(java.math.BigDecimal) List(java.util.List) Beans(com.axelor.inject.Beans) ScriptHelper(com.axelor.script.ScriptHelper) I18n(com.axelor.i18n.I18n) Pattern(java.util.regex.Pattern) Partner(com.axelor.apps.base.db.Partner) LogisticalFormError(com.axelor.apps.stock.exception.LogisticalFormError) LogisticalForm(com.axelor.apps.stock.db.LogisticalForm) ArrayList(java.util.ArrayList) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Partner(com.axelor.apps.base.db.Partner)

Aggregations

LogisticalFormLine (com.axelor.apps.stock.db.LogisticalFormLine)14 BigDecimal (java.math.BigDecimal)7 LogisticalFormError (com.axelor.apps.stock.exception.LogisticalFormError)5 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)4 ScriptHelper (com.axelor.script.ScriptHelper)4 Product (com.axelor.apps.base.db.Product)3 LogisticalForm (com.axelor.apps.stock.db.LogisticalForm)3 StockMove (com.axelor.apps.stock.db.StockMove)3 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)3 IExceptionMessage (com.axelor.apps.stock.exception.IExceptionMessage)3 LogisticalFormLineService (com.axelor.apps.stock.service.LogisticalFormLineService)3 StringTool (com.axelor.apps.tool.StringTool)3 I18n (com.axelor.i18n.I18n)3 Beans (com.axelor.inject.Beans)3 GroovyScriptHelper (com.axelor.script.GroovyScriptHelper)3 ArrayList (java.util.ArrayList)3 AppFilter (com.axelor.app.internal.AppFilter)2 ProductRepository (com.axelor.apps.base.db.repo.ProductRepository)2 FreightCarrierCustomerAccountNumber (com.axelor.apps.stock.db.FreightCarrierCustomerAccountNumber)2 StockConfig (com.axelor.apps.stock.db.StockConfig)2