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));
}
}
}
Aggregations