Search in sources :

Example 11 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity in project head by mifos.

the class CustomerServiceImpl method updateCustomerStatus.

@Override
public final void updateCustomerStatus(UserContext userContext, CustomerStatusUpdate customerStatusUpdate) throws CustomerException {
    CustomerBO customer = this.customerDao.findCustomerById(customerStatusUpdate.getCustomerId());
    customer.validateVersion(customerStatusUpdate.getVersionNum());
    customer.updateDetails(userContext);
    checkPermission(customer, userContext, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag());
    Short oldStatusId = customer.getCustomerStatus().getId();
    CustomerStatus oldStatus = CustomerStatus.fromInt(oldStatusId);
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    CustomerNoteEntity customerNote = new CustomerNoteEntity(customerStatusUpdate.getNotes(), new Date(), loggedInUser, customer);
    if (customer.isGroup()) {
        GroupBO group = (GroupBO) customer;
        updateGroupStatus(group, oldStatus, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    } else if (customer.isClient()) {
        ClientBO client = (ClientBO) customer;
        updateClientStatus(client, oldStatus, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    } else {
        CenterBO center = (CenterBO) customer;
        updateCenterStatus(center, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) GroupBO(org.mifos.customers.group.business.GroupBO) CenterBO(org.mifos.customers.center.business.CenterBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 12 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity in project head by mifos.

the class EditCustomerStatusActionStrutsTest method testUpdateStatusFailureWhenGroupHasActiveClientsWhenCenterIsInactiveWhileChangingStatusCancelToPartial.

@Test
public void testUpdateStatusFailureWhenGroupHasActiveClientsWhenCenterIsInactiveWhileChangingStatusCancelToPartial() throws Exception {
    // setup
    createInitialObjects(CustomerStatus.CENTER_ACTIVE, CustomerStatus.GROUP_CANCELLED, CustomerStatus.CLIENT_CLOSED);
    CustomerService customerService = ApplicationContextProvider.getBean(CustomerService.class);
    CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), center.getPersonnel(), center);
    customerService.updateCenterStatus((CenterBO) center, CustomerStatus.CENTER_INACTIVE, customerStatusFlag, customerNote);
    invokeLoadAndPreviewSuccessfully(CustomerStatus.GROUP_PARTIAL, null);
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    addRequestParameter("input", "group");
    // exercise
    actionPerform();
    // verification
    Assert.assertNotNull(request.getAttribute(Constants.CURRENTFLOWKEY));
    verifyActionErrors(new String[] { GroupConstants.CENTER_INACTIVE });
    cleanInitialObjects();
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerService(org.mifos.customers.business.service.CustomerService) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) Test(org.junit.Test)

Example 13 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetAllCustomerNotes.

@Test
public void testGetAllCustomerNotes() throws Exception {
    center = createCenter();
    center.addCustomerNotes(TestObjectFactory.getCustomerNote("Test Note", center));
    TestObjectFactory.updateObject(center);
    Assert.assertEquals(1, customerPersistence.getAllCustomerNotes(center.getCustomerId()).getSize());
    for (CustomerNoteEntity note : center.getCustomerNotes()) {
        Assert.assertEquals("Test Note", note.getComment());
        Assert.assertEquals(center.getPersonnel().getPersonnelId(), note.getPersonnel().getPersonnelId());
    }
    center = (CenterBO) StaticHibernateUtil.getSessionTL().get(CenterBO.class, Integer.valueOf(center.getCustomerId()));
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) Test(org.junit.Test)

Example 14 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity in project head by mifos.

the class CustomerPersistenceIntegrationTest method ignore_testFindCustomerWithNoAssocationsLoadedDoesntReturnInactiveCenter.

public void ignore_testFindCustomerWithNoAssocationsLoadedDoesntReturnInactiveCenter() throws Exception {
    meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Inactive Center", meeting);
    StaticHibernateUtil.flushSession();
    CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), center.getPersonnel(), center);
    CustomerService customerService = ApplicationContextProvider.getBean(CustomerService.class);
    customerService.updateCenterStatus((CenterBO) center, CustomerStatus.CENTER_INACTIVE, customerStatusFlag, customerNote);
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
    verifyCustomerNotLoaded(center.getCustomerId(), center.getDisplayName());
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerService(org.mifos.customers.business.service.CustomerService) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag)

Example 15 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity in project head by mifos.

the class GroupStatusChangeIntegrationTest method givenGroupIsPendingAndContainsClientsInPartialStateThenWhenTransitioningToCancelledStateAllClientsAreTransitionedToPartial.

@Test
public void givenGroupIsPendingAndContainsClientsInPartialStateThenWhenTransitioningToCancelledStateAllClientsAreTransitionedToPartial() throws Exception {
    // setup
    CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    GroupBO existingPendingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_PENDING).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingPendingGroup, existingMeeting);
    ClientBO existingPartialClient = new ClientBuilder().withName("partialClient").withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
    ClientBO existingPendingClient = new ClientBuilder().withName("pendingClient").withStatus(CustomerStatus.CLIENT_PENDING).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingPendingClient, existingMeeting);
    existingPendingGroup = this.customerDao.findGroupBySystemId(existingPendingGroup.getGlobalCustNum());
    existingPendingGroup.setUserContext(TestUtils.makeUser());
    StaticHibernateUtil.startTransaction();
    existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
    existingPendingClient = this.customerDao.findClientBySystemId(existingPendingClient.getGlobalCustNum());
    CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), existingPendingGroup.getPersonnel(), existingPendingGroup);
    // exercise test
    customerService.updateGroupStatus(existingPendingGroup, existingPendingGroup.getStatus(), CustomerStatus.GROUP_CANCELLED, customerStatusFlag, customerNote);
    // verification
    assertThat(existingPendingGroup.getStatus(), is(CustomerStatus.GROUP_CANCELLED));
    assertThat(existingPendingClient.getStatus(), is(CustomerStatus.CLIENT_PENDING));
    assertThat(existingPartialClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
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) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Aggregations

CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)17 Test (org.junit.Test)12 CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)12 ClientBO (org.mifos.customers.client.business.ClientBO)10 Date (java.util.Date)9 CenterBO (org.mifos.customers.center.business.CenterBO)9 GroupBO (org.mifos.customers.group.business.GroupBO)9 CenterBuilder (org.mifos.domain.builders.CenterBuilder)8 ClientBuilder (org.mifos.domain.builders.ClientBuilder)8 GroupBuilder (org.mifos.domain.builders.GroupBuilder)8 CustomerException (org.mifos.customers.exceptions.CustomerException)6 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 UserContext (org.mifos.security.util.UserContext)3 LocalDate (org.joda.time.LocalDate)2 CustomerBO (org.mifos.customers.business.CustomerBO)2 CustomerService (org.mifos.customers.business.service.CustomerService)2 AuditLog (org.mifos.framework.components.audit.business.AuditLog)2 AuditTransactionForTests (org.mifos.framework.hibernate.helper.AuditTransactionForTests)2 DateTimeService (org.mifos.framework.util.DateTimeService)2 MifosUser (org.mifos.security.MifosUser)2