Senesh Perera created FINERACT-2954:
---------------------------------------
Summary: ArithmeticException (Division by zero) in flat-rate
schedule generation when principal variation falls on last installment
Key: FINERACT-2954
URL: https://issues.apache.org/jira/browse/FINERACT-2954
Project: Apache Fineract
Issue Type: Bug
Components: Loan
Reporter: Senesh Perera
*Description*
During flat-rate loan schedule generation and recalculation, an
`ArithmeticException` (division by zero) occurs if a `PRINCIPAL_AMOUNT` term
variation is applicable on the final installment period (where `periodNumber ==
actualNumberOfRepayments`).
*Root Cause Analysis*
In `LoanApplicationTerms.java`, the method
`calculateTotalPrincipalPerPeriodWithoutGrace` computes schedule adjustments
for flat loans:
{code:java}
if (!isPrincipalGraceApplicableForThisPeriod(periodNumber) &&
currentPeriodFixedPrincipalAmount != null) {
this.adjustPrincipalForFlatLoans =
this.adjustPrincipalForFlatLoans.plus(principalPerPeriod
.minus(currentPeriodFixedPrincipalAmount).dividedBy(this.actualNumberOfRepayments
- periodNumber, mc));
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)