diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java
index 7c66482c9..28456cf28 100644
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java
@@ -87,8 +87,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer loanProductID = createLoanProduct(false, NONE);
final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, null, "12,000.00");
- final ArrayList
loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
- loanID);
+ final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,loanID);
verifyLoanRepaymentSchedule(loanSchedule);
}
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientStatusChecker.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientStatusChecker.java
new file mode 100644
index 000000000..5b1017105
--- /dev/null
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientStatusChecker.java
@@ -0,0 +1,48 @@
+/**
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+package org.mifosplatform.integrationtests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+
+public class ClientStatusChecker {
+ public static void verifyClientIsActive(final HashMap clientStatusHashMap) {
+ assertEquals((int) clientStatusHashMap.get("id"), 300);
+ }
+
+
+ public static void verifyClientClosed(final HashMap clientStatusHashMap) {
+ System.out.println("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
+ assertEquals((int) clientStatusHashMap.get("id"), 600);
+ System.out.println("Client Status:" + clientStatusHashMap + "\n");
+ }
+ public static void verifyClientPending(final HashMap clientStatusHashMap) {
+ System.out.println("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
+ assertEquals((int) clientStatusHashMap.get("id"), 100);
+ System.out.println("Client Status:" + clientStatusHashMap + "\n");
+ }
+ public static void verifyClientRejected(final HashMap clientStatusHashMap) {
+ System.out.println("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
+ assertEquals((int) clientStatusHashMap.get("id"), 700);
+ System.out.println("Client Status:" + clientStatusHashMap + "\n");
+ }
+
+ public static void verifyClientActiavted(final HashMap clientStatusHashMap) {
+ System.out.println("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
+ assertEquals((int) clientStatusHashMap.get("id"), 300);
+ System.out.println("Client Status:" + clientStatusHashMap + "\n");
+ }
+
+ public static void verifyClientWithdrawn(final HashMap clientStatusHashMap) {
+ System.out.println("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
+ assertEquals((int) clientStatusHashMap.get("id"), 800);
+ System.out.println("Client Status:" + clientStatusHashMap + "\n");
+ }
+
+
+}
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientTest.java
new file mode 100644
index 000000000..96fa5c580
--- /dev/null
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientTest.java
@@ -0,0 +1,78 @@
+/**
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+package org.mifosplatform.integrationtests;
+
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mifosplatform.integrationtests.common.ClientHelper;
+import org.mifosplatform.integrationtests.common.SchedulerJobHelper;
+import org.mifosplatform.integrationtests.common.Utils;
+import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
+import org.mifosplatform.integrationtests.common.accounting.JournalEntryHelper;
+import org.mifosplatform.integrationtests.common.accounting.PeriodicAccrualAccountingHelper;
+import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
+import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
+import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
+
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+public class ClientTest {
+
+ private ResponseSpecification responseSpec;
+ private RequestSpecification requestSpec;
+ private ClientHelper clientHelper;
+
+ @Before
+ public void setup() {
+ Utils.initializeRESTAssured();
+ this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+ this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+ this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+
+ }
+
+ @Test
+ public void testClientStatus() {
+ this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
+ final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+ Assert.assertNotNull(clientId);
+
+ HashMap status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
+ ClientStatusChecker.verifyClientIsActive(status);
+
+ HashMap clientStatusHashMap = this.clientHelper.closeClient(clientId);
+ ClientStatusChecker.verifyClientClosed(clientStatusHashMap);
+
+ clientStatusHashMap = this.clientHelper.reactivateClient(clientId);
+ ClientStatusChecker.verifyClientPending(clientStatusHashMap);
+
+ clientStatusHashMap = this.clientHelper.rejectClient(clientId);
+ ClientStatusChecker.verifyClientRejected(clientStatusHashMap);
+
+ clientStatusHashMap = this.clientHelper.activateClient(clientId);
+ ClientStatusChecker.verifyClientActiavted(clientStatusHashMap);
+
+ clientStatusHashMap = this.clientHelper.closeClient(clientId);
+ ClientStatusChecker.verifyClientClosed(clientStatusHashMap);
+
+ clientStatusHashMap = this.clientHelper.reactivateClient(clientId);
+ ClientStatusChecker.verifyClientPending(clientStatusHashMap);
+
+ clientStatusHashMap = this.clientHelper.withdrawClient(clientId);
+ ClientStatusChecker.verifyClientWithdrawn(clientStatusHashMap);
+
+
+
+ }
+
+}
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ClientHelper.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ClientHelper.java
index 80fab5744..66d2b5e89 100755
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ClientHelper.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ClientHelper.java
@@ -15,7 +15,27 @@ import com.jayway.restassured.specification.ResponseSpecification;
public class ClientHelper {
+ private final RequestSpecification requestSpec;
+ private final ResponseSpecification responseSpec;
+
private static final String CREATE_CLIENT_URL = "/mifosng-provider/api/v1/clients?" + Utils.TENANT_IDENTIFIER;
+ private static final String CLIENT_URL = "/mifosng-provider/api/v1/clients";
+ private static final String CLOSE_CLIENT_COMMAND = "close";
+ private static final String REACTIVATE_CLIENT_COMMAND = "reactivate";
+ private static final String REJECT_CLIENT_COMMAND = "reject";
+ private static final String ACTIVATE_CLIENT_COMMAND ="activate";
+ private static final String WITHDRAW_CLIENT_COMMAND = "withdraw";
+
+ public static final String CREATED_DATE = "27 November 2014";
+ public static final String CREATED_DATE_PLUS_ONE = "28 November 2014";
+ public static final String CREATED_DATE_MINUS_ONE = "27 November 2014";
+ public static final String TRANSACTION_DATE = "01 March 2013";
+ public static final String LAST_TRANSACTION_DATE = "01 March 2013";
+
+ public ClientHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
+ this.requestSpec = requestSpec;
+ this.responseSpec = responseSpec;
+ }
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return createClient(requestSpec, responseSpec, "04 March 2011");
@@ -34,21 +54,16 @@ public class ClientHelper {
}
public static Object assignStaffToClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
- final String clientId, final String staffId) {
- final String CLIENT_ASSIGN_STAFF_URL = "/mifosng-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff";
+ final String clientId, final String staffId) {
+ final String CLIENT_ASSIGN_STAFF_URL = "/mifosng-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER
+ + "&command=assignStaff";
System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------");
- return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId),
- "changes");
+ return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes");
}
- public static Integer getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
- final String clientId){
- final String GET_CLIENT_URL = "/mifosng-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER ;
-
- System.out.println("---------------------------------GET A CLIENT---------------------------------------------");
- return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL,"staffId");
-
+ public static Integer getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId) {
+ return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
}
public static String getTestClientAsJSON(final String dateOfJoining, final String officeId) {
@@ -65,7 +80,7 @@ public class ClientHelper {
return new Gson().toJson(map);
}
- public static String assignStaffToClientAsJson(final String staffId){
+ public static String assignStaffToClientAsJson(final String staffId) {
final HashMap map = new HashMap<>();
map.put("staffId", staffId);
System.out.println("map : " + map);
@@ -80,7 +95,110 @@ public class ClientHelper {
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
}
+ public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId,
+ final String jsonReturn) {
+ final String GET_CLIENT_URL = "/mifosng-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER;
+
+ System.out.println("---------------------------------GET A CLIENT---------------------------------------------");
+ return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn);
+
+ }
+
+ public static HashMap getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
+ final String clientId) {
+ return (HashMap) getClient(requestSpec, responseSpec, clientId, "status");
+ }
+
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
+
+ private String getCloseClientAsJSON() {
+ final HashMap map = new HashMap<>();
+ map.put("locale", CommonConstants.locale);
+ map.put("dateFormat", CommonConstants.dateFormat);
+ map.put("closureDate", CREATED_DATE_PLUS_ONE);
+ map.put("closureReasonId", "12");
+ String clientJson = new Gson().toJson(map);
+ System.out.println(clientJson);
+ return clientJson;
+
+ }
+ private String getReactivateClientAsJSON() {
+ final HashMap map = new HashMap<>();
+ map.put("locale", CommonConstants.locale);
+ map.put("dateFormat", CommonConstants.dateFormat);
+ map.put("reactivationDate", CREATED_DATE_PLUS_ONE);
+ String clientJson = new Gson().toJson(map);
+ System.out.println(clientJson);
+ return clientJson;
+
+ }
+ private String getRejectClientAsJSON() {
+ final HashMap map = new HashMap<>();
+ map.put("locale", CommonConstants.locale);
+ map.put("dateFormat", CommonConstants.dateFormat);
+ map.put("rejectDate", CREATED_DATE_PLUS_ONE);
+ map.put("rejectReasonId", "15");
+ String clientJson = new Gson().toJson(map);
+ System.out.println(clientJson);
+ return clientJson;
+
+ }
+ private String getActivateClientAsJSON() {
+ final HashMap map = new HashMap<>();
+ map.put("locale", CommonConstants.locale);
+ map.put("dateFormat", CommonConstants.dateFormat);
+ map.put("activationDate", CREATED_DATE_PLUS_ONE);
+ String clientJson = new Gson().toJson(map);
+ System.out.println(clientJson);
+ return clientJson;
+
+ }
+
+ private String getWithdrawClientAsJSON() {
+ final HashMap map = new HashMap<>();
+ map.put("locale", CommonConstants.locale);
+ map.put("dateFormat", CommonConstants.dateFormat);
+ map.put("withdrawDate", CREATED_DATE_PLUS_ONE);
+ map.put("withdrawReasonId", "17");
+ String clientJson = new Gson().toJson(map);
+ System.out.println(clientJson);
+ return clientJson;
+
+ }
+ public HashMap closeClient(final Integer clientId) {
+ System.out.println("--------------------------------- CLOSE CLIENT -------------------------------");
+ return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
+ }
+
+ public HashMap reactivateClient(final Integer clientId) {
+ System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------");
+ return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
+ }
+ public HashMap rejectClient(final Integer clientId) {
+ System.out.println("--------------------------------- REJECT CLIENT -------------------------------");
+ return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
+ }
+
+ public HashMap activateClient(final Integer clientId) {
+ System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
+ return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(), clientId);
+ }
+ public HashMap withdrawClient(final Integer clientId) {
+ System.out.println("--------------------------------- WITHDRAWN CLIENT -------------------------------");
+ return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
+ }
+ private String createClientOperationURL(final String command, final Integer clientId) {
+ return CLIENT_URL + "/" + clientId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+ }
+
+ private HashMap performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
+ HashMap status = null;
+ Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS);
+ HashMap response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
+
+ return response;
+ }
+
}
\ No newline at end of file
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/CommonConstants.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/CommonConstants.java
index 8e29d4792..dbebbd405 100755
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/CommonConstants.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/CommonConstants.java
@@ -12,6 +12,7 @@ public interface CommonConstants {
public static final String dateFormat = "dd MMMM yyyy";
public static final String RESPONSE_RESOURCE_ID = "resourceId";
public static final String RESPONSE_CHANGES = "changes";
+ public static final String RESPONSE_STATUS = "status";
public static final String RESPONSE_ERROR = "errors";
public static final String RESPONSE_ERROR_MESSAGE_CODE = "userMessageGlobalisationCode";
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
index 6c2f3aa4b..441ea97c2 100755
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
@@ -856,6 +856,12 @@ public class CommandWrapper {
public boolean isWithdrawal() {
return this.actionName.equalsIgnoreCase("WITHDRAWAL");
}
+ public boolean isWithdrawn() {
+ return this.actionName.equalsIgnoreCase("WITHDRAW");
+ }
+ public boolean isReactivated() {
+ return this.actionName.equalsIgnoreCase("REACTIVATE");
+ }
public boolean isActivation() {
return this.actionName.equalsIgnoreCase("ACTIVATE");
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
index a9c83213b..a745e4ae5 100755
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
@@ -418,7 +418,32 @@ public class CommandWrapperBuilder {
this.href = "/clients/" + clientId + "?command=close&template=true";
return this;
}
-
+
+ public CommandWrapperBuilder rejectClient(final Long clientId) {
+ this.actionName = "REJECT";
+ this.entityName = "CLIENT";
+ this.entityId = clientId;
+ this.clientId = clientId;
+ this.href = "/clients/" + clientId + "?command=reject&template=true";
+ return this;
+ }
+
+ public CommandWrapperBuilder withdrawClient(final Long clientId) {
+ this.actionName = "WITHDRAW";
+ this.entityName = "CLIENT";
+ this.entityId = clientId;
+ this.clientId = clientId;
+ this.href = "/clients/" + clientId + "?command=withdraw&template=true";
+ return this;
+ }
+ public CommandWrapperBuilder reActivateClient(final Long clientId) {
+ this.actionName = "REACTIVATE";
+ this.entityName = "CLIENT";
+ this.entityId = clientId;
+ this.clientId = clientId;
+ this.href = "/clients/" + clientId + "?command=reactivate&template=true";
+ return this;
+ }
public CommandWrapperBuilder proposeClientTransfer(final Long clientId) {
this.actionName = "PROPOSETRANSFER";
this.entityName = "CLIENT";
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
index bb146845e..0387d4713 100755
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
@@ -205,7 +205,13 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
handler = this.applicationContext.getBean("rejectClientTransferCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUpdateClientSavingsAccount()) {
handler = this.applicationContext.getBean("updateClientSavingsAccountCommandHandler", NewCommandSourceHandler.class);
- } else {
+ } else if(wrapper.isReject()){
+ handler = this.applicationContext.getBean("rejectClientCommandHandler", NewCommandSourceHandler.class);
+ }else if(wrapper.isWithdrawn()){
+ handler = this.applicationContext.getBean("withdrawClientCommandHandler", NewCommandSourceHandler.class);
+ }else if(wrapper.isReactivated()){
+ handler = this.applicationContext.getBean("reActivateClientCommandHandler", NewCommandSourceHandler.class);
+ }else {
throw new UnsupportedCommandException(wrapper.commandName());
}
// end of client
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java
index 0ec00bcaf..a1fe1c22b 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java
@@ -15,6 +15,11 @@ public class ClientApiConstants {
public static final String CLIENT_RESOURCE_NAME = "client";
public static final String CLIENT_CLOSURE_REASON = "ClientClosureReason";
+ public static final String CLIENT_ACTION_REASON = "ClientActionReason";
+ public static final String CLIENT_REJECT_REASON = "ClientRejectReason";
+ public static final String CLIENT_WITHDRAW_REASON = "ClientWithdrawReason";
+
+
public static final String GENDER = "Gender";
public static final String CLIENT_TYPE = "ClientType";
public static final String CLIENT_CLASSIFICATION = "ClientClassification";
@@ -36,9 +41,16 @@ public class ClientApiConstants {
public static final String transferOfficeIdParamName = "transferOfficeIdParamName";
public static final String activeParamName = "active";
public static final String activationDateParamName = "activationDate";
+ public static final String reactivationDateParamName = "reactivationDate";
public static final String staffIdParamName = "staffId";
public static final String closureDateParamName = "closureDate";
public static final String closureReasonIdParamName = "closureReasonId";
+
+ public static final String rejectDateParamName = "rejectDate";
+ public static final String rejectReasonIdParamName ="rejectReasonId";
+ public static final String withdrawDateParamName = "withdrawDate";
+ public static final String withdrawReasonIdParamName ="withdrawReasonId";
+
public static final String submittedOnDateParamName = "submittedOnDate";
public static final String savingsProductIdParamName = "savingsProductId";
public static final String savingsAccountIdParamName = "savingsAccountId";
@@ -97,7 +109,14 @@ public class ClientApiConstants {
public static final Set ACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
dateFormatParamName, activationDateParamName));
+ public static final Set REACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
+ dateFormatParamName, reactivationDateParamName));
public static final Set CLIENT_CLOSE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
dateFormatParamName, closureDateParamName, closureReasonIdParamName));
+
+ public static final Set CLIENT_REJECT_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,dateFormatParamName,rejectDateParamName,rejectReasonIdParamName));
+
+ public static final Set CLIENT_WITHDRAW_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,dateFormatParamName,withdrawDateParamName,withdrawReasonIdParamName));
+
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java
index b91043b54..e1f4c2319 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java
@@ -91,10 +91,15 @@ public class ClientsApiResource {
ClientData clientData = null;
this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME);
if (is(commandParam, "close")) {
- clientData = this.clientReadPlatformService.retrieveAllClosureReasons(ClientApiConstants.CLIENT_CLOSURE_REASON);
+ clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_CLOSURE_REASON);
} else if (is(commandParam, "acceptTransfer")) {
- clientData = this.clientReadPlatformService.retrieveAllClosureReasons(ClientApiConstants.CLIENT_CLOSURE_REASON);
- } else {
+ clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_CLOSURE_REASON);
+ }else if (is(commandParam, "reject")) {
+ clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_REJECT_REASON);
+ }else if (is(commandParam, "withdraw")) {
+ clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_WITHDRAW_REASON);
+ }
+ else {
clientData = this.clientReadPlatformService.retrieveTemplate(officeId, staffInSelectedOfficeOnly);
}
@@ -238,11 +243,21 @@ public class ClientsApiResource {
} else if (is(commandParam, "updateSavingsAccount")) {
commandRequest = builder.updateClientSavingsAccount(clientId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
- }
+ }else if (is(commandParam,"reject")){
+ commandRequest = builder.rejectClient(clientId).build();
+ result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+ }else if (is(commandParam,"withdraw")){
+ commandRequest = builder.withdrawClient(clientId).build();
+ result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+ }else if (is(commandParam,"reactivate")){
+ commandRequest = builder.reActivateClient(clientId).build();
+ result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+ }
+
if (result == null) { throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate",
"unassignStaff", "assignStaff", "close", "proposeTransfer", "withdrawTransfer", "acceptTransfer", "rejectTransfer",
- "updateSavingsAccount" }); }
+ "updateSavingsAccount","reject" ,"withdraw","reactivate"}); }
return this.toApiJsonSerializer.serialize(result);
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java
index f85385585..cd706fc6b 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java
@@ -69,7 +69,7 @@ final public class ClientData implements Comparable {
// template
private final Collection officeOptions;
private final Collection staffOptions;
- private final Collection closureReasons;
+ private final Collection narrations;
private final Collection savingProductOptions;
private final Collection savingAccountOptions;
private final Collection genderOptions;
@@ -77,7 +77,7 @@ final public class ClientData implements Comparable {
private final Collection clientClassificationOptions;
public static ClientData template(final Long officeId, final LocalDate joinedDate, final Collection officeOptions,
- final Collection staffOptions, final Collection closureReasons,
+ final Collection staffOptions, final Collection narrations,
final Collection genderOptions, final Collection savingProductOptions,
final Collection clientTypeOptions, final Collection clientClassificationOptions) {
final String accountNo = null;
@@ -109,7 +109,7 @@ final public class ClientData implements Comparable {
final CodeValueData clientClassification = null;
return new ClientData(accountNo, status, subStatus, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname,
middlename, lastname, fullname, displayName, externalId, mobileNo, dateOfBirth, gender, joinedDate, imageId, staffId,
- staffName, officeOptions, groups, staffOptions, closureReasons, genderOptions, timeline, savingProductOptions,
+ staffName, officeOptions, groups, staffOptions, narrations, genderOptions, timeline, savingProductOptions,
savingsProductId, savingsProductName, savingsAccountId, savingAccountOptions, clientType, clientClassification,
clientTypeOptions, clientClassificationOptions);
@@ -121,11 +121,10 @@ final public class ClientData implements Comparable {
clientData.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename,
clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo,
clientData.dateOfBirth, clientData.gender, clientData.activationDate, clientData.imageId, clientData.staffId,
- clientData.staffName, templateData.officeOptions, clientData.groups, templateData.staffOptions,
- templateData.closureReasons, templateData.genderOptions, clientData.timeline, templateData.savingProductOptions,
- clientData.savingsProductId, clientData.savingsProductName, clientData.savingsAccountId, clientData.savingAccountOptions,
- clientData.clientType, clientData.clientClassification, templateData.clientTypeOptions,
- templateData.clientClassificationOptions);
+ clientData.staffName, templateData.officeOptions, clientData.groups, templateData.staffOptions, templateData.narrations,
+ templateData.genderOptions, clientData.timeline, templateData.savingProductOptions, clientData.savingsProductId,
+ clientData.savingsProductName, clientData.savingsAccountId, clientData.savingAccountOptions, clientData.clientType,
+ clientData.clientClassification, templateData.clientTypeOptions, templateData.clientClassificationOptions);
}
@@ -136,7 +135,7 @@ final public class ClientData implements Comparable {
clientData.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename,
clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo,
clientData.dateOfBirth, clientData.gender, clientData.activationDate, clientData.imageId, clientData.staffId,
- clientData.staffName, clientData.officeOptions, clientData.groups, clientData.staffOptions, clientData.closureReasons,
+ clientData.staffName, clientData.officeOptions, clientData.groups, clientData.staffOptions, clientData.narrations,
clientData.genderOptions, clientData.timeline, clientData.savingProductOptions, clientData.savingsProductId,
clientData.savingsProductName, clientData.savingsAccountId, savingAccountOptions, clientData.clientType,
clientData.clientClassification, clientData.clientTypeOptions, clientData.clientClassificationOptions);
@@ -262,7 +261,7 @@ final public class ClientData implements Comparable {
final String externalId, final String mobileNo, final LocalDate dateOfBirth, final CodeValueData gender,
final LocalDate activationDate, final Long imageId, final Long staffId, final String staffName,
final Collection allowedOffices, final Collection groups,
- final Collection staffOptions, final Collection closureReasons,
+ final Collection staffOptions, final Collection narrations,
final Collection genderOptions, final ClientTimelineData timeline,
final Collection savingProductOptions, final Long savingsProductId, final String savingsProductName,
final Long savingsAccountId, final Collection savingAccountOptions, final CodeValueData clientType,
@@ -308,7 +307,8 @@ final public class ClientData implements Comparable {
// template
this.officeOptions = allowedOffices;
this.staffOptions = staffOptions;
- this.closureReasons = closureReasons;
+ this.narrations = narrations;
+
this.genderOptions = genderOptions;
this.clientClassificationOptions = clientClassificationOptions;
this.clientTypeOptions = clientTypeOptions;
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java
index 3c8f65ad4..cd2801c1f 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java
@@ -345,7 +345,6 @@ public final class ClientDataValidator {
.longGreaterThanZero();
}
-
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.dateOfBirthParamName, element)) {
atLeastOneParameterPassedForUpdate = true;
final LocalDate dateOfBirth = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.dateOfBirthParamName, element);
@@ -386,8 +385,6 @@ public final class ClientDataValidator {
baseDataValidator.reset().anyOfNotNull(forceError);
}
-
-
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
@@ -515,4 +512,78 @@ public final class ClientDataValidator {
}
+ public void validateRejection(final JsonCommand command) {
+
+ final String json = command.json();
+
+ if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
+
+ final Type typeOfMap = new TypeToken