You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "adamsaghy (via GitHub)" <gi...@apache.org> on 2025/01/02 22:22:22 UTC

Re: [PR] FINERACT-2148: Zero interest charge off, interestRecalculation = false and fix installment`s update after zero interest charge-off transaction [fineract]

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


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -1213,40 +1212,50 @@ private void handleZeroInterestChargeOff(final LoanTransaction loanTransaction,
                             installment.updatePrincipal(MathUtil.nullToZero(installment.getPrincipal()).add(interestRemoved));
                             installment.updateInterestCharged(newInterest);
                         });
+                progressiveTransactionCtx.setChargedOff(true);
             } else {
-                calculatePartialPeriodInterest(progressiveTransactionCtx, transactionDate);
+                calculatePartialPeriodInterest(transactionCtx, transactionDate);
             }
 
-            installments.stream().filter(installment -> installment.getFromDate().isAfter(transactionDate)).forEach(installment -> {
-                installment.updatePrincipal(MathUtil.nullToZero(installment.getPrincipal()).add(installment.getInterestCharged()));
-                installment.updateInterestCharged(BigDecimal.ZERO);
-            });
+            installments.stream()
+                    .filter(installment -> installment.getFromDate().isAfter(transactionDate) && !installment.isObligationsMet())
+                    .forEach(installment -> {
+                        final BigDecimal interestPaid = MathUtil.nullToZero(installment.getInterestPaid());
+                        final BigDecimal interestOutstanding = MathUtil.nullToZero(installment.getInterestCharged()).subtract(interestPaid);

Review Comment:
   You might wanna consider using the `getInterestOutstanding` method which calculates properly the outstanding amount. TLDR: alongside the paid, it can be waived or written off as well...



-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org