FINERACT-2721: Fix loan collateral quantity adjustment and modify-loan change detection - #6196
Open
Samer-Melhem-FOO wants to merge 1 commit into
Conversation
…n change detection
Contributor
Author
|
The only failing check here ( Would appreciate a re-run of that job when convenient — happy to investigate further if it fails again on a fresh run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two related defects in loan collateral handling (
LoanCollateralAssembler/LoanAssemblerImpl):Repeated quantity deduction.
LoanCollateralAssembler.fromParsedJson(...)deducted client collateral quantity on every call, including from read-only paths (loan application validation, schedule preview), not just actual loan submission/update. Since the same parsing method is reused across both, a client's available collateral quantity could be decremented more than once for the same loan, and submitting a loan with linked collateral could fail with an "invalid amount of collateral quantity" error even with sufficient collateral available.Inverted change detection on loan modification. In
LoanAssemblerImpl, the check that decides whether collateral changed on a Modify Loan Application request was inverted:This recorded a "collateral changed" entry (and triggered
loan.updateLoanCollateral(...)) only when the new and existing collateral sets were equal — i.e. when nothing changed — and skipped it when they genuinely differed. Real collateral changes on loan modification were silently dropped.Fix:
LoanCollateralAssembler.fromParsedJsonnow takes an explicitadjustClientCollateralQuantityflag, defaulting tofalsefor read-only/validation callers (existing single-arg overload preserved) andtrueonly for actual loan submission/update. The modify-loan condition is flipped to!equals(...)so genuine changes are detected and persisted.JIRA: https://issues.apache.org/jira/browse/FINERACT-2721
Checklist
Note: no existing unit/integration test covers
LoanCollateralAssembler/LoanAssemblerImpl's collateral-handling logic, so none were added — happy to add coverage if a reviewer points to the right harness (loan submission with collateral is normally exercised via integration tests).