Search in sources :

Example 6 with CustomerStatusFlag

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));
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) AuditLog(org.mifos.framework.components.audit.business.AuditLog) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 7 with CustomerStatusFlag

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));
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) Date(java.util.Date) AuditLog(org.mifos.framework.components.audit.business.AuditLog) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 8 with CustomerStatusFlag

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")));
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) Date(java.util.Date) Test(org.junit.Test)

Example 9 with CustomerStatusFlag

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);
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus)

Example 10 with CustomerStatusFlag

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);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) UserContext(org.mifos.security.util.UserContext) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) MifosUser(org.mifos.security.MifosUser)

Aggregations

CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)14 CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)12 Test (org.junit.Test)11 CenterBO (org.mifos.customers.center.business.CenterBO)8 ClientBO (org.mifos.customers.client.business.ClientBO)8 GroupBO (org.mifos.customers.group.business.GroupBO)8 CenterBuilder (org.mifos.domain.builders.CenterBuilder)8 ClientBuilder (org.mifos.domain.builders.ClientBuilder)8 GroupBuilder (org.mifos.domain.builders.GroupBuilder)8 Date (java.util.Date)7 CustomerException (org.mifos.customers.exceptions.CustomerException)6 CustomerService (org.mifos.customers.business.service.CustomerService)2 CustomerStatus (org.mifos.customers.util.helpers.CustomerStatus)2 AuditLog (org.mifos.framework.components.audit.business.AuditLog)2 AuditTransactionForTests (org.mifos.framework.hibernate.helper.AuditTransactionForTests)2 UserContext (org.mifos.security.util.UserContext)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1