You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by su...@apache.org on 2020/02/22 09:08:34 UTC
[ofbiz-framework] branch trunk updated: Fixed: Product Price set
based on 'Purchase Price Agreement' isn't honoured while same is used
during ordering. (OFBIZ-7610)
This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1fe4304 Fixed: Product Price set based on 'Purchase Price Agreement' isn't honoured while same is used during ordering. (OFBIZ-7610)
new 9a06b0b Merge branch 'trunk' of https://gitbox.apache.org/repos/asf/ofbiz-framework into trunk
1fe4304 is described below
commit 1fe4304a8dbf0d97463f144c9441eb577c2b9a3b
Author: Suraj Khurana <su...@apache.org>
AuthorDate: Sat Feb 22 14:37:59 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 | 3 ++-
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, 9 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 158320d..b46bd3c 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)) {
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 655d4ba..a0f0d7d 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
@@ -1285,7 +1285,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 967bfa1..9e2ccf2 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);