Search in sources :

Example 51 with CustomerBO

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

the class CustomerPersistenceIntegrationTest method testGetChildernOtherThanClosedAndCancelled.

@Test
public void testGetChildernOtherThanClosedAndCancelled() throws Exception {
    CustomerPersistence customerPersistence = new CustomerPersistence();
    center = createCenter();
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group);
    ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_PENDING, group);
    List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice().getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CANCELLED_AND_CLOSED);
    Assert.assertEquals(new Integer("2").intValue(), customerList.size());
    for (CustomerBO customer : customerList) {
        if (customer.getCustomerId().equals(client4.getCustomerId())) {
            Assert.assertTrue(true);
        }
    }
//        TestObjectFactory.cleanUp(client2);
//        TestObjectFactory.cleanUp(client3);
//        TestObjectFactory.cleanUp(client4);
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) Test(org.junit.Test)

Example 52 with CustomerBO

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

the class CenterServiceFacadeWebTier method retrieveAllAccountActivity.

@Override
public List<CustomerRecentActivityDto> retrieveAllAccountActivity(String globalCustNum) {
    List<CustomerRecentActivityDto> customerActivityViewList = new ArrayList<CustomerRecentActivityDto>();
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    List<CustomerActivityEntity> customerActivityDetails = customerBO.getCustomerAccount().getCustomerActivitDetails();
    for (CustomerActivityEntity customerActivityEntity : customerActivityDetails) {
        customerActivityViewList.add(assembleCustomerActivityDto(customerActivityEntity, Locale.getDefault()));
    }
    return customerActivityViewList;
}
Also used : CustomerActivityEntity(org.mifos.customers.business.CustomerActivityEntity) ArrayList(java.util.ArrayList) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerRecentActivityDto(org.mifos.dto.screen.CustomerRecentActivityDto)

Example 53 with CustomerBO

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

the class CenterServiceFacadeWebTier method retrieveRecentActivities.

@Override
public List<CustomerRecentActivityDto> retrieveRecentActivities(Integer customerId, Integer countOfActivities) {
    CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
    List<CustomerActivityEntity> customerActivityDetails = customerBO.getCustomerAccount().getCustomerActivitDetails();
    List<CustomerRecentActivityDto> customerActivityViewList = new ArrayList<CustomerRecentActivityDto>();
    int count = 0;
    for (CustomerActivityEntity customerActivityEntity : customerActivityDetails) {
        customerActivityViewList.add(getCustomerActivityView(customerActivityEntity));
        if (++count == countOfActivities) {
            break;
        }
    }
    return customerActivityViewList;
}
Also used : CustomerActivityEntity(org.mifos.customers.business.CustomerActivityEntity) ArrayList(java.util.ArrayList) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerRecentActivityDto(org.mifos.dto.screen.CustomerRecentActivityDto)

Example 54 with CustomerBO

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

the class CollectionSheetServiceFacadeWebTier method getCollectionSheet.

@Override
public CollectionSheetDto getCollectionSheet(Integer customerId, LocalDate meetingDate) {
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);
    CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
    try {
        personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    return collectionSheetService.retrieveCollectionSheet(customerId, meetingDate);
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 55 with CustomerBO

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

the class CenterServiceFacadeWebTier method retrieveCustomerNote.

@Override
public CustomerNoteFormDto retrieveCustomerNote(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO customer = this.customerDao.findCustomerBySystemId(globalCustNum);
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    Integer customerLevel = customer.getCustomerLevel().getId().intValue();
    String globalNum = customer.getGlobalCustNum();
    String displayName = customer.getDisplayName();
    LocalDate commentDate = new LocalDate();
    String commentUser = loggedInUser.getDisplayName();
    return new CustomerNoteFormDto(globalNum, displayName, customerLevel, commentDate, commentUser, "");
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) CustomerNoteFormDto(org.mifos.dto.screen.CustomerNoteFormDto) LocalDate(org.joda.time.LocalDate)

Aggregations

CustomerBO (org.mifos.customers.business.CustomerBO)138 ArrayList (java.util.ArrayList)39 Money (org.mifos.framework.util.helpers.Money)38 MifosUser (org.mifos.security.MifosUser)38 UserContext (org.mifos.security.util.UserContext)37 LocalDate (org.joda.time.LocalDate)35 MifosRuntimeException (org.mifos.core.MifosRuntimeException)31 AccountException (org.mifos.accounts.exceptions.AccountException)30 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)27 BusinessRuleException (org.mifos.service.BusinessRuleException)27 MeetingBO (org.mifos.application.meeting.business.MeetingBO)23 ClientBO (org.mifos.customers.client.business.ClientBO)23 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 DateTime (org.joda.time.DateTime)20 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)20 Date (java.util.Date)19 Test (org.junit.Test)19 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)18 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 HashMap (java.util.HashMap)15