oleksii-novikov-onix commented on code in PR #5063:
URL: https://github.com/apache/fineract/pull/5063#discussion_r2468534069
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -2890,12 +2890,18 @@ private void handleReAge(LoanTransaction
loanTransaction, TransactionCtx ctx) {
MonetaryCurrency currency = ctx.getCurrency();
List<LoanRepaymentScheduleInstallment> installments =
ctx.getInstallments();
- AtomicReference<Money> outstandingPrincipalBalance = new
AtomicReference<>(Money.zero(currency));
+ final LocalDate startDate =
loanTransaction.getLoanReAgeParameter().getStartDate();
+ final LocalDate endDate =
calculateReAgedInstallmentEndDate(loanTransaction.getLoanReAgeParameter());
+ final AtomicReference<Money> outstandingPrincipalBalance = new
AtomicReference<>(Money.zero(currency));
installments.forEach(i -> {
- Money principalOutstanding = i.getPrincipalOutstanding(currency);
- if (principalOutstanding.isGreaterThanZero()) {
-
outstandingPrincipalBalance.set(outstandingPrincipalBalance.get().add(principalOutstanding));
- i.addToPrincipal(loanTransaction.getTransactionDate(),
principalOutstanding.negated());
+ final boolean shouldInclude = !i.isAdditional() ||
i.getDueDate().isBefore(startDate)
+ || (!i.getDueDate().isBefore(startDate) &&
i.getDueDate().isBefore(endDate));
+ if (shouldInclude) {
+ Money principalOutstanding =
i.getPrincipalOutstanding(currency);
+ if (principalOutstanding.isGreaterThanZero()) {
+
outstandingPrincipalBalance.set(outstandingPrincipalBalance.get().add(principalOutstanding));
+ i.addToPrincipal(loanTransaction.getTransactionDate(),
principalOutstanding.negated());
+ }
Review Comment:
It was added to handle negative balances. I will review the logic again
--
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]