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


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -1999,17 +1996,39 @@ private void handleAccelerateMaturityDate(final 
LoanTransaction loanTransaction,
         final LocalDate transactionDate = loanTransaction.getTransactionDate();
         final List<LoanRepaymentScheduleInstallment> installments = 
transactionCtx.getInstallments();
         final Loan loan = loanTransaction.getLoan();
-        final LoanRepaymentScheduleInstallment currentInstallment = 
loan.getRelatedRepaymentScheduleInstallment(transactionDate);
+
+        final boolean isReAmortizedLoan = transactionCtx instanceof 
ProgressiveTransactionCtx ptx
+                && 
ptx.getModel().repaymentPeriods().stream().anyMatch(RepaymentPeriod::isReAmortized);
+        final LoanRepaymentScheduleInstallment currentInstallment = 
isReAmortizedLoan
+                ? 
installments.stream().filter(LoanRepaymentScheduleInstallment::isNotFullyPaidOff).findFirst().orElse(null)
+                : loan.getRelatedRepaymentScheduleInstallment(transactionDate);
 
         if (!installments.isEmpty() && 
transactionDate.isBefore(loan.getMaturityDate()) && currentInstallment != null) 
{
+            final List<LoanRepaymentScheduleInstallment> 
reAmortizedFutureInstallments = isReAmortizedLoan
+                    ? installments.stream().filter(i -> 
i.getFromDate().isAfter(currentInstallment.getFromDate())).toList()
+                    : null;
+
             if (currentInstallment.isNotFullyPaidOff()) {
                 if (transactionCtx instanceof ProgressiveTransactionCtx 
progressiveTransactionCtx
                         && 
loan.isInterestBearingAndInterestRecalculationEnabled()) {
-                    final BigDecimal interestOutstanding = 
currentInstallment.getInterestOutstanding(loan.getCurrency()).getAmount();
-                    final BigDecimal newInterest = 
emiCalculator.getPeriodInterestTillDate(progressiveTransactionCtx.getModel(),
-                            currentInstallment.getFromDate(), 
currentInstallment.getDueDate(), transactionDate, true).getAmount();
-                    if (interestOutstanding.compareTo(BigDecimal.ZERO) > 0 || 
newInterest.compareTo(BigDecimal.ZERO) > 0) {
-                        currentInstallment.updateInterestCharged(newInterest);
+                    if (isReAmortizedLoan) {

Review Comment:
   Can you please help me understand why it does matter?



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