FINERACT-1153: Split oversized last reschedule installment#5523
Open
airajena wants to merge 1 commit intoapache:developfrom
Open
FINERACT-1153: Split oversized last reschedule installment#5523airajena wants to merge 1 commit intoapache:developfrom
airajena wants to merge 1 commit intoapache:developfrom
Conversation
56530e1 to
85639c5
Compare
Contributor
|
@airajena Please rebase the PR (sorry we have a high number of PRs nowadays)! |
c989939 to
9ec5131
Compare
9ec5131 to
99e0bd7
Compare
adamsaghy
reviewed
Mar 2, 2026
Comment on lines
+524
to
+554
| private boolean isLastInstallmentAmountTooLarge(final LoanScheduleDTO loanScheduleDTO, final MonetaryCurrency currency, | ||
| final LocalDate rescheduleFromDate) { | ||
| final List<LoanRepaymentScheduleInstallment> installments = loanScheduleDTO.getInstallments(); | ||
| if (installments == null || installments.size() < 2) { | ||
| return false; | ||
| } | ||
|
|
||
| final List<LoanRepaymentScheduleInstallment> rescheduledInstallments = new ArrayList<>(); | ||
| for (LoanRepaymentScheduleInstallment installment : installments) { | ||
| if (installment.isDownPayment() || DateUtils.isBefore(installment.getDueDate(), rescheduleFromDate)) { | ||
| continue; | ||
| } | ||
| rescheduledInstallments.add(installment); | ||
| } | ||
|
|
||
| if (rescheduledInstallments.size() < 2) { | ||
| return false; | ||
| } | ||
|
|
||
| final LoanRepaymentScheduleInstallment lastInstallment = rescheduledInstallments.get(rescheduledInstallments.size() - 1); | ||
| BigDecimal maxPriorDueAmount = BigDecimal.ZERO; | ||
| for (int i = 0; i < rescheduledInstallments.size() - 1; i++) { | ||
| final BigDecimal dueAmount = rescheduledInstallments.get(i).getDue(currency).getAmount(); | ||
| if (dueAmount.compareTo(maxPriorDueAmount) > 0) { | ||
| maxPriorDueAmount = dueAmount; | ||
| } | ||
| } | ||
|
|
||
| final BigDecimal lastInstallmentDueAmount = lastInstallment.getDue(currency).getAmount(); | ||
| final BigDecimal minimumMaterialDifference = BigDecimal.ONE.movePointLeft(currency.getDigitsAfterDecimal()); | ||
| return lastInstallmentDueAmount.subtract(maxPriorDueAmount).compareTo(minimumMaterialDifference) > 0; |
Contributor
There was a problem hiding this comment.
Could you help me understand the logic behind this?
I’m curious about what constitutes “too large” in this context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements
FINERACT-1153by adding configurable handling for loan reschedule cases where the final installment becomes much larger than prior installments.Problem
For some loan reschedule flows (for example reduced EMI / interest appropriation scenarios), the generated schedule can produce an oversized last installment, which is not desirable operationally.
Solution
Introduced a new global configuration and reschedule logic to automatically split an oversized last installment by extending repayment periods until the last installment is in line.
New global configuration
split-large-last-installment-on-loan-reschedulefalse(disabled)Behavior
false: existing behavior is unchanged.true:Safety guard
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!