Skip to content

Conversation

@Cocoa-Puffs
Copy link
Contributor

@Cocoa-Puffs Cocoa-Puffs commented Jul 24, 2025

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 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.

@Cocoa-Puffs Cocoa-Puffs force-pushed the FINERACT-2326-Reschedule-loan-with-interest-rate-change-to-zero-breaks-repayment-schedule branch 3 times, most recently from d5cbd96 to c4a74ea Compare July 25, 2025 13:56
@adamsaghy
Copy link
Contributor

@Cocoa-Puffs Please check the failing tests!

@ruzeynalov ruzeynalov force-pushed the FINERACT-2326-Reschedule-loan-with-interest-rate-change-to-zero-breaks-repayment-schedule branch from e448001 to 745288a Compare July 28, 2025 12:35
@Cocoa-Puffs Cocoa-Puffs force-pushed the FINERACT-2326-Reschedule-loan-with-interest-rate-change-to-zero-breaks-repayment-schedule branch 2 times, most recently from dc9d8f5 to 14e8136 Compare July 28, 2025 16:37
@Cocoa-Puffs Cocoa-Puffs marked this pull request as ready for review July 29, 2025 11:46
| 3 | 0 | 16 January 2024 | 16 January 2024 | 625.0 | 125.0 | 0.0 | 0.0 | 0.0 | 125.0 | 125.0 | 0.0 | 0.0 | 0.0 |
| 4 | 15 | 31 January 2024 | | 313.0 | 312.0 | 0.0 | 0.0 | 0.0 | 312.0 | 125.0 | 125.0 | 0.0 | 187.0 |
| 5 | 15 | 15 February 2024 | | 0.0 | 313.0 | 0.0 | 0.0 | 0.0 | 313.0 | 125.0 | 125.0 | 0.0 | 188.0 |
| 4 | 15 | 31 January 2024 | | 312.5 | 312.5 | 0.0 | 0.0 | 0.0 | 312.5 | 125.0 | 125.0 | 0.0 | 187.5 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these balances got changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a non-interest bearing loan, previously disbursements were handled without using the EMI model. In the recalculateRepaymentInstallmentsWithoutEMICalculation method we have some rounding logic based on installmentAmountInMultiplesOf of the loan. So previously the periods got rounded to whole numbers (in case of installmentAmountInMultiplesOf = 1). Now with the EMI calculator we can just calculate the exact emi for the periods.

| 4 | 15 | 28 April 2024 | 24 March 2024 | 0.0 | 121.58 | 0.0 | 0.0 | 0.0 | 121.58 | 121.58 | 121.58 | 0.0 | 0.0 |
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 14 March 2024 | | 487.58 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 0 | 14 March 2024 | 14 March 2024 | 365.58 | 122.0 | 0.0 | 0.0 | 0.0 | 122.0 | 122.0 | 0.0 | 0.0 | 0.0 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these balances got changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a non-interest bearing loan, previously disbursements were handled without using the EMI model. In the recalculateRepaymentInstallmentsWithoutEMICalculation method we have some rounding logic based on installmentAmountInMultiplesOf of the loan. So previously the periods got rounded to whole numbers (in case of installmentAmountInMultiplesOf = 1). Now with the EMI calculator we can just calculate the exact emi for the periods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats not how it should work... it doesnt matter whether you are using emi model or not... installment amount in multiples of should be respected...


private void handleCapitalizedIncome(LoanTransaction capitalizedIncomeTransaction, TransactionCtx transactionCtx) {
if (capitalizedIncomeTransaction.getLoan().isInterestBearing()) {
// TODO: Fix this and enhance EMICalculator to support reamortization and reaging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this comment to do with capitalized income?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my understanding the scope of the issue was to move away from non EMI methods as much as possible as part of this ticket. This could not be done completely in a timely fashion as there were multiple operations that would need to be included in the emi calculator for everything to work. Reaging, reamortization, charges. I added the todo so that in the future if we implement these operations in the emi calculator we can remove the non emi calculator using method, same as with disbursements.


@Setter
@Getter
private BigDecimal totalCapitalizedIncomeAmount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there some issue with capitalized income handling? Should this to be extracted into a separate PR?

Copy link
Contributor Author

@Cocoa-Puffs Cocoa-Puffs Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a problem specifically with 0% interest loans that have FLAT interest method, with capitalized income transactions. The method that provides the principal calculation in these cases is (now called) RepaymentPeriod.calculateTotalDisbursedAndCapitalizedIncomeAmountTillGivenPeriod, it also calculates the EMI values for flat interest loans in ProgressiveEMICalculator.calculateEMIOnActualModelWithFlatInterestMethod, previously the calculate method didn't include the capitalized income amounts in the total and because of this the principal from capitalized income transactions were not calculated into the EMI. I made it a part of this PR because the problem arose because the non-emi capitalized income handling didn't have this issue.

@Cocoa-Puffs Cocoa-Puffs marked this pull request as draft July 30, 2025 08:45
@Cocoa-Puffs Cocoa-Puffs force-pushed the FINERACT-2326-Reschedule-loan-with-interest-rate-change-to-zero-breaks-repayment-schedule branch from becd20a to 7f1053d Compare July 30, 2025 10:58
Cocoa-Puffs and others added 2 commits July 30, 2025 13:37
@Cocoa-Puffs Cocoa-Puffs force-pushed the FINERACT-2326-Reschedule-loan-with-interest-rate-change-to-zero-breaks-repayment-schedule branch from 7f1053d to 0072998 Compare July 30, 2025 12:07
@Cocoa-Puffs Cocoa-Puffs marked this pull request as ready for review July 30, 2025 12:08
| 3 | 0 | 01 April 2024 | 01 April 2024 | 478.31 | 78.17 | 0.0 | 0.0 | 0.0 | 78.17 | 78.17 | 0.0 | 0.0 | 0.0 |
| 4 | 15 | 13 April 2024 | | 239.16 | 239.15 | 0.0 | 0.0 | 0.0 | 239.15 | 121.89 | 121.89 | 0.0 | 117.26 |
| 5 | 15 | 28 April 2024 | | 0.0 | 239.16 | 0.0 | 0.0 | 0.0 | 239.16 | 121.9 | 121.9 | 0.0 | 117.26 |
| 4 | 15 | 13 April 2024 | | 239.15 | 239.16 | 0.0 | 0.0 | 0.0 | 239.16 | 121.89 | 121.89 | 0.0 | 117.27 |
Copy link
Contributor

@adamsaghy adamsaghy Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cocoa-Puffs @ruzeynalov Any reason why these changed?

@adamsaghy adamsaghy merged commit 68f20c2 into apache:develop Aug 4, 2025
39 checks passed
@adamsaghy adamsaghy deleted the FINERACT-2326-Reschedule-loan-with-interest-rate-change-to-zero-breaks-repayment-schedule branch August 4, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants