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