FINERACT-2455: WC - delinquency bucket for regular loan shouldn't be available on WC loan product creation - #6477
Conversation
f1e0144 to
7e3aadb
Compare
…able on WC loan product creation
7e3aadb to
7b9f754
Compare
…cy bucket validation pre loan product type
|
@mariiaKraievska Please review my concerns / findings:
WorkingCapitalLoanAssemblerImpl.java:420-429 if (fromApiJsonHelper.parameterExists(delinquencyBucketIdParamName, element)) { The lookup + type validation runs unconditionally, outside the !Objects.equals(...) guard. The three sibling blocks around it (breachId, nearBreachId, delinquencyGraceDays) all gate the lookup on the change check. Consequence: a WC loan created before this PR with a REGULAR bucket (the old code was findById(bucketId).orElse(null) with no type check, so this was reachable) can no longer be modified at all if the client resends the unchanged delinquencyBucketId — it 400s on a no-op. Same shape for a since-deleted id, which used to be silently ignored and now throws DelinquencyBucketNotFoundException. Moving the resolve inside the if fixes both and matches the surrounding style. The WC product update path already does this correctly via isChangeInLongParameterNamed (WorkingCapitalLoanProductWritePlatformServiceImpl.java:276), as does the LP update path.
Both new errors pass the bucket id as a defaultUserMessageArgs value, but neither message has a {0} placeholder, so it's never rendered. The codes also drop the entity segment that the rest of the codebase uses (validation.msg.delinquencyBucketId.must.be.regular.type vs. the conventional validation.msg.loanproduct.delinquencyBucketId.…). The two messages are otherwise near-identical — one code parameterized by expected type would do.
WorkingCapitalDelinquencyBucketResolver.java:46-50. This preserves the old serialization behaviour, but it pushes null-returning into a shared service method that now has two callers (WC product template and, transitively, the WC loan template). Returning List.of() and keeping the null-ing at the response-building boundary would be safer.
retrieveAllDelinquencyBuckets() and retrieveDelinquencyBucketsByType() are identical apart from the finder (DelinquencyReadPlatformServiceImpl.java:105-119). Also validateIsWorkingCapitalType is public but only called from within its own class.
DelinquencyBucketResolver.resolveBucketId calls resolve(...) on this, so Spring's @Cacheable proxy is bypassed — every resolution re-fetches all buckets. Not a correctness issue. |
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.