use of org.mifos.customers.business.CustomerHierarchyEntity in project head by mifos.
the class ClientBO method createNewInGroupHierarchy.
public static ClientBO createNewInGroupHierarchy(UserContext userContext, String clientName, CustomerStatus clientStatus, DateTime mfiJoiningDate, CustomerBO group, PersonnelBO formedBy, ClientNameDetailEntity clientNameDetailEntity, DateTime dateOfBirth, String governmentId, boolean trained, DateTime trainedDate, Short groupFlag, String clientFirstName, String clientLastName, String secondLastName, ClientNameDetailEntity spouseFatherNameDetailEntity, ClientDetailEntity clientDetailEntity, List<ClientInitialSavingsOfferingEntity> associatedOfferings, String externalId, Address address, LocalDate activationDate) {
// inherit settings from parent (group)
OfficeBO office = group.getOffice();
MeetingBO meeting = group.getCustomerMeetingValue();
if (clientStatus.isClientActive()) {
Assert.notNull(meeting, "meeting inherited from parent group should not be null when client is active");
}
PersonnelBO loanOfficer = group.getPersonnel();
ClientBO client = new ClientBO(userContext, clientName, clientStatus, mfiJoiningDate, office, meeting, loanOfficer, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientFirstName, clientLastName, secondLastName, clientDetailEntity);
client.setParentCustomer(group);
client.generateSearchId();
client.updateAddress(address);
client.setExternalId(externalId);
client.addNameDetailSet(clientNameDetailEntity);
client.addNameDetailSet(spouseFatherNameDetailEntity);
if (clientStatus.isClientActive()) {
CustomerHierarchyEntity hierarchy = new CustomerHierarchyEntity(client, group);
client.addCustomerHierarchy(hierarchy);
client.setCustomerActivationDate(activationDate.toDateMidnight().toDate());
}
for (ClientInitialSavingsOfferingEntity clientInitialSavingsOfferingEntity : associatedOfferings) {
client.addOfferingAssociatedInCreate(clientInitialSavingsOfferingEntity);
}
return client;
}
use of org.mifos.customers.business.CustomerHierarchyEntity in project head by mifos.
the class ClientBO method transferTo.
public boolean transferTo(GroupBO receivingGroup) {
boolean regenerateClientSchedules = false;
this.setParentCustomer(receivingGroup);
this.setPersonnel(receivingGroup.getPersonnel());
CustomerHierarchyEntity currentHierarchy = this.getActiveCustomerHierarchy();
if (null != currentHierarchy) {
currentHierarchy.makeInactive(userContext.getId());
}
addCustomerHierarchy(new CustomerHierarchyEntity(this, receivingGroup));
MeetingBO parentGroupMeeting = receivingGroup.getCustomerMeetingValue();
MeetingBO clientMeeting = this.getCustomerMeetingValue();
if (parentGroupMeeting != null) {
if (clientMeeting != null) {
regenerateClientSchedules = receivingGroup.hasMeetingDifferentTo(clientMeeting);
CustomerMeetingEntity clientMeetingEntity = this.getCustomerMeeting();
clientMeetingEntity.setMeeting(receivingGroup.getCustomerMeetingValue());
} else {
CustomerMeetingEntity customerMeeting = this.createCustomerMeeting(parentGroupMeeting);
this.setCustomerMeeting(customerMeeting);
}
} else if (clientMeeting != null) {
this.setCustomerMeeting(null);
}
if (!isSameBranch(receivingGroup.getOffice())) {
this.makeCustomerMovementEntries(receivingGroup.getOffice());
regenerateClientSchedules = true;
}
this.addGroupMembership();
this.generateSearchId();
return regenerateClientSchedules;
}
use of org.mifos.customers.business.CustomerHierarchyEntity in project head by mifos.
the class GroupBO method transferTo.
public boolean transferTo(CenterBO receivingCenter) {
boolean regenerateGroupSchedules = false;
this.setParentCustomer(receivingCenter);
this.setPersonnel(receivingCenter.getPersonnel());
CustomerHierarchyEntity currentHierarchy = this.getActiveCustomerHierarchy();
if (null != currentHierarchy) {
currentHierarchy.makeInactive(this.getUserContext().getId());
}
this.addCustomerHierarchy(new CustomerHierarchyEntity(this, receivingCenter));
MeetingBO centerMeeting = receivingCenter.getCustomerMeetingValue();
MeetingBO groupMeeting = this.getCustomerMeetingValue();
if (centerMeeting != null) {
if (groupMeeting != null) {
regenerateGroupSchedules = receivingCenter.hasMeetingDifferentTo(groupMeeting);
CustomerMeetingEntity groupMeetingEntity = this.getCustomerMeeting();
groupMeetingEntity.setMeeting(receivingCenter.getCustomerMeetingValue());
} else {
CustomerMeetingEntity customerMeeting = this.createCustomerMeeting(centerMeeting);
this.setCustomerMeeting(customerMeeting);
}
} else if (groupMeeting != null) {
this.setCustomerMeeting(null);
}
OfficeBO centerOffice = receivingCenter.getOffice();
if (this.isDifferentBranch(centerOffice)) {
this.makeCustomerMovementEntries(centerOffice);
if (this.isActive()) {
this.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
}
regenerateGroupSchedules = true;
}
this.generateSearchId();
return regenerateGroupSchedules;
}
Aggregations