use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderController method updateEstimatedDelivDate.
public void updateEstimatedDelivDate(ActionRequest request, ActionResponse response) {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
List<PurchaseOrderLine> purchaseOrderLineList = purchaseOrder.getPurchaseOrderLineList();
if (purchaseOrderLineList != null) {
for (PurchaseOrderLine purchaseOrderLine : purchaseOrderLineList) {
Integer receiptState = purchaseOrderLine.getReceiptState();
if (receiptState != null && !receiptState.equals(PurchaseOrderLineRepository.RECEIPT_STATE_RECEIVED) && !receiptState.equals(PurchaseOrderLineRepository.RECEIPT_STATE_PARTIALLY_RECEIVED)) {
purchaseOrderLine.setEstimatedDelivDate(purchaseOrder.getDeliveryDate());
}
}
}
response.setValue("purchaseOrderLineList", purchaseOrderLineList);
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method computeAnalyticDistribution.
public void computeAnalyticDistribution(ActionRequest request, ActionResponse response) throws AxelorException {
PurchaseOrderLine purchaseOrderLine = request.getContext().asType(PurchaseOrderLine.class);
if (Beans.get(AppAccountService.class).getAppAccount().getManageAnalyticAccounting()) {
purchaseOrderLine = Beans.get(PurchaseOrderLineServiceSupplychainImpl.class).computeAnalyticDistribution(purchaseOrderLine);
response.setValue("analyticMoveLineList", purchaseOrderLine.getAnalyticMoveLineList());
}
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method createAnalyticDistributionWithTemplate.
public void createAnalyticDistributionWithTemplate(ActionRequest request, ActionResponse response) throws AxelorException {
PurchaseOrderLine purchaseOrderLine = request.getContext().asType(PurchaseOrderLine.class);
purchaseOrderLine = Beans.get(PurchaseOrderLineServiceSupplyChain.class).createAnalyticDistributionWithTemplate(purchaseOrderLine);
response.setValue("analyticMoveLineList", purchaseOrderLine.getAnalyticMoveLineList());
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class ImportSupplyChain method importPurchaseOrderFromSupplyChain.
@Transactional
public Object importPurchaseOrderFromSupplyChain(Object bean, Map<String, Object> values) {
try {
StockMoveService stockMoveService = Beans.get(StockMoveService.class);
PurchaseOrder purchaseOrder = (PurchaseOrder) bean;
int status = purchaseOrder.getStatusSelect();
purchaseOrder = (PurchaseOrder) importPurchaseOrder.importPurchaseOrder(bean, values);
for (PurchaseOrderLine line : purchaseOrder.getPurchaseOrderLineList()) {
Product product = line.getProduct();
if (product.getMassUnit() == null) {
product.setMassUnit(stockConfigService.getStockConfig(purchaseOrder.getCompany()).getCustomsMassUnit());
}
}
if (status == PurchaseOrderRepository.STATUS_VALIDATED || status == PurchaseOrderRepository.STATUS_FINISHED) {
purchaseOrderWorkflowService.validatePurchaseOrder(purchaseOrder);
}
if (status == PurchaseOrderRepository.STATUS_FINISHED) {
List<Long> idList = purchaseOrderStockServiceImpl.createStockMoveFromPurchaseOrder(purchaseOrder);
for (Long id : idList) {
StockMove stockMove = Beans.get(StockMoveRepository.class).find(id);
stockMoveService.copyQtyToRealQty(stockMove);
stockMoveService.realize(stockMove);
stockMove.setRealDate(purchaseOrder.getDeliveryDate());
}
purchaseOrder.setValidationDate(purchaseOrder.getOrderDate());
purchaseOrder.setValidatedByUser(AuthUtils.getUser());
purchaseOrder.setSupplierPartner(purchaseOrderService.validateSupplier(purchaseOrder));
Invoice invoice = Beans.get(PurchaseOrderInvoiceService.class).generateInvoice(purchaseOrder);
String prefixSupplierSeq = "INV000";
invoice.setSupplierInvoiceNb(prefixSupplierSeq + purchaseOrder.getImportId());
invoice.setInternalReference(purchaseOrder.getInternalReference());
LocalDate date;
if (purchaseOrder.getValidationDate() != null) {
date = purchaseOrder.getValidationDate();
} else {
date = Beans.get(AppBaseService.class).getTodayDate(purchaseOrder.getCompany());
}
invoice.setInvoiceDate(date);
invoice.setOriginDate(date.minusDays(15));
invoiceService.validateAndVentilate(invoice);
purchaseOrderWorkflowService.finishPurchaseOrder(purchaseOrder);
}
} catch (Exception e) {
TraceBackService.trace(e);
}
return null;
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method compute.
public void compute(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
PurchaseOrder purchaseOrder = this.getPurchaseOrder(context);
Map<String, BigDecimal> map = Beans.get(PurchaseOrderLineService.class).compute(purchaseOrderLine, purchaseOrder);
response.setValues(map);
response.setAttr("priceDiscounted", "hidden", map.getOrDefault("priceDiscounted", BigDecimal.ZERO).compareTo(purchaseOrder.getInAti() ? purchaseOrderLine.getInTaxPrice() : purchaseOrderLine.getPrice()) == 0);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations