Foo Developer created FINERACT-2999:
---------------------------------------

             Summary: A loan repaid, written off or overpaid while NPA keeps 
the NPA flag permanently
                 Key: FINERACT-2999
                 URL: https://issues.apache.org/jira/browse/FINERACT-2999
             Project: Apache Fineract
          Issue Type: Bug
          Components: Loan
            Reporter: Foo Developer
            Assignee: Foo Developer


h3. Summary

A loan that is repaid in full, written off, closed by reschedule or overpaid 
while it is flagged as a non-performing asset (NPA) keeps {{isNPA = true}} 
permanently. Reports and {{GET /loans/{loanId}}} then show a settled loan as 
non-performing.

h3. Steps to reproduce
# Create a loan product with "Overdue days for NPA" = {{5}} (and "Account moves 
out of NPA only on arrears completion" unticked), with short repayment periods 
(for example 12 daily installments).
# Create, approve and disburse a loan.
# Move the business date past several due dates without repaying, then run 
"Update Loan Arrears Ageing" and "Update Non Performing Assets" until the loan 
has {{isNPA = true}}.
# Repay the whole outstanding balance.
# {{GET /loans/{loanId}}}, and run "Update Non Performing Assets" again.

h3. Expected

The loan is {{Closed (obligations met)}} with {{isNPA = false}}.

h3. Actual

The loan is {{Closed (obligations met)}} with {{isNPA = true}}, and it stays 
that way after the NPA job runs again.

h3. Root cause

Nothing clears the NPA flag when a loan is settled. The "Update Non Performing 
Assets" job ({{UpdateNpaTasklet}}) only evaluates active loans: its reset query 
requires {{loan_status_id = 300}} for products that do not wait for arrears 
completion, so a loan that leaves the active status while NPA is never reset. 
{{DefaultLoanLifecycleStateMachine}} changes the status on closure or 
overpayment but does not touch the flag.

h3. Proposed fix
* {{DefaultLoanLifecycleStateMachine}} clears the NPA flag 
({{Loan.clearNpa()}}) in the same transaction whenever a loan transitions to a 
closed status (closed obligations met, written off, rescheduled) or to 
overpaid, because a settled loan has nothing left in arrears.
* A tenant changelog clears the flag on loans that were already settled while 
NPA.

Tests: unit tests for the state machine covering repaid in full, write-off and 
overpayment of an NPA loan (flag cleared), closure of a non-NPA loan 
(untouched) and reopening a closed NPA loan (untouched).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to