Search in sources :

Example 16 with PurchaseOrder

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

the class PurchaseOrderLineController method convertUnitPrice.

public void convertUnitPrice(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
    PurchaseOrder purchaseOrder = this.getPurchaseOrder(context);
    if (purchaseOrder == null || purchaseOrderLine.getProduct() == null || purchaseOrderLine.getPrice() == null || purchaseOrderLine.getInTaxPrice() == null || purchaseOrderLine.getTaxLine() == null) {
        return;
    }
    try {
        BigDecimal price = purchaseOrderLine.getPrice();
        BigDecimal inTaxPrice = price.add(price.multiply(purchaseOrderLine.getTaxLine().getValue()));
        response.setValue("inTaxPrice", inTaxPrice);
    } 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) BigDecimal(java.math.BigDecimal)

Example 17 with PurchaseOrder

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

the class PurchaseOrderLineController method getProductInformation.

public void getProductInformation(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
        Context context = request.getContext();
        PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
        PurchaseOrder purchaseOrder = this.getPurchaseOrder(context);
        Product product = purchaseOrderLine.getProduct();
        this.resetProductInformation(response);
        response.setValues(service.reset(purchaseOrderLine));
        if (purchaseOrder == null || product == null) {
            return;
        }
        purchaseOrderLine.setPurchaseOrder(purchaseOrder);
        service.fill(purchaseOrderLine, purchaseOrder);
        response.setValues(purchaseOrderLine);
    } 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) Product(com.axelor.apps.base.db.Product) PurchaseOrderLineService(com.axelor.apps.purchase.service.PurchaseOrderLineService)

Example 18 with PurchaseOrder

use of com.axelor.apps.purchase.db.PurchaseOrder 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 19 with PurchaseOrder

use of com.axelor.apps.purchase.db.PurchaseOrder 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 20 with PurchaseOrder

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

the class PurchaseOrderController method cancelReceipt.

public void cancelReceipt(ActionRequest request, ActionResponse response) throws AxelorException {
    PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
    purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
    Beans.get(PurchaseOrderStockServiceImpl.class).cancelReceipt(purchaseOrder);
}
Also used : PurchaseOrderStockServiceImpl(com.axelor.apps.supplychain.service.PurchaseOrderStockServiceImpl) 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