chinmaya samantara created FINERACT-2966:
--------------------------------------------

             Summary: Loan totalRecovered misses the latest recovery payment
                 Key: FINERACT-2966
                 URL: https://issues.apache.org/jira/browse/FINERACT-2966
             Project: Apache Fineract
          Issue Type: Bug
          Components: Loan
            Reporter: chinmaya samantara
            Assignee: chinmaya samantara


After a loan is written off, each recovery payment ("Repayment (after 
write-off)") should add to the loan
summary's totalRecovered (m_loan.total_recovered_derived). It always lags one 
payment behind: the payment
just made is never counted.

Steps to reproduce (develop 0e2b5e0af2):
1. Create, approve and disburse a loan, then write it off.
2. POST /loans/{id}/transactions?command=recoverypayment with transactionAmount 
100.
   GET /loans/{id} -> summary.totalRecovered = 0 (expected 100).
3. Make a second recovery payment of 50 -> totalRecovered = 100 (expected 150).
4. A third of 25 -> totalRecovered = 150 (expected 175).

Cause:
FINERACT-2234 (cb6a15c3d2) changed 
LoanBalanceService.calculateTotalRecoveredPayments to sum recovery
payments with a repository query 
(LoanTransactionRepository.calculateTotalRecoveryPaymentAmount).
The summary is refreshed in updateLoanSummaryDerivedFields with 
FlushModeType.COMMIT, before
LoanAccountDomainServiceJpa.makeRepayment saves the new recovery transaction, 
so the query cannot see it.

Proposed fix:
Sum the recovery payments from loan.getLoanTransactions() again (like 
calculateTotalOverpayment next to it),
which includes the unsaved transaction, and remove the now unused repository 
query.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to