Search in sources :

Example 6 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity 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 CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity 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 CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity 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 CustomerNoteEntity

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

the class ClientServiceFacadeWebTier method removeGroupMembership.

@Override
public void removeGroupMembership(String globalCustNum, Short loanOfficerId, String comment) {
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(mifosUser);
    ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
    client.updateDetails(userContext);
    PersonnelBO loanOfficer = null;
    if (loanOfficerId != null) {
        loanOfficer = this.personnelDao.findPersonnelById(loanOfficerId);
    }
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    java.sql.Date commentDate = new DateTimeService().getCurrentJavaSqlDate();
    CustomerNoteEntity accountNotesEntity = new CustomerNoteEntity(comment, commentDate, loggedInUser, client);
    customerService.removeGroupMembership(client, loanOfficer, accountNotesEntity, userContext.getLocaleId());
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) MifosUser(org.mifos.security.MifosUser) DateTimeService(org.mifos.framework.util.DateTimeService)

Example 10 with CustomerNoteEntity

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

the class CenterServiceFacadeWebTier method createCustomerNote.

@Override
public void createCustomerNote(CustomerNoteFormDto customerNoteForm) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO customer = this.customerDao.findCustomerBySystemId(customerNoteForm.getGlobalNum());
    customer.updateDetails(userContext);
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    CustomerNoteEntity customerNote = new CustomerNoteEntity(customerNoteForm.getComment(), new DateTimeService().getCurrentJavaSqlDate(), loggedInUser, customer);
    customer.addCustomerNotes(customerNote);
    try {
        this.transactionHelper.startTransaction();
        this.customerDao.save(customer);
        this.transactionHelper.commitTransaction();
    } catch (Exception e) {
        this.transactionHelper.rollbackTransaction();
        throw new BusinessRuleException(customer.getCustomerAccount().getAccountId().toString(), e);
    } finally {
        this.transactionHelper.closeSession();
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) BusinessRuleException(org.mifos.service.BusinessRuleException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) DateTimeService(org.mifos.framework.util.DateTimeService) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountException(org.mifos.accounts.exceptions.AccountException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) ServiceException(org.mifos.framework.exceptions.ServiceException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException)

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