[ 
https://issues.apache.org/jira/browse/FINERACT-2996?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Adam Saghy resolved FINERACT-2996.
----------------------------------
    Resolution: Fixed

> Percentage specified-due-date loan charge ignores its min/max cap in the 
> repayment schedule
> -------------------------------------------------------------------------------------------
>
>                 Key: FINERACT-2996
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2996
>             Project: Apache Fineract
>          Issue Type: Bug
>          Components: Loan
>            Reporter: Foo Developer
>            Assignee: Foo Developer
>            Priority: Major
>             Fix For: 1.17.0
>
>
> h3. Summary
> A loan charge calculated as a percentage, with a specified due date and a 
> minimum/maximum cap, is capped correctly on the charge itself, but the 
> repayment schedule puts the uncapped percentage on the installment that holds 
> the due date. The loan summary's fees charged is overstated by the 
> difference. A repayment then allocates the excess to the loan's other fee 
> charges.
> h3. Steps to reproduce
> # Create a loan charge: charge applies to Loan, charge time type "Specified 
> due date", charge calculation "% Amount", amount {{10}}, minimum cap {{50}}, 
> maximum cap {{200}}.
> # Create two flat "Installment Fee" loan charges, for example {{36}} and 
> {{57}}.
> # Create a loan of {{10000}} with 12 monthly installments (cumulative 
> schedule, {{mifos-standard-strategy}}) carrying all three charges, with the 
> specified-due-date charge due on the disbursement date. Approve and disburse 
> it.
> # {{GET /loans/{loanId}?associations=repaymentSchedule,charges}}
> # Make a repayment equal to installment 1's total due.
> h3. Expected
> * The specified-due-date charge's {{amount}} is {{200}} (10% of 10000 = 1000, 
> capped at 200).
> * Installment 1 {{feeChargesDue}} is {{293}} (200 + 36 + 57).
> * {{summary.feeChargesCharged}} includes {{200}} for this charge.
> h3. Actual
> * The charge's {{amount}} is {{200}} (correct).
> * Installment 1 {{feeChargesDue}} is {{1093}}: the schedule uses the uncapped 
> {{1000}}.
> * {{summary.feeChargesCharged}} is {{800}} too high.
> * On the repayment, the fee portion is {{1093}}. The specified-due-date 
> charge is paid {{200}} and the remaining {{800}} is spent on the 
> installment-fee charges, so the fees of later installments look already 
> collected while those installments still show them as due.
> h3. Root cause
> The charge's own amount is capped at creation 
> ({{LoanCharge.minimumAndMaximumCap}}). The schedule code recomputes the 
> period's charge as {{base × percentage / 100}}, where the base can differ 
> from creation time (for example the amount disbursed by the due date on a 
> multi-disbursement loan), and never applies the same cap. There are four 
> places:
> * 
> {{AbstractCumulativeLoanScheduleGenerator.calculateSpecificDueDateChargeWithPercentage}}
>  (schedule generation, cumulative)
> * 
> {{ProgressiveLoanScheduleGenerator.calculateSpecificDueDateChargeWithPercentage}}
>  (schedule generation, progressive)
> * {{LoanRepaymentScheduleProcessingWrapper.cumulativeFeeChargesDueWithin}} / 
> {{cumulativePenaltyChargesDueWithin}} (reprocessing all charges, e.g. on a 
> repayment)
> * {{SingleLoanChargeRepaymentScheduleProcessingWrapper.calcChargeDue}} 
> (reprocessing one charge, e.g. when a charge is added)
> h3. Proposed fix
> Pass each of the four calculated amounts through 
> {{loanCharge.minimumAndMaximumCap(...)}}, so the installment carries the same 
> amount as the charge. Flat charges, overdue charges and installment fees take 
> other branches and are unchanged.
> Tests: two unit tests in 
> {{SingleLoanChargeRepaymentScheduleProcessingWrapperTest}} for a percentage 
> specified-due-date charge, one capped at the maximum and one raised to the 
> minimum. Both fail on the current code.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to