Skip to content

Commit

Permalink
Confirm existance of elements before accessing them
Browse files Browse the repository at this point in the history
  • Loading branch information
wkigenyi committed Dec 1, 2024
1 parent f63df47 commit ae8d62b
Show file tree
Hide file tree
Showing 3 changed files with 2,171 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1594,12 +1594,19 @@ public void validateAccountBalanceDoesNotBecomeNegative(final String transaction
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()) {
if(savingsAccountTransaction.size()>0){
SavingsAccountTransaction savingsAccountTransactionFirst = savingsAccountTransaction.get(0);
if (!this.allowOverdraft) {
if (savingsAccountTransactionFirst.getRunningBalance(this.currency).minus(amountPaid).isLessThanZero()) {
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), null, amountPaid);
}
}
}else{
if (!this.allowOverdraft) {
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), null, amountPaid);
}
}

}
}

Expand Down
Loading

0 comments on commit ae8d62b

Please sign in to comment.