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);
}
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;
}
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;
}
}
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);
}
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 };
}
Aggregations