adamsaghy commented on code in PR #4770:
URL: https://github.com/apache/fineract/pull/4770#discussion_r2157080013


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanBalanceService.java:
##########
@@ -107,15 +110,68 @@ public void 
refreshSummaryAndBalancesForDisbursedLoan(final Loan loan) {
             loan.setTotalOverpaid(overpaidBy.getAmountDefaultedToNullIfZero());
         }
 
-        final Money recoveredAmount = loan.calculateTotalRecoveredPayments();
+        final Money recoveredAmount = calculateTotalRecoveredPayments(loan);
         
loan.setTotalRecovered(recoveredAmount.getAmountDefaultedToNullIfZero());
 
         final Money principal = 
loan.getLoanRepaymentScheduleDetail().getPrincipal();
         final Money capitalizedIncome = 
capitalizedIncomeBalanceService.calculateCapitalizedIncome(loan);
         final Money capitalizedIncomeAdjustment = 
capitalizedIncomeBalanceService.calculateCapitalizedIncomeAdjustment(loan);
         loan.getSummary().updateSummary(loan.getCurrency(), principal, 
loan.getRepaymentScheduleInstallments(), loan.getLoanCharges(),
                 capitalizedIncome, capitalizedIncomeAdjustment);
-        loan.updateLoanOutstandingBalances();
+        updateLoanOutstandingBalances(loan);
+    }
+
+    private Money calculateTotalRecoveredPayments(Loan loan) {
+        // in case logic for reversing recovered payment is implemented handle 
subtraction from totalRecoveredPayments
+        Money cumulativePaid = Money.zero(loan.getCurrency());
+
+        for (final LoanTransaction recoveredPayment : 
loan.getLoanTransactions()) {

Review Comment:
   We should rewrite this to find "RECOVERY_REPAYMENT" transactions and 
aggregate its amount and return that only.



-- 
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