[ 
https://issues.apache.org/jira/browse/FINERACT-2530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18065856#comment-18065856
 ] 

Shubham kumar commented on FINERACT-2530:
-----------------------------------------

Hi Adam Saghy, I’d like to take on this issue. I have already researched the 
cause of this issue, and I found that the cause is related to the INNER JOIN in 
ProvisioningEntriesReadPlatformServiceImpl. I’m ready to make a fix for this 
issue. Can you please assign this issue to me?

> 500 Internal Server Error on GET /provisioningentries/{id} when entry has no 
> associated loan products
> -----------------------------------------------------------------------------------------------------
>
>                 Key: FINERACT-2530
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2530
>             Project: Apache Fineract
>          Issue Type: Bug
>          Components: Accounting
>    Affects Versions: 1.15.0
>            Reporter: Shubham kumar
>            Priority: Major
>
> h2. Problem
> When a provisioning entry exists in *m_provisioning_history* but has no 
> related records in *m_loanproduct_provisioning_entry*, calling:
> GET /fineract-provider/api/v1/provisioningentries/{id}
> returns *HTTP 500 Internal Server Error* with 
> *EmptyResultDataAccessException*.
> h2. Root Cause
> In +ProvisioningEntriesReadPlatformServiceImpl.java+, the query in 
> *PROVISIONING_ENTRY_SUM_RESERVED_SCHEMA* uses an INNER JOIN:
> {code:sql}
> FROM m_provisioning_history entry
> JOIN m_loanproduct_provisioning_entry reserved 
> ON entry.id = reserved.history_id
> {code}
> If no rows exist in *m_loanproduct_provisioning_entry* for the given ID, 
> the query returns 0 rows and Spring's *queryForObject()* throws 
> *EmptyResultDataAccessException*.
> h2. Proposed Fix
> Replace the INNER JOIN with a LEFT JOIN:
> {code:sql}
> FROM m_provisioning_history entry
> LEFT JOIN m_loanproduct_provisioning_entry reserved 
> ON entry.id = reserved.history_id
> {code}
> This ensures the query always returns one row, with 
> *SUM(reserved.reserve_amount)* as NULL when no records exist.
> h2. Steps to Reproduce
> # Ensure no active loans exist.
> # Create a provisioning entry using POST /provisioningentries.
> # Call GET /provisioningentries/{id}.
> # Observe HTTP 500 error.
> h2. Expected Behavior
> API should return *HTTP 200* with provisioning entry details.  
> *totalReservedAmount* should be NULL if no loan product entries exist.
> h2. Actual Behavior
> HTTP 500 – *EmptyResultDataAccessException*
> h2. Affected File
> fineract-accounting/.../ProvisioningEntriesReadPlatformServiceImpl.java  
> (Line ~198)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to