You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "mariiaKraievska (via GitHub)" <gi...@apache.org> on 2026/01/21 13:44:16 UTC
[PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
mariiaKraievska opened a new pull request, #5360:
URL: https://github.com/apache/fineract/pull/5360
## Description
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 [our guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#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](https://fineract.apache.org/docs/current/#_testing) for verifying the changes made.
- [ ] Follow our [coding conventions](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
- [ ] [This PR must not be a "code dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit). Large changes can be made in a branch, with assistance. Ask for help on the [developer mailing list](https://fineract.apache.org/#contribute).
Your assigned reviewer(s) will follow our [guidelines for code reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide).
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5360:
URL: https://github.com/apache/fineract/pull/5360#discussion_r2721098213
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java:
##########
@@ -1104,7 +1104,12 @@ private void calculateLastUnpaidRepaymentPeriodEMI(ProgressiveLoanInterestSchedu
Money diff = totalDisbursedAmount.plus(totalCapitalizedIncome, mc).plus(scheduleModel.getTotalCreditedPrincipal(), mc)
.plus(totalDueInterest, mc).minus(totalEMI, mc);
- repaymentPeriod.setEmi(repaymentPeriod.getEmi().add(diff, mc));
+ Money adjustedEmi = repaymentPeriod.getEmi().add(diff, mc);
+ if (repaymentPeriod.getFixedInterest().isGreaterThanZero()
+ && adjustedEmi.isLessThan(repaymentPeriod.getPaidPrincipal().add(repaymentPeriod.getFixedInterest()))) {
+ adjustedEmi = repaymentPeriod.getPaidPrincipal().add(repaymentPeriod.getFixedInterest());
+ }
Review Comment:
Why is this needed? The fixed interest is part of the calculated interest period interest. why to consider here 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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5360:
URL: https://github.com/apache/fineract/pull/5360#discussion_r2721263308
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java:
##########
@@ -287,13 +289,8 @@ private void insertInterestPausePeriods(final RepaymentPeriod repaymentPeriod, f
}
private InterestPeriod findPreviousInterestPeriod(final RepaymentPeriod repaymentPeriod, final LocalDate date) {
- if (date.isAfter(repaymentPeriod.getFromDate())) {
- return repaymentPeriod.getLastInterestPeriod();
- } else {
- return repaymentPeriod.getInterestPeriods().stream()
- .filter(ip -> date.isAfter(ip.getFromDate()) && !date.isAfter(ip.getDueDate())).reduce((first, second) -> second)
- .orElse(repaymentPeriod.getInterestPeriods().getFirst());
- }
+ return repaymentPeriod.getInterestPeriods().stream().filter(ip -> date.isAfter(ip.getFromDate()) && !date.isAfter(ip.getDueDate()))
+ .reduce((first, second) -> second).orElse(repaymentPeriod.getInterestPeriods().getFirst());
Review Comment:
I think we are still missing 2 cases:
- If the date is on rp.getFromDate() -> use 1st interest period
- if the date is on rp.getduedate() -> use last interest period
otherwise use `repaymentPeriod.getInterestPeriods().stream().filter(ip -> date.isAfter(ip.getFromDate()) && !date.isAfter(ip.getDueDate()))
.reduce((first, second) -> second).orElse(repaymentPeriod.getInterestPeriods().getFirst());`
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5360:
URL: https://github.com/apache/fineract/pull/5360#discussion_r2721165146
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java:
##########
@@ -248,7 +248,9 @@ void insertInterestPeriod(final RepaymentPeriod repaymentPeriod, final LocalDate
previousInterestPeriod.addBalanceCorrectionAmount(correctionAmount);
final InterestPeriod interestPeriod = InterestPeriod.withEmptyAmounts(repaymentPeriod, newDueDate, originalDueDate, isPaused);
- repaymentPeriod.getInterestPeriods().add(interestPeriod);
+ final List<InterestPeriod> interestPeriods = repaymentPeriod.getInterestPeriods();
+ final int previousIndex = interestPeriods.indexOf(previousInterestPeriod);
+ interestPeriods.add(previousIndex + 1, interestPeriod);
Review Comment:
I would do this instead:
```
newInterestPeriods.sort(Comparator.comparing(InterestPeriod::getFromDate));
repaymentPeriod.setInterestPeriods(newInterestPeriods);
```
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #5360:
URL: https://github.com/apache/fineract/pull/5360
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5360:
URL: https://github.com/apache/fineract/pull/5360#discussion_r2721263308
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java:
##########
@@ -287,13 +289,8 @@ private void insertInterestPausePeriods(final RepaymentPeriod repaymentPeriod, f
}
private InterestPeriod findPreviousInterestPeriod(final RepaymentPeriod repaymentPeriod, final LocalDate date) {
- if (date.isAfter(repaymentPeriod.getFromDate())) {
- return repaymentPeriod.getLastInterestPeriod();
- } else {
- return repaymentPeriod.getInterestPeriods().stream()
- .filter(ip -> date.isAfter(ip.getFromDate()) && !date.isAfter(ip.getDueDate())).reduce((first, second) -> second)
- .orElse(repaymentPeriod.getInterestPeriods().getFirst());
- }
+ return repaymentPeriod.getInterestPeriods().stream().filter(ip -> date.isAfter(ip.getFromDate()) && !date.isAfter(ip.getDueDate()))
+ .reduce((first, second) -> second).orElse(repaymentPeriod.getInterestPeriods().getFirst());
Review Comment:
I think we are still missing 2 cases:
- If the date is on rp.getFromDate() -> use 1st interest period
- if the date is on rp.getduedate() -> use last interest period
otherwise use `repaymentPeriod.getInterestPeriods().stream().filter(ip -> date.isAfter(ip.getFromDate()) && !date.isAfter(ip.getDueDate()))
.reduce((first, second) -> second).orElse(repaymentPeriod.getInterestPeriods().getFirst());`
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5360:
URL: https://github.com/apache/fineract/pull/5360#discussion_r2721103223
##########
fineract-e2e-tests-runner/src/test/resources/features/LoanReAging.feature:
##########
@@ -8005,14 +8005,14 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 2 | 29 | 01 March 2024 | 15 March 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 3 | 14 | 15 March 2024 | 15 March 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 4 | 17 | 01 April 2024 | | 70.25 | 13.32 | 0.98 | 0.0 | 0.0 | 14.3 | 0.0 | 0.0 | 0.0 | 14.3 |
- | 5 | 30 | 01 May 2024 | | 56.08 | 14.17 | 0.13 | 0.0 | 0.0 | 14.3 | 0.0 | 0.0 | 0.0 | 14.3 |
- | 6 | 31 | 01 June 2024 | | 41.78 | 14.3 | 0.0 | 0.0 | 0.0 | 14.3 | 0.0 | 0.0 | 0.0 | 14.3 |
- | 7 | 30 | 01 July 2024 | | 27.65 | 14.13 | 0.17 | 0.0 | 0.0 | 14.3 | 0.0 | 0.0 | 0.0 | 14.3 |
- | 8 | 31 | 01 August 2024 | | 13.51 | 14.14 | 0.16 | 0.0 | 0.0 | 14.3 | 0.0 | 0.0 | 0.0 | 14.3 |
- | 9 | 31 | 01 September 2024 | | 0.0 | 13.51 | 0.08 | 0.0 | 0.0 | 13.59 | 0.0 | 0.0 | 0.0 | 13.59 |
+ | 5 | 30 | 01 May 2024 | | 56.06 | 14.19 | 0.11 | 0.0 | 0.0 | 14.3 | 0.0 | 0.0 | 0.0 | 14.3 |
Review Comment:
Were we calculating interest incorrectly?
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5360:
URL: https://github.com/apache/fineract/pull/5360#discussion_r2721098213
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java:
##########
@@ -1104,7 +1104,12 @@ private void calculateLastUnpaidRepaymentPeriodEMI(ProgressiveLoanInterestSchedu
Money diff = totalDisbursedAmount.plus(totalCapitalizedIncome, mc).plus(scheduleModel.getTotalCreditedPrincipal(), mc)
.plus(totalDueInterest, mc).minus(totalEMI, mc);
- repaymentPeriod.setEmi(repaymentPeriod.getEmi().add(diff, mc));
+ Money adjustedEmi = repaymentPeriod.getEmi().add(diff, mc);
+ if (repaymentPeriod.getFixedInterest().isGreaterThanZero()
+ && adjustedEmi.isLessThan(repaymentPeriod.getPaidPrincipal().add(repaymentPeriod.getFixedInterest()))) {
+ adjustedEmi = repaymentPeriod.getPaidPrincipal().add(repaymentPeriod.getFixedInterest());
+ }
Review Comment:
Why is this needed? The fixed interest rate is part of the calculated interest period interest. why to consider here 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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2389: loan is not closed with outstanding amount during pay-off loan with reschedule trns [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5360:
URL: https://github.com/apache/fineract/pull/5360#discussion_r2721165146
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java:
##########
@@ -248,7 +248,9 @@ void insertInterestPeriod(final RepaymentPeriod repaymentPeriod, final LocalDate
previousInterestPeriod.addBalanceCorrectionAmount(correctionAmount);
final InterestPeriod interestPeriod = InterestPeriod.withEmptyAmounts(repaymentPeriod, newDueDate, originalDueDate, isPaused);
- repaymentPeriod.getInterestPeriods().add(interestPeriod);
+ final List<InterestPeriod> interestPeriods = repaymentPeriod.getInterestPeriods();
+ final int previousIndex = interestPeriods.indexOf(previousInterestPeriod);
+ interestPeriods.add(previousIndex + 1, interestPeriod);
Review Comment:
I would do this instead:
```
newInterestPeriods.sort(Comparator.comparing(InterestPeriod::getFromDate));
repaymentPeriod.setInterestPeriods(newInterestPeriods);
```
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org