HuangXi created FINERACT-2558:
---------------------------------

             Summary: Duplicate gender update block in client update flow 
causes redundant lookup and assignment
                 Key: FINERACT-2558
                 URL: https://issues.apache.org/jira/browse/FINERACT-2558
             Project: Apache Fineract
          Issue Type: Bug
          Components: Client
    Affects Versions: 1.14.0
            Reporter: HuangXi
         Attachments: image-2026-03-27-19-52-13-369.png

h1. Duplicate gender update execution in client update flow
h2. Problem

In the client update flow, gender update logic is executed twice when genderId 
is changed.
This causes redundant code-value lookup and duplicate setter invocation with 
the same value.

!image-2026-03-27-19-52-13-369.png!
h2. Call Flow

API receives update request in ClientsApiResource.java:522
Command routed to update handler UpdateClientCommandHandler.java:45
Business logic executed in ClientWritePlatformServiceJpaRepositoryImpl.java:407
Evidence

Change detection for genderId is added once at 
ClientWritePlatformServiceJpaRepositoryImpl.java:479
First gender update block at 
ClientWritePlatformServiceJpaRepositoryImpl.java:566
Second gender update block at 
ClientWritePlatformServiceJpaRepositoryImpl.java:588
The domain method only performs plain assignment at Client.java:649
Actual Behavior
When genderId changes, both gender update blocks run in the same request.
h2. Expected Behavior

Gender should be resolved and assigned exactly once per request.
h2. Impact

Redundant repository lookup and duplicate setter call
Reduced code clarity and higher maintenance cost
No functional gain, no intended special behavior observed
h2. Root Cause

Likely historical duplication during earlier feature extension 
(clientType/clientClassification block introduction), leaving an older gender 
block in place.
h2. Proposed Fix

Remove one duplicate gender update block in updateClient and keep a single 
canonical gender update section.
h2. Acceptance Criteria

genderId update path executes exactly one gender resolution and one 
updateGender call
Existing behavior for staffId, savingsProductId, clientTypeId, and 
clientClassificationId remains unchanged
Client update tests pass without regression



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

Reply via email to