Search in sources :

Example 56 with PurchaseOrder

use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.

the class PurchaseOrderController method fillCompanyBankDetails.

/**
 * Called on partner, company or payment change. Fill the bank details with a default value.
 *
 * @param request
 * @param response
 */
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
        PaymentMode paymentMode = (PaymentMode) request.getContext().get("paymentMode");
        Company company = purchaseOrder.getCompany();
        Partner partner = purchaseOrder.getSupplierPartner();
        if (company == null) {
            return;
        }
        if (partner != null) {
            partner = Beans.get(PartnerRepository.class).find(partner.getId());
        }
        BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, null);
        response.setValue("companyBankDetails", defaultBankDetails);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BankDetailsService(com.axelor.apps.base.service.BankDetailsService) Company(com.axelor.apps.base.db.Company) BankDetails(com.axelor.apps.base.db.BankDetails) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) Partner(com.axelor.apps.base.db.Partner) AxelorException(com.axelor.exception.AxelorException) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 57 with PurchaseOrder

use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.

the class PurchaseOrderController method fillPriceList.

/**
 * Called from purchase order form view on partner change. Get the default price list for the
 * purchase order. Call {@link PartnerPriceListService#getDefaultPriceList(Partner, int)}.
 *
 * @param request
 * @param response
 */
public void fillPriceList(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
        response.setValue("priceList", Beans.get(PartnerPriceListService.class).getDefaultPriceList(purchaseOrder.getSupplierPartner(), PriceListRepository.TYPE_PURCHASE));
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) AxelorException(com.axelor.exception.AxelorException)

Example 58 with PurchaseOrder

use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.

the class PurchaseOrderController method requestPurchaseOrder.

public void requestPurchaseOrder(ActionRequest request, ActionResponse response) {
    PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
    try {
        Beans.get(PurchaseOrderService.class).requestPurchaseOrder(Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId()));
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PurchaseOrderService(com.axelor.apps.purchase.service.PurchaseOrderService) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) AxelorException(com.axelor.exception.AxelorException)

Example 59 with PurchaseOrder

use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.

the class PurchaseOrderController method finishPurchaseOrder.

public void finishPurchaseOrder(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
        purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
        Beans.get(PurchaseOrderWorkflowService.class).finishPurchaseOrder(purchaseOrder);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) AxelorException(com.axelor.exception.AxelorException) PurchaseOrderWorkflowService(com.axelor.apps.purchase.service.PurchaseOrderWorkflowService)

Example 60 with PurchaseOrder

use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.

the class PurchaseOrderController method changePriceListDomain.

public void changePriceListDomain(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
        String domain = Beans.get(PartnerPriceListService.class).getPriceListDomain(purchaseOrder.getSupplierPartner(), PriceListRepository.TYPE_PURCHASE);
        response.setAttr("priceList", "domain", domain);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PartnerPriceListService(com.axelor.apps.base.service.PartnerPriceListService) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) AxelorException(com.axelor.exception.AxelorException)

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