FINERACT-2237: Fix GSIM account creation to generate single parent for multiple clients
This commit is contained in:
committed by
Adam Saghy
parent
67cdb88f66
commit
bad50aaa4d
+9
-2
@@ -168,7 +168,9 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
||||
|
||||
Group group = this.groupRepositoryWrapper.findOneWithNotFoundDetection(groupId);
|
||||
|
||||
if (command.booleanObjectValueOfParameterNamed("isParentAccount") != null) {
|
||||
if (command.booleanObjectValueOfParameterNamed("isParentAccount") != null
|
||||
&& ("1".equals(command.stringValueOfParameterNamed("isParentAccount"))
|
||||
|| command.booleanObjectValueOfParameterNamed("isParentAccount"))) {
|
||||
// empty table check
|
||||
if (gsimRepository.count() != 0) {
|
||||
// Parent-Not an empty table
|
||||
@@ -193,7 +195,12 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
||||
} else {
|
||||
if (gsimRepository.count() != 0) {
|
||||
// Child-Not an empty table check
|
||||
gsimAccount = gsimRepository.findOneByIsAcceptingChildAndApplicationId(true, applicationId);
|
||||
if (applicationId.compareTo(BigDecimal.ZERO) == 0) {
|
||||
gsimAccount = gsimRepository.findOneByIsAcceptingChildAndApplicationIdAndGroupId(true, applicationId,
|
||||
groupId);
|
||||
} else {
|
||||
gsimAccount = gsimRepository.findOneByIsAcceptingChildAndApplicationId(true, applicationId);
|
||||
}
|
||||
accountNumber = gsimAccount.getAccountNumber() + (gsimAccount.getChildAccountsCount() + 1);
|
||||
account.updateAccountNo(accountNumber);
|
||||
this.gsimWritePlatformService.incrementChildAccountCount(gsimAccount);
|
||||
|
||||
+3
@@ -31,4 +31,7 @@ public interface GSIMRepositoy
|
||||
GroupSavingsIndividualMonitoring findOneByIsAcceptingChildAndApplicationId(boolean acceptingChild, BigDecimal applicationId);
|
||||
|
||||
GroupSavingsIndividualMonitoring findOneByAccountNumber(String accountNumber);
|
||||
|
||||
GroupSavingsIndividualMonitoring findOneByIsAcceptingChildAndApplicationIdAndGroupId(boolean acceptingChild, BigDecimal applicationId,
|
||||
Long groupId);
|
||||
}
|
||||
|
||||
+58
-7
@@ -179,6 +179,57 @@ public class GroupSavingsIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testGsimSavingsAccount_WithTwoClients_ChildCountTwo() {
|
||||
|
||||
// Initialize the helper for savings account operations
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// Create two clients: one designated as the parent and one as the child
|
||||
final Integer parentClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assertions.assertNotNull(parentClientID);
|
||||
|
||||
final Integer childClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assertions.assertNotNull(childClientID);
|
||||
|
||||
// Create a group and associate both clients with it
|
||||
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
|
||||
Assertions.assertNotNull(groupID);
|
||||
|
||||
// obtain the latest application ID of the gsim accounts
|
||||
// BigDecimal applicationId = GroupHelper.getLastApplicationIdOfGsimSavingAccount(this.requestSpec,
|
||||
// this.responseSpec, groupID).add(BigDecimal.ONE);
|
||||
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), parentClientID.toString());
|
||||
Assertions.assertNotNull(groupID);
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), childClientID.toString());
|
||||
Assertions.assertNotNull(groupID);
|
||||
|
||||
// Create a savings product necessary for the GSIM application
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
// Prepare the client array with two entries:
|
||||
// one for the parent client (isParent = true) and one for the child client (isParent = false)
|
||||
List<Map<String, Object>> clientArray = new ArrayList<>();
|
||||
clientArray.add(clientArray(parentClientID, groupID, savingsProductID, "08 January 2013", true));
|
||||
clientArray.add(clientArray(childClientID, groupID, savingsProductID, "08 January 2013", false));
|
||||
|
||||
// Apply for a GSIM savings account with both clients under the same application
|
||||
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
|
||||
Assertions.assertNotNull(gsimID);
|
||||
|
||||
// get child account count
|
||||
final Integer childAccountCount = GroupHelper.getChildAccountCount(this.requestSpec, this.responseSpec, groupID);
|
||||
assertEquals(childAccountCount, 2);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccount_DELETE_APPLICATION() {
|
||||
@@ -254,7 +305,7 @@ public class GroupSavingsIntegrationTest {
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
List<Map<String, Object>> clientArray = new ArrayList<>();
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013", true));
|
||||
|
||||
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
|
||||
|
||||
@@ -306,7 +357,7 @@ public class GroupSavingsIntegrationTest {
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
List<Map<String, Object>> clientArray = new ArrayList<>();
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013", true));
|
||||
LOG.info("client Array : {} ", clientArray);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -365,7 +416,7 @@ public class GroupSavingsIntegrationTest {
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
List<Map<String, Object>> clientArray = new ArrayList<>();
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013", true));
|
||||
|
||||
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
|
||||
|
||||
@@ -414,7 +465,7 @@ public class GroupSavingsIntegrationTest {
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
List<Map<String, Object>> clientArray = new ArrayList<>();
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013", true));
|
||||
|
||||
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
|
||||
|
||||
@@ -448,7 +499,7 @@ public class GroupSavingsIntegrationTest {
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
List<Map<String, Object>> clientArray = new ArrayList<>();
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013"));
|
||||
clientArray.add(clientArray(clientID, groupID, savingsProductID, "08 January 2013", true));
|
||||
final Integer gsimID = this.savingsAccountHelper.applyForGsimApplication(clientArray);
|
||||
|
||||
final List<String> retrievedGsimId = GroupHelper.verifyRetrieveGsimAccounts(this.requestSpec, this.responseSpec, groupID);
|
||||
@@ -797,7 +848,7 @@ public class GroupSavingsIntegrationTest {
|
||||
}
|
||||
|
||||
private Map<String, Object> clientArray(final Integer clientId, final Integer groupId, final Integer productId,
|
||||
final String submittedOnDate) {
|
||||
final String submittedOnDate, final boolean isParent) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("clientId", clientId);
|
||||
map.put("groupId", groupId);
|
||||
@@ -805,7 +856,7 @@ public class GroupSavingsIntegrationTest {
|
||||
map.put("submittedOnDate", submittedOnDate);
|
||||
map.put("dateFormat", CommonConstants.DATE_FORMAT);
|
||||
map.put("locale", "en");
|
||||
map.put("isParentAccount", "1");
|
||||
map.put("isParentAccount", isParent);
|
||||
map.put("isGSIM", "true");
|
||||
return map;
|
||||
}
|
||||
|
||||
+11
@@ -407,6 +407,17 @@ public class GroupHelper {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static Integer getChildAccountCount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer groupID) {
|
||||
List<Object> list;
|
||||
LOG.info("------------------------------GET CHILD ACCOUNT COUNT------------------------------------\n");
|
||||
final String GROUP_URL = "/fineract-provider/api/v1/groups/" + groupID + "/gsimaccounts?" + Utils.TENANT_IDENTIFIER;
|
||||
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "childGSIMAccounts");
|
||||
|
||||
return ((ArrayList) list.get(0)).size();
|
||||
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.uniqueRandomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user