use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientStatusChangeIntegrationTest method givenGroupIsInCancelledStateShouldNotPassValidationWhenTryingToTranistionClientToActive.
@Test
public void givenGroupIsInCancelledStateShouldNotPassValidationWhenTryingToTranistionClientToActive() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingCancelledGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_CANCELLED).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingCancelledGroup, existingMeeting);
ClientBO existingPartialClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingCancelledGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
existingCancelledGroup = this.customerDao.findGroupBySystemId(existingCancelledGroup.getGlobalCustNum());
existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
existingPartialClient.setUserContext(TestUtils.makeUser());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingPartialClient.getPersonnel(), existingPartialClient);
// exercise test
try {
customerService.updateClientStatus(existingPartialClient, existingPartialClient.getStatus(), CustomerStatus.CLIENT_ACTIVE, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
assertThat(expected.getKey(), is(ClientConstants.ERRORS_GROUP_CANCELLED));
assertThat(existingPartialClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class TestObjectFactory method createClient.
public static ClientBO createClient(final String customerName, final CustomerStatus status, final CustomerBO parentCustomer, final Date startDate) {
ClientBO client;
Short personnel = PersonnelConstants.SYSTEM_USER;
try {
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.MAYBE_CLIENT.getValue(), SAMPLE_SALUTATION, customerName, "", customerName, "");
clientNameDetailDto.setNames(ClientRules.getNameSequence());
ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
// groups
if (null == parentCustomer) {
client = new // UserContext
ClientBO(// UserContext
TestUtils.makeUserWithLocales(), // String
clientNameDetailDto.getDisplayName(), // CustomerStatus
status, // String externalId
null, // Date mfiJoiningDate
null, // Address
null, // List<CustomFieldDto> customFields
null, // List<FeeDto> fees
getFees(), // List<SavingsOfferingBO> offeringsSelected
null, // Short
getPersonnel(personnel), // Short
new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), // MeetingBO
null, // Short loanOfficerId
null, // Date dateOfBirth
null, // String governmentId
"", // Short trained
null, // Date trainedDate
null, // Short groupFlag
YesNoFlag.NO.getValue(), // ClientNameDetailDto
clientNameDetailDto, // ClientNameDetailDto
spouseNameDetailView, // ClientPersonalDetailDto
clientPersonalDetailDto, // InputStream picture
null);
} else {
client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), status, null, null, null, null, getFees(), null, getPersonnel(personnel), parentCustomer.getOffice(), parentCustomer, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
}
ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
StaticHibernateUtil.flushSession();
} catch (Exception e) {
throw new RuntimeException(e);
}
return client;
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class TestObjectFactory method createClient.
public static ClientBO createClient(final String customerName, final CustomerStatus status, final CustomerBO parentCustomer, final List<FeeDto> fees, final String governmentId, final Date dateOfBirth, final Address address) {
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(132, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
ClientNameDetailDto clientNameDetailDto = clientNameView(NameType.CLIENT, customerName);
ClientNameDetailDto spouseNameDetailView = clientNameView(NameType.SPOUSE, customerName);
ClientBO client;
try {
client = new ClientBO(TestUtils.makeUserWithLocales(), customerName, status, null, null, address, null, fees, null, getPersonnel(PersonnelConstants.SYSTEM_USER), new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), parentCustomer, dateOfBirth, governmentId, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
} catch (CustomerException e) {
throw new RuntimeException(e);
} catch (PersistenceException e) {
throw new RuntimeException(e);
}
StaticHibernateUtil.flushSession();
return client;
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class TestObjectFactory method createClient.
public static ClientBO createClient(final String customerName, final MeetingBO meeting, final CustomerStatus status) {
ClientBO client;
try {
PersonnelBO systemUser = getPersonnel(PersonnelConstants.SYSTEM_USER);
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
clientNameDetailDto.setNames(ClientRules.getNameSequence());
ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), status, null, null, null, null, getFees(), null, systemUser, new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), meeting, systemUser, new DateTimeService().getCurrentJavaDateTime(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
StaticHibernateUtil.flushSession();
} catch (Exception e) {
throw new RuntimeException(e);
}
return client;
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class PersonnelRESTController method getCustomersUnderPersonnel.
@RequestMapping(value = "personnel/id-current/clients", method = RequestMethod.GET)
@ResponseBody
public CustomerHierarchyDto getCustomersUnderPersonnel() {
PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(getCurrentPersonnel().getPersonnelId());
CustomerHierarchyDto hierarchy = new CustomerHierarchyDto();
if (ClientRules.getCenterHierarchyExists()) {
for (CustomerDetailDto center : this.customerDao.findActiveCentersUnderUser(loanOfficer)) {
CenterDescriptionDto centerDescription = new CenterDescriptionDto();
centerDescription.setId(center.getCustomerId());
centerDescription.setDisplayName(center.getDisplayName());
centerDescription.setGlobalCustNum(center.getGlobalCustNum());
centerDescription.setSearchId(center.getSearchId());
hierarchy.getCenters().add(centerDescription);
}
}
allGroups: for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(loanOfficer)) {
GroupDescriptionDto groupDescription = new GroupDescriptionDto();
groupDescription.setId(group.getCustomerId());
groupDescription.setDisplayName(group.getDisplayName());
groupDescription.setGlobalCustNum(group.getGlobalCustNum());
groupDescription.setSearchId(group.getSearchId());
for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsUnderParent(group.getSearchId(), loanOfficer.getOffice().getOfficeId())) {
ClientDescriptionDto clientDescription = new ClientDescriptionDto();
clientDescription.setId(client.getCustomerId());
clientDescription.setDisplayName(client.getDisplayName());
clientDescription.setGlobalCustNum(client.getGlobalCustNum());
clientDescription.setSearchId(client.getSearchId());
groupDescription.getClients().add(clientDescription);
}
for (CenterDescriptionDto center : hierarchy.getCenters()) {
if (group.getSearchId().startsWith(center.getSearchId())) {
center.getGroups().add(groupDescription);
continue allGroups;
}
}
hierarchy.getGroups().add(groupDescription);
}
for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsWithoutGroupForLoanOfficer(loanOfficer.getPersonnelId(), loanOfficer.getOffice().getOfficeId())) {
ClientDescriptionDto clientDescription = new ClientDescriptionDto();
clientDescription.setId(client.getCustomerId());
clientDescription.setDisplayName(client.getDisplayName());
clientDescription.setGlobalCustNum(client.getGlobalCustNum());
clientDescription.setSearchId(client.getSearchId());
hierarchy.getClients().add(clientDescription);
}
return hierarchy;
}
Aggregations