Search in sources :

Example 21 with CustomerDetailDto

use of org.mifos.dto.domain.CustomerDetailDto in project head by mifos.

the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsAssignedPosition.

@Test
public void testUIHelperWhenClientIsAssignedPosition() throws CustomerException, PageExpiredException {
    createInitialObjects();
    PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
    CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
    group.addCustomerPosition(customerPositionEntity);
    group.update();
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group.setUserContext(TestObjectFactory.getContext());
    CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
    List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
    }
    String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
    Assert.assertEquals("(Center Leader)", positionName);
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.loadStatus.toString());
    addRequestParameter("customerId", client.getCustomerId().toString());
    actionPerform();
    verifyForward(ActionForwards.loadStatus_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
    Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.previewStatus.toString());
    addRequestParameter("notes", "Test");
    addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
    addRequestParameter("newStatusId", "6");
    addRequestParameter("flagId", "7");
    actionPerform();
    verifyForward(ActionForwards.previewStatus_success.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
    Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNotNull(customerPosition.getCustomer());
        break;
    }
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.client_detail_page.toString());
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    Assert.assertFalse(client.isActive());
    for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
        Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
        break;
    }
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNull(customerPosition.getCustomer());
        break;
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) ArrayList(java.util.ArrayList) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerFlagDetailEntity(org.mifos.customers.business.CustomerFlagDetailEntity) Test(org.junit.Test)

Example 22 with CustomerDetailDto

use of org.mifos.dto.domain.CustomerDetailDto in project head by mifos.

the class CenterActionStrutsTest method testGet.

@Test
public void testGet() throws Exception {
    setNonLoanOfficerMifosUser();
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    savingsBO = getSavingsAccount("fsaf6", "ads6", center);
    StaticHibernateUtil.flushSession();
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "get");
    addRequestParameter("globalCustNum", center.getGlobalCustNum());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.get_success.toString());
    CustomerBO centerBO = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    Assert.assertNotNull(center);
    Assert.assertEquals(center.getCustomerId(), centerBO.getCustomerId());
    CenterInformationDto centerInformation = (CenterInformationDto) SessionUtils.getAttribute("centerInformationDto", request);
    List<CustomerDetailDto> children = centerInformation.getGroupsOtherThanClosedAndCancelled();
    Assert.assertNotNull(children);
    Assert.assertEquals(1, children.size());
    Assert.assertEquals("Size of the active accounts should be 1", 1, centerInformation.getSavingsAccountsInUse().size());
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCenter(center.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Test(org.junit.Test)

Example 23 with CustomerDetailDto

use of org.mifos.dto.domain.CustomerDetailDto in project head by mifos.

the class PersonnelRESTController method getCustomersUnderPersonnel.

@RequestMapping(value = "personnel/id-current/clients", method = RequestMethod.GET)
@ResponseBody
public CustomerHierarchyDto getCustomersUnderPersonnel() {
    PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(getCurrentPersonnel().getPersonnelId());
    CustomerHierarchyDto hierarchy = new CustomerHierarchyDto();
    if (ClientRules.getCenterHierarchyExists()) {
        for (CustomerDetailDto center : this.customerDao.findActiveCentersUnderUser(loanOfficer)) {
            CenterDescriptionDto centerDescription = new CenterDescriptionDto();
            centerDescription.setId(center.getCustomerId());
            centerDescription.setDisplayName(center.getDisplayName());
            centerDescription.setGlobalCustNum(center.getGlobalCustNum());
            centerDescription.setSearchId(center.getSearchId());
            hierarchy.getCenters().add(centerDescription);
        }
    }
    allGroups: for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(loanOfficer)) {
        GroupDescriptionDto groupDescription = new GroupDescriptionDto();
        groupDescription.setId(group.getCustomerId());
        groupDescription.setDisplayName(group.getDisplayName());
        groupDescription.setGlobalCustNum(group.getGlobalCustNum());
        groupDescription.setSearchId(group.getSearchId());
        for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsUnderParent(group.getSearchId(), loanOfficer.getOffice().getOfficeId())) {
            ClientDescriptionDto clientDescription = new ClientDescriptionDto();
            clientDescription.setId(client.getCustomerId());
            clientDescription.setDisplayName(client.getDisplayName());
            clientDescription.setGlobalCustNum(client.getGlobalCustNum());
            clientDescription.setSearchId(client.getSearchId());
            groupDescription.getClients().add(clientDescription);
        }
        for (CenterDescriptionDto center : hierarchy.getCenters()) {
            if (group.getSearchId().startsWith(center.getSearchId())) {
                center.getGroups().add(groupDescription);
                continue allGroups;
            }
        }
        hierarchy.getGroups().add(groupDescription);
    }
    for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsWithoutGroupForLoanOfficer(loanOfficer.getPersonnelId(), loanOfficer.getOffice().getOfficeId())) {
        ClientDescriptionDto clientDescription = new ClientDescriptionDto();
        clientDescription.setId(client.getCustomerId());
        clientDescription.setDisplayName(client.getDisplayName());
        clientDescription.setGlobalCustNum(client.getGlobalCustNum());
        clientDescription.setSearchId(client.getSearchId());
        hierarchy.getClients().add(clientDescription);
    }
    return hierarchy;
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CenterDescriptionDto(org.mifos.dto.domain.CenterDescriptionDto) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerHierarchyDto(org.mifos.dto.domain.CustomerHierarchyDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupDescriptionDto(org.mifos.dto.domain.GroupDescriptionDto) ClientDescriptionDto(org.mifos.dto.domain.ClientDescriptionDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 24 with CustomerDetailDto

use of org.mifos.dto.domain.CustomerDetailDto in project head by mifos.

the class PersonnelServiceFacadeWebTier method getLoanOfficerCustomersHierarchyForDay.

@Override
public CustomerHierarchyDto getLoanOfficerCustomersHierarchyForDay(Short loanOfficerId, DateTime day) {
    PersonnelBO personnel = personnelDao.findPersonnelById(loanOfficerId);
    CustomerHierarchyDto hierarchy = new CustomerHierarchyDto();
    // Yesterday as current date because upcoming meetings should include current day
    DateTime currentDate = new DateTime().minusDays(1);
    if (ClientRules.getCenterHierarchyExists()) {
        for (CustomerDetailDto center : this.customerDao.findActiveCentersUnderUser(personnel)) {
            CustomerBO centerBO = this.customerDao.findCustomerById(center.getCustomerId());
            if (isCustomerHavingMeetingOnDay(centerBO, day, currentDate)) {
                CenterDescriptionDto centerDescription = new CenterDescriptionDto();
                centerDescription.setId(center.getCustomerId());
                centerDescription.setDisplayName(center.getDisplayName());
                centerDescription.setGlobalCustNum(center.getGlobalCustNum());
                centerDescription.setSearchId(center.getSearchId());
                hierarchy.getCenters().add(centerDescription);
            }
        }
    }
    allGroups: for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(personnel)) {
        CustomerBO groupBO = this.customerDao.findCustomerById(group.getCustomerId());
        if (isCustomerHavingMeetingOnDay(groupBO, day, currentDate)) {
            GroupDescriptionDto groupDescription = new GroupDescriptionDto();
            groupDescription.setId(group.getCustomerId());
            groupDescription.setDisplayName(group.getDisplayName());
            groupDescription.setGlobalCustNum(group.getGlobalCustNum());
            groupDescription.setSearchId(group.getSearchId());
            for (ClientBO client : this.customerDao.findActiveClientsUnderParent(group.getSearchId(), personnel.getOffice().getOfficeId())) {
                ClientDescriptionDto clientDescription = new ClientDescriptionDto();
                clientDescription.setId(client.getCustomerId());
                clientDescription.setDisplayName(client.getDisplayName());
                clientDescription.setGlobalCustNum(client.getGlobalCustNum());
                clientDescription.setSearchId(client.getSearchId());
                groupDescription.getClients().add(clientDescription);
            }
            for (CenterDescriptionDto center : hierarchy.getCenters()) {
                if (group.getSearchId().startsWith(center.getSearchId())) {
                    center.getGroups().add(groupDescription);
                    continue allGroups;
                }
            }
            hierarchy.getGroups().add(groupDescription);
        }
    }
    return hierarchy;
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CenterDescriptionDto(org.mifos.dto.domain.CenterDescriptionDto) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerHierarchyDto(org.mifos.dto.domain.CustomerHierarchyDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) GroupDescriptionDto(org.mifos.dto.domain.GroupDescriptionDto) ClientDescriptionDto(org.mifos.dto.domain.ClientDescriptionDto) DateTime(org.joda.time.DateTime)

Aggregations

CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)24 ArrayList (java.util.ArrayList)14 ClientBO (org.mifos.customers.client.business.ClientBO)9 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)7 CustomerBO (org.mifos.customers.business.CustomerBO)6 CustomerPositionOtherDto (org.mifos.dto.domain.CustomerPositionOtherDto)5 HashMap (java.util.HashMap)3 List (java.util.List)3 Test (org.junit.Test)3 AccountException (org.mifos.accounts.exceptions.AccountException)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 GroupBO (org.mifos.customers.group.business.GroupBO)3 ValueListElement (org.mifos.dto.domain.ValueListElement)3 ClientDetailDto (org.mifos.dto.screen.ClientDetailDto)3 UserContext (org.mifos.security.util.UserContext)3 Date (java.util.Date)2 LocalDate (org.joda.time.LocalDate)2 AccountBO (org.mifos.accounts.business.AccountBO)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2