MIFOSX-1662:Client life cycle and adding new statuses
This commit is contained in:
@@ -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");
|
||||
|
||||
+26
-1
@@ -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";
|
||||
|
||||
+7
-1
@@ -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
|
||||
|
||||
+19
@@ -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<String> ACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
|
||||
dateFormatParamName, activationDateParamName));
|
||||
public static final Set<String> REACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
|
||||
dateFormatParamName, reactivationDateParamName));
|
||||
|
||||
public static final Set<String> CLIENT_CLOSE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
|
||||
dateFormatParamName, closureDateParamName, closureReasonIdParamName));
|
||||
|
||||
public static final Set<String> CLIENT_REJECT_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,dateFormatParamName,rejectDateParamName,rejectReasonIdParamName));
|
||||
|
||||
public static final Set<String> CLIENT_WITHDRAW_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,dateFormatParamName,withdrawDateParamName,withdrawReasonIdParamName));
|
||||
|
||||
}
|
||||
+20
-5
@@ -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);
|
||||
}
|
||||
|
||||
+11
-11
@@ -69,7 +69,7 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
// template
|
||||
private final Collection<OfficeData> officeOptions;
|
||||
private final Collection<StaffData> staffOptions;
|
||||
private final Collection<CodeValueData> closureReasons;
|
||||
private final Collection<CodeValueData> narrations;
|
||||
private final Collection<SavingsProductData> savingProductOptions;
|
||||
private final Collection<SavingsAccountData> savingAccountOptions;
|
||||
private final Collection<CodeValueData> genderOptions;
|
||||
@@ -77,7 +77,7 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
private final Collection<CodeValueData> clientClassificationOptions;
|
||||
|
||||
public static ClientData template(final Long officeId, final LocalDate joinedDate, final Collection<OfficeData> officeOptions,
|
||||
final Collection<StaffData> staffOptions, final Collection<CodeValueData> closureReasons,
|
||||
final Collection<StaffData> staffOptions, final Collection<CodeValueData> narrations,
|
||||
final Collection<CodeValueData> genderOptions, final Collection<SavingsProductData> savingProductOptions,
|
||||
final Collection<CodeValueData> clientTypeOptions, final Collection<CodeValueData> clientClassificationOptions) {
|
||||
final String accountNo = null;
|
||||
@@ -109,7 +109,7 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
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> {
|
||||
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> {
|
||||
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<ClientData> {
|
||||
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<OfficeData> allowedOffices, final Collection<GroupGeneralData> groups,
|
||||
final Collection<StaffData> staffOptions, final Collection<CodeValueData> closureReasons,
|
||||
final Collection<StaffData> staffOptions, final Collection<CodeValueData> narrations,
|
||||
final Collection<CodeValueData> genderOptions, final ClientTimelineData timeline,
|
||||
final Collection<SavingsProductData> savingProductOptions, final Long savingsProductId, final String savingsProductName,
|
||||
final Long savingsAccountId, final Collection<SavingsAccountData> savingAccountOptions, final CodeValueData clientType,
|
||||
@@ -308,7 +307,8 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
// template
|
||||
this.officeOptions = allowedOffices;
|
||||
this.staffOptions = staffOptions;
|
||||
this.closureReasons = closureReasons;
|
||||
this.narrations = narrations;
|
||||
|
||||
this.genderOptions = genderOptions;
|
||||
this.clientClassificationOptions = clientClassificationOptions;
|
||||
this.clientTypeOptions = clientTypeOptions;
|
||||
|
||||
+74
-3
@@ -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<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, ClientApiConstants.CLIENT_REJECT_DATA_PARAMETERS);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
.resource(ClientApiConstants.CLIENT_RESOURCE_NAME);
|
||||
|
||||
final JsonElement element = command.parsedJson();
|
||||
|
||||
final LocalDate rejectDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.rejectDateParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.rejectDateParamName).value(rejectDate).notNull();
|
||||
|
||||
final Long rejectReasonId = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.rejectReasonIdParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.rejectReasonIdParamName).value(rejectReasonId).notNull()
|
||||
.longGreaterThanZero();
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
|
||||
}
|
||||
|
||||
public void validateWithdrawn(final JsonCommand command) {
|
||||
|
||||
final String json = command.json();
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, ClientApiConstants.CLIENT_WITHDRAW_DATA_PARAMETERS);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
.resource(ClientApiConstants.CLIENT_RESOURCE_NAME);
|
||||
|
||||
final JsonElement element = command.parsedJson();
|
||||
|
||||
final LocalDate withdrawDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.withdrawDateParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.withdrawDateParamName).value(withdrawDate).notNull();
|
||||
|
||||
final Long withdrawReasonId = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.withdrawReasonIdParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.withdrawReasonIdParamName).value(withdrawReasonId).notNull()
|
||||
.longGreaterThanZero();
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
|
||||
}
|
||||
|
||||
public void validateReactivate(final JsonCommand command) {
|
||||
|
||||
final String json = command.json();
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, ClientApiConstants.REACTIVATION_REQUEST_DATA_PARAMETERS);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
.resource(ClientApiConstants.CLIENT_RESOURCE_NAME);
|
||||
|
||||
final JsonElement element = command.parsedJson();
|
||||
|
||||
final LocalDate reactivationDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.reactivationDateParamName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.reactivationDateParamName).value(reactivationDate).notNull();
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
|
||||
}
|
||||
}
|
||||
+71
-2
@@ -133,9 +133,42 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date closureDate;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "reject_reason_cv_id", nullable = true)
|
||||
private CodeValue rejectReason;
|
||||
|
||||
@Column(name = "rejectedon_date", nullable = true)
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date rejectDate;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "rejectedon_userid", nullable = true)
|
||||
private AppUser rejectedBy;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "withdraw_reason_cv_id", nullable = true)
|
||||
private CodeValue withdrawReason;
|
||||
|
||||
@Column(name = "withdrawn_on_date", nullable = true)
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date withdrawDate;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "withdraw_on_userid", nullable = true)
|
||||
private AppUser withdrawnBy;
|
||||
|
||||
@Column(name = "reactivated_on_date", nullable = true)
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date reactivateDate;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "reactivated_on_userid", nullable = true)
|
||||
private AppUser reactivatedBy;
|
||||
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "closedon_userid", nullable = true)
|
||||
private AppUser closeddBy;
|
||||
private AppUser closedBy;
|
||||
|
||||
@Column(name = "submittedon_date", nullable = true)
|
||||
@Temporal(TemporalType.DATE)
|
||||
@@ -145,6 +178,14 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
@JoinColumn(name = "submittedon_userid", nullable = true)
|
||||
private AppUser submittedBy;
|
||||
|
||||
@Column(name = "updated_on", nullable = true)
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date updatedOnDate;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "updated_by", nullable = true)
|
||||
private AppUser updatedBy;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "activatedon_userid", nullable = true)
|
||||
private AppUser activatedBy;
|
||||
@@ -693,7 +734,7 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
public void close(final AppUser currentUser, final CodeValue closureReason, final Date closureDate) {
|
||||
this.closureReason = closureReason;
|
||||
this.closureDate = closureDate;
|
||||
this.closeddBy = currentUser;
|
||||
this.closedBy = currentUser;
|
||||
this.status = ClientStatus.CLOSED.getValue();
|
||||
}
|
||||
|
||||
@@ -805,4 +846,32 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
}
|
||||
return dateOfBirth;
|
||||
}
|
||||
|
||||
public void reject(AppUser currentUser, CodeValue rejectReason, Date rejectDate) {
|
||||
this.rejectReason = rejectReason;
|
||||
this.rejectDate = rejectDate;
|
||||
this.rejectedBy = currentUser;
|
||||
this.updatedBy = currentUser;
|
||||
this.updatedOnDate = rejectDate;
|
||||
this.status = ClientStatus.REJECTED.getValue();
|
||||
|
||||
}
|
||||
|
||||
public void withdraw(AppUser currentUser, CodeValue withdrawReason, Date withdrawDate) {
|
||||
this.withdrawReason = withdrawReason;
|
||||
this.withdrawDate = withdrawDate;
|
||||
this.withdrawnBy = currentUser;
|
||||
this.updatedBy = currentUser;
|
||||
this.updatedOnDate = withdrawDate;
|
||||
this.status = ClientStatus.WITHDRAWN.getValue();
|
||||
|
||||
}
|
||||
public void reActivate(AppUser currentUser, Date reactivateDate) {
|
||||
this.reactivateDate = reactivateDate;
|
||||
this.reactivatedBy = currentUser;
|
||||
this.updatedBy = currentUser;
|
||||
this.updatedOnDate = reactivateDate;
|
||||
this.status = ClientStatus.PENDING.getValue();
|
||||
|
||||
}
|
||||
}
|
||||
+6
@@ -29,6 +29,12 @@ public class ClientEnumerations {
|
||||
case CLOSED:
|
||||
optionData = new EnumOptionData(ClientStatus.CLOSED.getValue().longValue(), ClientStatus.CLOSED.getCode(), "Closed");
|
||||
break;
|
||||
case REJECTED:
|
||||
optionData = new EnumOptionData(ClientStatus.REJECTED.getValue().longValue(), ClientStatus.REJECTED.getCode(), "Rejected");
|
||||
break;
|
||||
case WITHDRAWN:
|
||||
optionData = new EnumOptionData(ClientStatus.WITHDRAWN.getValue().longValue(), ClientStatus.WITHDRAWN.getCode(), "Withdrawn");
|
||||
break;
|
||||
case TRANSFER_IN_PROGRESS:
|
||||
optionData = new EnumOptionData(ClientStatus.TRANSFER_IN_PROGRESS.getValue().longValue(),
|
||||
ClientStatus.TRANSFER_IN_PROGRESS.getCode(), "Transfer in progress");
|
||||
|
||||
+18
-3
@@ -15,7 +15,10 @@ public enum ClientStatus {
|
||||
ACTIVE(300, "clientStatusType.active"), //
|
||||
TRANSFER_IN_PROGRESS(303, "clientStatusType.transfer.in.progress"), //
|
||||
TRANSFER_ON_HOLD(304, "clientStatusType.transfer.on.hold"), //
|
||||
CLOSED(600, "clientStatusType.closed");
|
||||
CLOSED(600, "clientStatusType.closed"),
|
||||
REJECTED(700,"clientStatusType.rejected"),
|
||||
WITHDRAWN(800,"clientStatusType.withdraw");
|
||||
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
@@ -39,6 +42,13 @@ public enum ClientStatus {
|
||||
case 600:
|
||||
enumeration = ClientStatus.CLOSED;
|
||||
break;
|
||||
case 700:
|
||||
enumeration = ClientStatus.REJECTED;
|
||||
break;
|
||||
case 800:
|
||||
enumeration = ClientStatus.WITHDRAWN;
|
||||
break;
|
||||
|
||||
}
|
||||
return enumeration;
|
||||
}
|
||||
@@ -67,11 +77,16 @@ public enum ClientStatus {
|
||||
public boolean isActive() {
|
||||
return this.value.equals(ClientStatus.ACTIVE.getValue());
|
||||
}
|
||||
|
||||
|
||||
public boolean isClosed() {
|
||||
return this.value.equals(ClientStatus.CLOSED.getValue());
|
||||
}
|
||||
|
||||
public boolean isRejected(){
|
||||
return this.value.equals(ClientStatus.REJECTED.getValue());
|
||||
}
|
||||
public boolean isWithdrawn(){
|
||||
return this.value.equals(ClientStatus.WITHDRAWN.getValue());
|
||||
}
|
||||
public boolean isTransferInProgress() {
|
||||
return this.value.equals(ClientStatus.TRANSFER_IN_PROGRESS.getValue());
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class ReActivateClientCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final ClientWritePlatformService clientWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public ReActivateClientCommandHandler(final ClientWritePlatformService clientWritePlatformService) {
|
||||
this.clientWritePlatformService = clientWritePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.reActivateClient(command.entityId(), command);
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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.portfolio.client.handler;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
public class RejectClientCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final ClientWritePlatformService clientWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public RejectClientCommandHandler(final ClientWritePlatformService clientWritePlatformService) {
|
||||
this.clientWritePlatformService = clientWritePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.rejectClient(command.entityId(), command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Service
|
||||
public class WithdrawClientCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final ClientWritePlatformService clientWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public WithdrawClientCommandHandler(final ClientWritePlatformService clientWritePlatformService) {
|
||||
this.clientWritePlatformService = clientWritePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.withdrawClient(command.entityId(), command);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -31,5 +31,5 @@ public interface ClientReadPlatformService {
|
||||
|
||||
Collection<ClientData> retrieveActiveClientMembersOfCenter(final Long centerId);
|
||||
|
||||
ClientData retrieveAllClosureReasons(String clientClosureReason);
|
||||
ClientData retrieveAllNarrations(String clientNarrations);
|
||||
}
|
||||
+4
-4
@@ -661,12 +661,12 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientData retrieveAllClosureReasons(final String clientClosureReason) {
|
||||
final List<CodeValueData> closureReasons = new ArrayList<>(
|
||||
this.codeValueReadPlatformService.retrieveCodeValuesByCode(clientClosureReason));
|
||||
public ClientData retrieveAllNarrations(final String clientNarrations) {
|
||||
final List<CodeValueData> narrations = new ArrayList<>(
|
||||
this.codeValueReadPlatformService.retrieveCodeValuesByCode(clientNarrations));
|
||||
final Collection<CodeValueData> clientTypeOptions = null;
|
||||
final Collection<CodeValueData> clientClassificationOptions = null;
|
||||
return ClientData.template(null, null, null, null, closureReasons, null, null, clientTypeOptions, clientClassificationOptions);
|
||||
return ClientData.template(null, null, null, null, narrations, null, null, clientTypeOptions, clientClassificationOptions);
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -26,4 +26,10 @@ public interface ClientWritePlatformService {
|
||||
|
||||
CommandProcessingResult updateDefaultSavingsAccount(Long clientId, JsonCommand command);
|
||||
|
||||
CommandProcessingResult rejectClient(Long entityId, JsonCommand command);
|
||||
|
||||
CommandProcessingResult withdrawClient(Long entityId, JsonCommand command);
|
||||
|
||||
CommandProcessingResult reActivateClient(Long entityId, JsonCommand command);
|
||||
|
||||
}
|
||||
+87
-2
@@ -575,7 +575,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
}
|
||||
|
||||
/*
|
||||
* To become a part of a group, group may have set of criteria to be met
|
||||
* To become a part of a group, group may have set of criteria to be m et
|
||||
* before client can become member of it.
|
||||
*/
|
||||
private void validateParentGroupRulesBeforeClientActivation(Client client) {
|
||||
@@ -593,4 +593,89 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult rejectClient(final Long entityId, final JsonCommand command) {
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
this.fromApiJsonDeserializer.validateRejection(command);
|
||||
|
||||
final Client client = this.clientRepository.findOneWithNotFoundDetection(entityId);
|
||||
final LocalDate rejectDate = command.localDateValueOfParameterNamed(ClientApiConstants.rejectDateParamName);
|
||||
final Long rejectReasonId = command.longValueOfParameterNamed(ClientApiConstants.rejectReasonIdParamName);
|
||||
|
||||
final CodeValue rejectReason = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
ClientApiConstants.CLIENT_REJECT_REASON, rejectReasonId);
|
||||
|
||||
if (ClientStatus.fromInt(client.getStatus()).isRejected()) {
|
||||
final String errorMessage = "Client is already rejected.";
|
||||
throw new InvalidClientStateTransitionException("rejected", "is.already.rejected", errorMessage);
|
||||
} else if (client.isNotPending() || client.getSubmittedOnDate().isAfter(rejectDate)) {
|
||||
final String errorMessage = "The client is active or The client rejetDate cannot be before the client SubmittedDate.";
|
||||
throw new InvalidClientStateTransitionException("rejected", "date.cannot.before.client.submitted.date", errorMessage,
|
||||
rejectDate, client.getSubmittedOnDate());
|
||||
} else {
|
||||
client.reject(currentUser, rejectReason, rejectDate.toDate());
|
||||
this.clientRepository.saveAndFlush(client);
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withClientId(entityId) //
|
||||
.withEntityId(entityId) //
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult withdrawClient(Long entityId, JsonCommand command) {
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
this.fromApiJsonDeserializer.validateWithdrawn(command);
|
||||
|
||||
final Client client = this.clientRepository.findOneWithNotFoundDetection(entityId);
|
||||
final LocalDate withdrawDate = command.localDateValueOfParameterNamed(ClientApiConstants.withdrawDateParamName);
|
||||
final Long withdrawReasonId = command.longValueOfParameterNamed(ClientApiConstants.withdrawReasonIdParamName);
|
||||
|
||||
final CodeValue withdrawReason = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
ClientApiConstants.CLIENT_WITHDRAW_REASON, withdrawReasonId);
|
||||
|
||||
if (ClientStatus.fromInt(client.getStatus()).isRejected()) {
|
||||
final String errorMessage = "Client is already Withdrawn.";
|
||||
throw new InvalidClientStateTransitionException("withdrawn", "is.already.withdrawn", errorMessage);
|
||||
} else if (client.isNotPending() || client.getSubmittedOnDate().isAfter(withdrawDate)) {
|
||||
final String errorMessage = "The client is active or The client withdrawDate cannot be before the client SubmittedDate.";
|
||||
throw new InvalidClientStateTransitionException("withdrawn", "date.cannot.before.client.submitted.date", errorMessage,
|
||||
withdrawDate, client.getSubmittedOnDate());
|
||||
} else {
|
||||
client.withdraw(currentUser, withdrawReason, withdrawDate.toDate());
|
||||
this.clientRepository.saveAndFlush(client);
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withClientId(entityId) //
|
||||
.withEntityId(entityId) //
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult reActivateClient(Long entityId, JsonCommand command) {
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
this.fromApiJsonDeserializer.validateReactivate(command);
|
||||
|
||||
final Client client = this.clientRepository.findOneWithNotFoundDetection(entityId);
|
||||
final LocalDate reactivateDate = command.localDateValueOfParameterNamed(ClientApiConstants.reactivationDateParamName);
|
||||
|
||||
|
||||
if (ClientStatus.fromInt(client.getStatus()).isActive()) {
|
||||
final String errorMessage = "Client is already activated.";
|
||||
throw new InvalidClientStateTransitionException("activated", "is.already.activated", errorMessage);
|
||||
} else if (client.isClosed()) {
|
||||
client.reActivate(currentUser, reactivateDate.toDate());
|
||||
this.clientRepository.saveAndFlush(client);
|
||||
}
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withClientId(entityId) //
|
||||
.withEntityId(entityId) //
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `m_client`
|
||||
ADD COLUMN `reject_reason_cv_id` INT(11) NULL DEFAULT NULL AFTER `client_classification_cv_id`,
|
||||
ADD COLUMN `rejectedon_date` DATE NULL DEFAULT NULL AFTER `reject_reason_cv_id`,
|
||||
ADD COLUMN `rejectedon_userid` BIGINT(20) NULL DEFAULT NULL AFTER `rejectedon_date`,
|
||||
ADD COLUMN `withdraw_reason_cv_id` INT(11) NULL DEFAULT NULL AFTER `rejectedon_userid`,
|
||||
ADD COLUMN `withdrawn_on_date` DATE NULL DEFAULT NULL AFTER `withdraw_reason_cv_id`,
|
||||
ADD COLUMN `withdraw_on_userid` BIGINT(20) NULL DEFAULT NULL AFTER `withdrawn_on_date`,
|
||||
ADD CONSTRAINT `FK_m_client_type_mcode_value_reject` FOREIGN KEY (`reject_reason_cv_id`) REFERENCES `m_code_value` (`id`),
|
||||
ADD CONSTRAINT `FK_m_client_type_m_code_value_withdraw` FOREIGN KEY (`withdraw_reason_cv_id`) REFERENCES `m_code_value` (`id`);
|
||||
SELECT `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`='mifostenant-default';
|
||||
SHOW TABLE STATUS FROM `mifostenant-default`;
|
||||
SHOW FUNCTION STATUS WHERE `Db`='mifostenant-default';
|
||||
SHOW PROCEDURE STATUS WHERE `Db`='mifostenant-default';
|
||||
SHOW TRIGGERS FROM `mifostenant-default`;
|
||||
SHOW EVENTS FROM `mifostenant-default`;
|
||||
SHOW CREATE TABLE `mifostenant-default`.`m_client`;
|
||||
/* Entering session "mifosx" */
|
||||
|
||||
ALTER TABLE `m_client`
|
||||
ADD COLUMN `updated_by` BIGINT(20) NULL DEFAULT NULL AFTER `closedon_date`,
|
||||
ADD COLUMN `updated_on` DATE NULL DEFAULT NULL AFTER `updated_by`;
|
||||
|
||||
|
||||
|
||||
INSERT INTO `m_permission` ( `grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'REJECT_CLIENT', 'CLIENT', 'REJECT', 1);
|
||||
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'REJECT_CLIENT_CHECKER', 'CLIENT', 'REJECT_CHECKER', 0);
|
||||
|
||||
INSERT INTO `m_permission` ( `grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'WITHDRAW_CLIENT', 'CLIENT', 'WITHDRAW', 1);
|
||||
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'WITHDRAW_CLIENT_CHECKER', 'CLIENT', 'WITHDRAW_CHECKER', 0);
|
||||
|
||||
|
||||
INSERT INTO `m_code` ( `code_name`, `is_system_defined`) VALUES ( 'ClientRejectReason', 1);
|
||||
|
||||
|
||||
INSERT INTO `m_code_value` ( `code_id`, `code_value`, `order_position`, `code_score`) VALUES ( (SELECT id from m_code where code_name = 'ClientRejectReason') , 'Client Rejected', 1, NULL);
|
||||
|
||||
INSERT INTO `m_code` ( `code_name`, `is_system_defined`) VALUES ( 'ClientWithdrawReason', 1);
|
||||
|
||||
INSERT INTO `m_code_value` ( `code_id`, `code_value`, `order_position`, `code_score`) VALUES ( (SELECT id from m_code where code_name = 'ClientWithdrawReason') , 'Client Withdrawn', 1, NULL);
|
||||
|
||||
|
||||
|
||||
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'REACTIVATE_CLIENT', 'CLIENT', 'REACTIVATE', 1);
|
||||
INSERT INTO `m_permission` ( `grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'REACTIVATE_CLIENT_CHECKER', 'CLIENT', 'REACTIVATE_CHECKER', 0);
|
||||
|
||||
|
||||
ALTER TABLE `m_client`
|
||||
ADD COLUMN `reactivated_on_date` DATE NULL AFTER `withdraw_on_userid`,
|
||||
ADD COLUMN `reactivated_on_userid` BIGINT(20) NULL AFTER `reactivated_on_date`;
|
||||
Reference in New Issue
Block a user