Author: erwan
Date: Mon Mar 26 16:19:21 2012 New Revision: 1305426 URL: http://svn.apache.org/viewvc?rev=1305426&view=rev Log: I replaced too much while in order component at rev 1305309. Here are the right ones back Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=1305426&r1=1305425&r2=1305426&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Mon Mar 26 16:19:21 2012 @@ -2357,12 +2357,17 @@ public class OrderReadHelper { public static BigDecimal getOrderItemsSubTotal(List<GenericValue> orderItems, List<GenericValue> adjustments, List<GenericValue> workEfforts) { BigDecimal result = ZERO; - for(GenericValue orderItem : orderItems) { + Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems); + + while (itemIter != null && itemIter.hasNext()) { + GenericValue orderItem = itemIter.next(); BigDecimal itemTotal = getOrderItemSubTotal(orderItem, adjustments); // Debug.logInfo("Item : " + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + " = " + itemTotal, module); if (workEfforts != null && orderItem.getString("orderItemTypeId").compareTo("RENTAL_ORDER_ITEM") == 0) { - for(GenericValue workEffort : workEfforts) { + Iterator<GenericValue> weIter = UtilMisc.toIterator(workEfforts); + while (weIter != null && weIter.hasNext()) { + GenericValue workEffort = weIter.next(); if (workEffort.getString("workEffortId").compareTo(orderItem.getString("orderItemSeqId")) == 0) { itemTotal = itemTotal.multiply(getWorkEffortRentalQuantity(workEffort)).setScale(scale, rounding); break; @@ -2422,8 +2427,10 @@ public class OrderReadHelper { public static BigDecimal getOrderItemsTotal(List<GenericValue> orderItems, List<GenericValue> adjustments) { BigDecimal result = ZERO; - for(GenericValue orderItem : orderItems) { - result = result.add(getOrderItemTotal(orderItem, adjustments)); + Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems); + + while (itemIter != null && itemIter.hasNext()) { + result = result.add(getOrderItemTotal(itemIter.next(), adjustments)); } return result.setScale(scale, rounding); } @@ -2439,7 +2446,9 @@ public class OrderReadHelper { List<GenericValue> promoAdjustments = EntityUtil.filterByAnd(allOrderAdjustments, UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT")); if (UtilValidate.isNotEmpty(promoAdjustments)) { - for(GenericValue promoAdjustment : promoAdjustments) { + Iterator<GenericValue> promoAdjIter = promoAdjustments.iterator(); + while (promoAdjIter.hasNext()) { + GenericValue promoAdjustment = promoAdjIter.next(); if (promoAdjustment != null) { BigDecimal amount = promoAdjustment.getBigDecimal("amount").setScale(taxCalcScale, taxRounding); promoAdjTotal = promoAdjTotal.add(amount); @@ -2492,8 +2501,10 @@ public class OrderReadHelper { public static BigDecimal getAllOrderItemsAdjustmentsTotal(List<GenericValue> orderItems, List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping) { BigDecimal result = ZERO; - for(GenericValue orderItem : orderItems) { - result = result.add(getOrderItemAdjustmentsTotal(orderItem, adjustments, includeOther, includeTax, includeShipping)); + Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems); + + while (itemIter != null && itemIter.hasNext()) { + result = result.add(getOrderItemAdjustmentsTotal(itemIter.next(), adjustments, includeOther, includeTax, includeShipping)); } return result.setScale(scale, rounding); } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?rev=1305426&r1=1305425&r2=1305426&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Mon Mar 26 16:19:21 2012 @@ -774,8 +774,9 @@ public class OrderReturnServices { billingAccounts = EntityUtil.filterByDate(billingAccounts); billingAccounts = EntityUtil.orderBy(billingAccounts, UtilMisc.toList("-fromDate")); if (UtilValidate.isNotEmpty(billingAccounts)) { - for(GenericValue billingAccount : billingAccounts) { - String thisBillingAccountId = billingAccount.getString("billingAccountId"); + ListIterator<GenericValue> billingAccountItr = billingAccounts.listIterator(); + while (billingAccountItr.hasNext() && billingAccountId == null) { + String thisBillingAccountId = billingAccountItr.next().getString("billingAccountId"); BigDecimal billingAccountBalance = ZERO; try { billingAccountBalance = getBillingAccountBalance(thisBillingAccountId, dctx); |
Free forum by Nabble | Edit this page |