budaidev commented on code in PR #5314:
URL: https://github.com/apache/fineract/pull/5314#discussion_r2682888011
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -626,6 +626,19 @@ private void
handleReamortizationWithEqualAmortizationInterestSplitHandlingType(
Money totalOverDuePrincipal = Money.zero(currency);
Money totalOverDueFee = Money.zero(currency);
+ Money totalOverDueInterest = Money.zero(currency);
+
+ if (previousInstallments.isEmpty()) {
+ loanTransaction.resetDerivedComponents();
+
loanTransaction.updateComponentsAndTotal(totalOverDuePrincipal,
totalOverDueInterest, Money.zero(currency),
+ Money.zero(currency));
+ if (loanTransaction.isNotReversed()) {
+ loanTransaction.reverse();
+ loanTransaction.manuallyAdjustedOrReversed();
+ }
+ return;
+ }
+
Review Comment:
The logic handles an edge case where re-amortization is requested on
disbursement day. At this point, previousInstallments (installments with due
date ≤ transaction date) is empty because all installments are scheduled in the
future.
Without this guard, calling previousInstallments.getLast() throws
NoSuchElementException causing a 500 error.
The fix gracefully handles this by:
1. Setting transaction amounts to zero
2. Reversing the transaction (since there's nothing to re-amortize)
3. Returning early
This is consistent with the existing logic that reverses the transaction
when both principal and interest are zero
--
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]