mariiaKraievska commented on code in PR #5294:
URL: https://github.com/apache/fineract/pull/5294#discussion_r2686720384
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -1703,14 +1705,36 @@ private void
recalculateRepaymentPeriodsWithEMICalculation(Money amortizableAmou
}
}
+ final ListIterator<LoanRepaymentScheduleInstallment> iterator =
installments.listIterator();
+ final AtomicInteger installmentCounter = new AtomicInteger();
+
model.repaymentPeriods().forEach(rm -> {
- LoanRepaymentScheduleInstallment installment =
installments.stream().filter(
- ri -> ri.getDueDate().equals(rm.getDueDate()) &&
!ri.isDownPayment() && !ri.getDueDate().isBefore(transactionDate))
- .findFirst().orElse(null);
- if (installment != null) {
+ LoanRepaymentScheduleInstallment installment = null;
+ while (iterator.hasNext() && (installment == null ||
installment.isAdditional() || installment.isDownPayment())) {
+ installment = iterator.next();
+ installmentCounter.getAndIncrement();
+ }
+
+ if (installment != null &&
installment.getDueDate().equals(rm.getDueDate())
+ &&
!installment.getDueDate().isBefore(transactionDate)) {
installment.updatePrincipal(rm.getDuePrincipal().getAmount());
installment.updateInterestCharged(rm.getDueInterest().getAmount());
installment.updateObligationsMet(currency,
transactionDate);
+ } else {
+ if
(model.loanProductRelatedDetail().isAllowFullTermForTranche()
+ &&
loanTransaction.getLoan().getNumberOfRepayments() > 0 &&
!rm.getDueDate().isBefore(transactionDate)) {
Review Comment:
Done
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -1703,14 +1705,36 @@ private void
recalculateRepaymentPeriodsWithEMICalculation(Money amortizableAmou
}
}
+ final ListIterator<LoanRepaymentScheduleInstallment> iterator =
installments.listIterator();
+ final AtomicInteger installmentCounter = new AtomicInteger();
+
model.repaymentPeriods().forEach(rm -> {
- LoanRepaymentScheduleInstallment installment =
installments.stream().filter(
- ri -> ri.getDueDate().equals(rm.getDueDate()) &&
!ri.isDownPayment() && !ri.getDueDate().isBefore(transactionDate))
- .findFirst().orElse(null);
- if (installment != null) {
+ LoanRepaymentScheduleInstallment installment = null;
+ while (iterator.hasNext() && (installment == null ||
installment.isAdditional() || installment.isDownPayment())) {
+ installment = iterator.next();
+ installmentCounter.getAndIncrement();
+ }
+
+ if (installment != null &&
installment.getDueDate().equals(rm.getDueDate())
+ &&
!installment.getDueDate().isBefore(transactionDate)) {
installment.updatePrincipal(rm.getDuePrincipal().getAmount());
installment.updateInterestCharged(rm.getDueInterest().getAmount());
installment.updateObligationsMet(currency,
transactionDate);
+ } else {
+ if
(model.loanProductRelatedDetail().isAllowFullTermForTranche()
+ &&
loanTransaction.getLoan().getNumberOfRepayments() > 0 &&
!rm.getDueDate().isBefore(transactionDate)) {
+ installmentCounter.getAndIncrement();
+ final LoanRepaymentScheduleInstallment newInstallment
= new LoanRepaymentScheduleInstallment(
+ loanTransaction.getLoan(),
installmentCounter.get(), rm.getFromDate(), rm.getDueDate(),
+ rm.getDuePrincipal().getAmount(), null, null,
null, null, null, null, null, false, false, false);
+
+ if (rm.getDueInterest().isGreaterThanZero()) {
Review Comment:
Done
--
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]