FINERACT-2181: Fix in advance paydate calculation#4798
Merged
adamsaghy merged 1 commit intoapache:developfrom Jul 7, 2025
openMF:FINERACT-2181-Loan-prepay-template-gives-wrong-amount-in-case-of-Interest-Recalculation-loans
Conversation
b23a782 to
7bd8a24
Compare
| case SAME_AS_REPAYMENT_PERIOD -> | ||
| recalculationDetails.getPreCloseInterestCalculationStrategy().calculateTillRestFrequencyEnabled(); | ||
| case WEEKLY -> throw new IllegalStateException("Unexpected RecalculationFrequencyType: WEEKLY"); | ||
| case MONTHLY -> throw new IllegalStateException("Unexpected RecalculationFrequencyType: MONTHLY"); |
Contributor
There was a problem hiding this comment.
I see the issue here - runtime exceptions are not good. Could we add validation during loan product creation to prevent selecting WEEKLY or MONTHLY frequency?
Contributor
Author
There was a problem hiding this comment.
I have added the validation to LoanProductDataValidator, however I've kept the exceptions just to be sure we aren't processing loans we are not supporting.
… prepay api and payment allocation inconsistent
7bd8a24 to
c833987
Compare
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.
Description
Rest frequency type and pre close interest calculation strategy defined in LoanInterestRecalculationDetails can make the prepayment api and payment allocation inconsistent.
if restFrequencyType == DAILY and preCloseInterestCalculationStrategy == TILL_PRE_CLOSURE_DATE then no problem.
if restFrequencyType == SAME_AS_REPAYMENT_PERIOD and preCloseInterestCalculationStrategy == TILL_REST_FREQUENCY_DATE then again, no problem.
But if we mix these settings: restFrequencyType == DAILY and preCloseInterestCalculationStrategy == TILL_REST_FREQUENCY_DATE or restFrequencyType == SAME_AS_REPAYMENT_PERIOD and preCloseInterestCalculationStrategy == TILL_PRE_CLOSURE_DATE
Then currently the prepay api calculates the amount payable until the end of the current period because of the pre close setting, but during payment allocation we go into overpayment, because the interest between the transaction date and the related installment periods due date will not be taken into account.
In this PR I attempt to make the functionality consistent, by calculating if the current repayment transaction fully pays off the outstanding amount of the loan, and in the case that it does even if we have daily interest recalculation set it will still allocate the remainder of the period, like if it was set to 'same as repayment period'
Ignore if these details are present on the associated Apache Fineract JIRA ticket.
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.