From 54e39c939e2e06315faa50922babb91b9bd10998 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Thu, 25 Jul 2013 11:43:03 +0100 Subject: [PATCH] MIFOSX-566: ensure all types of debits and credits are taken into account when validating if transaction causes account balance to go negative. --- .../portfolio/savings/domain/SavingsAccount.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java index 4810811b0..2691d21fc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java @@ -706,9 +706,9 @@ public class SavingsAccount extends AbstractPersistable { Money runningBalance = Money.zero(this.currency); for (SavingsAccountTransaction transaction : transactionsSortedByDate) { - if (transaction.isNotReversed() && transaction.isDeposit() || transaction.isInterestPostingAndNotReversed()) { + if (transaction.isNotReversed() && transaction.isCredit()) { runningBalance = runningBalance.plus(transaction.getAmount(this.currency)); - } else if (transaction.isNotReversed() && transaction.isWithdrawal()) { + } else if (transaction.isNotReversed() && transaction.isDebit()) { runningBalance = runningBalance.minus(transaction.getAmount(this.currency)); } @@ -726,9 +726,9 @@ public class SavingsAccount extends AbstractPersistable { Money runningBalance = Money.zero(this.currency); for (SavingsAccountTransaction transaction : transactionsSortedByDate) { - if (transaction.isNotReversed() && transaction.isDeposit() || transaction.isInterestPostingAndNotReversed()) { + if (transaction.isNotReversed() && transaction.isCredit()) { runningBalance = runningBalance.plus(transaction.getAmount(this.currency)); - } else if (transaction.isNotReversed() && transaction.isWithdrawal()) { + } else if (transaction.isNotReversed() && transaction.isDebit()) { runningBalance = runningBalance.minus(transaction.getAmount(this.currency)); }