Skip to content

Conversation

@Akshat-Soni02
Copy link

Description

Implemented missing status mappings for savings and share entities in the SearchMapper to ensure accurate and complete search results.

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per https://github.com/apache/fineract/#pull-requests
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)

FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.

Copy link
Contributor

@IOhacker IOhacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to do a squash and commit. Are you proposing to look up by the internal ID?

@Akshat-Soni02
Copy link
Author

Make sure to do a squash and commit. Are you proposing to look up by the internal ID?

I’m not directly using the internal status ID.
I’m following the same pattern used for loan and client:
using SavingsEnumerations , SharesEnumerations

@Akshat-Soni02 Akshat-Soni02 force-pushed the fineract-2408/search-api-for-savings branch from bc62c6b to a34c455 Compare November 20, 2025 06:36
@rhopman
Copy link
Contributor

rhopman commented Nov 23, 2025

Implementation looks good to me. I would recommend adding a test in SearchResourcesTest.java, something like this:

    @Test
    public void searchSavingsAndSharesHaveEntityStatus() {
        // Create client
        String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null);
        final PostClientsResponse clientResponse = ClientHelper.addClientAsPerson(requestSpec, responseSpec, jsonPayload);
        final Long clientId = clientResponse.getClientId();
        final GetClientsClientIdResponse getClientResponse = ClientHelper.getClient(requestSpec, responseSpec, clientId.intValue());

        // Search for savings accounts - should return results with proper entityStatus
        final List<String> savingsResources = Arrays.asList("savings");
        final ArrayList<GetSearchResponse> savingsSearchResponse = SearchHelper.getSearch(requestSpec, responseSpec,
                getClientResponse.getAccountNo(), Boolean.FALSE, getResources(savingsResources));
        
        // Verify that if any SAVING entities are returned, they have valid entityStatus
        savingsSearchResponse.stream()
                .filter(result -> "SAVING".equalsIgnoreCase(result.getEntityType()))
                .forEach(result -> {
                    assertNotNull(result.getEntityStatus(), "SAVING entity should have entityStatus");
                    assertNotNull(result.getEntityStatus().getId(), "SAVING entityStatus should have id");
                    assertNotNull(result.getEntityStatus().getCode(), "SAVING entityStatus should have code");
                });

        // Search for share accounts - should return results with proper entityStatus
        final List<String> shareResources = Arrays.asList("shares");
        final ArrayList<GetSearchResponse> shareSearchResponse = SearchHelper.getSearch(requestSpec, responseSpec,
                getClientResponse.getAccountNo(), Boolean.FALSE, getResources(shareResources));
        
        // Verify that if any SHARE entities are returned, they have valid entityStatus
        shareSearchResponse.stream()
                .filter(result -> "SHARE".equalsIgnoreCase(result.getEntityType()))
                .forEach(result -> {
                    assertNotNull(result.getEntityStatus(), "SHARE entity should have entityStatus");
                    assertNotNull(result.getEntityStatus().getId(), "SHARE entityStatus should have id");
                    assertNotNull(result.getEntityStatus().getCode(), "SHARE entityStatus should have code");
                });
    }

@adamsaghy
Copy link
Contributor

@Akshat-Soni02 Could you please add the appropriate test cases to this PR to verify the correct behavior?

@Akshat-Soni02 Akshat-Soni02 force-pushed the fineract-2408/search-api-for-savings branch from a34c455 to ec3ce4a Compare November 30, 2025 06:34
@adamsaghy
Copy link
Contributor

@Akshat-Soni02 Please kindly check the failing test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants