FINERACT-2455: working capital breach reset split period undo - #6283
FINERACT-2455: working capital breach reset split period undo#6283budaidev wants to merge 1 commit into
Conversation
galovics
left a comment
There was a problem hiding this comment.
The undo path is well covered - unit tests on both the resolver and the schedule methods, plus six integration tests including the pause-extended and payment-reassignment cases. That's usually the part I have to ask for, so nice work there.
My concern is with how the undo figures out what to revert. restoreSplitPeriod reverse-engineers the pre-split state from the schedule as it stands now plus the current breach config, using three guard clauses to decide whether the split it's looking at is actually the one this undo owns. Two of those guards fall through to a log.warn and a false, and the caller then just recalculates past due and returns 200 - so the user gets a success response for an undo that only lifted a flag and left the split in place.
Concretely: a RESCHEDULE recorded between the reset and the undo changes resolveEffectiveRescheduleParams, so the restore recomputes a boundary that never existed. And any PAUSE/RESUME between reset and undo rewrites every period contiguously from the schedule's first fromDate without knowing about the split, so the split disappears from the schedule entirely while the RESET row still says restartPeriodFromResetDate = true - the undo then silently falls into the flag-only branch.
Wouldn't it be simpler and deterministic to record on the RESET action row what the reset actually changed (the pre-split toDate, maybe the period id), and have the undo just write that back? Then there's nothing to guess and nothing that can silently degrade. The same reconstruction problem shows up in findLatestFlaggedPeriod's "last flagged period by period number" fallback in the reset service - it assumes period-number order tracks reset-date order, which is exactly the assumption the boundary rewrites can break.
Two smaller things while I was in there:
splitPeriodAtResetonly guardsresetDate == fromDate;resetDate < fromDatefalls through and can persist a period withtoDate < fromDate/ negativenumberOfDays.- The RESET-undo replay in
WorkingCapitalLoanActiveBreachResetResolveris ordered bystartDate, id- since reset/undo dates are always "the current business date," if the business date is ever moved backwards between two actions the replay order diverges from creation order, and thebreak-on-id can stop before the reset it's meant to cancel.
This is a draft so nothing's blocking yet, but I'd like to settle the design question (store vs. reconstruct) before it comes out of draft - it affects several of the methods above at once.
Recommendation: COMMENT
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.