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));
}
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));
}
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")));
}
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());
}
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();
}
}
Aggregations