FINERACT-2455: Working Capital Loan product payment amount calculation strategy - Annual EIR - #6398
Conversation
8b85fbe to
5a24ce5
Compare
|
@mariiaKraievska Please rebase |
galovics
left a comment
There was a problem hiding this comment.
This directly overlaps with #6264 and #6343 on the same JIRA ticket - 6 of the same files touched, including a three-way constructor collision on ProjectedAmortizationScheduleModel where this PR adds a field called annualEir (the operator-supplied target) right as #6343 adds annualEffectiveInterestRate (the solved output) - near-identical names, opposite meanings, on the same class. This needs to be settled with the other two PR authors before any of the three goes further.
Two reachable NPEs, both blocking:
withDiscount()unconditionally dereferencestotalPaymentVolume.getAmount(), butgenerateFromAnnualEirpassesnullfor that field.regenerate()correctly branches on whetherannualEir != null, butwithDiscount()doesn't - and it's reached from a routine unearned-fee query (totalActualAmortizationWithDiscount) on any Annual EIR loan.resolveAnnualEirinWorkingCapitalLoanAmortizationScheduleWriteServiceImplis missing the samegetLoanProduct() != null && getRelatedDetail() != nullguard that its sibling methodresolvePaymentAmountCalculationStrategyhas right above it.
Also blocking: the new Liquibase part (0077_wc_payment_amount_calculation_strategy.xml) duplicates a changeset number already taken by 0077_wc_loan_recovery_payment.xml on develop. Needs a rebase and renumber.
On the math itself - dailyRateFromAnnualEir computes the deannualized rate via Math.pow(...).doubleValue() and discards the passed-in MathContext on the result, rather than reusing #6343's TvmFunctions.deannualize (which has an overflow-safe Newton-Raphson implementation of the identical formula in the same file). And the stored effectiveInterestRate for this strategy is the target rate, not the realized IRR of the actual (whole-cent-rounded) schedule - which will disagree with what a client recomputes from the emitted payment rows.
A few more worth addressing: validation is asymmetric between create and update (a TPV loan can have annualEir set via update with no strategy check, and vice versa for periodPaymentRate), and the loan-level annualEir override has no min/max bounds unlike its periodPaymentRate counterpart - a real pricing-control gap, not just incompleteness.
I know it's a draft, but given the collision with two other open PRs on the same fields, I'd rather this get coordinated before more work goes into any of the three.
Recommendation: CHANGES_REQUESTED
5a24ce5 to
2ae28e5
Compare
…n strategy - Annual EIR
2ae28e5 to
e5601ec
Compare
@galovics Thanks for the review. Naming #6343: Coordinated with the @oleksii-novikov-onix . Blocking / other notes: Addressed on this branch — |
|
@mariiaKraievska Please rebase |
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!
Your assigned reviewer(s) will follow our guidelines for code reviews.