This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new c1f4a3e747 FINERACT-2408: Add entityStatus mapping for SAVING and
SHARE entities in search API
c1f4a3e747 is described below
commit c1f4a3e74799f9cd860e9fe5979736b641d36f2a
Author: Dhananjay Bhagat <[email protected]>
AuthorDate: Sun Feb 8 21:25:31 2026 +0530
FINERACT-2408: Add entityStatus mapping for SAVING and SHARE entities in
search API
---
.../savings/service/SavingsEnumerations.java | 9 +++
.../service/SearchReadPlatformServiceImpl.java | 19 +++--
.../shareaccounts/service/SharesEnumerations.java | 9 +++
.../integrationtests/SearchResourcesTest.java | 83 ++++++++++++++++++++++
4 files changed, 114 insertions(+), 6 deletions(-)
diff --git
a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java
b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java
index 7f4cab97be..abbf4f7196 100644
---
a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java
+++
b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java
@@ -202,6 +202,15 @@ public final class SavingsEnumerations {
return optionData;
}
+ public static EnumOptionData status(final SavingsAccountStatusEnumData
status) {
+
+ Long id = status.getId();
+ String code = status.getCode();
+ String value = status.getValue();
+
+ return new EnumOptionData(id, code, value);
+ }
+
public static SavingsAccountStatusEnumData status(final Integer
statusEnum) {
return status(SavingsAccountStatusType.fromInt(statusEnum));
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java
index e04b3226b1..af38378498 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java
@@ -38,12 +38,15 @@ import
org.apache.fineract.portfolio.loanaccount.data.LoanStatusEnumData;
import org.apache.fineract.portfolio.loanproduct.data.LoanProductData;
import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
import
org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
+import org.apache.fineract.portfolio.savings.data.SavingsAccountStatusEnumData;
import org.apache.fineract.portfolio.savings.service.SavingsEnumerations;
import org.apache.fineract.portfolio.search.SearchConstants;
import org.apache.fineract.portfolio.search.data.AdHocQuerySearchConditions;
import org.apache.fineract.portfolio.search.data.AdHocSearchQueryData;
import org.apache.fineract.portfolio.search.data.SearchConditions;
import org.apache.fineract.portfolio.search.data.SearchData;
+import
org.apache.fineract.portfolio.shareaccounts.data.ShareAccountStatusEnumData;
+import org.apache.fineract.portfolio.shareaccounts.service.SharesEnumerations;
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -165,16 +168,20 @@ public class SearchReadPlatformServiceImpl implements
SearchReadPlatformService
if (entityType.equalsIgnoreCase("client") ||
entityType.equalsIgnoreCase("clientidentifier")) {
entityStatus = ClientEnumerations.status(entityStatusEnum);
- }
-
- else if (entityType.equalsIgnoreCase("group") ||
entityType.equalsIgnoreCase("center")) {
+ } else if (entityType.equalsIgnoreCase("group") ||
entityType.equalsIgnoreCase("center")) {
entityStatus =
GroupingTypeEnumerations.status(entityStatusEnum);
- }
-
- else if (entityType.equalsIgnoreCase("loan")) {
+ } else if (entityType.equalsIgnoreCase("loan")) {
LoanStatusEnumData loanStatusEnumData =
LoanEnumerations.status(entityStatusEnum);
entityStatus = LoanEnumerations.status(loanStatusEnumData);
+ } else if (entityType.equalsIgnoreCase("saving")) {
+ SavingsAccountStatusEnumData savingsAccountStatusEnumData =
SavingsEnumerations.status(entityStatusEnum);
+
+ entityStatus =
SavingsEnumerations.status(savingsAccountStatusEnumData);
+ } else if (entityType.equalsIgnoreCase("share")) {
+ ShareAccountStatusEnumData shareAccountStatusEnumData =
SharesEnumerations.status(entityStatusEnum);
+
+ entityStatus =
SharesEnumerations.status(shareAccountStatusEnumData);
}
return new SearchData(entityId, entityAccountNo, entityExternalId,
entityName, entityType, parentId, parentName, parentType,
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/SharesEnumerations.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/SharesEnumerations.java
index 596d93fedb..efe1998727 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/SharesEnumerations.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/SharesEnumerations.java
@@ -32,6 +32,15 @@ public final class SharesEnumerations {
}
+ public static EnumOptionData status(final ShareAccountStatusEnumData
status) {
+
+ Long id = status.getId();
+ String code = status.getCode();
+ String value = status.getValue();
+
+ return new EnumOptionData(id, code, value);
+ }
+
public static ShareAccountStatusEnumData status(final Integer statusEnum) {
return status(ShareAccountStatusType.fromInt(statusEnum));
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SearchResourcesTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SearchResourcesTest.java
index 59be82bb29..bdb751034c 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SearchResourcesTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SearchResourcesTest.java
@@ -29,12 +29,18 @@ import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import org.apache.fineract.client.models.GetClientsClientIdResponse;
import org.apache.fineract.client.models.GetSearchResponse;
import org.apache.fineract.client.models.PostClientsResponse;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.SearchHelper;
import org.apache.fineract.integrationtests.common.Utils;
+import
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
+import org.apache.fineract.integrationtests.common.shares.ShareAccountHelper;
+import
org.apache.fineract.integrationtests.common.shares.ShareAccountTransactionHelper;
+import org.apache.fineract.integrationtests.common.shares.ShareProductHelper;
+import
org.apache.fineract.integrationtests.common.shares.ShareProductTransactionHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -102,6 +108,83 @@ public class SearchResourcesTest {
assertEquals(0, searchResponse.size());
}
+ @Test
+ public void searchOverSavingsResources() {
+ final List<String> resources = Arrays.asList("savings");
+
+ 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 Integer savingsId =
SavingsAccountHelper.openSavingsAccount(requestSpec, responseSpec,
clientId.intValue(), "1000");
+ final SavingsAccountHelper savingsAccountHelper = new
SavingsAccountHelper(requestSpec, responseSpec);
+ final String query = (String)
savingsAccountHelper.getSavingsAccountDetail(savingsId, "accountNo");
+
+ final ArrayList<GetSearchResponse> searchResponse =
SearchHelper.getSearch(requestSpec, responseSpec, query, Boolean.FALSE,
+ getResources(resources));
+
+ assertNotNull(searchResponse);
+ assertEquals(1, searchResponse.size());
+
+ final GetSearchResponse result = searchResponse.getFirst();
+
+ assertEquals("SAVING", result.getEntityType());
+ assertNotNull(result.getEntityStatus());
+ assertNotNull(result.getEntityStatus().getId());
+ assertNotNull(result.getEntityStatus().getCode());
+ assertNotNull(result.getEntityStatus().getValue());
+ }
+
+ @Test
+ public void searchOverSharesResources() {
+ final List<String> resources = Arrays.asList("shares");
+
+ String jsonPayload =
ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID,
ClientHelper.LEGALFORM_ID_PERSON, null);
+ final PostClientsResponse clientsResponse =
ClientHelper.addClientAsPerson(requestSpec, responseSpec, jsonPayload);
+ final Long clientId = clientsResponse.getClientId();
+
+ final ShareProductHelper shareProductHelper = new ShareProductHelper();
+ final Integer productId =
ShareProductTransactionHelper.createShareProduct(shareProductHelper.build(),
requestSpec, responseSpec);
+
+ final Integer savingsId =
SavingsAccountHelper.openSavingsAccount(requestSpec, responseSpec,
clientId.intValue(), "1000");
+
+ final String shareJson = new
ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId))
+
.withSavingsAccountId(String.valueOf(savingsId)).withSubmittedDate("01 January
2026").withApplicationDate("01 January 2026")
+ .withRequestedShares("10").build();
+
+ final Integer shareAccountId =
ShareAccountTransactionHelper.createShareAccount(shareJson, requestSpec,
responseSpec);
+
+ final String approveJson = "{}";
+ ShareAccountTransactionHelper.postCommand("approve", shareAccountId,
approveJson, requestSpec, responseSpec);
+
+ final String activateJson = """
+ {
+ "activatedDate": "01 January 2026",
+ "dateFormat": "dd MMMM yyyy",
+ "locale": "en"
+ }
+ """;
+ ShareAccountTransactionHelper.postCommand("activate", shareAccountId,
activateJson, requestSpec, responseSpec);
+
+ final Map<String, Object> shareAccountData =
ShareAccountTransactionHelper.retrieveShareAccount(shareAccountId, requestSpec,
+ responseSpec);
+ final String query = (String) shareAccountData.get("accountNo");
+
+ final ArrayList<GetSearchResponse> searchResponse =
SearchHelper.getSearch(requestSpec, responseSpec, query, Boolean.FALSE,
+ getResources(resources));
+
+ assertNotNull(searchResponse);
+ assertEquals(1, searchResponse.size());
+
+ final GetSearchResponse result = searchResponse.getFirst();
+
+ assertEquals("SHARE", result.getEntityType());
+ assertNotNull(result.getEntityStatus());
+ assertNotNull(result.getEntityStatus().getId());
+ assertNotNull(result.getEntityStatus().getCode());
+ assertNotNull(result.getEntityStatus().getValue());
+ }
+
private String getResources(final List<String> resources) {
return String.join(",", resources);
}