Skip to content

FINERACT-1981: Progressive Loan schedule handling - Installment charges#4800

Merged
adamsaghy merged 2 commits intoapache:developfrom
openMF:FINERACT-1981/progressive-loan-schedule-handling-installment-charges
Jul 8, 2025
Merged

FINERACT-1981: Progressive Loan schedule handling - Installment charges#4800
adamsaghy merged 2 commits intoapache:developfrom
openMF:FINERACT-1981/progressive-loan-schedule-handling-installment-charges

Conversation

@mariiaKraievska
Copy link
Contributor

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.

@adamsaghy
Copy link
Contributor

@mariiaKraievska Please run spotlessApply to avoid checkstyle issues!

@mariiaKraievska mariiaKraievska force-pushed the FINERACT-1981/progressive-loan-schedule-handling-installment-charges branch 3 times, most recently from 52c8414 to 81b573a Compare June 25, 2025 09:38
if (installment.isDownPayment()) {
continue;
}
boolean installmentChargeApplicable = !installment.isRecalculatedInterestComponent();
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to remove this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have reverted this change, since we agreed to disallow installment fee charges that are calculated as a percentage of principal or interest when interest recalculation is enabled.

if (loanCharge.isFeeCharge() && loanCharge.isDueAtDisbursement()) {
return zero;
}
if (loanCharge.isInstalmentFee() && isInstallmentChargeApplicable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to remove this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have reverted this change, since we agreed to disallow installment fee charges that are calculated as a percentage of principal or interest when interest recalculation is enabled.

if (!predicate.test(loanCharge)) {
return zero;
}
if (loanCharge.isInstalmentFee() && isInstallmentChargeApplicable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to remove this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have reverted this change, since we agreed to disallow installment fee charges that are calculated as a percentage of principal or interest when interest recalculation is enabled.

for (LoanCharge loanCharge : charges) {
String errorcode = null;
switch (loanCharge.getChargeCalculation()) {
case PERCENT_OF_AMOUNT:
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to remove these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have reverted this change, since we agreed to disallow installment fee charges that are calculated as a percentage of principal or interest when interest recalculation is enabled.

Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

Please review my questions

@adamsaghy
Copy link
Contributor

@mariiaKraievska please rebase

@mariiaKraievska mariiaKraievska force-pushed the FINERACT-1981/progressive-loan-schedule-handling-installment-charges branch 2 times, most recently from c2123dd to eb81c8d Compare July 7, 2025 06:59
for (LoanInstallmentCharge oldCharge : loanCharge.getLoanInstallmentCharge()) {
oldCharge.getInstallment().getInstallmentCharges().remove(oldCharge);
}
loanCharge.getLoanInstallmentCharge().clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to drop all charges? That would recreate charges every time... Was the previous version which only updated the existing once wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your question!
After reverting to the previous logic, I encountered a database integrity error during testing (specifically on charge-off with accelerate maturity date behaviour), caused by a foreign key constraint violation between m_loan_installment_charge and m_loan_repayment_schedule.
It seems that the old approach does not always properly remove or update all related installment charges before the repayment schedule is changed, which leads to this issue.
That’s why the logic to clear and recreate all charges was introduced — to ensure data consistency and avoid such integrity problems.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, it is suboptimal, as we are recreating charges which are unchanged :/ I wonder whether we should have some logic which can compare them properly...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please check updated version of this method 🙏

@mariiaKraievska mariiaKraievska force-pushed the FINERACT-1981/progressive-loan-schedule-handling-installment-charges branch from eb81c8d to d6b4e43 Compare July 7, 2025 12:04
@adamsaghy
Copy link
Contributor

@mariiaKraievska Please rebase this PR.

@mariiaKraievska mariiaKraievska force-pushed the FINERACT-1981/progressive-loan-schedule-handling-installment-charges branch from 6ba1912 to 6af18e7 Compare July 8, 2025 09:19
@mariiaKraievska
Copy link
Contributor Author

@mariiaKraievska Please rebase this PR.

Done

@mariiaKraievska mariiaKraievska force-pushed the FINERACT-1981/progressive-loan-schedule-handling-installment-charges branch from 6af18e7 to a8b56f3 Compare July 8, 2025 20:28
Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

LGTM

@adamsaghy adamsaghy marked this pull request as ready for review July 8, 2025 21:22
@adamsaghy adamsaghy merged commit 3f359bb into apache:develop Jul 8, 2025
39 checks passed
@adamsaghy adamsaghy deleted the FINERACT-1981/progressive-loan-schedule-handling-installment-charges branch July 8, 2025 21:22
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