use of org.mifos.customers.util.helpers.CustomerStatusFlag in project head by mifos.
the class GroupStatusChangeIntegrationTest method auditLogingTracksStatusChangeOfGroupFromActiveToCancelled.
@Test
public void auditLogingTracksStatusChangeOfGroupFromActiveToCancelled() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().withName("Center-IntegrationTest").with(existingMeeting).with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
ClientBO existingCancelledClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
existingActiveGroup.setUserContext(TestUtils.makeUserWithLocales());
CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), existingActiveGroup.getPersonnel(), existingActiveGroup);
// exercise test
customerService.updateGroupStatus(existingActiveGroup, existingActiveGroup.getStatus(), CustomerStatus.GROUP_CANCELLED, customerStatusFlag, customerNote);
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
// verification
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.GROUP, existingActiveGroup.getCustomerId());
assertThat(auditLogList.size(), is(1));
assertThat(auditLogList.get(0).getEntityTypeAsEnum(), is(EntityType.GROUP));
}
use of org.mifos.customers.util.helpers.CustomerStatusFlag in project head by mifos.
the class CenterStatusChangeIntegrationTest method auditLogingTracksStatusChangeOfCenterFromActiveToInactive.
@Test
public void auditLogingTracksStatusChangeOfCenterFromActiveToInactive() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().withName("Center-IntegrationTest").with(existingMeeting).with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingPendingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_CANCELLED).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingPendingGroup, existingMeeting);
ClientBO existingCancelledClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
existingCenter = this.customerDao.findCenterBySystemId(existingCenter.getGlobalCustNum());
existingPendingGroup = this.customerDao.findGroupBySystemId(existingPendingGroup.getGlobalCustNum());
existingCancelledClient = this.customerDao.findClientBySystemId(existingCancelledClient.getGlobalCustNum());
existingCenter.setUserContext(TestUtils.makeUserWithLocales());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go inactive", new Date(), existingCenter.getPersonnel(), existingCenter);
// exercise test
customerService.updateCenterStatus(existingCenter, CustomerStatus.CENTER_INACTIVE, customerStatusFlag, customerNote);
// verification
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.CENTER, existingCenter.getCustomerId());
assertThat(auditLogList.size(), is(1));
assertThat(auditLogList.get(0).getEntityTypeAsEnum(), is(EntityType.CENTER));
}
use of org.mifos.customers.util.helpers.CustomerStatusFlag in project head by mifos.
the class LegacyPersonnelDaoIntegrationTest method testGetAllCustomerUnderLO.
@Test
public void testGetAllCustomerUnderLO() throws Exception {
createCustomers(CustomerStatus.GROUP_CLOSED, CustomerStatus.CLIENT_CANCELLED);
Assert.assertTrue(legacyPersonnelDao.getAllChildrenForLoanOfficer(Short.valueOf("1"), Short.valueOf("3")));
StaticHibernateUtil.flushSession();
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), center.getPersonnel(), center);
customerService.updateCenterStatus((CenterBO) center, CustomerStatus.CENTER_INACTIVE, customerStatusFlag, customerNote);
center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
Assert.assertTrue(legacyPersonnelDao.getAllChildrenForLoanOfficer(Short.valueOf("1"), Short.valueOf("3")));
}
use of org.mifos.customers.util.helpers.CustomerStatusFlag in project head by mifos.
the class CenterServiceFacadeWebTier method retrieveCustomerStatusDetails.
@Override
public CustomerStatusDetailDto retrieveCustomerStatusDetails(Short newStatusId, Short flagIdValue, Short customerLevelId) {
CustomerLevel customerLevel = CustomerLevel.getLevel(customerLevelId);
CustomerStatus customerStatus = CustomerStatus.fromInt(newStatusId);
CustomerStatusFlag statusFlag = null;
if (customerStatus.isCustomerCancelledOrClosed()) {
statusFlag = CustomerStatusFlag.getStatusFlag(flagIdValue);
}
String statusName = AccountStateMachines.getInstance().getCustomerStatusName(customerStatus, customerLevel);
String flagName = AccountStateMachines.getInstance().getCustomerFlagName(statusFlag, customerLevel);
return new CustomerStatusDetailDto(statusName, flagName);
}
use of org.mifos.customers.util.helpers.CustomerStatusFlag in project head by mifos.
the class CenterServiceFacadeWebTier method updateCustomerStatus.
@Override
public void updateCustomerStatus(Integer customerId, Integer previousCustomerVersionNo, String flagIdAsString, String newStatusIdAsString, String notes) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
Short flagId = null;
Short newStatusId = null;
if (StringUtils.isNotBlank(flagIdAsString)) {
flagId = Short.valueOf(flagIdAsString);
}
if (StringUtils.isNotBlank(newStatusIdAsString)) {
newStatusId = Short.valueOf(newStatusIdAsString);
}
CustomerStatusFlag customerStatusFlag = null;
if (flagId != null) {
customerStatusFlag = CustomerStatusFlag.fromInt(flagId);
}
CustomerStatus newStatus = CustomerStatus.fromInt(newStatusId);
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdate(customerId, previousCustomerVersionNo, customerStatusFlag, newStatus, notes);
try {
this.customerService.updateCustomerStatus(userContext, customerStatusUpdate);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations