use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class ImportPurchaseOrder method importPurchaseOrder.
public Object importPurchaseOrder(Object bean, Map<String, Object> values) throws Exception {
assert bean instanceof PurchaseOrder;
PurchaseOrder purchaseOrder = (PurchaseOrder) bean;
purchaseOrder = purchaseOrderService.computePurchaseOrder(purchaseOrder);
if (purchaseOrder.getStatusSelect() == 1) {
purchaseOrder.setPurchaseOrderSeq(sequenceService.getDraftSequenceNumber(purchaseOrder));
} else {
purchaseOrderService.requestPurchaseOrder(purchaseOrder);
}
return purchaseOrder;
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierService method createPurchaseOrder.
@Transactional(rollbackOn = { Exception.class })
public void createPurchaseOrder(Partner supplierPartner, List<PurchaseOrderLine> purchaseOrderLineList, PurchaseOrder parentPurchaseOrder) throws AxelorException {
LOG.debug("Création d'une commande fournisseur depuis le devis fournisseur : {} et le fournisseur : {}", parentPurchaseOrder.getPurchaseOrderSeq(), supplierPartner.getFullName());
PurchaseOrder purchaseOrder = purchaseOrderSupplychainService.createPurchaseOrder(AuthUtils.getUser(), parentPurchaseOrder.getCompany(), null, supplierPartner.getCurrency(), null, parentPurchaseOrder.getPurchaseOrderSeq(), parentPurchaseOrder.getExternalReference(), Beans.get(StockLocationService.class).getDefaultReceiptStockLocation(parentPurchaseOrder.getCompany()), Beans.get(AppBaseService.class).getTodayDate(parentPurchaseOrder.getCompany()), Beans.get(PartnerPriceListService.class).getDefaultPriceList(supplierPartner, PriceListRepository.TYPE_PURCHASE), supplierPartner, parentPurchaseOrder.getTradingName());
purchaseOrder.setParentPurchaseOrder(parentPurchaseOrder);
for (PurchaseOrderLine purchaseOrderLine : purchaseOrderLineList) {
purchaseOrder.addPurchaseOrderLineListItem(this.createPurchaseOrderLine(purchaseOrder, purchaseOrderLine));
}
purchaseOrderService.computePurchaseOrder(purchaseOrder);
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_REQUESTED);
purchaseOrder.setReceiptState(PurchaseOrderRepository.STATE_NOT_RECEIVED);
poRepo.save(purchaseOrder);
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderSupplychainRepository method copy.
@Override
public PurchaseOrder copy(PurchaseOrder entity, boolean deep) {
PurchaseOrder copy = super.copy(entity, deep);
if (!appService.isApp("supplychain")) {
return copy;
}
copy.setReceiptState(PurchaseOrderRepository.STATE_NOT_RECEIVED);
copy.setAmountInvoiced(null);
if (copy.getPurchaseOrderLineList() != null) {
for (PurchaseOrderLine purchaseOrderLine : copy.getPurchaseOrderLineList()) {
purchaseOrderLine.setReceiptState(null);
purchaseOrderLine.setReceivedQty(null);
purchaseOrderLine.setAmountInvoiced(null);
purchaseOrderLine.setInvoiced(null);
}
}
return copy;
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class SupplierViewServiceImpl method updateSupplierViewIndicators.
@Override
public Map<String, Object> updateSupplierViewIndicators() {
User user = getSupplierUser();
Map<String, Object> map = new HashMap<>();
/* PurchaseOrder */
map.put("$orders", getCount(PurchaseOrder.class, getPurchaseOrdersOfSupplier(user)));
map.put("$quotationInProgress", getCount(PurchaseOrder.class, getPurchaseQuotationsInProgressOfSupplier(user)));
PurchaseOrder lastOrder = getData(PurchaseOrder.class, getLastPurchaseOrderOfSupplier(user));
map.put("$lastOrder", lastOrder != null ? lastOrder.getValidationDate().format(DATE_FORMATTER) : I18n.get(SUPPLIER_PORTAL_NO_DATE));
/* StockMove */
StockMove stockMoveLastDelivery = getData(StockMove.class, getLastDeliveryOfSupplier(user));
map.put("$lastDelivery", stockMoveLastDelivery != null ? stockMoveLastDelivery.getRealDate().format(DATE_FORMATTER) : I18n.get(SUPPLIER_PORTAL_NO_DATE));
StockMove stockMoveNextDelivery = getData(StockMove.class, getNextDeliveryOfSupplier(user));
map.put("$nextDelivery", stockMoveNextDelivery != null ? stockMoveNextDelivery.getEstimatedDate().format(DATE_FORMATTER) : I18n.get(SUPPLIER_PORTAL_NO_DATE));
map.put("$deliveriesToPrepare", getCount(StockMove.class, getDeliveriesToPrepareOfSupplier(user)));
/* Invoice */
map.put("$overdueInvoices", getCount(Invoice.class, getOverdueInvoicesOfSupplier(user)));
map.put("$awaitingInvoices", getCount(Invoice.class, getAwaitingInvoicesOfSupplier(user)));
map.put("$totalRemaining", getCount(Invoice.class, getTotalRemainingOfSupplier(user)));
return map;
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderController method generateSuppliersRequests.
public void generateSuppliersRequests(ActionRequest request, ActionResponse response) {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
try {
Beans.get(PurchaseOrderSupplierService.class).generateAllSuppliersRequests(Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId()));
response.setFlash(I18n.get(IExceptionMessage.PURCHASE_ORDER_2));
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations