Author: jacopoc
Date: Thu Jul 5 23:18:56 2007
New Revision: 553754
URL:
http://svn.apache.org/viewvc?view=rev&rev=553754Log:
Applied patch by Rashko Rejmer (OFBIZ-1128) to fix a bug in the billing account balance calculation: the error was that the query to the OrderPurchasePaymentSummary entity doesn't group the OrderPaymentPreference records with different order statuses.
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java?view=diff&rev=553754&r1=553753&r2=553754==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java Thu Jul 5 23:18:56 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?