Search in sources :

Example 1 with SaleOrderLineServiceSupplyChainImpl

use of com.axelor.apps.supplychain.service.SaleOrderLineServiceSupplyChainImpl 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)

Aggregations

SaleOrder (com.axelor.apps.sale.db.SaleOrder)1 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)1 SaleOrderLineServiceSupplyChainImpl (com.axelor.apps.supplychain.service.SaleOrderLineServiceSupplyChainImpl)1 Context (com.axelor.rpc.Context)1 BigDecimal (java.math.BigDecimal)1