Search in sources :

Example 16 with PurchaseOrderLine

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

the class PurchaseOrderLineController method emptyLine.

public void emptyLine(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrderLine purchaseOrderLine = request.getContext().asType(PurchaseOrderLine.class);
        if (purchaseOrderLine.getIsTitleLine()) {
            PurchaseOrderLine newPurchaseOrderLine = new PurchaseOrderLine();
            newPurchaseOrderLine.setIsTitleLine(true);
            newPurchaseOrderLine.setQty(BigDecimal.ZERO);
            newPurchaseOrderLine.setId(purchaseOrderLine.getId());
            newPurchaseOrderLine.setVersion(purchaseOrderLine.getVersion());
            response.setValues(Mapper.toMap(purchaseOrderLine));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine)

Example 17 with PurchaseOrderLine

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

the class PurchaseOrderLineController method checkQty.

public void checkQty(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
        PurchaseOrder purchaseOrder = getPurchaseOrder(context);
        PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
        service.checkMinQty(purchaseOrder, purchaseOrderLine, request, response);
        service.checkMultipleQty(purchaseOrderLine, response);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) PurchaseOrderLineService(com.axelor.apps.purchase.service.PurchaseOrderLineService)

Example 18 with PurchaseOrderLine

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

the class PurchaseOrderLineController method checkDifferentSupplier.

public void checkDifferentSupplier(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
        PurchaseOrder purchaseOrder = getPurchaseOrder(context);
        PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
        service.checkDifferentSupplier(purchaseOrder, purchaseOrderLine, response);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) PurchaseOrderLineService(com.axelor.apps.purchase.service.PurchaseOrderLineService)

Example 19 with PurchaseOrderLine

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

the class PurchaseOrderController method checkPurchaseOrderAnalyticDistributionTemplate.

/**
 * Called from purchase order form view when validating purchase order and analytic distribution
 * is required from company's purchase config.
 *
 * @param request
 * @param response
 */
public void checkPurchaseOrderAnalyticDistributionTemplate(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
        List<String> productList = new ArrayList<String>();
        for (PurchaseOrderLine purchaseOrderLine : purchaseOrder.getPurchaseOrderLineList()) {
            if (purchaseOrderLine.getAnalyticDistributionTemplate() == null) {
                productList.add(purchaseOrderLine.getProduct().getFullName());
            }
        }
        if (productList != null && !productList.isEmpty()) {
            throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.PURCHASE_ORDER_ANALYTIC_DISTRIBUTION_ERROR), productList);
        }
    } catch (AxelorException e) {
        TraceBackService.trace(response, e, ResponseMessageType.ERROR);
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AxelorException(com.axelor.exception.AxelorException) ArrayList(java.util.ArrayList) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 20 with PurchaseOrderLine

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

the class PurchaseOrderLineController method computeBudgetDistributionSumAmount.

public void computeBudgetDistributionSumAmount(ActionRequest request, ActionResponse response) {
    PurchaseOrderLine purchaseOrderLine = request.getContext().asType(PurchaseOrderLine.class);
    PurchaseOrder purchaseOrder = request.getContext().getParent().asType(PurchaseOrder.class);
    Beans.get(PurchaseOrderLineServiceSupplychainImpl.class).computeBudgetDistributionSumAmount(purchaseOrderLine, purchaseOrder);
    response.setValue("budgetDistributionSumAmount", purchaseOrderLine.getBudgetDistributionSumAmount());
    response.setValue("budgetDistributionList", purchaseOrderLine.getBudgetDistributionList());
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) PurchaseOrderLineServiceSupplychainImpl(com.axelor.apps.supplychain.service.PurchaseOrderLineServiceSupplychainImpl)

Aggregations

PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)76 BigDecimal (java.math.BigDecimal)28 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)26 Transactional (com.google.inject.persist.Transactional)18 Product (com.axelor.apps.base.db.Product)14 ArrayList (java.util.ArrayList)13 AxelorException (com.axelor.exception.AxelorException)11 Context (com.axelor.rpc.Context)10 Company (com.axelor.apps.base.db.Company)9 Unit (com.axelor.apps.base.db.Unit)9 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)9 PurchaseOrderLineService (com.axelor.apps.purchase.service.PurchaseOrderLineService)8 LocalDate (java.time.LocalDate)8 Partner (com.axelor.apps.base.db.Partner)7 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)7 HashMap (java.util.HashMap)7 BudgetDistribution (com.axelor.apps.account.db.BudgetDistribution)5 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)5 TaxLine (com.axelor.apps.account.db.TaxLine)5 List (java.util.List)5