This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch release18.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/release18.12 by this push: new b16fc9b Fixed: Product Price set based on 'Purchase Price Agreement' isn't honoured while same is used during ordering. (OFBIZ-7610) b16fc9b is described below commit b16fc9baf52b1067a83f862a8ef41a05c899000c Author: Suraj Khurana <[hidden email]> AuthorDate: Sat Feb 22 14:39:45 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 04e560d..60a91d4 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 @@ -482,7 +482,8 @@ 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); if (ServiceUtil.isError(result)) { @@ -490,6 +491,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return null; } 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 e03aa94..6495ee1 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 85f79d8..bfe29c5 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 @@ -1287,7 +1287,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 |