Search in sources :

Example 1 with CustomerPositionOtherDto

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

the class CenterServiceFacadeWebTier method getCenterInformationDto.

@Override
public CenterInformationDto getCenterInformationDto(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CenterBO center = customerDao.findCenterBySystemId(globalCustNum);
    if (center == null) {
        throw new MifosRuntimeException("Center not found for globalCustNum" + globalCustNum);
    }
    try {
        personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    CenterDisplayDto centerDisplay = customerDao.getCenterDisplayDto(center.getCustomerId(), userContext);
    Integer centerId = center.getCustomerId();
    String searchId = center.getSearchId();
    Short branchId = centerDisplay.getBranchId();
    CustomerAccountSummaryDto customerAccountSummary = customerDao.getCustomerAccountSummaryDto(centerId);
    CenterPerformanceHistoryDto centerPerformanceHistory = customerDao.getCenterPerformanceHistory(searchId, branchId);
    CustomerAddressDto centerAddress = customerDao.getCustomerAddressDto(center);
    List<CustomerDetailDto> groups = customerDao.getGroupsOtherThanClosedAndCancelledForGroup(searchId, branchId);
    List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(centerId);
    List<CustomerPositionOtherDto> customerPositions = customerDao.getCustomerPositionDto(centerId, userContext);
    List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(centerId, userContext);
    CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(center.getCustomerMeeting(), userContext);
    List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(centerId);
    List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
    for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
        if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.SAVINGS_ACCOUNT.getValue().intValue()) {
            closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
        }
    }
    //new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CENTER);
    Boolean activeSurveys = Boolean.FALSE;
    List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    return new CenterInformationDto(centerDisplay, customerAccountSummary, centerPerformanceHistory, centerAddress, groups, recentCustomerNotes, customerPositions, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedSavingsAccounts);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) CenterPerformanceHistoryDto(org.mifos.dto.domain.CenterPerformanceHistoryDto) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MifosUser(org.mifos.security.MifosUser) AccountException(org.mifos.accounts.exceptions.AccountException) CenterDisplayDto(org.mifos.dto.domain.CenterDisplayDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with CustomerPositionOtherDto

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

the class CustomerUIHelperFn method getClientPosition.

public static String getClientPosition(Object customerPositions, Object customer) {
    logger.debug("Inside UI helper function getClientPositions");
    StringBuilder stringBuilder = new StringBuilder();
    if (customerPositions != null && customer != null) {
        logger.debug("Iterating over customerPositions list");
        List<CustomerPositionOtherDto> customerPositionList = (List<CustomerPositionOtherDto>) customerPositions;
        String[] positionNames = new String[customerPositionList.size()];
        int i = 0;
        for (CustomerPositionOtherDto customerPosition : customerPositionList) {
            CustomerDetailDto customerDetails = (CustomerDetailDto) customer;
            if (null != customerPosition && customerPosition.getCustomerId() != null && customerDetails != null) {
                if (customerPosition.getCustomerId().equals((customerDetails).getCustomerId())) {
                    String posName = customerPosition.getPositionName();
                    logger.debug("The position name is " + posName);
                    positionNames[i] = posName;
                    i++;
                }
            }
        }
        for (; i < positionNames.length; i++) {
            positionNames[i] = null;
        }
        stringBuilder.append("(");
        for (int j = 0; j < positionNames.length; j++) {
            if (positionNames[j] != null && positionNames[j] != "") {
                stringBuilder.append(positionNames[j]);
            }
            if (j + 1 < positionNames.length && positionNames[j + 1] != null && positionNames[j + 1] != "") {
                stringBuilder.append(",");
            }
        }
        stringBuilder.append(")");
    }
    if (stringBuilder.toString().equals("()")) {
        return "";
    }
    return stringBuilder.toString();
}
Also used : CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) List(java.util.List)

Example 3 with CustomerPositionOtherDto

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

the class GroupServiceFacadeWebTier method getGroupInformationDto.

//    private void checkPermissionForCreate(Short newState, UserContext userContext, Short recordOfficeId,
//            Short recordLoanOfficerId) throws ApplicationException {
//        if (!isPermissionAllowed(newState, userContext, recordOfficeId, recordLoanOfficerId)) {
//            logger.info("permission not allowed: " + userContext.toString() + " officeId: " + recordLoanOfficerId + " loanOfficerId: " + recordLoanOfficerId);
//            throw new AccountException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
//        }
//    }
//    private boolean isPermissionAllowed(Short newState, UserContext userContext, Short recordOfficeId,
//            Short recordLoanOfficerId) {
//        return ActivityMapper.getInstance().isSavePermittedForCustomer(newState.shortValue(), userContext,
//                recordOfficeId, recordLoanOfficerId);
//    }
@Override
public GroupInformationDto getGroupInformationDto(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
    if (group == null) {
        throw new MifosRuntimeException("Group not found for globalCustNum: " + globalCustNum);
    }
    try {
        personnelDao.checkAccessPermission(userContext, group.getOfficeId(), group.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    GroupDisplayDto groupDisplay = this.customerDao.getGroupDisplayDto(group.getCustomerId(), userContext);
    Integer groupId = group.getCustomerId();
    String searchId = group.getSearchId();
    Short branchId = groupDisplay.getBranchId();
    CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(groupId);
    GroupPerformanceHistoryDto groupPerformanceHistory = assembleGroupPerformanceHistoryDto(group.getGroupPerformanceHistory(), searchId, branchId, groupId);
    CustomerAddressDto groupAddress = this.customerDao.getCustomerAddressDto(group);
    List<CustomerDetailDto> clients = this.customerDao.findClientsThatAreNotCancelledOrClosedReturningDetailDto(searchId, branchId);
    List<CustomerNoteDto> recentCustomerNotes = this.customerDao.getRecentCustomerNoteDto(groupId);
    List<CustomerPositionOtherDto> customerPositions = this.customerDao.getCustomerPositionDto(groupId, userContext);
    List<CustomerFlagDto> customerFlags = this.customerDao.getCustomerFlagDto(group.getCustomerFlags());
    List<LoanDetailDto> loanDetail = this.customerDao.getLoanDetailDto(group.getOpenLoanAccountsAndGroupLoans());
    List<SavingsDetailDto> savingsDetail = this.customerDao.getSavingsDetailDto(groupId, userContext);
    CustomerMeetingDto customerMeeting = this.customerDao.getCustomerMeetingDto(group.getCustomerMeeting(), userContext);
    List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(groupId);
    List<LoanDetailDto> closedLoanAccounts = new ArrayList<LoanDetailDto>();
    List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
    for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
        if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.LOAN_ACCOUNT.getValue().intValue()) {
            closedLoanAccounts.add(new LoanDetailDto(closedAccount.getGlobalAccountNum(), ((LoanBO) closedAccount).getLoanOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((LoanBO) closedAccount).getLoanSummary().getOutstandingBalance().toString(), closedAccount.getTotalAmountDue().toString(), closedAccount.getTotalAmountInArrears().toString()));
        } else {
            closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
        }
    }
    boolean activeSurveys = false;
    //        boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.GROUP);
    List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    return new GroupInformationDto(groupDisplay, customerAccountSummary, groupPerformanceHistory, groupAddress, clients, recentCustomerNotes, customerPositions, customerFlags, loanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedLoanAccounts, closedSavingsAccounts);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) GroupDisplayDto(org.mifos.dto.screen.GroupDisplayDto) ArrayList(java.util.ArrayList) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AccountBO(org.mifos.accounts.business.AccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) LoanDetailDto(org.mifos.dto.domain.LoanDetailDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MifosUser(org.mifos.security.MifosUser) CustomerFlagDto(org.mifos.dto.domain.CustomerFlagDto) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) GroupPerformanceHistoryDto(org.mifos.dto.screen.GroupPerformanceHistoryDto) AccountException(org.mifos.accounts.exceptions.AccountException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with CustomerPositionOtherDto

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

the class CustomerDaoHibernate method getCustomerPositionDto.

@SuppressWarnings("unchecked")
@Override
public List<CustomerPositionOtherDto> getCustomerPositionDto(final Integer parentId, final UserContext userContext) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("PARENT_ID", parentId);
    List<Object[]> queryResult = (List<Object[]>) this.genericDao.executeNamedQuery("Customer.getCustomerPositionDto", queryParameters);
    if (queryResult.size() == 0) {
        return null;
    }
    List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
    String lookupName;
    Integer customerId;
    String customerDisplayName;
    String positionName;
    for (Object[] customerPosition : queryResult) {
        lookupName = (String) customerPosition[0];
        customerId = (Integer) customerPosition[1];
        customerDisplayName = (String) customerPosition[2];
        positionName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupName);
        customerPositions.add(new CustomerPositionOtherDto(positionName, customerId, customerDisplayName));
    }
    return customerPositions;
}
Also used : BigInteger(java.math.BigInteger) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with CustomerPositionOtherDto

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

the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsNotAssignedPosition.

@Test
public void testUIHelperWhenClientIsNotAssignedPosition() 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)

Aggregations

CustomerPositionOtherDto (org.mifos.dto.domain.CustomerPositionOtherDto)6 ArrayList (java.util.ArrayList)5 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)5 List (java.util.List)2 Test (org.junit.Test)2 AccountBO (org.mifos.accounts.business.AccountBO)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2 AccountException (org.mifos.accounts.exceptions.AccountException)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerFlagDetailEntity (org.mifos.customers.business.CustomerFlagDetailEntity)2 CustomerPositionEntity (org.mifos.customers.business.CustomerPositionEntity)2 PositionEntity (org.mifos.customers.business.PositionEntity)2 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)2 CustomerAccountSummaryDto (org.mifos.dto.domain.CustomerAccountSummaryDto)2 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)2 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)2 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)2 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)2 SurveyDto (org.mifos.dto.domain.SurveyDto)2 MifosUser (org.mifos.security.MifosUser)2