Search in sources :

Example 76 with PurchaseOrder

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;
}
Also used : PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 77 with 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);
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) Transactional(com.google.inject.persist.Transactional)

Example 78 with 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;
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 79 with PurchaseOrder

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;
}
Also used : User(com.axelor.auth.db.User) StockMove(com.axelor.apps.stock.db.StockMove) Invoice(com.axelor.apps.account.db.Invoice) HashMap(java.util.HashMap) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 80 with PurchaseOrder

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);
    }
}
Also used : PurchaseOrderSupplierService(com.axelor.apps.suppliermanagement.service.PurchaseOrderSupplierService) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Aggregations

PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)84 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)26 AxelorException (com.axelor.exception.AxelorException)26 Transactional (com.google.inject.persist.Transactional)16 BigDecimal (java.math.BigDecimal)12 Company (com.axelor.apps.base.db.Company)11 Context (com.axelor.rpc.Context)10 Partner (com.axelor.apps.base.db.Partner)9 Product (com.axelor.apps.base.db.Product)9 ArrayList (java.util.ArrayList)9 Invoice (com.axelor.apps.account.db.Invoice)7 List (java.util.List)7 PurchaseOrderRepository (com.axelor.apps.purchase.db.repo.PurchaseOrderRepository)6 SaleOrder (com.axelor.apps.sale.db.SaleOrder)6 PurchaseOrderSupplychainService (com.axelor.apps.supplychain.service.PurchaseOrderSupplychainService)6 LocalDate (java.time.LocalDate)6 PurchaseOrderService (com.axelor.apps.purchase.service.PurchaseOrderService)5 StockMove (com.axelor.apps.stock.db.StockMove)5 Unit (com.axelor.apps.base.db.Unit)4 PurchaseOrderLineService (com.axelor.apps.purchase.service.PurchaseOrderLineService)4