You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2022/08/05 20:56:22 UTC
[GitHub] [fineract] rrpawar96 commented on a diff in pull request #2436: FINERACT-1330:fixPayCharge
rrpawar96 commented on code in PR #2436:
URL: https://github.com/apache/fineract/pull/2436#discussion_r939220089
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java:
##########
@@ -1574,21 +1579,36 @@ public void validateAccountBalanceDoesNotBecomeNegative(final String transaction
throw new PlatformApiDataValidationException(dataValidationErrors);
}
}
-
}
lastSavingsDate = transaction.transactionLocalDate();
-
}
BigDecimal withdrawalFee = null;
- BigDecimal transactionAmount = null;
if (isOverdraft()) {
if (runningBalance.minus(minRequiredBalance).isLessThanZero()) {
- throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount);
+ overdraftLimitExceededException("transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount);
}
}
}
+ public void validateAccountBalanceDoesNotViolateOverdraft(final List<SavingsAccountTransaction> savingsAccountTransaction,
+ final BigDecimal amountPaid) {
+ if (savingsAccountTransaction != null) {
+ SavingsAccountTransaction savingsAccountTransactionFirst = savingsAccountTransaction.get(0);
+ if (!this.allowOverdraft) {
+ if (savingsAccountTransactionFirst.getRunningBalance(this.currency).minus(amountPaid).isLessThanZero()) {
+ throw new InsufficientAccountBalanceException("chargeAmount", getAccountBalance(), null, amountPaid);
+ }
+ }
+ }
+ }
+
+ private void overdraftLimitExceededException(final String paramName, final BigDecimal accountBalance, final BigDecimal withdrawalFee,
+ final BigDecimal transactionAmount) {
+ String showMessageForLimitExaustion = "Overdraft Limit is Exceeded";
+ throw new PlatformDataIntegrityException(showMessageForLimitExaustion, showMessageForLimitExaustion);
Review Comment:
Thanks for the review, @adamsaghy Comment addressed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org