FINERACT-2455: Fix COB amortizing discount fee before payment, fix WC loan closedOnDate wrong when backdated transaction closes - #6469
Conversation
f58976a to
f09191e
Compare
… loan closedOnDate wrong when backdated transaction closes
f09191e to
8b768c6
Compare
…ing discount fee before payment, fix WC loan closedOnDate wrong when backdated transaction closes
adamsaghy
left a comment
There was a problem hiding this comment.
Please review the below findings / concerns:
the undoTransaction call site is a no-op in the case it was added for
WorkingCapitalLoanTransactionProcessor.recalculateClosedOnDate's javadoc says it "must be called wherever determineAndTransition can stamp a closure … the repayment path here, a discount fee adjustment, and a transaction undo", and the PR duly adds it at WorkingCapitalLoanWritePlatformServiceImpl.java line 1145. That call can never fire there:
-
undoTransaction transitions with DateUtils.getBusinessLocalDate(), so any closure it stamps carries today's date.
-
Future-dated transactions are rejected (WorkingCapitalLoanDataValidator), so MAX(repayment date) <= today, and the isBefore guard is always false.
The reachable case it would need to fix is the mirror image: validateUndoTransaction explicitly allows OVERPAID, so undoing an overpaying repayment that leaves the loan exactly settled fires LOAN_REPAID_IN_FULL and stamps closedOnDate = the undo day, while maturedOnDate keeps the earlier date it got when the loan first went overpaid. You end up with timeline.closedOnDate after timeline.actualMaturityDate — the drift the settlementDate javadoc says these two should not have. Pre-existing, not a regression, but the javadoc currently overstates what the call does.
Smaller, same shape: recalculateClosedOnDate returns early unless isClosedObligationsMet(), so on the overpaid path maturedOnDate is never corrected. A backdated repayment tipping a part-paid loan into OVERPAID leaves actualMaturityDate at the backdated date even though recalculateOverpaidOnDate fixes overpaidOnDate and settlementDate uses the corrected value for the amortization.
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.