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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to