Skip to content

Conversation

@airajena
Copy link
Contributor

@airajena airajena commented Jan 17, 2026

Description

This PR addresses two distinct issues identified in e2e testing:

  1. Client Charges: Enhances validation for client charge payments (e.g., annual fees) to strictly prevent payments before the due date, while allowing payments on or after the due date.
  2. Progressive Loan Schedule: Fixes the EMI calculation for Progressive Loans to correctly honor the allowPartialPeriodInterestCalculation configuration.

Changes

  • ClientChargeWritePlatformServiceImpl.java:
    • Added a validation check in validatePaymentDateAndAmount.
    • Ensures that if a transaction date is before the clientCharge due date, it fails with the error code transaction.before.dueDate. This clarifies that payments are allowed on or after the due date, but not before.
  • ProgressiveEMICalculator.java:
    • Modified calculateRateFactorPerPeriod logic.
    • Added a check for !loanProductRelatedDetail.isAllowPartialPeriodInterestCalculation().
    • If partial period calculation is disabled, the system now forces the interest calculation to use the full calculatedDaysInRepaymentPeriod instead of the actualDaysInPeriod, preventing incorrect partial interest accrual in specific schedule generation scenarios.

Rationale

  • Client Charges: In real-world scenarios, charges like annual fees might be paid after the due date (e.g., due to weekends or processing delays). The system should explicitly allow this while maintaining a check against premature payments.
  • Progressive Loan: The allowPartialPeriodInterestCalculation flag was not being consistently applied in the rate factor calculation, causing discrepancies in EMI schedules for loans where partial interest should be disabled.

Testing

  • Validated that transaction.before.dueDate error is raised for early client charge payments.
  • Ensured Progressive Loan EMI calculations are correct when allowPartialPeriodInterestCalculation is set to false.
  • Resolves failing e2e tests related to these scenarios.

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 attach proper integration or E2E test cases to cover this functionality!

@airajena airajena force-pushed the FINERACT-2155/allow-charge-payment-after-due-date branch 2 times, most recently from a93912c to 8e40cff Compare January 21, 2026 17:51
@airajena
Copy link
Contributor Author

Please attach proper integration or E2E test cases to cover this functionality!

Added integration test.

@airajena airajena force-pushed the FINERACT-2155/allow-charge-payment-after-due-date branch from fd36cb1 to 589f19b Compare January 23, 2026 08:09
Comment on lines 1374 to 1379
BigDecimal actualDaysInPeriod = BigDecimal.valueOf(DateUtils.getDifferenceInDays(interestPeriodFromDate, interestPeriodDueDate));
if (loanProductRelatedDetail.getInterestCalculationPeriodMethod() != null
&& loanProductRelatedDetail.getInterestCalculationPeriodMethod().isSameAsRepaymentPeriod()
&& !loanProductRelatedDetail.isAllowPartialPeriodInterestCalculation()) {
actualDaysInPeriod = calculatedDaysInRepaymentPeriod;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think this is relevant for the FINERACT-2155 story.

Also I dont think this is correct either... Ratefactor is only from the interest period. It is independent from interest calculation period method. That should only control whether we are taking all the interest periods anyway or not, but not directly the sub interest period.

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 the review. I have removed the changes to ProgressiveEMICalculator.java and ClientChargeWritePlatformServiceImpl.java as requested, keeping the PR focused solely on the valid fix for FINERACT-2155 in SavingsAccount.java.

Regarding the reverted changes: I initially thought they were necessary to fix e2e test failures I encountered earlier.

Could you please point me to any documentation regarding the financial architecture calculations in Fineract? It would help me better understand the model for future contributions.

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 remove the unrelated parts of the PR!

@airajena airajena force-pushed the FINERACT-2155/allow-charge-payment-after-due-date branch from 589f19b to b66a85d Compare January 23, 2026 14:03
@airajena airajena force-pushed the FINERACT-2155/allow-charge-payment-after-due-date branch from b66a85d to 34fb56e Compare January 23, 2026 14:11
@adamsaghy adamsaghy merged commit 52aaad9 into apache:develop Jan 26, 2026
36 checks passed
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.

2 participants