svn commit: r554555 - /ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java

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

svn commit: r554555 - /ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java

lektran
Author: lektran
Date: Mon Jul  9 01:06:02 2007
New Revision: 554555

URL: http://svn.apache.org/viewvc?view=rev&rev=554555
Log:
Applied fix from trunk for revision: 553754

Modified:
    ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java

Modified: ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java?view=diff&rev=554555&r1=554554&r2=554555
==============================================================================
--- ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java (original)
+++ ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java Mon Jul  9 01:06:02 2007
@@ -153,14 +153,13 @@
                 new EntityExpr("preferenceStatusId", EntityOperator.NOT_IN, UtilMisc.toList("PAYMENT_SETTLED", "PAYMENT_RECEIVED", "PAYMENT_DECLINED", "PAYMENT_CANCELLED")) // PAYMENT_NOT_AUTH
             ), EntityOperator.AND);
 
-        GenericValue orderPaymentPreferenceSum = EntityUtil.getFirst(delegator.findByCondition("OrderPurchasePaymentSummary", whereConditions, null, UtilMisc.toList("maxAmount"), null, null));
-        BigDecimal ordersTotal = null;
-        if (UtilValidate.isNotEmpty(orderPaymentPreferenceSum)) {
-            ordersTotal = orderPaymentPreferenceSum.getBigDecimal("maxAmount");
-        } else {
-            ordersTotal = ZERO;
+        List orderPaymentPreferenceSums = delegator.findByCondition("OrderPurchasePaymentSummary", whereConditions, null, UtilMisc.toList("maxAmount"), null, null);
+        if (orderPaymentPreferenceSums != null) {
+            for (Iterator oppsi = orderPaymentPreferenceSums.iterator(); oppsi.hasNext(); ) {
+                GenericValue orderPaymentPreferenceSum = (GenericValue) oppsi.next();
+                balance = balance.subtract(orderPaymentPreferenceSum.getBigDecimal("maxAmount"));
+            }
         }
-        balance = balance.subtract(ordersTotal);
 
         List paymentAppls = delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId", billingAccountId));
         // TODO: cancelled payments?