Samer-Melhem-FOO opened a new pull request, #6742:
URL: https://github.com/apache/fineract/pull/6742

   ## Description
   
   JIRA: [FINERACT-2997](https://issues.apache.org/jira/browse/FINERACT-2997)
   
   Once a loan is NPA, `addAccruals` returns immediately on every path 
(periodic job / COB and the final accrual on closure), and 
`LoanAccrualEventService.LoanBalanceChangedListener` only handles closed or 
overpaid loans. A repayment still credits Interest Receivable with its whole 
interest portion, so interest that was never accrued drives the loan's 
receivable negative and never reaches Interest Income. If the loan closes while 
NPA, that stays permanent.
   
   The fix keeps NPA loans out of normal accrual but recognises interest on 
receipt:
   
   - `addAccruals` no longer skips NPA loans. On a non-final run an NPA loan's 
accruable interest is capped at the interest already paid on each installment 
(never below what is accrued), fees and penalties are not accrued, the accrual 
is dated on the run date, and `accruedTill` does not move. When the loan leaves 
NPA, normal accrual adds only the remainder.
   - The final accrual on closure runs for NPA loans too.
   - New `LoanAccrualsProcessingService.processAccrualsOnNpaLoanRepayment`, 
called from `LoanBalanceChangedListener` for an open NPA loan, posts the income 
in the same transaction as the repayment.
   
   ### Testing
   
   - Unit: new tests in `LoanAccrualsProcessingServiceImplTest` for the capping 
(accrued-and-paid, paid-but-unaccrued, unpaid, partly paid, fee left unaccrued) 
and for the new entry point being a no-op on a non-NPA or closed loan. The 
class passes (43 tests); `spotlessJavaCheck` is clean for both modules.
   - Live, on stock `develop` against PostgreSQL: periodic-accrual product, 12 
daily installments, overdue days for NPA = 5. Accrual job on day 4 (28.80 
accrued), then on day 10 the arrears ageing, NPA and accrual jobs (loan becomes 
NPA, nothing accrued), then a repayment of installments 1-8 and a closing 
repayment.
     - Before: after the NPA repayment Interest Receivable = -17.88 and 
Interest Income = 28.80 (interest paid 46.68); after closure Interest 
Receivable = -24.78, Interest Income = 28.80 (interest paid 53.58).
     - After: Interest Receivable = 0.00 and Interest Income = interest paid at 
both points (46.68, then 53.58), with the income-on-receipt accruals dated on 
the repayment date.
   
   ## Checklist
   
   - [x] Write the commit message as per [our 
guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [x] Acknowledge that we will not review PRs that are not passing the build 
_("green")_ - it is your responsibility to get a proposed PR to pass the build, 
not primarily the project's maintainers.
   - [x] Create/update [unit or integration 
tests](https://fineract.apache.org/docs/current/#_testing) for verifying the 
changes made.
   - [x] Follow our [coding 
conventions](https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions).
   - [ ] Add required Swagger annotation and update API documentation at 
fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with 
details of any API changes (no API change)
   - [x] [This PR must not be a "code 
dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit).
 Large changes can be made in a branch, with assistance. Ask for help on the 
[developer mailing list](https://fineract.apache.org/#contribute).
   - [x] If merging this PR resolves a JIRA issue, I will mark that issue as 
resolved and set "Fix Version/s" appropriately.
   - [x] I followed the [AI 
Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to