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


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -182,13 +185,46 @@ public void processLatestTransaction(LoanTransaction 
loanTransaction, Transactio
             case CHARGE_PAYMENT -> handleChargePayment(loanTransaction, 
ctx.getCurrency(), ctx.getInstallments(), ctx.getCharges(),
                     ctx.getOverpaymentHolder());
             case WAIVE_CHARGES -> log.debug("WAIVE_CHARGES transaction will 
not be processed.");
+            case REAMORTIZE -> handleReAmortization(loanTransaction, 
ctx.getCurrency(), ctx.getInstallments());
             // TODO: Cover rest of the transaction types
             default -> {
                 log.warn("Unhandled transaction processing for transaction 
type: {}", loanTransaction.getTypeOf());
             }
         }
     }
 
+    private void handleReAmortization(LoanTransaction loanTransaction, 
MonetaryCurrency currency,
+            List<LoanRepaymentScheduleInstallment> installments) {
+        BigDecimal remainingAmount = loanTransaction.getAmount();
+        LocalDate transactionDate = loanTransaction.getTransactionDate();
+        List<LoanRepaymentScheduleInstallment> previousInstallments = 
installments.stream() //
+                .filter(installment -> 
!installment.getDueDate().isAfter(transactionDate)) //
+                .toList();
+        List<LoanRepaymentScheduleInstallment> futureInstallments = 
installments.stream() //
+                .filter(installment -> 
installment.getDueDate().isAfter(transactionDate)) //
+                .filter(installment -> !installment.isAdditional()) //
+                .toList();
+        previousInstallments.forEach(installment -> {

Review Comment:
   are you sure about this?



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