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


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -2842,6 +2842,54 @@ private static final class Balances {
         private Money aggregatedPenaltyChargesPortion;
     }
 
+    private void mergeReAgedInstallment(final LoanRepaymentScheduleInstallment 
target,
+            final LoanRepaymentScheduleInstallment reAgedInstallment, 
MonetaryCurrency currency, LocalDate transactionDate) {
+        target.setAdditional(false);
+        target.setReAged(true);
+        target.setFromDate(reAgedInstallment.getFromDate());
+        target.setDueDate(reAgedInstallment.getDueDate());
+        
target.setPrincipal(reAgedInstallment.getPrincipal().add(MathUtil.nullToZero(target.getPrincipalCompleted())));
+        target.setInterestCharged(reAgedInstallment.getInterestCharged());
+        target.updateObligationsMet(currency, transactionDate);
+    }
+
+    private void 
insertOrReplaceRelatedInstallment(List<LoanRepaymentScheduleInstallment> 
installments,
+            final LoanRepaymentScheduleInstallment reAgedInstallment, final 
MonetaryCurrency currency, final LocalDate transactionDate) {
+        List<LoanRepaymentScheduleInstallment> list = installments.stream()
+                .filter(installment -> 
Objects.equals(installment.getInstallmentNumber(), 
reAgedInstallment.getInstallmentNumber()))
+                
.sorted(Comparator.comparing(LoanRepaymentScheduleInstallment::getDueDate)).toList();
+        Optional<LoanRepaymentScheduleInstallment> first = Optional.empty();
+
+        if (!list.isEmpty()) {
+            first = Optional.of(list.getFirst());
+            for (int i = 1; i < list.size(); i++) {
+                LoanRepaymentScheduleInstallment installmentToAdjust = 
list.get(i);
+                
installmentToAdjust.setInstallmentNumber(installmentToAdjust.getInstallmentNumber()
 + 1);
+            }
+        }

Review Comment:
   list has 1 element, no?



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