Confirm existance of elements before accessing them
This commit is contained in:
committed by
Adam Saghy
parent
898a18c873
commit
2ac1445dba
+6
-1
@@ -1593,13 +1593,18 @@ public class SavingsAccount extends AbstractAuditableWithUTCDateTimeCustom<Long>
|
||||
|
||||
public void validateAccountBalanceDoesNotViolateOverdraft(final List<SavingsAccountTransaction> savingsAccountTransaction,
|
||||
final BigDecimal amountPaid) {
|
||||
if (savingsAccountTransaction != null) {
|
||||
if (savingsAccountTransaction != null && 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", BigDecimal.ZERO, null, amountPaid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user