Author: ashish
Date: Mon Jun 8 14:20:47 2009 New Revision: 782642 URL: http://svn.apache.org/viewvc?rev=782642&view=rev Log: 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/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=782642&r1=782641&r2=782642&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Mon Jun 8 14:20:47 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/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=782642&r1=782641&r2=782642&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 Jun 8 14:20:47 2009 @@ -3793,6 +3793,10 @@ } return groups; } + + public int getShipInfoSize() { + return this.shipInfo.size(); + } public List makeAllOrderItemAttributes() { return makeAllOrderItemAttributes(null, ALL); |
Free forum by Nabble | Edit this page |