svn commit: r595663 - /ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r595663 - /ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java

jleroux@apache.org
Author: jleroux
Date: Fri Nov 16 06:02:47 2007
New Revision: 595663

URL: http://svn.apache.org/viewvc?rev=595663&view=rev
Log:
Applied fix from trunk for revision: 594781

Modified:
    ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java

Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=595663&r1=595662&r2=595663&view=diff
==============================================================================
--- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Fri Nov 16 06:02:47 2007
@@ -470,14 +470,17 @@
 
         // check promo code use limits, per customer, code
         Long codeUseLimitPerCustomer = productPromoCode.getLong("useLimitPerCustomer");
-        if (codeUseLimitPerCustomer != null && UtilValidate.isNotEmpty(partyId)) {
-            // check to see how many times this has been used for other orders for this customer, the remainder is the limit for this order
-            EntityCondition checkCondition = new EntityConditionList(UtilMisc.toList(
-                    new EntityExpr("productPromoCodeId", EntityOperator.EQUALS, productPromoCodeId),
-                    new EntityExpr("partyId", EntityOperator.EQUALS, partyId),
-                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"),
-                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED")), EntityOperator.AND);
-            long productPromoCustomerUseSize = delegator.findCountByCondition("ProductPromoUseCheck", checkCondition, null);
+        if (codeUseLimitPerCustomer != null) {
+            long productPromoCustomerUseSize = 0;
+            if (UtilValidate.isNotEmpty(partyId)) {
+                // check to see how many times this has been used for other orders for this customer, the remainder is the limit for this order
+                EntityCondition checkCondition = new EntityConditionList(UtilMisc.toList(
+                        new EntityExpr("productPromoCodeId", EntityOperator.EQUALS, productPromoCodeId),
+                        new EntityExpr("partyId", EntityOperator.EQUALS, partyId),
+                        new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"),
+                        new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED")), EntityOperator.AND);
+                productPromoCustomerUseSize = delegator.findCountByCondition("ProductPromoUseCheck", checkCondition, null);
+            }
             long perCustomerThisOrder = codeUseLimitPerCustomer.longValue() - productPromoCustomerUseSize;
             if (codeUseLimit == null || codeUseLimit.longValue() > perCustomerThisOrder) {
                 codeUseLimit = new Long(perCustomerThisOrder);