Search in sources :

Example 86 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class SaleOrderController method updateStockReservationDate.

/**
 * Called from sale order view, on delivery date change. <br>
 * Update stock reservation date for each sale order line by calling {@link
 * SaleOrderLineServiceSupplyChain#updateStockMoveReservationDateTime(SaleOrderLine)}.
 *
 * @param request
 * @param response
 */
public void updateStockReservationDate(ActionRequest request, ActionResponse response) {
    try {
        SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
        saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
        for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
            Beans.get(SaleOrderLineServiceSupplyChain.class).updateStockMoveReservationDateTime(saleOrderLine);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : SaleOrderLineServiceSupplyChain(com.axelor.apps.supplychain.service.SaleOrderLineServiceSupplyChain) SaleOrder(com.axelor.apps.sale.db.SaleOrder) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) AxelorException(com.axelor.exception.AxelorException)

Example 87 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class SaleOrderController method checkSaleOrderAnalyticDistributionTemplate.

/**
 * Called from sale order form view when confirming sale order and analytic distribution is
 * required from company's sale config.
 *
 * @param request
 * @param response
 */
public void checkSaleOrderAnalyticDistributionTemplate(ActionRequest request, ActionResponse response) {
    try {
        SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
        List<String> productList = new ArrayList<String>();
        for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
            if (saleOrderLine.getAnalyticDistributionTemplate() == null) {
                productList.add(saleOrderLine.getProductName());
            }
        }
        if (!productList.isEmpty()) {
            throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.SALE_ORDER_ANALYTIC_DISTRIBUTION_ERROR), productList);
        }
    } catch (AxelorException e) {
        TraceBackService.trace(response, e, ResponseMessageType.ERROR);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) ArrayList(java.util.ArrayList) SaleOrder(com.axelor.apps.sale.db.SaleOrder) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

Example 88 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class SaleOrderLineController method createAnalyticDistributionWithTemplate.

public void createAnalyticDistributionWithTemplate(ActionRequest request, ActionResponse response) throws AxelorException {
    SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
    saleOrderLine = Beans.get(SaleOrderLineServiceSupplyChain.class).createAnalyticDistributionWithTemplate(saleOrderLine);
    response.setValue("analyticMoveLineList", saleOrderLine.getAnalyticMoveLineList());
}
Also used : SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

Example 89 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class SaleOrderLineController method fillAvailableAndAllocatedStock.

public void fillAvailableAndAllocatedStock(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    SaleOrderLineServiceSupplyChainImpl saleOrderLineServiceSupplyChainImpl = Beans.get(SaleOrderLineServiceSupplyChainImpl.class);
    SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
    SaleOrder saleOrder = saleOrderLineServiceSupplyChainImpl.getSaleOrder(context);
    if (saleOrder != null) {
        if (saleOrderLine.getProduct() != null && saleOrder.getStockLocation() != null) {
            BigDecimal availableStock = saleOrderLineServiceSupplyChainImpl.getAvailableStock(saleOrder, saleOrderLine);
            BigDecimal allocatedStock = saleOrderLineServiceSupplyChainImpl.getAllocatedStock(saleOrder, saleOrderLine);
            response.setValue("$availableStock", availableStock);
            response.setValue("$allocatedStock", allocatedStock);
            response.setValue("$totalStock", availableStock.add(allocatedStock));
        }
    }
}
Also used : Context(com.axelor.rpc.Context) SaleOrderLineServiceSupplyChainImpl(com.axelor.apps.supplychain.service.SaleOrderLineServiceSupplyChainImpl) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) SaleOrder(com.axelor.apps.sale.db.SaleOrder) BigDecimal(java.math.BigDecimal)

Example 90 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class SaleOrderLineController method checkInvoicedOrDeliveredOrderQty.

public void checkInvoicedOrDeliveredOrderQty(ActionRequest request, ActionResponse response) {
    SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
    SaleOrderLineServiceSupplyChain saleOrderLineService = Beans.get(SaleOrderLineServiceSupplyChain.class);
    BigDecimal qty = saleOrderLineService.checkInvoicedOrDeliveredOrderQty(saleOrderLine);
    saleOrderLineService.updateDeliveryState(saleOrderLine);
    response.setValue("qty", qty);
    response.setValue("deliveryState", saleOrderLine.getDeliveryState());
}
Also used : SaleOrderLineServiceSupplyChain(com.axelor.apps.supplychain.service.SaleOrderLineServiceSupplyChain) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) BigDecimal(java.math.BigDecimal)

Aggregations

SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)116 AxelorException (com.axelor.exception.AxelorException)41 BigDecimal (java.math.BigDecimal)39 SaleOrder (com.axelor.apps.sale.db.SaleOrder)33 ArrayList (java.util.ArrayList)24 Transactional (com.google.inject.persist.Transactional)23 Product (com.axelor.apps.base.db.Product)21 Context (com.axelor.rpc.Context)16 SaleOrderLineService (com.axelor.apps.sale.service.saleorder.SaleOrderLineService)14 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)9 Partner (com.axelor.apps.base.db.Partner)8 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)8 TaxLine (com.axelor.apps.account.db.TaxLine)7 Unit (com.axelor.apps.base.db.Unit)7 HashMap (java.util.HashMap)7 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)6 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)6 SaleOrderLineRepository (com.axelor.apps.sale.db.repo.SaleOrderLineRepository)6 ReservedQtyService (com.axelor.apps.supplychain.service.ReservedQtyService)6 List (java.util.List)6