Shubham kumar created FINERACT-2530:
---------------------------------------
Summary: 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
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)