Repository: fineract Updated Branches: refs/heads/develop fcb5ba30c -> b56cc4354
Fineract-521 Project: http://git-wip-us.apache.org/repos/asf/fineract/repo Commit: http://git-wip-us.apache.org/repos/asf/fineract/commit/e81d810b Tree: http://git-wip-us.apache.org/repos/asf/fineract/tree/e81d810b Diff: http://git-wip-us.apache.org/repos/asf/fineract/diff/e81d810b Branch: refs/heads/develop Commit: e81d810b244cd24093e65e062f6682182156ed85 Parents: df16dc3 Author: avikganguly01 <[email protected]> Authored: Tue Sep 19 18:39:48 2017 +0530 Committer: avikganguly01 <[email protected]> Committed: Tue Sep 19 18:39:48 2017 +0530 ---------------------------------------------------------------------- .../portfolio/savings/domain/SavingsAccount.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/fineract/blob/e81d810b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java index d7a6298..e874701 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java @@ -1085,13 +1085,21 @@ public class SavingsAccount extends AbstractPersistableCustom<Long> { // deal with potential minRequiredBalance and // enforceMinRequiredBalance - if (!isException && transaction.canProcessBalanceCheck()) { + if (!isException && transaction.canProcessBalanceCheck() && !isOverdraft()) { if (runningBalance.minus(minRequiredBalance).isLessThanZero()) { throw new InsufficientAccountBalanceException( "transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount); } } lastSavingsDate = transaction.transactionLocalDate(); } + + //In overdraft cases, minRequiredBalance can be in violation after interest posting + //and should be checked after processing all transactions + if(isOverdraft()) { + if (runningBalance.minus(minRequiredBalance).isLessThanZero()) { throw new InsufficientAccountBalanceException( + "transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount); } + } + if (this.getSavingsHoldAmount().compareTo(BigDecimal.ZERO) == 1) { if (runningBalance.minus(this.getSavingsHoldAmount()).isLessThanZero()) { throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), withdrawalFee, @@ -3048,5 +3056,9 @@ public class SavingsAccount extends AbstractPersistableCustom<Long> { public void releaseAmount(BigDecimal amount) { this.savingsOnHoldAmount = getSavingsHoldAmount().subtract(amount); } + + private boolean isOverdraft() { + return allowOverdraft; + } } \ No newline at end of file
