This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch release17.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/release17.12 by this push: new b694b38 Fixed: Product Price set based on 'Purchase Price Agreement' isn't honoured while same is used during ordering. (OFBIZ-7610) b694b38 is described below commit b694b389604c8335bf4e313700992edff1260503 Author: Suraj Khurana <[hidden email]> AuthorDate: Sat Feb 22 14:41:18 2020 +0530 Fixed: Product Price set based on 'Purchase Price Agreement' isn't honoured while same is used during ordering. (OFBIZ-7610) Thanks Ankush Upadhyay for the patch and Swapnil Shah for reporting the ticket. --- .../main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java | 4 +++- applications/product/servicedef/services_view.xml | 1 + .../src/main/java/org/apache/ofbiz/product/price/PriceServices.java | 2 +- .../org/apache/ofbiz/product/supplier/SupplierProductServices.java | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java index 79c9d4e..a2608b7 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java @@ -478,10 +478,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { Map<String, Object> params = UtilMisc.<String, Object>toMap("productId", productId, "partyId", this.getPartyId(), "currencyUomId", this.getCurrency(), - "quantity", quantity); + "quantity", quantity, + "agreementId", this.agreementId); try { Map<String, Object> result = dispatcher.runSync("getSuppliersForProduct", params); List<GenericValue> productSuppliers = UtilGenerics.checkList(result.get("supplierProducts")); + if ((productSuppliers != null) && (productSuppliers.size() > 0)) { supplierProduct = productSuppliers.get(0); } diff --git a/applications/product/servicedef/services_view.xml b/applications/product/servicedef/services_view.xml index 3aed90d..ce97df7 100644 --- a/applications/product/servicedef/services_view.xml +++ b/applications/product/servicedef/services_view.xml @@ -98,6 +98,7 @@ under the License. <attribute name="quantity" type="BigDecimal" mode="IN" optional="true"/> <attribute name="canDropShip" type="String" mode="IN" optional="true"/> <attribute name="supplierProducts" type="java.util.List" mode="OUT" optional="false"/> + <attribute name="agreementId" type="String" mode="IN" optional="true"/> </service> <service name="convertFeaturesForSupplier" engine="java" location = "org.apache.ofbiz.product.supplier.SupplierProductServices" invoke="convertFeaturesForSupplier"> diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java index 75f760c..25b70db 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java @@ -1227,7 +1227,7 @@ public class PriceServices { // b) If no price can be found, get the lastPrice from the SupplierProduct entity if (!validPriceFound) { - Map<String, Object> priceContext = UtilMisc.toMap("currencyUomId", currencyUomId, "partyId", partyId, "productId", productId, "quantity", quantity); + Map<String, Object> priceContext = UtilMisc.toMap("currencyUomId", currencyUomId, "partyId", partyId, "productId", productId, "quantity", quantity, "agreementId", agreementId); List<GenericValue> productSuppliers = null; try { Map<String, Object> priceResult = dispatcher.runSync("getSuppliersForProduct", priceContext); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java index e152142..1252813 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java @@ -63,6 +63,8 @@ public class SupplierProductServices { String currencyUomId = (String) context.get("currencyUomId"); BigDecimal quantity =(BigDecimal) context.get("quantity"); String canDropShip = (String) context.get("canDropShip"); + String agreementId = (String) context.get("agreementId"); + try { product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); if (product == null) { @@ -80,7 +82,10 @@ public class SupplierProductServices { supplierProducts = virtualProduct.getRelated("SupplierProduct", null, null, true); } } + if(agreementId != null) { + supplierProducts = EntityUtil.filterByAnd(supplierProducts, UtilMisc.toMap("agreementId", agreementId)); + } // filter the list by date supplierProducts = EntityUtil.filterByDate(supplierProducts, UtilDateTime.nowTimestamp(), "availableFromDate", "availableThruDate", true); |
Free forum by Nabble | Edit this page |