svn commit: r450076 - /incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

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

svn commit: r450076 - /incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

jonesde
Author: jonesde
Date: Tue Sep 26 08:06:21 2006
New Revision: 450076

URL: http://svn.apache.org/viewvc?view=rev&rev=450076
Log:
Fixed a bug in ensure quantity method, in certain circumstances was remove a full quantity of an item instead of reducing it to quantity to keep

Modified:
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=450076&r1=450075&r2=450076
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Tue Sep 26 08:06:21 2006
@@ -677,19 +677,19 @@
         while (localIter.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) localIter.next();
             
-            if (quantityToKeep > item.getQuantity()) {
+            if (quantityToKeep >= item.getQuantity()) {
                 // quantityToKeep sufficient to keep it all... just reduce quantityToKeep and move on  
                 quantityToKeep = quantityToKeep - item.getQuantity();
             } else {
                 // there is more in this than we want to keep, so reduce the quantity, or remove altogether...
                 if (quantityToKeep == 0) {
                     // nothing left to keep, just remove it...
-                    this.removeCartItem(item, dispatcher);
                     quantityRemoved += item.getQuantity();
+                    this.removeCartItem(item, dispatcher);
                 } else {
-                    // there is some to keep, so reduce quantity by quantityToKeep, at this point we know we'll take up all of the rest of the quantityToKeep
-                    item.setQuantity(item.getQuantity() - quantityToKeep, dispatcher, this);
-                    quantityRemoved += quantityToKeep;
+                    // there is some to keep, so reduce quantity to quantityToKeep, at this point we know we'll take up all of the rest of the quantityToKeep
+                    quantityRemoved += (item.getQuantity() - quantityToKeep);
+                    item.setQuantity(quantityToKeep, dispatcher, this);
                     quantityToKeep = 0;
                 }
             }