use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method updateReservationDate.
/**
* Called from sale order line, on desired delivery date change. Call {@link
* SaleOrderLineServiceSupplyChain#updateStockMoveReservationDateTime(SaleOrderLine)}.
*
* @param request
* @param response
*/
public void updateReservationDate(ActionRequest request, ActionResponse response) {
try {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
saleOrderLine = Beans.get(SaleOrderLineRepository.class).find(saleOrderLine.getId());
Beans.get(SaleOrderLineServiceSupplyChain.class).updateStockMoveReservationDateTime(saleOrderLine);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method computeAnalyticDistribution.
public void computeAnalyticDistribution(ActionRequest request, ActionResponse response) throws AxelorException {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
if (Beans.get(AppAccountService.class).getAppAccount().getManageAnalyticAccounting()) {
saleOrderLine = Beans.get(SaleOrderLineServiceSupplyChain.class).computeAnalyticDistribution(saleOrderLine);
response.setValue("analyticDistributionTemplate", saleOrderLine.getAnalyticDistributionTemplate());
response.setValue("analyticMoveLineList", saleOrderLine.getAnalyticMoveLineList());
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class ImportSupplyChain method importSaleOrderFromSupplyChain.
@Transactional
public Object importSaleOrderFromSupplyChain(Object bean, Map<String, Object> values) {
try {
SaleOrderWorkflowService saleOrderWorkflowService = Beans.get(SaleOrderWorkflowService.class);
StockMoveService stockMoveService = Beans.get(StockMoveService.class);
SaleOrder saleOrder = (SaleOrder) importSaleOrder.importSaleOrder(bean, values);
for (SaleOrderLine line : saleOrder.getSaleOrderLineList()) {
Product product = line.getProduct();
if (product.getMassUnit() == null) {
product.setMassUnit(stockConfigService.getStockConfig(saleOrder.getCompany()).getCustomsMassUnit());
}
}
if (saleOrder.getStatusSelect() == SaleOrderRepository.STATUS_FINALIZED_QUOTATION) {
// taskSaleOrderService.createTasks(saleOrder); TODO once we will have done the generation//
// of tasks in project module
saleOrderWorkflowService.confirmSaleOrder(saleOrder);
// Beans.get(SaleOrderPurchaseService.class).createPurchaseOrders(saleOrder);
// productionOrderSaleOrderService.generateProductionOrder(saleOrder);
// saleOrder.setClientPartner(saleOrderWorkflowService.validateCustomer(saleOrder));
// Generate invoice from sale order
Invoice invoice = Beans.get(SaleOrderInvoiceService.class).generateInvoice(saleOrder);
if (saleOrder.getConfirmationDateTime() != null) {
invoice.setInvoiceDate(saleOrder.getConfirmationDateTime().toLocalDate());
} else {
invoice.setInvoiceDate(Beans.get(AppBaseService.class).getTodayDate(saleOrder.getCompany()));
}
invoiceService.validateAndVentilate(invoice);
List<Long> idList = saleOrderStockService.createStocksMovesFromSaleOrder(saleOrder);
for (Long id : idList) {
StockMove stockMove = Beans.get(StockMoveRepository.class).find(id);
if (stockMove.getStockMoveLineList() != null && !stockMove.getStockMoveLineList().isEmpty()) {
stockMoveService.copyQtyToRealQty(stockMove);
stockMoveService.validate(stockMove);
if (saleOrder.getConfirmationDateTime() != null) {
stockMove.setRealDate(saleOrder.getConfirmationDateTime().toLocalDate());
}
}
}
}
saleOrderRepo.save(saleOrder);
} catch (Exception e) {
TraceBackService.trace(e);
}
return null;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class TestSaleOrderStockService method testUpdateDeliveryStatePartiallyDeliveredLinesSaleOrder.
@Test
public void testUpdateDeliveryStatePartiallyDeliveredLinesSaleOrder() throws AxelorException {
SaleOrder saleOrder = new SaleOrder();
saleOrder.setSaleOrderLineList(new ArrayList<>());
SaleOrderLine saleOrderLine1 = new SaleOrderLine();
SaleOrderLine saleOrderLine2 = new SaleOrderLine();
SaleOrderLine saleOrderLine3 = new SaleOrderLine();
saleOrderLine1.setDeliveryState(SaleOrderRepository.DELIVERY_STATE_DELIVERED);
saleOrderLine2.setDeliveryState(SaleOrderRepository.DELIVERY_STATE_NOT_DELIVERED);
saleOrderLine3.setDeliveryState(SaleOrderRepository.DELIVERY_STATE_PARTIALLY_DELIVERED);
saleOrder.addSaleOrderLineListItem(saleOrderLine1);
saleOrder.addSaleOrderLineListItem(saleOrderLine2);
saleOrder.addSaleOrderLineListItem(saleOrderLine3);
saleOrderStockService.updateDeliveryState(saleOrder);
Assert.assertEquals(SaleOrderRepository.DELIVERY_STATE_PARTIALLY_DELIVERED, (int) saleOrder.getDeliveryState());
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class TestSaleOrderStockService method testUpdateDeliveryStatePartiallyDeliveredSaleOrder.
@Test
public void testUpdateDeliveryStatePartiallyDeliveredSaleOrder() throws AxelorException {
SaleOrder saleOrder = new SaleOrder();
SaleOrderLine saleOrderLine1 = new SaleOrderLine();
SaleOrderLine saleOrderLine2 = new SaleOrderLine();
saleOrderLine1.setDeliveryState(SaleOrderRepository.DELIVERY_STATE_DELIVERED);
saleOrderLine2.setDeliveryState(SaleOrderRepository.DELIVERY_STATE_NOT_DELIVERED);
saleOrder.addSaleOrderLineListItem(saleOrderLine1);
saleOrder.addSaleOrderLineListItem(saleOrderLine2);
saleOrderStockService.updateDeliveryState(saleOrder);
Assert.assertEquals(SaleOrderRepository.DELIVERY_STATE_PARTIALLY_DELIVERED, (int) saleOrder.getDeliveryState());
}
Aggregations