Author: diveshdutta
Date: Sat May 7 18:38:36 2016
New Revision: 1742741
URL: http://svn.apache.org/viewvc?rev=1742741&view=rev
Log:
(OFBIZ-7046) Fixed: Non existent Bulk Item throwing errors while its respective
qty get updated. Actually system tries to get SupplierProduct data when
updating quantity. When productId is not available for item in cart, added
check in code so that system should not fetch SupplierProduct record. Thanks
Swapnil Shah for reporting the issue and Devanshu Vyas for providing the patch.
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=1742741&r1=1742740&r2=1742741&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
Sat May 7 18:38:36 2016
@@ -811,25 +811,28 @@ public class ShoppingCartHelper {
oldDescription = item.getName();
oldPrice = item.getBasePrice();
+ if
(UtilValidate.isNotEmpty(item.getProductId())) {
+ GenericValue supplierProduct =
this.cart.getSupplierProduct(item.getProductId(), quantity, this.dispatcher);
- GenericValue supplierProduct =
this.cart.getSupplierProduct(item.getProductId(), quantity, this.dispatcher);
-
- if (supplierProduct == null) {
- if
("_NA_".equals(cart.getPartyId())) {
- // no supplier does not
require the supplier product
- item.setQuantity(quantity,
dispatcher, this.cart);
-
item.setName(item.getProduct().getString("internalName"));
+ if (supplierProduct == null) {
+ if
("_NA_".equals(cart.getPartyId())) {
+ // no supplier does
not require the supplier product
+
item.setQuantity(quantity, dispatcher, this.cart);
+
item.setName(item.getProduct().getString("internalName"));
+ } else {
+ // in this case, the
user wanted to purchase a quantity which is not available (probably below
minimum)
+ String errMsg =
UtilProperties.getMessage(resource_error,
"cart.product_not_valid_for_supplier", this.cart.getLocale());
+ errMsg = errMsg + " ("
+ item.getProductId() + ", " + quantity + ", " + cart.getCurrency() + ")";
+ errorMsgs.add(errMsg);
+ }
} else {
- // in this case, the user
wanted to purchase a quantity which is not available (probably below minimum)
- String errMsg =
UtilProperties.getMessage(resource_error,
"cart.product_not_valid_for_supplier", this.cart.getLocale());
- errMsg = errMsg + " (" +
item.getProductId() + ", " + quantity + ", " + cart.getCurrency() + ")";
- errorMsgs.add(errMsg);
+
item.setSupplierProductId(supplierProduct.getString("supplierProductId"));
+ item.setQuantity(quantity,
dispatcher, this.cart);
+
item.setBasePrice(supplierProduct.getBigDecimal("lastPrice"));
+
item.setName(ShoppingCartItem.getPurchaseOrderItemDescription(item.getProduct(),
supplierProduct, cart.getLocale()));
}
} else {
-
item.setSupplierProductId(supplierProduct.getString("supplierProductId"));
item.setQuantity(quantity,
dispatcher, this.cart);
-
item.setBasePrice(supplierProduct.getBigDecimal("lastPrice"));
-
item.setName(ShoppingCartItem.getPurchaseOrderItemDescription(item.getProduct(),
supplierProduct, cart.getLocale()));
}
}
} else {