Merge pull request #1004 from Musoni/MIFOSX-1400
abillity to modify client submission date
This commit is contained in:
+3
-1
@@ -78,8 +78,10 @@ public class ClientApiConstants {
|
||||
|
||||
public static final Set<String> CLIENT_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
|
||||
dateFormatParamName, accountNoParamName, externalIdParamName, mobileNoParamName, firstnameParamName, middlenameParamName,
|
||||
|
||||
lastnameParamName, fullnameParamName, activeParamName, activationDateParamName, staffIdParamName, savingsProductIdParamName,
|
||||
dateOfBirthParamName, genderIdParamName, clientTypeIdParamName, clientClassificationIdParamName));
|
||||
dateOfBirthParamName, genderIdParamName, clientTypeIdParamName, clientClassificationIdParamName,submittedOnDateParamName));
|
||||
|
||||
|
||||
/**
|
||||
* These parameters will match the class level parameters of
|
||||
|
||||
+11
@@ -324,6 +324,7 @@ public final class ClientDataValidator {
|
||||
|
||||
final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(ClientApiConstants.activeParamName, element);
|
||||
if (active != null) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
if (active.booleanValue()) {
|
||||
final LocalDate joinedDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.activationDateParamName,
|
||||
element);
|
||||
@@ -344,6 +345,7 @@ public final class ClientDataValidator {
|
||||
.longGreaterThanZero();
|
||||
}
|
||||
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.dateOfBirthParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final LocalDate dateOfBirth = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.dateOfBirthParamName, element);
|
||||
@@ -371,12 +373,21 @@ public final class ClientDataValidator {
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.clientClassificationIdParamName).value(clientClassification)
|
||||
.integerGreaterThanZero();
|
||||
}
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.submittedOnDateParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final LocalDate submittedDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.submittedOnDateParamName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.submittedOnDateParamName).value(submittedDate).notNull();
|
||||
|
||||
}
|
||||
|
||||
if (!atLeastOneParameterPassedForUpdate) {
|
||||
final Object forceError = null;
|
||||
baseDataValidator.reset().anyOfNotNull(forceError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
|
||||
@@ -446,6 +446,7 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
actualChanges.put(ClientApiConstants.savingsProductIdParamName, newValue);
|
||||
}
|
||||
|
||||
|
||||
if (command.isChangeInLongParameterNamed(ClientApiConstants.genderIdParamName, genderId())) {
|
||||
final Long newValue = command.longValueOfParameterNamed(ClientApiConstants.genderIdParamName);
|
||||
actualChanges.put(ClientApiConstants.genderIdParamName, newValue);
|
||||
@@ -461,6 +462,7 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
actualChanges.put(ClientApiConstants.clientClassificationIdParamName, newValue);
|
||||
}
|
||||
|
||||
|
||||
final String dateFormatAsInput = command.dateFormat();
|
||||
final String localeAsInput = command.locale();
|
||||
|
||||
@@ -485,6 +487,16 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
this.dateOfBirth = newValue.toDate();
|
||||
}
|
||||
|
||||
if (command.isChangeInLocalDateParameterNamed(ClientApiConstants.submittedOnDateParamName,getSubmittedOnDate())) {
|
||||
final String valueAsInput = command.stringValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName);
|
||||
actualChanges.put(ClientApiConstants.submittedOnDateParamName, valueAsInput);
|
||||
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
|
||||
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
|
||||
|
||||
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName);
|
||||
this.submittedOnDate = newValue.toDate();
|
||||
}
|
||||
|
||||
validate();
|
||||
|
||||
deriveDisplayName();
|
||||
@@ -492,6 +504,7 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
return actualChanges;
|
||||
}
|
||||
|
||||
|
||||
private void validateNameParts(final List<ApiParameterError> dataValidationErrors) {
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("client");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user