Merge branch 'Fineract-521' into develop
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 @@
// 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 void releaseAmount(BigDecimal amount) {
this.savingsOnHoldAmount = getSavingsHoldAmount().subtract(amount);
}
+
+ private boolean isOverdraft() {
+ return allowOverdraft;
+ }
}
\ No newline at end of file