[
https://issues.apache.org/jira/browse/FINERACT-2721?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Foo Developer reassigned FINERACT-2721:
---------------------------------------
Assignee: Foo Developer
> Loan collateral quantity handling is incorrect on submission and modify-loan
> silently drops collateral changes
> --------------------------------------------------------------------------------------------------------------
>
> Key: FINERACT-2721
> URL: https://issues.apache.org/jira/browse/FINERACT-2721
> Project: Apache Fineract
> Issue Type: Bug
> Reporter: Foo Developer
> Assignee: Foo Developer
> Priority: Major
>
> Two related defects in loan collateral handling (LoanCollateralAssembler /
> LoanAssemblerImpl):
> # Client collateral quantity is deducted every time
> {{LoanCollateralAssembler.fromParsedJson(...)}} is called, including from
> code paths that only need to read/validate the requested collateral (e.g.
> loan application validation, schedule preview) rather than actually commit a
> loan. Because the same parsing method is reused for both read-only and write
> paths, the client's available collateral quantity can be decremented more
> than once for the same loan, and submitting a loan with linked collateral can
> fail with an "invalid amount of collateral quantity" error even though the
> client has sufficient collateral.
> # In {{LoanAssemblerImpl}}, when modifying an existing loan application's
> collateral, the change-detection check is inverted:
>
> possiblyModifedLoanCollateralItems.equals(loan.getLoanCollateralManagements())
> This records a "collateral changed" entry (and therefore calls
> {{loan.updateLoanCollateral(...)}}) only when the new and existing collateral
> sets are equal — i.e. when nothing actually changed — and skips it when they
> differ. As a result, the Modify Loan Application API silently fails to
> persist real collateral changes, while doing a redundant no-op update when
> nothing changed.
> Proposed fix: give {{LoanCollateralAssembler.fromParsedJson}} an explicit
> flag for whether client collateral quantities should be adjusted, defaulting
> to {{false}} for read-only/validation callers and {{true}} only when actually
> submitting or updating a loan; and flip the modify-loan change-detection
> condition to {{!equals(...)}} so real collateral changes are detected and
> persisted correctly.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)