-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FINERACT-1971: N plus one installment loan reschedule #3651
FINERACT-1971: N plus one installment loan reschedule #3651
Conversation
LoanScheduleModelPeriod lastInstallment = periods.get(periods.size() - 1); | ||
// get end date for the schedule from loan charges | ||
LocalDate scheduleDueDate = null; | ||
if (!(BigDecimal.ZERO.compareTo(loanApplicationTerms.getAnnualNominalInterestRate()) < 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please simplify this condition?
Negating whether annual nominal interest rate is higher than 0 is not easy to read.
Also interest rate cannot be negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However i am not fully sure why does it matter whether there is interest or not...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Adam, here i tried to mimic the condition we have for add charge scenario in LoanChargeWritePlatformServiceImpl->addCharge, where for n+1 case we are checking whether the loan is interest bearing or not.
final Collection<LoanTermVariationsData> interestRates = loanApplicationTerms.getLoanTermVariations() | ||
.getInterestRateChanges(); | ||
|
||
LocalDate periodStartDateApplicableForInterest = calculateInterestStartDateForPeriod(loanApplicationTerms, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we need to calculate interest after maturity date. @bharathc27 Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bharathc27 Please comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruchiD As discussed there is not interest calculcation involved for N+1 Installment that is after the maturity date.
N+1 Installment scenario happens only for 2 cases
- for charges - here user entered amount will be the installment amount
- for Charge-backs- here amounts are inherited from the repayment that charge-back was triggered from.
@adamsaghy cc
@@ -410,6 +410,10 @@ private LoanScheduleModel generate(final MathContext mc, final LoanApplicationTe | |||
scheduleParams.addTotalCumulativeInterest(totalInterest); | |||
} | |||
|
|||
// add charges only repayment schedule for charges with due date after maturity date (N+1) | |||
addChargesOnlyRepaymentSchedule(currency, scheduleParams, periods, loanCharges, mc, loanApplicationTerms, transactions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only needed for cumulative loans? What about progressive ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required for progressive ones also, but since interest handling, reschedule, prepayment and related stories for progressive schedule handling are pending i did not changed for progressive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does that mean if a progressive N+1 loan got rescheduled the N+1 charge will disappear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test and confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamsaghy, verified with latest, for progressive loans also N+1 installment vanishes after reschedule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please kindly review my comments!
be51f75
to
6bce7e3
Compare
Made changes to Loan Repayment schedule transaction processors for adding N+1 installments, for loan reschedule cases. |
@@ -78,6 +79,7 @@ public ChangedTransactionDetail reprocessLoanTransactions(final LocalDate disbur | |||
} | |||
} | |||
} | |||
addChargeOnlyRepaymentInstallmentIfRequired(charges, installments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont really understand why we need this here.
I am assuming when we are reprocessing the transactions, the installments list containing all the installments including the N+1... no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamsaghy, when reschedule happens N+1 installment is not created/retained for loan installments and hence the issue. When reprocess is called after schedule regeneration we are adding the missing installment if required.
if (!CollectionUtils.isEmpty(charges) && !CollectionUtils.isEmpty(installments)) { | ||
LoanRepaymentScheduleInstallment latestRepaymentScheduleInstalment = installments.get(installments.size() - 1); | ||
LocalDate installmentDueDate = null; | ||
for (final LoanCharge loanCharge : charges) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
charges are a set, there is no order how you are iterating through on it, and it can happen multiple charges are after the last installment due date, no?
I would be happier if we were taking the latest charge which was after the maturity date and set that one instead of iterating though on them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Will make this change.
6bce7e3
to
e90abc9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Modifications for N+1 installment for loan reschedule for cumulative loan schedule generator.
Tests
Describe the changes made and why they were made.
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!
Write the commit message as per https://github.com/apache/fineract/#pull-requests
Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
Create/update unit or integration tests for verifying the changes made.
Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)
FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.