Samer-Melhem-FOO opened a new pull request, #6745: URL: https://github.com/apache/fineract/pull/6745
## Description JIRA: [FINERACT-2999](https://issues.apache.org/jira/browse/FINERACT-2999) A loan that is repaid in full, written off, closed by reschedule or overpaid while it is NPA keeps `isNPA = true` for good. The "Update Non Performing Assets" job only resets active loans (its reset query requires `loan_status_id = 300` for products that do not wait for arrears completion), and `DefaultLoanLifecycleStateMachine` never touches the flag, so a settled loan is reported as non-performing. - `DefaultLoanLifecycleStateMachine` clears the flag (new `Loan.clearNpa()`) in the same transaction whenever a loan moves to a closed status (closed obligations met, written off, rescheduled) or to overpaid. - Tenant changelog `0273_clear_npa_on_settled_loans.xml` clears it on loans that were already settled while NPA. ### Testing - Unit: new `DefaultLoanLifecycleStateMachineNpaTest` (repaid in full, write-off and overpayment of an NPA loan clear the flag; closing a non-NPA loan and reopening a closed NPA loan leave it alone), 5 tests; `DefaultLoanLifecycleStateMachineTest` still passes (33 tests); `spotlessCheck` is clean. - Live, on stock `develop` against PostgreSQL: product with overdue days for NPA = 5 and 12 daily installments; after the arrears ageing and NPA jobs the loan is NPA, then it is repaid in full. - Before: `Closed (obligations met)` with `isNPA = true`, still `true` after the NPA job runs again; loans settled while NPA earlier also show `isNPA = true`. - After: `Closed (obligations met)` with `isNPA = false`, still `false` after the NPA job runs again; the changelog cleared the earlier settled loans (`isNPA = false`). ## 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]
