|
Also, when the repayment amount is less than or equal to the interest (and repayment strategy collects interest first - like Mifos repayment strategy): then a null pointer exception is thrown on the following line:
amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal, this.roundingMode);
This is because amountForRelease is null, when amount repaid is less than or equal to the interest for an installment. This too need to be fixed by including relevant null checks: for example: if ( (amountForRelease != null) && (totalGuaranteeAmount != null) ) { amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal, this.roundingMode); List<DepositAccountOnHoldTransaction> accountOnHoldTransactions = new ArrayList<>();
BigDecimal amountLeft = calculateAndRelaseGuarantorFunds(externalGuarantorList, guarantorGuarantee, amountForRelease, loanTransaction, accountOnHoldTransactions);
if (amountLeft.compareTo(BigDecimal.ZERO) == 1) { calculateAndRelaseGuarantorFunds(selfGuarantorList, selfGuarantee, amountLeft, loanTransaction, accountOnHoldTransactions); externalGuarantorList.addAll(selfGuarantorList); }
if (!externalGuarantorList.isEmpty()) { this.depositAccountOnHoldTransactionRepository.save(accountOnHoldTransactions); this.guarantorFundingRepository.save(externalGuarantorList); }
}
|