Merge pull request #1608 from deepak7conflux/clientNonPersonFeature
Added Client as Entity feature
This commit is contained in:
+66
@@ -66,4 +66,70 @@ public class ClientTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientAsPersonStatus() {
|
||||
|
||||
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
|
||||
final Integer clientId = ClientHelper.createClientAsPerson(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
ClientStatusChecker.verifyClientIsActive(status);
|
||||
|
||||
HashMap<String, Object> 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);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientAsEntityStatus() {
|
||||
|
||||
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
|
||||
final Integer clientId = ClientHelper.createClientAsEntity(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
ClientStatusChecker.verifyClientIsActive(status);
|
||||
|
||||
HashMap<String, Object> 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+72
@@ -9,6 +9,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||
import org.mifosplatform.integrationtests.common.system.CodeHelper;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -56,6 +57,43 @@ public class ClientHelper {
|
||||
"clientId");
|
||||
}
|
||||
|
||||
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createClientAsPerson(requestSpec, responseSpec, "04 March 2011");
|
||||
}
|
||||
|
||||
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String activationDate) {
|
||||
return createClientAsPerson(requestSpec, responseSpec, activationDate, "1");
|
||||
}
|
||||
|
||||
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String activationDate, final String officeId) {
|
||||
|
||||
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId),
|
||||
"clientId");
|
||||
}
|
||||
|
||||
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
|
||||
}
|
||||
|
||||
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String activationDate) {
|
||||
return createClientAsEntity(requestSpec, responseSpec, activationDate, "1");
|
||||
}
|
||||
|
||||
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String activationDate, final String officeId) {
|
||||
|
||||
Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id");
|
||||
Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id");
|
||||
|
||||
System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId),
|
||||
"clientId");
|
||||
}
|
||||
|
||||
public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer clientType, String jsonAttributeToGetBack) {
|
||||
final String activationDate = "04 March 2011";
|
||||
@@ -94,6 +132,40 @@ public class ClientHelper {
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String getTestPersonClientAsJSON(final String dateOfJoining, final String officeId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("officeId", officeId);
|
||||
map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
map.put("dateFormat", DATE_FORMAT);
|
||||
map.put("locale", "en");
|
||||
map.put("active", "true");
|
||||
map.put("activationDate", dateOfJoining);
|
||||
map.put("legalFormId", 1);
|
||||
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String getTestEntityClientAsJSON(final String dateOfJoining, final String officeId, final Integer soleProprietorCodeValueId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("officeId", officeId);
|
||||
map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
map.put("dateFormat", DATE_FORMAT);
|
||||
map.put("locale", "en");
|
||||
map.put("active", "true");
|
||||
map.put("activationDate", dateOfJoining);
|
||||
map.put("legalFormId", 2);
|
||||
|
||||
final HashMap<String, Object> clientNonPersonMap = new HashMap<>();
|
||||
clientNonPersonMap.put("constitutionId", soleProprietorCodeValueId);
|
||||
map.put("clientNonPersonDetails", clientNonPersonMap);
|
||||
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, final String clientType) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("officeId", officeId);
|
||||
|
||||
@@ -40,6 +40,10 @@ public class Code extends AbstractPersistable<Long> {
|
||||
return new Code(name);
|
||||
}
|
||||
|
||||
public static Code createNew(final String name) {
|
||||
return new Code(name);
|
||||
}
|
||||
|
||||
protected Code() {
|
||||
this.systemDefined = false;
|
||||
}
|
||||
|
||||
+32
-3
@@ -48,10 +48,16 @@ public class ClientApiConstants {
|
||||
public static final String GENDER = "Gender";
|
||||
public static final String CLIENT_TYPE = "ClientType";
|
||||
public static final String CLIENT_CLASSIFICATION = "ClientClassification";
|
||||
|
||||
public static final String CLIENT_NON_PERSON_CONSTITUTION = "Constitution";
|
||||
public static final String CLIENT_NON_PERSON_MAIN_BUSINESS_LINE = "Main Business Line";
|
||||
|
||||
// general
|
||||
public static final String localeParamName = "locale";
|
||||
public static final String dateFormatParamName = "dateFormat";
|
||||
|
||||
public static final String CLIENT_TYPE_INDIVIDUAL = "Individual";
|
||||
|
||||
// request parameters
|
||||
public static final String idParamName = "id";
|
||||
public static final String groupIdParamName = "groupId";
|
||||
@@ -62,6 +68,7 @@ public class ClientApiConstants {
|
||||
public static final String middlenameParamName = "middlename";
|
||||
public static final String lastnameParamName = "lastname";
|
||||
public static final String fullnameParamName = "fullname";
|
||||
public static final String displaynameParamName = "displayname";
|
||||
public static final String officeIdParamName = "officeId";
|
||||
public static final String transferOfficeIdParamName = "transferOfficeIdParamName";
|
||||
public static final String activeParamName = "active";
|
||||
@@ -86,6 +93,8 @@ public class ClientApiConstants {
|
||||
public static final String clientTypeParamName = "clientType";
|
||||
public static final String clientClassificationIdParamName = "clientClassificationId";
|
||||
public static final String clientClassificationParamName = "clientClassification";
|
||||
public static final String legalFormIdParamName = "legalFormId";
|
||||
public static final String legalFormParamName = "legalForm";
|
||||
// request parameters for payment details
|
||||
public static final String paymentTypeIdParamName = "paymentTypeId";
|
||||
public static final String transactionAccountNumberParamName = "accountNumber";
|
||||
@@ -94,6 +103,15 @@ public class ClientApiConstants {
|
||||
public static final String receiptNumberParamName = "receiptNumber";
|
||||
public static final String bankNumberParamName = "bankNumber";
|
||||
|
||||
//request parameters for client non person
|
||||
public static final String clientNonPersonDetailsParamName = "clientNonPersonDetails";
|
||||
public static final String incorpNumberParamName = "incorpNumber";
|
||||
public static final String remarksParamName = "remarks";
|
||||
public static final String incorpValidityTillParamName = "incorpValidityTillDate";
|
||||
public static final String constitutionIdParamName = "constitutionId";
|
||||
public static final String mainBusinessLineIdParamName = "mainBusinessLineId";
|
||||
|
||||
|
||||
// response parameters
|
||||
public static final String statusParamName = "status";
|
||||
public static final String hierarchyParamName = "hierarchy";
|
||||
@@ -147,13 +165,23 @@ public class ClientApiConstants {
|
||||
Arrays.asList(localeParamName, dateFormatParamName, groupIdParamName, accountNoParamName, externalIdParamName,
|
||||
mobileNoParamName, firstnameParamName, middlenameParamName, lastnameParamName, fullnameParamName, officeIdParamName,
|
||||
activeParamName, activationDateParamName, staffIdParamName, submittedOnDateParamName, savingsProductIdParamName,
|
||||
dateOfBirthParamName, genderIdParamName, clientTypeIdParamName, clientClassificationIdParamName));
|
||||
dateOfBirthParamName, genderIdParamName, clientTypeIdParamName, clientClassificationIdParamName,
|
||||
clientNonPersonDetailsParamName, displaynameParamName, legalFormIdParamName));
|
||||
|
||||
public static final Set<String> CLIENT_NON_PERSON_CREATE_REQUEST_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(localeParamName, dateFormatParamName, incorpNumberParamName, remarksParamName, incorpValidityTillParamName,
|
||||
constitutionIdParamName, mainBusinessLineIdParamName));
|
||||
|
||||
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, submittedOnDateParamName));
|
||||
dateOfBirthParamName, genderIdParamName, clientTypeIdParamName, clientClassificationIdParamName, submittedOnDateParamName,
|
||||
clientNonPersonDetailsParamName, displaynameParamName, legalFormIdParamName));
|
||||
|
||||
public static final Set<String> CLIENT_NON_PERSON_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
|
||||
dateFormatParamName, incorpNumberParamName, remarksParamName, incorpValidityTillParamName,
|
||||
constitutionIdParamName, mainBusinessLineIdParamName));
|
||||
|
||||
/**
|
||||
* These parameters will match the class level parameters of
|
||||
@@ -165,7 +193,8 @@ public class ClientApiConstants {
|
||||
lastnameParamName, fullnameParamName, displayNameParamName, mobileNoParamName, officeIdParamName, officeNameParamName,
|
||||
transferToOfficeIdParamName, transferToOfficeNameParamName, hierarchyParamName, imageIdParamName, imagePresentParamName,
|
||||
staffIdParamName, staffNameParamName, timelineParamName, groupsParamName, officeOptionsParamName, staffOptionsParamName,
|
||||
dateOfBirthParamName, genderParamName, clientTypeParamName, clientClassificationParamName));
|
||||
dateOfBirthParamName, genderParamName, clientTypeParamName, clientClassificationParamName, legalFormParamName,
|
||||
clientNonPersonDetailsParamName));
|
||||
|
||||
public static final Set<String> ACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(localeParamName, dateFormatParamName, activationDateParamName));
|
||||
|
||||
+51
-10
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.portfolio.client.data;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.CompareToBuilder;
|
||||
@@ -62,6 +63,7 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
private final String savingsProductName;
|
||||
|
||||
private final Long savingsAccountId;
|
||||
private final EnumOptionData legalForm;
|
||||
|
||||
// associations
|
||||
private final Collection<GroupGeneralData> groups;
|
||||
@@ -75,11 +77,18 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
private final Collection<CodeValueData> genderOptions;
|
||||
private final Collection<CodeValueData> clientTypeOptions;
|
||||
private final Collection<CodeValueData> clientClassificationOptions;
|
||||
private final Collection<CodeValueData> clientNonPersonConstitutionOptions;
|
||||
private final Collection<CodeValueData> clientNonPersonMainBusinessLineOptions;
|
||||
private final List<EnumOptionData> clientLegalFormOptions;
|
||||
|
||||
private final ClientNonPersonData clientNonPersonDetails;
|
||||
|
||||
public static ClientData template(final Long officeId, final LocalDate joinedDate, final Collection<OfficeData> officeOptions,
|
||||
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 Collection<CodeValueData> clientTypeOptions, final Collection<CodeValueData> clientClassificationOptions,
|
||||
final Collection<CodeValueData> clientNonPersonConstitutionOptions, final Collection<CodeValueData> clientNonPersonMainBusinessLineOptions,
|
||||
final List<EnumOptionData> clientLegalFormOptions) {
|
||||
final String accountNo = null;
|
||||
final EnumOptionData status = null;
|
||||
final CodeValueData subStatus = null;
|
||||
@@ -107,11 +116,14 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
final Collection<SavingsAccountData> savingAccountOptions = null;
|
||||
final CodeValueData clientType = null;
|
||||
final CodeValueData clientClassification = null;
|
||||
final EnumOptionData legalForm = null;
|
||||
final ClientNonPersonData clientNonPersonDetails = 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, narrations, genderOptions, timeline, savingProductOptions,
|
||||
savingsProductId, savingsProductName, savingsAccountId, savingAccountOptions, clientType, clientClassification,
|
||||
clientTypeOptions, clientClassificationOptions);
|
||||
clientTypeOptions, clientClassificationOptions, clientNonPersonConstitutionOptions, clientNonPersonMainBusinessLineOptions,
|
||||
clientNonPersonDetails, clientLegalFormOptions, legalForm);
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +136,9 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
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);
|
||||
clientData.clientClassification, templateData.clientTypeOptions, templateData.clientClassificationOptions,
|
||||
templateData.clientNonPersonConstitutionOptions, templateData.clientNonPersonMainBusinessLineOptions, clientData.clientNonPersonDetails,
|
||||
templateData.clientLegalFormOptions, clientData.legalForm);
|
||||
|
||||
}
|
||||
|
||||
@@ -138,7 +152,9 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
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);
|
||||
clientData.clientClassification, clientData.clientTypeOptions, clientData.clientClassificationOptions,
|
||||
clientData.clientNonPersonConstitutionOptions, clientData.clientNonPersonMainBusinessLineOptions, clientData.clientNonPersonDetails,
|
||||
clientData.clientLegalFormOptions, clientData.legalForm);
|
||||
|
||||
}
|
||||
|
||||
@@ -150,7 +166,8 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
clientData.staffName, clientData.officeOptions, parentGroups, clientData.staffOptions, null, null, clientData.timeline,
|
||||
clientData.savingProductOptions, clientData.savingsProductId, clientData.savingsProductName, clientData.savingsAccountId,
|
||||
clientData.savingAccountOptions, clientData.clientType, clientData.clientClassification, clientData.clientTypeOptions,
|
||||
clientData.clientClassificationOptions);
|
||||
clientData.clientClassificationOptions, clientData.clientNonPersonConstitutionOptions, clientData.clientNonPersonMainBusinessLineOptions,
|
||||
clientData.clientNonPersonDetails, clientData.clientLegalFormOptions, clientData.legalForm);
|
||||
|
||||
}
|
||||
|
||||
@@ -182,13 +199,19 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
final CodeValueData clientClassification = null;
|
||||
final Collection<CodeValueData> clientTypeOptions = null;
|
||||
final Collection<CodeValueData> clientClassificationOptions = null;
|
||||
final Collection<CodeValueData> clientNonPersonConstitutionOptions = null;
|
||||
final Collection<CodeValueData> clientNonPersonMainBusinessLineOptions = null;
|
||||
final List<EnumOptionData> clientLegalFormOptions = null;
|
||||
final EnumOptionData status = null;
|
||||
final CodeValueData subStatus = null;
|
||||
final EnumOptionData legalForm = null;
|
||||
final ClientNonPersonData clientNonPerson = null;
|
||||
return new ClientData(accountNo, status, subStatus, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname,
|
||||
middlename, lastname, fullname, displayName, externalId, mobileNo, dateOfBirth, gender, activationDate, imageId, staffId,
|
||||
staffName, allowedOffices, groups, staffOptions, closureReasons, genderOptions, timeline, savingProductOptions,
|
||||
savingsProductId, savingsProductName, savingsAccountId, savingAccountOptions, clientType, clientClassification,
|
||||
clientTypeOptions, clientClassificationOptions);
|
||||
clientTypeOptions, clientClassificationOptions, clientNonPersonConstitutionOptions, clientNonPersonMainBusinessLineOptions,
|
||||
clientNonPerson, clientLegalFormOptions, legalForm);
|
||||
}
|
||||
|
||||
public static ClientData lookup(final Long id, final String displayName, final Long officeId, final String officeName) {
|
||||
@@ -224,11 +247,17 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
final CodeValueData clientClassification = null;
|
||||
final Collection<CodeValueData> clientTypeOptions = null;
|
||||
final Collection<CodeValueData> clientClassificationOptions = null;
|
||||
final Collection<CodeValueData> clientNonPersonConstitutionOptions = null;
|
||||
final Collection<CodeValueData> clientNonPersonMainBusinessLineOptions = null;
|
||||
final List<EnumOptionData> clientLegalFormOptions = null;
|
||||
final EnumOptionData legalForm = null;
|
||||
final ClientNonPersonData clientNonPerson = null;
|
||||
return new ClientData(accountNo, status, subStatus, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname,
|
||||
middlename, lastname, fullname, displayName, externalId, mobileNo, dateOfBirth, gender, activationDate, imageId, staffId,
|
||||
staffName, allowedOffices, groups, staffOptions, closureReasons, genderOptions, timeline, savingProductOptions,
|
||||
savingsProductId, savingsProductName, savingsAccountId, savingAccountOptions, clientType, clientClassification,
|
||||
clientTypeOptions, clientClassificationOptions);
|
||||
clientTypeOptions, clientClassificationOptions, clientNonPersonConstitutionOptions, clientNonPersonMainBusinessLineOptions,
|
||||
clientNonPerson, clientLegalFormOptions, legalForm);
|
||||
|
||||
}
|
||||
|
||||
@@ -238,7 +267,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 ClientTimelineData timeline, final Long savingsProductId, final String savingsProductName, final Long savingsAccountId,
|
||||
final CodeValueData clientType, final CodeValueData clientClassification) {
|
||||
final CodeValueData clientType, final CodeValueData clientClassification, final EnumOptionData legalForm, final ClientNonPersonData clientNonPerson) {
|
||||
|
||||
final Collection<OfficeData> allowedOffices = null;
|
||||
final Collection<GroupGeneralData> groups = null;
|
||||
@@ -248,11 +277,15 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
final Collection<SavingsProductData> savingProductOptions = null;
|
||||
final Collection<CodeValueData> clientTypeOptions = null;
|
||||
final Collection<CodeValueData> clientClassificationOptions = null;
|
||||
final Collection<CodeValueData> clientNonPersonConstitutionOptions = null;
|
||||
final Collection<CodeValueData> clientNonPersonMainBusinessLineOptions = null;
|
||||
final List<EnumOptionData> clientLegalFormOptions = null;
|
||||
return new ClientData(accountNo, status, subStatus, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname,
|
||||
middlename, lastname, fullname, displayName, externalId, mobileNo, dateOfBirth, gender, activationDate, imageId, staffId,
|
||||
staffName, allowedOffices, groups, staffOptions, closureReasons, genderOptions, timeline, savingProductOptions,
|
||||
savingsProductId, savingsProductName, savingsAccountId, null, clientType, clientClassification, clientTypeOptions,
|
||||
clientClassificationOptions);
|
||||
clientClassificationOptions, clientNonPersonConstitutionOptions, clientNonPersonMainBusinessLineOptions, clientNonPerson,
|
||||
clientLegalFormOptions, legalForm);
|
||||
|
||||
}
|
||||
|
||||
@@ -267,7 +300,9 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
final Collection<SavingsProductData> savingProductOptions, final Long savingsProductId, final String savingsProductName,
|
||||
final Long savingsAccountId, final Collection<SavingsAccountData> savingAccountOptions, final CodeValueData clientType,
|
||||
final CodeValueData clientClassification, final Collection<CodeValueData> clientTypeOptions,
|
||||
final Collection<CodeValueData> clientClassificationOptions) {
|
||||
final Collection<CodeValueData> clientClassificationOptions, final Collection<CodeValueData> clientNonPersonConstitutionOptions,
|
||||
final Collection<CodeValueData> clientNonPersonMainBusinessLineOptions, final ClientNonPersonData clientNonPerson,
|
||||
final List<EnumOptionData> clientLegalFormOptions, final EnumOptionData legalForm) {
|
||||
this.accountNo = accountNo;
|
||||
this.status = status;
|
||||
if (status != null) {
|
||||
@@ -314,12 +349,18 @@ final public class ClientData implements Comparable<ClientData> {
|
||||
this.clientClassificationOptions = clientClassificationOptions;
|
||||
this.clientTypeOptions = clientTypeOptions;
|
||||
|
||||
this.clientNonPersonConstitutionOptions = clientNonPersonConstitutionOptions;
|
||||
this.clientNonPersonMainBusinessLineOptions = clientNonPersonMainBusinessLineOptions;
|
||||
this.clientLegalFormOptions = clientLegalFormOptions;
|
||||
|
||||
this.timeline = timeline;
|
||||
this.savingProductOptions = savingProductOptions;
|
||||
this.savingsProductId = savingsProductId;
|
||||
this.savingsProductName = savingsProductName;
|
||||
this.savingsAccountId = savingsAccountId;
|
||||
this.savingAccountOptions = savingAccountOptions;
|
||||
this.legalForm = legalForm;
|
||||
this.clientNonPersonDetails = clientNonPerson;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+122
-1
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.client.data;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -47,6 +48,12 @@ public final class ClientDataValidator {
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, ClientApiConstants.CLIENT_CREATE_REQUEST_DATA_PARAMETERS);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.clientNonPersonDetailsParamName, element)) {
|
||||
final String clientNonPersonJson = this.fromApiJsonHelper.toJson(element.getAsJsonObject().get(ClientApiConstants.clientNonPersonDetailsParamName));
|
||||
if(clientNonPersonJson != null)
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, clientNonPersonJson, ClientApiConstants.CLIENT_NON_PERSON_CREATE_REQUEST_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
@@ -168,9 +175,58 @@ public final class ClientDataValidator {
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.clientClassificationIdParamName).value(clientClassification)
|
||||
.integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.legalFormIdParamName, element)) {
|
||||
final Integer legalFormId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.legalFormIdParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.legalFormIdParamName).value(legalFormId).ignoreIfNull().inMinMaxRange(1, 2);
|
||||
}
|
||||
|
||||
List<ApiParameterError> dataValidationErrorsForClientNonPerson = getDataValidationErrorsForCreateOnClientNonPerson(element.getAsJsonObject().get(ClientApiConstants.clientNonPersonDetailsParamName));
|
||||
dataValidationErrors.addAll(dataValidationErrorsForClientNonPerson);
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
List<ApiParameterError> getDataValidationErrorsForCreateOnClientNonPerson(JsonElement element)
|
||||
{
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
.resource(ClientApiConstants.CLIENT_RESOURCE_NAME);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.incorpNumberParamName, element)) {
|
||||
final String incorpNumber = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.incorpNumberParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.incorpNumberParamName).value(incorpNumber).ignoreIfNull()
|
||||
.notExceedingLengthOf(50);
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.remarksParamName, element)) {
|
||||
final String remarks = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.remarksParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.remarksParamName).value(remarks).ignoreIfNull()
|
||||
.notExceedingLengthOf(150);
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.incorpValidityTillParamName, element)) {
|
||||
final LocalDate incorpValidityTill = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.incorpValidityTillParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.incorpValidityTillParamName).value(incorpValidityTill).ignoreIfNull();
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.constitutionIdParamName, element)) {
|
||||
final Integer constitution = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.constitutionIdParamName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.constitutionIdParamName).value(constitution).notNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mainBusinessLineIdParamName, element)) {
|
||||
final Integer mainBusinessLine = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.mainBusinessLineIdParamName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.mainBusinessLineIdParamName).value(mainBusinessLine).integerGreaterThanZero();
|
||||
}
|
||||
|
||||
return dataValidationErrors;
|
||||
}
|
||||
|
||||
private void validateIndividualNamePartsCannotBeUsedWithFullname(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
|
||||
final String firstnameParam = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.firstnameParamName, element);
|
||||
if (StringUtils.isNotBlank(firstnameParam)) {
|
||||
@@ -244,6 +300,12 @@ public final class ClientDataValidator {
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, ClientApiConstants.CLIENT_UPDATE_REQUEST_DATA_PARAMETERS);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.clientNonPersonDetailsParamName, element)) {
|
||||
final String clientNonPersonJson = this.fromApiJsonHelper.toJson(element.getAsJsonObject().get(ClientApiConstants.clientNonPersonDetailsParamName));
|
||||
if(clientNonPersonJson != null)
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, clientNonPersonJson, ClientApiConstants.CLIENT_NON_PERSON_UPDATE_REQUEST_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
@@ -380,14 +442,73 @@ public final class ClientDataValidator {
|
||||
|
||||
}
|
||||
|
||||
if (!atLeastOneParameterPassedForUpdate) {
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.legalFormIdParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final Integer legalFormId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.legalFormIdParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.legalFormIdParamName).value(legalFormId).ignoreIfNull().inMinMaxRange(1, 2);
|
||||
}
|
||||
|
||||
Map<String, Object> parameterUpdateStatusDetails = getParameterUpdateStatusAndDataValidationErrorsForUpdateOnClientNonPerson(element.getAsJsonObject().get(ClientApiConstants.clientNonPersonDetailsParamName));
|
||||
boolean atLeastOneParameterPassedForClientNonPersonUpdate = (boolean) parameterUpdateStatusDetails.get("parameterUpdateStatus");
|
||||
|
||||
if (!atLeastOneParameterPassedForUpdate && !atLeastOneParameterPassedForClientNonPersonUpdate) {
|
||||
final Object forceError = null;
|
||||
baseDataValidator.reset().anyOfNotNull(forceError);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ApiParameterError> dataValidationErrorsForClientNonPerson = (List<ApiParameterError>) parameterUpdateStatusDetails.get("dataValidationErrors");
|
||||
dataValidationErrors.addAll(dataValidationErrorsForClientNonPerson);
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
Map<String, Object> getParameterUpdateStatusAndDataValidationErrorsForUpdateOnClientNonPerson(JsonElement element)
|
||||
{
|
||||
boolean atLeastOneParameterPassedForUpdate = false;
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
.resource(ClientApiConstants.CLIENT_RESOURCE_NAME);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.incorpNumberParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final String incorpNo = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.incorpNumberParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.incorpNumberParamName).value(incorpNo).ignoreIfNull().notExceedingLengthOf(50);
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.remarksParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final String remarks = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.remarksParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.remarksParamName).value(remarks).notExceedingLengthOf(150);
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.incorpValidityTillParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final LocalDate incorpValidityTill = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.incorpValidityTillParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.incorpValidityTillParamName).value(incorpValidityTill);
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.constitutionIdParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final Integer constitutionId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.constitutionIdParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.constitutionIdParamName).value(constitutionId).notNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mainBusinessLineIdParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final Integer mainBusinessLineId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.mainBusinessLineIdParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.mainBusinessLineIdParamName).value(mainBusinessLineId).integerGreaterThanZero();
|
||||
}
|
||||
|
||||
Map<String, Object> parameterUpdateStatusDetails = new HashMap<>();
|
||||
parameterUpdateStatusDetails.put("parameterUpdateStatus", atLeastOneParameterPassedForUpdate);
|
||||
parameterUpdateStatusDetails.put("dataValidationErrors", dataValidationErrors);
|
||||
|
||||
return parameterUpdateStatusDetails;
|
||||
|
||||
}
|
||||
|
||||
public void validateActivation(final JsonCommand command) {
|
||||
final String json = command.json();
|
||||
|
||||
|
||||
+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.data;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
|
||||
/**
|
||||
* Immutable data object representing the ClientNonPerson
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientNonPersonData {
|
||||
|
||||
private final CodeValueData constitution;
|
||||
private final String incorpNumber;
|
||||
private final LocalDate incorpValidityTillDate;
|
||||
private final CodeValueData mainBusinessLine;
|
||||
private final String remarks;
|
||||
|
||||
public ClientNonPersonData(CodeValueData constitution, String incorpNo, LocalDate incorpValidityTillDate,
|
||||
CodeValueData mainBusinessLine, String remarks) {
|
||||
super();
|
||||
this.constitution = constitution;
|
||||
this.incorpNumber = incorpNo;
|
||||
this.incorpValidityTillDate = incorpValidityTillDate;
|
||||
this.mainBusinessLine = mainBusinessLine;
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
}
|
||||
+71
-20
@@ -88,16 +88,16 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date officeJoiningDate;
|
||||
|
||||
@Column(name = "firstname", length = 50)
|
||||
@Column(name = "firstname", length = 50, nullable = true)
|
||||
private String firstname;
|
||||
|
||||
@Column(name = "middlename", length = 50)
|
||||
@Column(name = "middlename", length = 50, nullable = true)
|
||||
private String middlename;
|
||||
|
||||
@Column(name = "lastname", length = 50)
|
||||
@Column(name = "lastname", length = 50, nullable = true)
|
||||
private String lastname;
|
||||
|
||||
@Column(name = "fullname", length = 100)
|
||||
@Column(name = "fullname", length = 100, nullable = true)
|
||||
private String fullname;
|
||||
|
||||
@Column(name = "display_name", length = 100, nullable = false)
|
||||
@@ -209,9 +209,12 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
@JoinColumn(name = "client_classification_cv_id", nullable = true)
|
||||
private CodeValue clientClassification;
|
||||
|
||||
@Column(name = "legal_form_enum", nullable = true)
|
||||
private Integer legalForm;
|
||||
|
||||
public static Client createNew(final AppUser currentUser, final Office clientOffice, final Group clientParentGroup, final Staff staff,
|
||||
final SavingsProduct savingsProduct, final CodeValue gender, final CodeValue clientType, final CodeValue clientClassification,
|
||||
final JsonCommand command) {
|
||||
final Integer legalForm, final JsonCommand command) {
|
||||
|
||||
final String accountNo = command.stringValueOfParameterNamed(ClientApiConstants.accountNoParamName);
|
||||
final String externalId = command.stringValueOfParameterNamed(ClientApiConstants.externalIdParamName);
|
||||
@@ -248,18 +251,18 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
final SavingsAccount account = null;
|
||||
return new Client(currentUser, status, clientOffice, clientParentGroup, accountNo, firstname, middlename, lastname, fullname,
|
||||
activationDate, officeJoiningDate, externalId, mobileNo, staff, submittedOnDate, savingsProduct, account, dataOfBirth,
|
||||
gender, clientType, clientClassification);
|
||||
gender, clientType, clientClassification, legalForm);
|
||||
}
|
||||
|
||||
protected Client() {
|
||||
//
|
||||
this.setLegalForm(null);
|
||||
}
|
||||
|
||||
private Client(final AppUser currentUser, final ClientStatus status, final Office office, final Group clientParentGroup,
|
||||
final String accountNo, final String firstname, final String middlename, final String lastname, final String fullname,
|
||||
final LocalDate activationDate, final LocalDate officeJoiningDate, final String externalId, final String mobileNo,
|
||||
final Staff staff, final LocalDate submittedOnDate, final SavingsProduct savingsProduct, final SavingsAccount savingsAccount,
|
||||
final LocalDate dateOfBirth, final CodeValue gender, final CodeValue clientType, final CodeValue clientClassification) {
|
||||
final LocalDate dateOfBirth, final CodeValue gender, final CodeValue clientType, final CodeValue clientClassification, final Integer legalForm) {
|
||||
|
||||
if (StringUtils.isBlank(accountNo)) {
|
||||
this.accountNumber = new RandomPasswordGenerator(19).generate();
|
||||
@@ -333,6 +336,7 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
}
|
||||
this.clientType = clientType;
|
||||
this.clientClassification = clientClassification;
|
||||
this.setLegalForm(legalForm);
|
||||
|
||||
deriveDisplayName();
|
||||
validate();
|
||||
@@ -347,6 +351,16 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
|
||||
}
|
||||
|
||||
private void validateUpdate() {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
//Not validating name parts while update request as firstname/lastname can be along with fullname
|
||||
//when we change clientType from Individual to Organisation or vice-cersa
|
||||
validateActivationDate(dataValidationErrors);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
|
||||
}
|
||||
|
||||
public boolean isAccountNumberRequiresAutoGeneration() {
|
||||
return this.accountNumberRequiresAutoGeneration;
|
||||
}
|
||||
@@ -507,6 +521,29 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
actualChanges.put(ClientApiConstants.clientClassificationIdParamName, newValue);
|
||||
}
|
||||
|
||||
if (command.isChangeInIntegerParameterNamed(ClientApiConstants.legalFormIdParamName, this.getLegalForm())) {
|
||||
final Integer newValue = command.integerValueOfParameterNamed(ClientApiConstants.legalFormIdParamName);
|
||||
if(newValue != null)
|
||||
{
|
||||
LegalForm legalForm = LegalForm.fromInt(newValue);
|
||||
if(legalForm != null)
|
||||
{
|
||||
actualChanges.put(ClientApiConstants.legalFormIdParamName, ClientEnumerations.legalForm(newValue));
|
||||
this.setLegalForm(legalForm.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
actualChanges.put(ClientApiConstants.legalFormIdParamName, null);
|
||||
this.setLegalForm(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actualChanges.put(ClientApiConstants.legalFormIdParamName, null);
|
||||
this.setLegalForm(null);
|
||||
}
|
||||
}
|
||||
|
||||
final String dateFormatAsInput = command.dateFormat();
|
||||
final String localeAsInput = command.locale();
|
||||
|
||||
@@ -541,7 +578,7 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
this.submittedOnDate = newValue.toDate();
|
||||
}
|
||||
|
||||
validate();
|
||||
validateUpdate();
|
||||
|
||||
deriveDisplayName();
|
||||
|
||||
@@ -615,20 +652,26 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
private void deriveDisplayName() {
|
||||
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
if (StringUtils.isNotBlank(this.firstname)) {
|
||||
nameBuilder.append(this.firstname).append(' ');
|
||||
}
|
||||
Integer legalForm = this.getLegalForm();
|
||||
if(legalForm == null || LegalForm.fromInt(legalForm).isPerson())
|
||||
{
|
||||
if (StringUtils.isNotBlank(this.firstname)) {
|
||||
nameBuilder.append(this.firstname).append(' ');
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(this.middlename)) {
|
||||
nameBuilder.append(this.middlename).append(' ');
|
||||
}
|
||||
if (StringUtils.isNotBlank(this.middlename)) {
|
||||
nameBuilder.append(this.middlename).append(' ');
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(this.lastname)) {
|
||||
nameBuilder.append(this.lastname);
|
||||
if (StringUtils.isNotBlank(this.lastname)) {
|
||||
nameBuilder.append(this.lastname);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(this.fullname)) {
|
||||
nameBuilder = new StringBuilder(this.fullname);
|
||||
else if(LegalForm.fromInt(legalForm).isEntity())
|
||||
{
|
||||
if (StringUtils.isNotBlank(this.fullname)) {
|
||||
nameBuilder = new StringBuilder(this.fullname);
|
||||
}
|
||||
}
|
||||
|
||||
this.displayName = nameBuilder.toString();
|
||||
@@ -896,4 +939,12 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
this.status = ClientStatus.PENDING.getValue();
|
||||
|
||||
}
|
||||
|
||||
public Integer getLegalForm() {
|
||||
return legalForm;
|
||||
}
|
||||
|
||||
public void setLegalForm(Integer legalForm) {
|
||||
this.legalForm = legalForm;
|
||||
}
|
||||
}
|
||||
+18
@@ -54,6 +54,24 @@ public class ClientEnumerations {
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData legalForm(final Integer statusId) {
|
||||
return legalForm(LegalForm.fromInt(statusId));
|
||||
}
|
||||
|
||||
public static EnumOptionData legalForm(final LegalForm legalForm) {
|
||||
final EnumOptionData optionData = new EnumOptionData(legalForm.getValue().longValue(), legalForm.getCode(),
|
||||
legalForm.toString());
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static List<EnumOptionData> legalForm(final LegalForm[] legalForms) {
|
||||
final List<EnumOptionData> optionDatas = new ArrayList<>();
|
||||
for (final LegalForm legalForm : legalForms) {
|
||||
optionDatas.add(legalForm(legalForm));
|
||||
}
|
||||
return optionDatas;
|
||||
}
|
||||
|
||||
public static EnumOptionData clientTransactionType(final int id) {
|
||||
return clientTransactionType(ClientTransactionType.fromInt(id));
|
||||
}
|
||||
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* 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.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.portfolio.client.api.ClientApiConstants;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "m_client_non_person")
|
||||
public class ClientNonPerson extends AbstractPersistable<Long> {
|
||||
|
||||
@OneToOne(optional = false)
|
||||
@JoinColumn(name = "client_id", referencedColumnName = "id", nullable = false, unique = true)
|
||||
private Client client;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "constitution_cv_id", nullable = false)
|
||||
private CodeValue constitution;
|
||||
|
||||
@Column(name = "incorp_no", length = 50, nullable = true)
|
||||
private String incorpNumber;
|
||||
|
||||
@Column(name = "incorp_validity_till", nullable = true)
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date incorpValidityTill;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "main_business_line_cv_id", nullable = true)
|
||||
private CodeValue mainBusinessLine;
|
||||
|
||||
@Column(name = "remarks", length = 150, nullable = true)
|
||||
private String remarks;
|
||||
|
||||
|
||||
public static ClientNonPerson createNew(final Client client, final CodeValue constitution, final CodeValue mainBusinessLine, String incorpNumber, LocalDate incorpValidityTill, String remarks)
|
||||
{
|
||||
return new ClientNonPerson(client, constitution, mainBusinessLine, incorpNumber, incorpValidityTill, remarks);
|
||||
}
|
||||
|
||||
protected ClientNonPerson() {
|
||||
//
|
||||
}
|
||||
|
||||
private ClientNonPerson(final Client client, final CodeValue constitution, final CodeValue mainBusinessLine, final String incorpNumber, final LocalDate incorpValidityTill, final String remarks)
|
||||
{
|
||||
if(client != null)
|
||||
this.client = client;
|
||||
|
||||
if(constitution != null)
|
||||
this.constitution = constitution;
|
||||
|
||||
if(mainBusinessLine != null)
|
||||
this.mainBusinessLine = mainBusinessLine;
|
||||
|
||||
if (StringUtils.isNotBlank(incorpNumber)) {
|
||||
this.incorpNumber = incorpNumber.trim();
|
||||
} else {
|
||||
this.incorpNumber = null;
|
||||
}
|
||||
|
||||
if (incorpValidityTill != null) {
|
||||
this.incorpValidityTill = incorpValidityTill.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(remarks)) {
|
||||
this.remarks = remarks.trim();
|
||||
} else {
|
||||
this.remarks = null;
|
||||
}
|
||||
|
||||
validate(client);
|
||||
}
|
||||
|
||||
private void validate(final Client client) {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
validateIncorpValidityTillDate(client, dataValidationErrors);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
|
||||
}
|
||||
|
||||
private void validateIncorpValidityTillDate(final Client client, final List<ApiParameterError> dataValidationErrors) {
|
||||
if (getIncorpValidityTillLocalDate() != null && client.dateOfBirthLocalDate() != null && client.dateOfBirthLocalDate().isAfter(getIncorpValidityTillLocalDate())) {
|
||||
|
||||
final String defaultUserMessage = "incorpvaliditytill date cannot be after the incorporation date";
|
||||
final ApiParameterError error = ApiParameterError.parameterError("error.msg.clients.incorpValidityTill.after.incorp.date",
|
||||
defaultUserMessage, ClientApiConstants.incorpValidityTillParamName, this.incorpValidityTill);
|
||||
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
|
||||
public LocalDate getIncorpValidityTillLocalDate() {
|
||||
LocalDate incorpValidityTillLocalDate = null;
|
||||
if (this.incorpValidityTill != null) {
|
||||
incorpValidityTillLocalDate = LocalDate.fromDateFields(this.incorpValidityTill);
|
||||
}
|
||||
return incorpValidityTillLocalDate;
|
||||
}
|
||||
|
||||
public Long constitutionId() {
|
||||
Long constitutionId = null;
|
||||
if (this.constitution != null) {
|
||||
constitutionId = this.constitution.getId();
|
||||
}
|
||||
return constitutionId;
|
||||
}
|
||||
|
||||
public Long mainBusinessLineId() {
|
||||
Long mainBusinessLineId = null;
|
||||
if (this.mainBusinessLine != null) {
|
||||
mainBusinessLineId = this.mainBusinessLine.getId();
|
||||
}
|
||||
return mainBusinessLineId;
|
||||
}
|
||||
|
||||
public void updateConstitution(CodeValue constitution) {
|
||||
this.constitution = constitution;
|
||||
}
|
||||
|
||||
public void updateMainBusinessLine(CodeValue mainBusinessLine) {
|
||||
this.mainBusinessLine = mainBusinessLine;
|
||||
}
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<>(9);
|
||||
|
||||
if (command.isChangeInStringParameterNamed(ClientApiConstants.incorpNumberParamName, this.incorpNumber)) {
|
||||
final String newValue = command.stringValueOfParameterNamed(ClientApiConstants.incorpNumberParamName);
|
||||
actualChanges.put(ClientApiConstants.incorpNumberParamName, newValue);
|
||||
this.incorpNumber = StringUtils.defaultIfEmpty(newValue, null);
|
||||
}
|
||||
|
||||
if (command.isChangeInStringParameterNamed(ClientApiConstants.remarksParamName, this.remarks)) {
|
||||
final String newValue = command.stringValueOfParameterNamed(ClientApiConstants.remarksParamName);
|
||||
actualChanges.put(ClientApiConstants.remarksParamName, newValue);
|
||||
this.remarks = StringUtils.defaultIfEmpty(newValue, null);
|
||||
}
|
||||
|
||||
final String dateFormatAsInput = command.dateFormat();
|
||||
final String localeAsInput = command.locale();
|
||||
|
||||
if (command.isChangeInLocalDateParameterNamed(ClientApiConstants.incorpValidityTillParamName, getIncorpValidityTillLocalDate())) {
|
||||
final String valueAsInput = command.stringValueOfParameterNamed(ClientApiConstants.incorpValidityTillParamName);
|
||||
actualChanges.put(ClientApiConstants.incorpValidityTillParamName, valueAsInput);
|
||||
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
|
||||
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
|
||||
|
||||
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.incorpValidityTillParamName);
|
||||
this.incorpValidityTill = newValue.toDate();
|
||||
}
|
||||
|
||||
if (command.isChangeInLongParameterNamed(ClientApiConstants.constitutionIdParamName, constitutionId())) {
|
||||
final Long newValue = command.longValueOfParameterNamed(ClientApiConstants.constitutionIdParamName);
|
||||
actualChanges.put(ClientApiConstants.constitutionIdParamName, newValue);
|
||||
}
|
||||
|
||||
if (command.isChangeInLongParameterNamed(ClientApiConstants.mainBusinessLineIdParamName, mainBusinessLineId())) {
|
||||
final Long newValue = command.longValueOfParameterNamed(ClientApiConstants.mainBusinessLineIdParamName);
|
||||
actualChanges.put(ClientApiConstants.mainBusinessLineIdParamName, newValue);
|
||||
}
|
||||
|
||||
//validate();
|
||||
|
||||
return actualChanges;
|
||||
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.domain;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface ClientNonPersonRepository extends JpaRepository<ClientNonPerson, Long>, JpaSpecificationExecutor<ClientNonPerson>{
|
||||
|
||||
@Query("from ClientNonPerson clientNonPerson where clientNonPerson.client.id = :clientId")
|
||||
ClientNonPerson findByClientId(@Param("clientId") Long clientId);
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 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.domain;
|
||||
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientNonPersonNotFoundByClientIdException;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientNonPersonNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Wrapper for {@link ClientNonPersonRepository} that adds NULL checking and Error
|
||||
* handling capabilities
|
||||
* </p>
|
||||
*/
|
||||
@Service
|
||||
public class ClientNonPersonRepositoryWrapper {
|
||||
|
||||
private final ClientNonPersonRepository repository;
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public ClientNonPersonRepositoryWrapper(final ClientNonPersonRepository repository, final PlatformSecurityContext context) {
|
||||
this.repository = repository;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public ClientNonPerson findOneWithNotFoundDetection(final Long id) {
|
||||
final ClientNonPerson clientNonPerson = this.repository.findOne(id);
|
||||
if (clientNonPerson == null) { throw new ClientNonPersonNotFoundException(id); }
|
||||
return clientNonPerson;
|
||||
}
|
||||
|
||||
public ClientNonPerson findOneByClientId(final Long clientId) {
|
||||
return this.repository.findByClientId(clientId);
|
||||
}
|
||||
|
||||
public ClientNonPerson findOneByClientIdWithNotFoundDetection(final Long clientId) {
|
||||
final ClientNonPerson clientNonPerson = this.repository.findByClientId(clientId);
|
||||
if (clientNonPerson == null) { throw new ClientNonPersonNotFoundByClientIdException(clientId); }
|
||||
return clientNonPerson;
|
||||
}
|
||||
|
||||
public void save(final ClientNonPerson clientNonPerson) {
|
||||
this.repository.save(clientNonPerson);
|
||||
}
|
||||
|
||||
public void saveAndFlush(final ClientNonPerson clientNonPerson) {
|
||||
this.repository.saveAndFlush(clientNonPerson);
|
||||
}
|
||||
|
||||
public void delete(final ClientNonPerson clientNonPerson) {
|
||||
this.repository.delete(clientNonPerson);
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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.domain;
|
||||
|
||||
/**
|
||||
* Type used to differentiate the type of client
|
||||
*/
|
||||
public enum LegalForm {
|
||||
|
||||
PERSON(1, "legalFormType.person"),
|
||||
|
||||
ENTITY(2, "legalFormType.entity");
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private LegalForm(final Integer value, final String code) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public static LegalForm fromInt(final Integer type) {
|
||||
|
||||
LegalForm legalForm = null;
|
||||
switch (type) {
|
||||
case 1:
|
||||
legalForm = LegalForm.PERSON;
|
||||
break;
|
||||
case 2:
|
||||
legalForm = LegalForm.ENTITY;
|
||||
break;
|
||||
}
|
||||
return legalForm;
|
||||
}
|
||||
|
||||
public boolean isPerson() {
|
||||
return this.value.equals(LegalForm.PERSON.getValue());
|
||||
}
|
||||
|
||||
public boolean isEntity() {
|
||||
return this.value.equals(LegalForm.ENTITY.getValue());
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* A {@link RuntimeException} thrown when clientNonPerson resources are not found.
|
||||
*/
|
||||
public class ClientNonPersonNotFoundByClientIdException extends AbstractPlatformResourceNotFoundException {
|
||||
|
||||
public ClientNonPersonNotFoundByClientIdException(final Long id) {
|
||||
super("error.msg.clientnonperson.id.invalid", "ClientNonPerson with client identifier " + id + " does not exist", id);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* A {@link RuntimeException} thrown when clientNonPerson resources are not found.
|
||||
*/
|
||||
public class ClientNonPersonNotFoundException extends AbstractPlatformResourceNotFoundException {
|
||||
|
||||
public ClientNonPersonNotFoundException(final Long id) {
|
||||
super("error.msg.clientnonperson.id.invalid", "ClientNonPerson with identifier " + id + " does not exist", id);
|
||||
}
|
||||
|
||||
}
|
||||
+78
-5
@@ -29,9 +29,11 @@ import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.service.StaffReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.api.ClientApiConstants;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientNonPersonData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientTimelineData;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientEnumerations;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientStatus;
|
||||
import org.mifosplatform.portfolio.client.domain.LegalForm;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientNotFoundException;
|
||||
import org.mifosplatform.portfolio.group.data.GroupGeneralData;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
|
||||
@@ -104,8 +106,17 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final List<CodeValueData> clientClassificationOptions = new ArrayList<>(
|
||||
this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION));
|
||||
|
||||
final List<CodeValueData> clientNonPersonConstitutionOptions = new ArrayList<>(
|
||||
this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_NON_PERSON_CONSTITUTION));
|
||||
|
||||
final List<CodeValueData> clientNonPersonMainBusinessLineOptions = new ArrayList<>(
|
||||
this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_NON_PERSON_MAIN_BUSINESS_LINE));
|
||||
|
||||
final List<EnumOptionData> clientLegalFormOptions = ClientEnumerations.legalForm(LegalForm.values());
|
||||
|
||||
return ClientData.template(defaultOfficeId, new LocalDate(), offices, staffOptions, null, genderOptions, savingsProductDatas,
|
||||
clientTypeOptions, clientClassificationOptions);
|
||||
clientTypeOptions, clientClassificationOptions, clientNonPersonConstitutionOptions, clientNonPersonMainBusinessLineOptions,
|
||||
clientLegalFormOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,6 +313,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
sqlBuilder.append("cvclienttype.code_value as clienttypeValue, ");
|
||||
sqlBuilder.append("c.client_classification_cv_id as classificationId, ");
|
||||
sqlBuilder.append("cvclassification.code_value as classificationValue, ");
|
||||
sqlBuilder.append("c.legal_form_enum as legalFormEnum, ");
|
||||
sqlBuilder.append("c.activation_date as activationDate, c.image_id as imageId, ");
|
||||
sqlBuilder.append("c.staff_id as staffId, s.display_name as staffName,");
|
||||
sqlBuilder.append("c.default_savings_product as savingsProductId, sp.name as savingsProductName, ");
|
||||
@@ -319,10 +331,19 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
|
||||
sqlBuilder.append("acu.username as activatedByUsername, ");
|
||||
sqlBuilder.append("acu.firstname as activatedByFirstname, ");
|
||||
sqlBuilder.append("acu.lastname as activatedByLastname ");
|
||||
sqlBuilder.append("acu.lastname as activatedByLastname, ");
|
||||
|
||||
sqlBuilder.append("cnp.constitution_cv_id as constitutionId, ");
|
||||
sqlBuilder.append("cvConstitution.code_value as constitutionValue, ");
|
||||
sqlBuilder.append("cnp.incorp_no as incorpNo, ");
|
||||
sqlBuilder.append("cnp.incorp_validity_till as incorpValidityTill, ");
|
||||
sqlBuilder.append("cnp.main_business_line_cv_id as mainBusinessLineId, ");
|
||||
sqlBuilder.append("cvMainBusinessLine.code_value as mainBusinessLineValue, ");
|
||||
sqlBuilder.append("cnp.remarks as remarks ");
|
||||
|
||||
sqlBuilder.append("from m_client c ");
|
||||
sqlBuilder.append("join m_office o on o.id = c.office_id ");
|
||||
sqlBuilder.append("left join m_client_non_person cnp on cnp.client_id = c.id ");
|
||||
sqlBuilder.append("join m_group_client pgc on pgc.client_id = c.id ");
|
||||
sqlBuilder.append("left join m_staff s on s.id = c.staff_id ");
|
||||
sqlBuilder.append("left join m_savings_product sp on sp.id = c.default_savings_product ");
|
||||
@@ -335,6 +356,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
sqlBuilder.append("left join m_code_value cvclienttype on cvclienttype.id = c.client_type_cv_id ");
|
||||
sqlBuilder.append("left join m_code_value cvclassification on cvclassification.id = c.client_classification_cv_id ");
|
||||
sqlBuilder.append("left join m_code_value cvSubStatus on cvSubStatus.id = c.sub_status ");
|
||||
sqlBuilder.append("left join m_code_value cvConstitution on cvConstitution.id = cnp.constitution_cv_id ");
|
||||
sqlBuilder.append("left join m_code_value cvMainBusinessLine on cvMainBusinessLine.id = cnp.main_business_line_cv_id ");
|
||||
|
||||
this.schema = sqlBuilder.toString();
|
||||
}
|
||||
@@ -408,6 +431,23 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final String activatedByFirstname = rs.getString("activatedByFirstname");
|
||||
final String activatedByLastname = rs.getString("activatedByLastname");
|
||||
|
||||
final Integer legalFormEnum = JdbcSupport.getInteger(rs, "legalFormEnum");
|
||||
EnumOptionData legalForm = null;
|
||||
if(legalFormEnum != null)
|
||||
legalForm = ClientEnumerations.legalForm(legalFormEnum);
|
||||
|
||||
final Long constitutionId = JdbcSupport.getLong(rs, "constitutionId");
|
||||
final String constitutionValue = rs.getString("constitutionValue");
|
||||
final CodeValueData constitution = CodeValueData.instance(constitutionId, constitutionValue);
|
||||
final String incorpNo = rs.getString("incorpNo");
|
||||
final LocalDate incorpValidityTill = JdbcSupport.getLocalDate(rs, "incorpValidityTill");
|
||||
final Long mainBusinessLineId = JdbcSupport.getLong(rs, "mainBusinessLineId");
|
||||
final String mainBusinessLineValue = rs.getString("mainBusinessLineValue");
|
||||
final CodeValueData mainBusinessLine = CodeValueData.instance(mainBusinessLineId, mainBusinessLineValue);
|
||||
final String remarks = rs.getString("remarks");
|
||||
|
||||
final ClientNonPersonData clientNonPerson = new ClientNonPersonData(constitution, incorpNo, incorpValidityTill, mainBusinessLine, remarks);
|
||||
|
||||
final ClientTimelineData timeline = new ClientTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname,
|
||||
submittedByLastname, activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate,
|
||||
closedByUsername, closedByFirstname, closedByLastname);
|
||||
@@ -415,7 +455,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
return ClientData.instance(accountNo, status, subStatus, officeId, officeName, transferToOfficeId, transferToOfficeName, id,
|
||||
firstname, middlename, lastname, fullname, displayName, externalId, mobileNo, dateOfBirth, gender, activationDate,
|
||||
imageId, staffId, staffName, timeline, savingsProductId, savingsProductName, savingsAccountId, clienttype,
|
||||
classification);
|
||||
classification, legalForm, clientNonPerson);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -455,6 +495,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
builder.append("cvclienttype.code_value as clienttypeValue, ");
|
||||
builder.append("c.client_classification_cv_id as classificationId, ");
|
||||
builder.append("cvclassification.code_value as classificationValue, ");
|
||||
builder.append("c.legal_form_enum as legalFormEnum, ");
|
||||
|
||||
builder.append("c.submittedon_date as submittedOnDate, ");
|
||||
builder.append("sbu.username as submittedByUsername, ");
|
||||
@@ -471,12 +512,21 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
builder.append("acu.firstname as activatedByFirstname, ");
|
||||
builder.append("acu.lastname as activatedByLastname, ");
|
||||
|
||||
builder.append("cnp.constitution_cv_id as constitutionId, ");
|
||||
builder.append("cvConstitution.code_value as constitutionValue, ");
|
||||
builder.append("cnp.incorp_no as incorpNo, ");
|
||||
builder.append("cnp.incorp_validity_till as incorpValidityTill, ");
|
||||
builder.append("cnp.main_business_line_cv_id as mainBusinessLineId, ");
|
||||
builder.append("cvMainBusinessLine.code_value as mainBusinessLineValue, ");
|
||||
builder.append("cnp.remarks as remarks, ");
|
||||
|
||||
builder.append("c.activation_date as activationDate, c.image_id as imageId, ");
|
||||
builder.append("c.staff_id as staffId, s.display_name as staffName, ");
|
||||
builder.append("c.default_savings_product as savingsProductId, sp.name as savingsProductName, ");
|
||||
builder.append("c.default_savings_account as savingsAccountId ");
|
||||
builder.append("from m_client c ");
|
||||
builder.append("join m_office o on o.id = c.office_id ");
|
||||
builder.append("left join m_client_non_person cnp on cnp.client_id = c.id ");
|
||||
builder.append("left join m_staff s on s.id = c.staff_id ");
|
||||
builder.append("left join m_savings_product sp on sp.id = c.default_savings_product ");
|
||||
builder.append("left join m_office transferToOffice on transferToOffice.id = c.transfer_to_office_id ");
|
||||
@@ -487,6 +537,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
builder.append("left join m_code_value cvclienttype on cvclienttype.id = c.client_type_cv_id ");
|
||||
builder.append("left join m_code_value cvclassification on cvclassification.id = c.client_classification_cv_id ");
|
||||
builder.append("left join m_code_value cvSubStatus on cvSubStatus.id = c.sub_status ");
|
||||
builder.append("left join m_code_value cvConstitution on cvConstitution.id = cnp.constitution_cv_id ");
|
||||
builder.append("left join m_code_value cvMainBusinessLine on cvMainBusinessLine.id = cnp.main_business_line_cv_id ");
|
||||
|
||||
this.schema = builder.toString();
|
||||
}
|
||||
@@ -559,6 +611,23 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final String activatedByFirstname = rs.getString("activatedByFirstname");
|
||||
final String activatedByLastname = rs.getString("activatedByLastname");
|
||||
|
||||
final Integer legalFormEnum = JdbcSupport.getInteger(rs, "legalFormEnum");
|
||||
EnumOptionData legalForm = null;
|
||||
if(legalFormEnum != null)
|
||||
legalForm = ClientEnumerations.legalForm(legalFormEnum);
|
||||
|
||||
final Long constitutionId = JdbcSupport.getLong(rs, "constitutionId");
|
||||
final String constitutionValue = rs.getString("constitutionValue");
|
||||
final CodeValueData constitution = CodeValueData.instance(constitutionId, constitutionValue);
|
||||
final String incorpNo = rs.getString("incorpNo");
|
||||
final LocalDate incorpValidityTill = JdbcSupport.getLocalDate(rs, "incorpValidityTill");
|
||||
final Long mainBusinessLineId = JdbcSupport.getLong(rs, "mainBusinessLineId");
|
||||
final String mainBusinessLineValue = rs.getString("mainBusinessLineValue");
|
||||
final CodeValueData mainBusinessLine = CodeValueData.instance(mainBusinessLineId, mainBusinessLineValue);
|
||||
final String remarks = rs.getString("remarks");
|
||||
|
||||
final ClientNonPersonData clientNonPerson = new ClientNonPersonData(constitution, incorpNo, incorpValidityTill, mainBusinessLine, remarks);
|
||||
|
||||
final ClientTimelineData timeline = new ClientTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname,
|
||||
submittedByLastname, activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate,
|
||||
closedByUsername, closedByFirstname, closedByLastname);
|
||||
@@ -566,7 +635,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
return ClientData.instance(accountNo, status, subStatus, officeId, officeName, transferToOfficeId, transferToOfficeName, id,
|
||||
firstname, middlename, lastname, fullname, displayName, externalId, mobileNo, dateOfBirth, gender, activationDate,
|
||||
imageId, staffId, staffName, timeline, savingsProductId, savingsProductName, savingsAccountId, clienttype,
|
||||
classification);
|
||||
classification, legalForm, clientNonPerson);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -674,7 +743,11 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
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, narrations, null, null, clientTypeOptions, clientClassificationOptions);
|
||||
final Collection<CodeValueData> clientNonPersonConstitutionOptions = null;
|
||||
final Collection<CodeValueData> clientNonPersonMainBusinessLineOptions = null;
|
||||
final List<EnumOptionData> clientLegalFormOptions = null;
|
||||
return ClientData.template(null, null, null, null, narrations, null, null, clientTypeOptions, clientClassificationOptions,
|
||||
clientNonPersonConstitutionOptions, clientNonPersonMainBusinessLineOptions, clientLegalFormOptions);
|
||||
}
|
||||
|
||||
}
|
||||
+125
-3
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
package org.mifosplatform.portfolio.client.service;
|
||||
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -32,6 +33,7 @@ import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.domain.Office;
|
||||
import org.mifosplatform.organisation.office.domain.OfficeRepository;
|
||||
@@ -42,8 +44,11 @@ import org.mifosplatform.portfolio.client.api.ClientApiConstants;
|
||||
import org.mifosplatform.portfolio.client.data.ClientDataValidator;
|
||||
import org.mifosplatform.portfolio.client.domain.AccountNumberGenerator;
|
||||
import org.mifosplatform.portfolio.client.domain.Client;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientNonPerson;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientNonPersonRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientStatus;
|
||||
import org.mifosplatform.portfolio.client.domain.LegalForm;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientActiveForUpdateException;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientHasNoStaffException;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientMustBePendingToBeDeletedException;
|
||||
@@ -73,6 +78,8 @@ import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
@Service
|
||||
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
|
||||
|
||||
@@ -80,6 +87,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final ClientRepositoryWrapper clientRepository;
|
||||
private final ClientNonPersonRepositoryWrapper clientNonPersonRepository;
|
||||
private final OfficeRepository officeRepository;
|
||||
private final NoteRepository noteRepository;
|
||||
private final GroupRepository groupRepository;
|
||||
@@ -94,19 +102,21 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
private final CommandProcessingService commandProcessingService;
|
||||
private final ConfigurationDomainService configurationDomainService;
|
||||
private final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository;
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
|
||||
@Autowired
|
||||
public ClientWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||
final ClientRepositoryWrapper clientRepository, final OfficeRepository officeRepository, final NoteRepository noteRepository,
|
||||
final ClientRepositoryWrapper clientRepository, final ClientNonPersonRepositoryWrapper clientNonPersonRepository, final OfficeRepository officeRepository, final NoteRepository noteRepository,
|
||||
final ClientDataValidator fromApiJsonDeserializer, final AccountNumberGenerator accountNumberGenerator,
|
||||
final GroupRepository groupRepository, final StaffRepositoryWrapper staffRepository,
|
||||
final CodeValueRepositoryWrapper codeValueRepository, final LoanRepository loanRepository,
|
||||
final SavingsAccountRepository savingsRepository, final SavingsProductRepository savingsProductRepository,
|
||||
final SavingsApplicationProcessWritePlatformService savingsApplicationProcessWritePlatformService,
|
||||
final CommandProcessingService commandProcessingService, final ConfigurationDomainService configurationDomainService,
|
||||
final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository) {
|
||||
final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository, final FromJsonHelper fromApiJsonHelper) {
|
||||
this.context = context;
|
||||
this.clientRepository = clientRepository;
|
||||
this.clientNonPersonRepository = clientNonPersonRepository;
|
||||
this.officeRepository = officeRepository;
|
||||
this.noteRepository = noteRepository;
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
@@ -121,6 +131,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
this.commandProcessingService = commandProcessingService;
|
||||
this.configurationDomainService = configurationDomainService;
|
||||
this.accountNumberFormatRepository = accountNumberFormatRepository;
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -134,6 +145,10 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
final List<Note> relatedNotes = this.noteRepository.findByClientId(clientId);
|
||||
this.noteRepository.deleteInBatch(relatedNotes);
|
||||
|
||||
final ClientNonPerson clientNonPerson = this.clientNonPersonRepository.findOneByClientId(clientId);
|
||||
if(clientNonPerson != null)
|
||||
this.clientNonPersonRepository.delete(clientNonPerson);
|
||||
|
||||
this.clientRepository.delete(client);
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
@@ -226,8 +241,21 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
}
|
||||
|
||||
final Integer legalFormParamValue = command.integerValueOfParameterNamed(ClientApiConstants.legalFormIdParamName);
|
||||
boolean isEntity = false;
|
||||
Integer legalFormValue = null;
|
||||
if(legalFormParamValue != null)
|
||||
{
|
||||
LegalForm legalForm = LegalForm.fromInt(legalFormParamValue);
|
||||
if(legalForm != null)
|
||||
{
|
||||
legalFormValue = legalForm.getValue();
|
||||
isEntity = legalForm.isEntity();
|
||||
}
|
||||
}
|
||||
|
||||
final Client newClient = Client.createNew(currentUser, clientOffice, clientParentGroup, staff, savingsProduct, gender,
|
||||
clientType, clientClassification, command);
|
||||
clientType, clientClassification, legalFormValue, command);
|
||||
boolean rollbackTransaction = false;
|
||||
if (newClient.isActive()) {
|
||||
validateParentGroupRulesBeforeClientActivation(newClient);
|
||||
@@ -250,6 +278,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
this.clientRepository.save(newClient);
|
||||
}
|
||||
|
||||
if(isEntity)
|
||||
extractAndCreateClientNonPerson(newClient, command);
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withOfficeId(clientOffice.getId()) //
|
||||
@@ -266,6 +297,42 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method extracts ClientNonPerson details from Client command and creates a new ClientNonPerson record
|
||||
* @param client
|
||||
* @param command
|
||||
*/
|
||||
public void extractAndCreateClientNonPerson(Client client, JsonCommand command)
|
||||
{
|
||||
final JsonElement clientNonPersonElement = this.fromApiJsonHelper.parse(command.jsonFragment(ClientApiConstants.clientNonPersonDetailsParamName));
|
||||
|
||||
if(clientNonPersonElement != null)
|
||||
{
|
||||
final String incorpNumber = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.incorpNumberParamName, clientNonPersonElement);
|
||||
final String remarks = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.remarksParamName, clientNonPersonElement);
|
||||
final LocalDate incorpValidityTill = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.incorpValidityTillParamName, clientNonPersonElement);
|
||||
|
||||
//JsonCommand clientNonPersonCommand = JsonCommand.fromExistingCommand(command, command.arrayOfParameterNamed(ClientApiConstants.clientNonPersonDetailsParamName).getAsJsonObject());
|
||||
CodeValue clientNonPersonConstitution = null;
|
||||
final Long clientNonPersonConstitutionId = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.constitutionIdParamName, clientNonPersonElement);
|
||||
if (clientNonPersonConstitutionId != null) {
|
||||
clientNonPersonConstitution = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.CLIENT_NON_PERSON_CONSTITUTION,
|
||||
clientNonPersonConstitutionId);
|
||||
}
|
||||
|
||||
CodeValue clientNonPersonMainBusinessLine = null;
|
||||
final Long clientNonPersonMainBusinessLineId = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.mainBusinessLineIdParamName, clientNonPersonElement);
|
||||
if (clientNonPersonMainBusinessLineId != null) {
|
||||
clientNonPersonMainBusinessLine = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.CLIENT_NON_PERSON_MAIN_BUSINESS_LINE,
|
||||
clientNonPersonMainBusinessLineId);
|
||||
}
|
||||
|
||||
final ClientNonPerson newClientNonPerson = ClientNonPerson.createNew(client, clientNonPersonConstitution, clientNonPersonMainBusinessLine, incorpNumber, incorpValidityTill, remarks);
|
||||
|
||||
this.clientNonPersonRepository.save(newClientNonPerson);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult updateClient(final Long clientId, final JsonCommand command) {
|
||||
@@ -346,6 +413,61 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
this.clientRepository.saveAndFlush(clientForUpdate);
|
||||
}
|
||||
|
||||
if (changes.containsKey(ClientApiConstants.legalFormIdParamName)) {
|
||||
Integer legalFormValue = clientForUpdate.getLegalForm();
|
||||
boolean isChangedToEntity = false;
|
||||
if(legalFormValue != null)
|
||||
{
|
||||
LegalForm legalForm = LegalForm.fromInt(legalFormValue);
|
||||
if(legalForm != null)
|
||||
isChangedToEntity = legalForm.isEntity();
|
||||
}
|
||||
|
||||
if(isChangedToEntity)
|
||||
{
|
||||
extractAndCreateClientNonPerson(clientForUpdate, command);
|
||||
}
|
||||
else
|
||||
{
|
||||
final ClientNonPerson clientNonPerson = this.clientNonPersonRepository.findOneByClientId(clientForUpdate.getId());
|
||||
if(clientNonPerson != null)
|
||||
this.clientNonPersonRepository.delete(clientNonPerson);
|
||||
}
|
||||
}
|
||||
|
||||
final ClientNonPerson clientNonPersonForUpdate = this.clientNonPersonRepository.findOneByClientId(clientId);
|
||||
if(clientNonPersonForUpdate != null)
|
||||
{
|
||||
final JsonElement clientNonPersonElement = this.fromApiJsonHelper.parse(command.jsonFragment(ClientApiConstants.clientNonPersonDetailsParamName));
|
||||
final Map<String, Object> clientNonPersonChanges = clientNonPersonForUpdate.update(JsonCommand.fromExistingCommand(command, clientNonPersonElement));
|
||||
|
||||
if (clientNonPersonChanges.containsKey(ClientApiConstants.constitutionIdParamName)) {
|
||||
|
||||
final Long newValue = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.constitutionIdParamName, clientNonPersonElement);
|
||||
CodeValue constitution = null;
|
||||
if (newValue != null) {
|
||||
constitution = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.CLIENT_NON_PERSON_CONSTITUTION, newValue);
|
||||
}
|
||||
clientNonPersonForUpdate.updateConstitution(constitution);
|
||||
}
|
||||
|
||||
if (clientNonPersonChanges.containsKey(ClientApiConstants.mainBusinessLineIdParamName)) {
|
||||
|
||||
final Long newValue = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.mainBusinessLineIdParamName, clientNonPersonElement);
|
||||
CodeValue mainBusinessLine = null;
|
||||
if (newValue != null) {
|
||||
mainBusinessLine = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.CLIENT_NON_PERSON_MAIN_BUSINESS_LINE, newValue);
|
||||
}
|
||||
clientNonPersonForUpdate.updateMainBusinessLine(mainBusinessLine);
|
||||
}
|
||||
|
||||
if (!clientNonPersonChanges.isEmpty()) {
|
||||
this.clientNonPersonRepository.saveAndFlush(clientNonPersonForUpdate);
|
||||
}
|
||||
|
||||
changes.putAll(clientNonPersonChanges);
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withOfficeId(clientForUpdate.officeId()) //
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
|
||||
INSERT INTO `m_code` (`code_name`, `is_system_defined`) values
|
||||
("Constitution", true);
|
||||
|
||||
INSERT INTO `m_code` (`code_name`, `is_system_defined`) values
|
||||
("Main Business Line", true);
|
||||
|
||||
ALTER TABLE `m_client` ADD `legal_form_enum` INT(5);
|
||||
|
||||
CREATE TABLE `m_client_non_person` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` BIGINT(20) NOT NULL UNIQUE,
|
||||
`constitution_cv_id` INT(11) NOT NULL,
|
||||
`incorp_no` varchar(50),
|
||||
`incorp_validity_till` DATETIME,
|
||||
`main_business_line_cv_id` INT(11),
|
||||
`remarks` varchar(150),
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `FK_client_id` (`client_id`),
|
||||
CONSTRAINT `FK_client_id` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user