svn commit: r678421 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart: CheckOutHelper.java 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: r678421 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart: CheckOutHelper.java ShoppingCart.java

jacopoc
Author: jacopoc
Date: Mon Jul 21 07:03:44 2008
New Revision: 678421

URL: http://svn.apache.org/viewvc?rev=678421&view=rev
Log:
Slightly simplified methods containing very similar code.

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

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=678421&r1=678420&r2=678421&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Mon Jul 21 07:03:44 2008
@@ -772,6 +772,9 @@
                 for (int x = 0; x < itemAdj.size(); x++) {
                     List adjs = (List) itemAdj.get(x);
                     ShoppingCartItem item = (ShoppingCartItem) csi.shipItemInfo.get(x);
+                    if (adjs == null) {
+                        adjs = new LinkedList();
+                    }
                     csi.setItemInfo(item, adjs);
                     Debug.log("Added item adjustments to ship group [" + i + " / " + x + "] - " + adjs, module);
                 }

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=678421&r1=678420&r2=678421&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Mon Jul 21 07:03:44 2008
@@ -4311,45 +4311,23 @@
                 itemInfo.item = item;
                 shipItemInfo.put(item, itemInfo);
             }
-            itemInfo.quantity = quantity;
-            itemInfo.itemTaxAdj.clear();
-            if (taxAdj == null) {
+            if (quantity >= 0) {
+                itemInfo.quantity = quantity;
+            }
+            if (taxAdj != null) {
+                itemInfo.itemTaxAdj.clear();
                 taxAdj = new LinkedList();
+                itemInfo.itemTaxAdj.addAll(taxAdj);
             }
-            itemInfo.itemTaxAdj.addAll(taxAdj);
             return itemInfo;
         }
 
         public CartShipItemInfo setItemInfo(ShoppingCartItem item, List taxAdj) {
-            CartShipItemInfo itemInfo = (CartShipItemInfo) shipItemInfo.get(item);
-            if (itemInfo == null) {
-                if (!isShippableToAddress(item)) {
-                    throw new IllegalArgumentException("The shipping address is not compatible with ProductGeos rules.");
-                }
-                itemInfo = new CartShipItemInfo();
-                itemInfo.item = item;
-                shipItemInfo.put(item, itemInfo);
-            }
-            itemInfo.itemTaxAdj.clear();
-            if (taxAdj == null) {
-                taxAdj = new LinkedList();
-            }
-            itemInfo.itemTaxAdj.addAll(taxAdj);
-            return itemInfo;
+            return setItemInfo(item, -1, taxAdj);
         }
 
         public CartShipItemInfo setItemInfo(ShoppingCartItem item, double quantity) {
-            CartShipItemInfo itemInfo = (CartShipItemInfo) shipItemInfo.get(item);
-            if (itemInfo == null) {
-                if (!isShippableToAddress(item)) {
-                    throw new IllegalArgumentException("The shipping address is not compatible with ProductGeos rules.");
-                }
-                itemInfo = new CartShipItemInfo();
-                itemInfo.item = item;
-                shipItemInfo.put(item, itemInfo);
-            }
-            itemInfo.quantity = quantity;
-            return itemInfo;
+            return setItemInfo(item, quantity, null);
         }
 
         public CartShipItemInfo getShipItemInfo(ShoppingCartItem item) {