Search in sources :

Example 71 with Product

use of com.axelor.apps.base.db.Product in project axelor-open-suite by axelor.

the class PurchaseOrderLinePurchaseRepository method populate.

@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
    if (context.get("_model") != null && context.get("_model").toString().contains("PurchaseOrder") && context.get("id") != null) {
        Long id = (Long) json.get("id");
        if (id != null) {
            PurchaseOrderLine purchaseOrderLine = find(id);
            PurchaseOrder purchaseOrder = purchaseOrderLine.getPurchaseOrder();
            Product product = purchaseOrderLine.getProduct();
            json.put("$hasWarning", purchaseOrder != null && product != null && product.getDefaultSupplierPartner() != null && purchaseOrder.getSupplierPartner() != null && product.getDefaultSupplierPartner() != purchaseOrder.getSupplierPartner());
        }
    }
    return super.populate(json, context);
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) Product(com.axelor.apps.base.db.Product)

Example 72 with Product

use of com.axelor.apps.base.db.Product in project axelor-open-suite by axelor.

the class PurchaseOrderLineServiceImpl method getSupplierCatalog.

@Override
public SupplierCatalog getSupplierCatalog(PurchaseOrder purchaseOrder, PurchaseOrderLine purchaseOrderLine) throws AxelorException {
    Product product = purchaseOrderLine.getProduct();
    SupplierCatalog supplierCatalog = supplierCatalogService.getSupplierCatalog(product, purchaseOrder.getSupplierPartner(), purchaseOrder.getCompany());
    return supplierCatalog;
}
Also used : Product(com.axelor.apps.base.db.Product) SupplierCatalog(com.axelor.apps.purchase.db.SupplierCatalog)

Example 73 with Product

use of com.axelor.apps.base.db.Product in project axelor-open-suite by axelor.

the class PurchaseOrderLineServiceImpl method getPurchaseMaxPrice.

@Override
public BigDecimal getPurchaseMaxPrice(PurchaseOrder purchaseOrder, PurchaseOrderLine purchaseOrderLine) throws AxelorException {
    try {
        Product product = purchaseOrderLine.getProduct();
        if (product == null || !((Boolean) productCompanyService.get(product, "sellable", purchaseOrder.getCompany()))) {
            return BigDecimal.ZERO;
        }
        TaxLine saleTaxLine = accountManagementService.getTaxLine(purchaseOrder.getOrderDate(), purchaseOrderLine.getProduct(), purchaseOrder.getCompany(), purchaseOrder.getSupplierPartner().getFiscalPosition(), false);
        BigDecimal price;
        if (purchaseOrder.getInAti() != (Boolean) productCompanyService.get(product, "inAti", purchaseOrder.getCompany())) {
            price = this.convertUnitPrice((Boolean) productCompanyService.get(product, "inAti", purchaseOrder.getCompany()), saleTaxLine, ((BigDecimal) productCompanyService.get(product, "salePrice", purchaseOrder.getCompany())).divide(product.getManagPriceCoef().signum() == 0 ? BigDecimal.ONE : product.getManagPriceCoef(), appBaseService.getNbDecimalDigitForUnitPrice(), RoundingMode.HALF_UP));
        } else {
            price = ((BigDecimal) productCompanyService.get(product, "salePrice", purchaseOrder.getCompany())).divide(product.getManagPriceCoef().signum() == 0 ? BigDecimal.ONE : product.getManagPriceCoef(), appBaseService.getNbDecimalDigitForUnitPrice(), RoundingMode.HALF_UP);
        }
        return currencyService.getAmountCurrencyConvertedAtDate((Currency) productCompanyService.get(product, "saleCurrency", purchaseOrder.getCompany()), purchaseOrder.getCurrency(), price, purchaseOrder.getOrderDate()).setScale(appBaseService.getNbDecimalDigitForUnitPrice(), RoundingMode.HALF_UP);
    } catch (Exception e) {
        return BigDecimal.ZERO;
    }
}
Also used : Currency(com.axelor.apps.base.db.Currency) Product(com.axelor.apps.base.db.Product) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 74 with Product

use of com.axelor.apps.base.db.Product in project axelor-open-suite by axelor.

the class PurchaseOrderLineServiceImpl method checkMultipleQty.

@Override
public void checkMultipleQty(PurchaseOrderLine purchaseOrderLine, ActionResponse response) {
    Product product = purchaseOrderLine.getProduct();
    if (product == null) {
        return;
    }
    productMultipleQtyService.checkMultipleQty(purchaseOrderLine.getQty(), product.getPurchaseProductMultipleQtyList(), product.getAllowToForcePurchaseQty(), response);
}
Also used : Product(com.axelor.apps.base.db.Product)

Example 75 with Product

use of com.axelor.apps.base.db.Product in project axelor-open-suite by axelor.

the class PurchaseOrderLineServiceImpl method getProductSupplierInfos.

public String[] getProductSupplierInfos(PurchaseOrder purchaseOrder, PurchaseOrderLine purchaseOrderLine) throws AxelorException {
    Product product = purchaseOrderLine.getProduct();
    String productName = "";
    String productCode = "";
    if (product == null) {
        return new String[] { productName, productCode };
    }
    SupplierCatalog supplierCatalog = supplierCatalogService.getSupplierCatalog(product, purchaseOrder.getSupplierPartner(), purchaseOrder.getCompany());
    if (supplierCatalog != null) {
        productName = supplierCatalog.getProductSupplierName();
        productCode = supplierCatalog.getProductSupplierCode();
    }
    return new String[] { Strings.isNullOrEmpty(productName) ? product.getName() : productName, Strings.isNullOrEmpty(productCode) ? product.getCode() : productCode };
}
Also used : Product(com.axelor.apps.base.db.Product) SupplierCatalog(com.axelor.apps.purchase.db.SupplierCatalog)

Aggregations

Product (com.axelor.apps.base.db.Product)189 BigDecimal (java.math.BigDecimal)91 AxelorException (com.axelor.exception.AxelorException)70 Transactional (com.google.inject.persist.Transactional)45 ArrayList (java.util.ArrayList)38 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)33 Company (com.axelor.apps.base.db.Company)24 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)24 Unit (com.axelor.apps.base.db.Unit)23 ProductRepository (com.axelor.apps.base.db.repo.ProductRepository)23 HashMap (java.util.HashMap)20 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)19 StockLocation (com.axelor.apps.stock.db.StockLocation)19 List (java.util.List)19 ProdProduct (com.axelor.apps.production.db.ProdProduct)18 StockLocationLine (com.axelor.apps.stock.db.StockLocationLine)18 LocalDate (java.time.LocalDate)18 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)16 StockMove (com.axelor.apps.stock.db.StockMove)16 Map (java.util.Map)16