svn commit: r782655 - in /ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order: order/OrderServices.java 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: r782655 - in /ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order: order/OrderServices.java shoppingcart/ShoppingCart.java

ashish-18
Author: ashish
Date: Mon Jun  8 14:43:34 2009
New Revision: 782655

URL: http://svn.apache.org/viewvc?rev=782655&view=rev
Log:
Applied fix from trunk for revision: 782642
Initial patch from jira issue /OFBIZ-2560 (On order view page when editing items, on clicking update items all the adjustments are duplicated.)

Thanks Chirag & Ratnesh Upadhyay for your contribution.
Special thanks to Vikas for reviewing & putting the comment on issue.

Modified:
    ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
    ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=782655&r1=782654&r2=782655&view=diff
==============================================================================
--- ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java Mon Jun  8 14:43:34 2009
@@ -42,6 +42,7 @@
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.GeneralRuntimeException;
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilNumber;
 import org.ofbiz.base.util.UtilProperties;
@@ -55,6 +56,7 @@
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.entity.condition.EntityExpr;
+import org.ofbiz.entity.condition.EntityJoinOperator;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.transaction.GenericTransactionException;
 import org.ofbiz.entity.transaction.TransactionUtil;
@@ -3830,6 +3832,32 @@
         List toStore = new LinkedList();
         toStore.addAll(cart.makeOrderItems());
         toStore.addAll(cart.makeAllAdjustments());
+        
+        String shipGroupSeqId = null;
+        long groupIndex = cart.getShipInfoSize();
+        List orderAdjustments = new ArrayList();
+        for (long itr = 1; itr <= groupIndex; itr++) {
+            shipGroupSeqId = UtilFormatOut.formatPaddedNumber(1, 5);
+            List<GenericValue> removeList = new ArrayList<GenericValue>();
+            for (GenericValue stored: (List<GenericValue>)toStore) {
+                if ("OrderAdjustment".equals(stored.getEntityName())) {
+                    if (("SHIPPING_CHARGES".equals(stored.get("orderAdjustmentTypeId")) ||
+                            "SALES_TAX".equals(stored.get("orderAdjustmentTypeId"))) &&
+                            stored.get("orderId").equals(orderId) &&
+                            stored.get("shipGroupSeqId").equals(shipGroupSeqId)) {
+                        // Removing objects from toStore list for old Shipping and Handling Charges Adjustment and Sales Tax Adjustment.
+                        removeList.add(stored);
+                    }
+                    if (stored.get("comments") != null && ((String)stored.get("comments")).startsWith("Added manually by")) {
+                        // Removing objects from toStore list for Manually added Adjustment.
+                        removeList.add(stored);
+                    }
+                }
+            }
+            toStore.removeAll(removeList);
+        }
+        
+        // Creating objects for New Shipping and Handling Charges Adjustment and Sales Tax Adjustment
         toStore.addAll(cart.makeAllShipGroupInfos());
         toStore.addAll(cart.makeAllOrderPaymentInfos(dispatcher));
         toStore.addAll(cart.makeAllOrderItemAttributes(orderId, ShoppingCart.FILLED_ONLY));

Modified: ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=782655&r1=782654&r2=782655&view=diff
==============================================================================
--- ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Mon Jun  8 14:43:34 2009
@@ -3792,6 +3792,10 @@
         }
         return groups;
     }
+    
+    public int getShipInfoSize() {
+        return this.shipInfo.size();
+    }
 
     public List makeAllOrderItemAttributes() {
         return makeAllOrderItemAttributes(null, ALL);