From 5d8cd54dfbc57b9883f0184ed5f861be6b35bb4c Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Mon, 12 Aug 2013 15:23:36 +0100 Subject: [PATCH] MIFOSX-601: fix issue with negative interest been calculated due to incorrect calculation of end of day balance. --- .../portfolio/savings/domain/SavingsAccountTransaction.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java index 4dce66684..edae019c0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java @@ -277,7 +277,10 @@ public final class SavingsAccountTransaction extends AbstractPersistable { if (isDeposit()) { endOfDayBalance = openingBalance.plus(getAmount(currency)); } else if (isWithdrawal() || isWithdrawalFeeAndNotReversed()) { - endOfDayBalance = openingBalance.minus(getAmount(currency)); + + if (openingBalance.isGreaterThanZero()) { + endOfDayBalance = openingBalance.minus(getAmount(currency)); + } } return EndOfDayBalance.from(getTransactionLocalDate(), openingBalance, endOfDayBalance, this.balanceNumberOfDays);