aya-abdallah-FOO opened a new pull request, #6209:
URL: https://github.com/apache/fineract/pull/6209

   Description:                                                                 
                                                                                
                     
                                                                                
                                                                                
                       
     ## Bug                                                                     
                                                                                
                       
                                                                                
                                                                                
                       
     Fineract has a global configuration flag 
`office-specific-products-enabled`                                              
                                                         
     intended 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:                                                                       
                              
                                                                                
                                                                                
                       
     1. **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.                          
                                                                                
                       
                                                                                
                                                                                
                       
     2. **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).                    
                                                                                
                       
                                                                                
                                                                                
                       
     3. **Loan application template** — the `/loans/template` API returns an    
                                                                                
                       
        empty product list, blocking any new loan application when the flag is 
on.    
   The root cause is that `retrieveAllLoanProducts()` ignores the               
                                                                                
                     
     `office-specific-products-enabled` flag entirely. There is no code path 
that                                                                            
                          
     filters or resolves the entity mappings to determine which products are    
                                                                                
                       
     visible to a given office.                                                 
                                                                                
                       
                                                                                
                                                                                
                       
     ## Fix                                                                     
                                                                                
                       
                                                                                
                                                                                
                       
     Introduce office-aware loan product retrieval:                             
                                                                                
                       
                                                                                
                                                                                
                       
     - `FineractEntityAccessReadServiceImpl`: add                               
                                                                                
                       
       `getSQLQueryInClauseIDList_ForLoanProductsVisibleToOffice(officeId)` 
which                                                                           
                           
       resolves 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 query 
                                                                                
                       
       when `office-specific-products-enabled` is on, falling back to the 
original                                                                        
                             
       behavior when it is off.                                                 
                                                                                
                       
                                                                                
                                                                                
                       
     - `LoanProductsApiResourceV2`: new API endpoint that calls                 
                                                                                
                       
       `retrieveAllLoanProductsV2()`, used by the Entity to Entity Mapping 
screen                                                                          
                            
       and the self-service loan products endpoint.                             
                                                                                
                       
                                                                                
                                                                                
                       
     - `LoansApiResource` and `BulkImportWorkbookPopulatorServiceImpl`: updated 
to                                                                              
                       
       use 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:                                 
                                                                                
                       
     - It has no entity mapping at all, OR                                      
                                                                                
                       
     - It is mapped to "All", OR                                                
                                                                                
                       
     - It is explicitly mapped to the user's office or any office in its        
                                                                                
                       
       parent hierarchy.                                                        
                                                                                
                       
                            


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to