[
https://issues.apache.org/jira/browse/FINERACT-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18127446#comment-18127446
]
Senesh Perera commented on FINERACT-2954:
-----------------------------------------
Working on this. Will prepare a fix and open a PR shortly.
> 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
> Priority: Major
>
> *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)