FINERACT-2727: Fix loan product visibility when office-specific-products-enabled is on - #6209
Conversation
…cts-enabled is on
…product visibility
|
Run these before pushing any changes: |
elnafateh
left a comment
There was a problem hiding this comment.
squash the two commits into one
@elnafateh it would be better to keep the 2 commits seperated by the 2 tickets as they are related to each other and the second depends on the fixes in the first |
Yeah Maybe but It does'nt matter, It's a fineract rule... |
@elnafateh what is the rule? |
Since the PR says: @elnafateh is asking you to create a new PR for the |
@adamsaghy the issue here is that for the commit 2 if i want to create the new PR it needs commit 1 to be merged first or i need to base from the PR branch instead of develop |
Yes, thats the way... You have this PR with first commit, and based on this you create the new PR and once this is merged, you can auto rebase the 2nd and that way it is clear which PR is addressing which stories. |
|
|
Description:
Bug
Fineract has a global configuration flag
office-specific-products-enabledintended to restrict which loan products each office can offer. When enabled,
only the products explicitly mapped to an office (via Entity to Entity
Mapping) should be available to that office's users.
In practice, enabling this flag causes the opposite of the intended behavior:
Entity to Entity Mapping screen — the Loan Product dropdown in
Admin → System → Entity to Entity Mapping → Offices → Loan Products
shows only "All" and no individual products. This makes it impossible
to create the mappings the feature depends on.
Loan product listing — all loan products disappear from the listing
page for branch users, even products that should be visible (e.g. products
mapped to "All" or products with no mapping at all).
Loan application template — the
/loans/templateAPI returns anempty product list, blocking any new loan application when the flag is on.
The root cause is that
retrieveAllLoanProducts()ignores theoffice-specific-products-enabledflag entirely. There is no code path thatfilters or resolves the entity mappings to determine which products are
visible to a given office.
Fix
Introduce office-aware loan product retrieval:
FineractEntityAccessReadServiceImpl: addgetSQLQueryInClauseIDList_ForLoanProductsVisibleToOffice(officeId)whichresolves the entity mappings for an office (including parent–child hierarchy,
so a product mapped to a parent office is also available to child branches).
LoanProductReadPlatformService/LoanProductReadPlatformServiceImpl:add
retrieveAllLoanProductsV2()and overloads that use the above querywhen
office-specific-products-enabledis on, falling back to the originalbehavior when it is off.
LoanProductsApiResourceV2: new API endpoint that callsretrieveAllLoanProductsV2(), used by the Entity to Entity Mapping screenand the self-service loan products endpoint.
LoansApiResourceandBulkImportWorkbookPopulatorServiceImpl: updated touse the office-aware method so the loans template and bulk import respect
the same visibility rules.
Visibility rules when office-specific-products-enabled is ON
A loan product is visible to an office if:
parent hierarchy.