MIFOSX-566: ensure all types of debits and credits are taken into account when validating if transaction causes account balance to go negative.
This commit is contained in:
+4
-4
@@ -706,9 +706,9 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
Money runningBalance = Money.zero(this.currency);
|
Money runningBalance = Money.zero(this.currency);
|
||||||
|
|
||||||
for (SavingsAccountTransaction transaction : transactionsSortedByDate) {
|
for (SavingsAccountTransaction transaction : transactionsSortedByDate) {
|
||||||
if (transaction.isNotReversed() && transaction.isDeposit() || transaction.isInterestPostingAndNotReversed()) {
|
if (transaction.isNotReversed() && transaction.isCredit()) {
|
||||||
runningBalance = runningBalance.plus(transaction.getAmount(this.currency));
|
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));
|
runningBalance = runningBalance.minus(transaction.getAmount(this.currency));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,9 +726,9 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
Money runningBalance = Money.zero(this.currency);
|
Money runningBalance = Money.zero(this.currency);
|
||||||
|
|
||||||
for (SavingsAccountTransaction transaction : transactionsSortedByDate) {
|
for (SavingsAccountTransaction transaction : transactionsSortedByDate) {
|
||||||
if (transaction.isNotReversed() && transaction.isDeposit() || transaction.isInterestPostingAndNotReversed()) {
|
if (transaction.isNotReversed() && transaction.isCredit()) {
|
||||||
runningBalance = runningBalance.plus(transaction.getAmount(this.currency));
|
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));
|
runningBalance = runningBalance.minus(transaction.getAmount(this.currency));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user