Samer-Melhem-FOO opened a new pull request, #6741:
URL: https://github.com/apache/fineract/pull/6741

   ## Description
   
   JIRA: [FINERACT-2996](https://issues.apache.org/jira/browse/FINERACT-2996)
   
   A percentage loan charge with a specified due date is capped to its min/max 
when the charge is created (`LoanCharge.minimumAndMaximumCap`), but the 
repayment schedule recomputes the period's amount as `base × percentage / 100` 
and never applies the cap. The installment holding the due date then carries 
the uncapped amount, `summary.feeChargesCharged` is overstated, and a repayment 
spends the excess on the loan's other fee charges.
   
   The fix applies `loanCharge.minimumAndMaximumCap(...)` in the four places 
that compute the amount:
   
   - 
`AbstractCumulativeLoanScheduleGenerator.calculateSpecificDueDateChargeWithPercentage`
   - 
`ProgressiveLoanScheduleGenerator.calculateSpecificDueDateChargeWithPercentage`
   - `LoanRepaymentScheduleProcessingWrapper.cumulativeFeeChargesDueWithin` / 
`cumulativePenaltyChargesDueWithin`
   - `SingleLoanChargeRepaymentScheduleProcessingWrapper.calcChargeDue`
   
   Flat, overdue and installment-fee charges take other branches and are 
unchanged.
   
   ### Testing
   
   - Unit: two new tests in 
`SingleLoanChargeRepaymentScheduleProcessingWrapperTest` (max cap and min cap). 
Both fail on `develop` (`100` instead of `50` / `150`) and pass with the fix. 
The class's existing tests still pass; `spotlessJavaCheck` is clean for both 
modules.
   - Live, on stock `develop` against PostgreSQL: a "Specified due date" / "% 
Amount" charge of 10% (min 50, max 200) plus two flat installment fees (36, 57) 
on a 10000, 12-installment cumulative loan, disbursed with the charge due on 
the disbursement date.
     - Before: charge amount 200, but installment 1 `feeChargesDue` = 1093 and 
`summary.feeChargesCharged` = 2116. Repaying installment 1 paid the 
installment-fee charges 360 and 533.
     - After: installment 1 `feeChargesDue` = 293, `summary.feeChargesCharged` 
= 1316. Repaying installment 1 paid the installment-fee charges exactly 36 and 
57.
   
   ## Checklist
   
   - [x] Write the commit message as per [our 
guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [x] 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.
   - [x] Create/update [unit or integration 
tests](https://fineract.apache.org/docs/current/#_testing) for verifying the 
changes made.
   - [x] 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 (no API change)
   - [x] [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).
   - [x] If merging this PR resolves a JIRA issue, I will mark that issue as 
resolved and set "Fix Version/s" appropriately.
   - [x] I followed the [AI 
Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy).
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to