You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2011/03/13 19:28:41 UTC

svn commit: r1081185 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java

Author: jonesde
Date: Sun Mar 13 18:28:41 2011
New Revision: 1081185

URL: http://svn.apache.org/viewvc?rev=1081185&view=rev
Log:
Fixed bug causing promotions with text condValues to blow up, causing other promos to also not run

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=1081185&r1=1081184&r2=1081185&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Sun Mar 13 18:28:41 2011
@@ -1295,20 +1295,22 @@ public class ProductPromoWorker {
         BigDecimal amountOff = listPrice.subtract(basePrice);
         BigDecimal percentOff = amountOff.divide(listPrice, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100L));
 
-        BigDecimal condValueBigDecimal = new BigDecimal(condValue);
-
         Integer compareBase = null;
 
         if ("PPIP_LPMUP_AMT".equals(inputParamEnumId)) {
+            // NOTE: only check this after we know it's this type of cond, otherwise condValue may not be a number
+            BigDecimal condValueBigDecimal = new BigDecimal(condValue);
             compareBase = Integer.valueOf(amountOff.compareTo(condValueBigDecimal));
         } else if ("PPIP_LPMUP_PER".equals(inputParamEnumId)) {
+            // NOTE: only check this after we know it's this type of cond, otherwise condValue may not be a number
+            BigDecimal condValueBigDecimal = new BigDecimal(condValue);
             compareBase = Integer.valueOf(percentOff.compareTo(condValueBigDecimal));
         } else {
             // condition doesn't apply to individual item, always passes
             return true;
         }
 
-        Debug.logInfo("Checking condition for item productId=" + cartItem.getProductId() + ", listPrice=" + listPrice + ", basePrice=" + basePrice + ", amountOff=" + amountOff + ", percentOff=" + percentOff + ", condValueBigDecimal=" + condValueBigDecimal + ", compareBase=" + compareBase + ", productPromoCond=" + productPromoCond, module);
+        Debug.logInfo("Checking condition for item productId=" + cartItem.getProductId() + ", listPrice=" + listPrice + ", basePrice=" + basePrice + ", amountOff=" + amountOff + ", percentOff=" + percentOff + ", condValue=" + condValue + ", compareBase=" + compareBase + ", productPromoCond=" + productPromoCond, module);
 
         if (compareBase != null) {
             int compare = compareBase.intValue();