use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderComputeServiceSupplychainImpl method _computeSaleOrder.
@Override
public void _computeSaleOrder(SaleOrder saleOrder) throws AxelorException {
super._computeSaleOrder(saleOrder);
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
return;
}
int maxDelay = 0;
if (saleOrder.getSaleOrderLineList() != null && !saleOrder.getSaleOrderLineList().isEmpty()) {
for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
if ((saleOrderLine.getSaleSupplySelect() == SaleOrderLineRepository.SALE_SUPPLY_PRODUCE || saleOrderLine.getSaleSupplySelect() == SaleOrderLineRepository.SALE_SUPPLY_PURCHASE)) {
maxDelay = Integer.max(maxDelay, saleOrderLine.getStandardDelay() == null ? 0 : saleOrderLine.getStandardDelay());
}
}
}
saleOrder.setStandardDelay(maxDelay);
if (Beans.get(AppAccountService.class).getAppAccount().getManageAdvancePaymentInvoice()) {
saleOrder.setAdvanceTotal(computeTotalInvoiceAdvancePayment(saleOrder));
}
Beans.get(SaleOrderServiceSupplychainImpl.class).updateAmountToBeSpreadOverTheTimetable(saleOrder);
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineServiceSupplyChainImpl method createSaleOrderLine.
@Override
public SaleOrderLine createSaleOrderLine(PackLine packLine, SaleOrder saleOrder, BigDecimal packQty, BigDecimal conversionRate, Integer sequence) {
SaleOrderLine soLine = super.createSaleOrderLine(packLine, saleOrder, packQty, conversionRate, sequence);
if (soLine != null && soLine.getProduct() != null) {
soLine.setSaleSupplySelect(soLine.getProduct().getSaleSupplySelect());
getAndComputeAnalyticDistribution(soLine, saleOrder);
if (ObjectUtils.notEmpty(soLine.getAnalyticMoveLineList())) {
soLine.getAnalyticMoveLineList().stream().forEach(analyticMoveLine -> analyticMoveLine.setSaleOrderLine(soLine));
}
try {
SupplyChainConfig supplyChainConfig = Beans.get(SupplyChainConfigService.class).getSupplyChainConfig(saleOrder.getCompany());
if (supplyChainConfig.getAutoRequestReservedQty()) {
Beans.get(ReservedQtyService.class).requestQty(soLine);
}
} catch (AxelorException e) {
TraceBackService.trace(e);
}
}
return soLine;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderPurchaseServiceImpl method createPurchaseOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public PurchaseOrder createPurchaseOrder(Partner supplierPartner, List<SaleOrderLine> saleOrderLineList, SaleOrder saleOrder) throws AxelorException {
LOG.debug("Création d'une commande fournisseur pour le devis client : {}", saleOrder.getSaleOrderSeq());
PurchaseOrder purchaseOrder = purchaseOrderSupplychainService.createPurchaseOrder(AuthUtils.getUser(), saleOrder.getCompany(), supplierPartner.getContactPartnerSet().size() == 1 ? supplierPartner.getContactPartnerSet().iterator().next() : null, supplierPartner.getCurrency(), null, saleOrder.getSaleOrderSeq(), saleOrder.getExternalReference(), saleOrder.getDirectOrderLocation() ? saleOrder.getStockLocation() : Beans.get(StockLocationService.class).getDefaultReceiptStockLocation(saleOrder.getCompany()), Beans.get(AppBaseService.class).getTodayDate(saleOrder.getCompany()), Beans.get(PartnerPriceListService.class).getDefaultPriceList(supplierPartner, PriceListRepository.TYPE_PURCHASE), supplierPartner, saleOrder.getTradingName());
purchaseOrder.setGeneratedSaleOrderId(saleOrder.getId());
purchaseOrder.setGroupProductsOnPrintings(supplierPartner.getGroupProductsOnPrintings());
Integer atiChoice = Beans.get(PurchaseConfigService.class).getPurchaseConfig(saleOrder.getCompany()).getPurchaseOrderInAtiSelect();
if (atiChoice == AccountConfigRepository.INVOICE_ATI_ALWAYS || atiChoice == AccountConfigRepository.INVOICE_ATI_DEFAULT) {
purchaseOrder.setInAti(true);
} else {
purchaseOrder.setInAti(false);
}
for (SaleOrderLine saleOrderLine : saleOrderLineList) {
purchaseOrder.addPurchaseOrderLineListItem(purchaseOrderLineServiceSupplychain.createPurchaseOrderLine(purchaseOrder, saleOrderLine));
}
purchaseOrderService.computePurchaseOrder(purchaseOrder);
purchaseOrder.setNotes(supplierPartner.getPurchaseOrderComments());
Beans.get(PurchaseOrderRepository.class).save(purchaseOrder);
return purchaseOrder;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class MrpServiceImpl method createSaleOrderMrpLines.
protected void createSaleOrderMrpLines() throws AxelorException {
MrpLineType saleOrderMrpLineType = this.getMrpLineType(MrpLineTypeRepository.ELEMENT_SALE_ORDER);
if (saleOrderMrpLineType == null) {
return;
}
String statusSelect = saleOrderMrpLineType.getStatusSelect();
List<Integer> statusList = StringTool.getIntegerList(statusSelect);
List<SaleOrderLine> saleOrderLineList = new ArrayList<>();
mrp = mrpRepository.find(mrp.getId());
if (mrp.getSaleOrderLineSet().isEmpty()) {
saleOrderLineList.addAll(saleOrderLineRepository.all().filter("self.product.id in (?1) AND self.saleOrder.stockLocation in (?2) AND self.deliveryState != ?3 " + "AND self.saleOrder.statusSelect IN (?4)", this.productMap.keySet(), this.stockLocationList, SaleOrderLineRepository.DELIVERY_STATE_DELIVERED, statusList).fetch());
} else {
saleOrderLineList.addAll(mrp.getSaleOrderLineSet());
}
for (SaleOrderLine saleOrderLine : saleOrderLineList) {
this.createSaleOrderMrpLines(mrpRepository.find(mrp.getId()), saleOrderLineRepository.find(saleOrderLine.getId()), mrpLineTypeRepository.find(saleOrderMrpLineType.getId()), statusList);
JPA.clear();
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class ReservedQtyServiceImpl method updateReservedQuantityFromStockMoveLine.
@Override
public void updateReservedQuantityFromStockMoveLine(StockMoveLine stockMoveLine, Product product, BigDecimal reservedQtyToAdd) throws AxelorException {
if (product == null || !product.getStockManaged()) {
return;
}
SaleOrderLine saleOrderLine = stockMoveLine.getSaleOrderLine();
stockMoveLine.setReservedQty(stockMoveLine.getReservedQty().add(reservedQtyToAdd));
if (saleOrderLine != null) {
updateReservedQty(saleOrderLine);
}
}
Aggregations