Search in sources :

Example 11 with CustomerDetailDto

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

the class PersonnelRESTController method getLastRepayments.

@RequestMapping(value = "personnel/id-current/last-repayments", method = RequestMethod.GET)
@ResponseBody
public List<LastRepaymentDto> getLastRepayments() {
    List<LastRepaymentDto> lastRepayments = new ArrayList<LastRepaymentDto>();
    PersonnelBO loanOfficer = personnelDao.findPersonnelById(getCurrentPersonnel().getPersonnelId());
    List<CustomerBO> borrowers = new ArrayList<CustomerBO>();
    for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(loanOfficer)) {
        borrowers.add(customerDao.findGroupBySystemId(group.getGlobalCustNum()));
        for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsUnderParent(group.getSearchId(), loanOfficer.getOffice().getOfficeId())) {
            borrowers.add(client);
        }
    }
    for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsWithoutGroupForLoanOfficer(loanOfficer.getPersonnelId(), loanOfficer.getOffice().getOfficeId())) {
        borrowers.add(client);
    }
    for (CustomerBO borrower : borrowers) {
        List<LoanBO> loans = borrower.getOpenLoanAccountsAndGroupLoans();
        if (loans != null && loans.size() != 0) {
            LoanBO lastLoan = null;
            Date lastLoanDate = null;
            for (LoanBO loan : loans) {
                Date lastAction = null;
                for (AccountActionDateEntity accountAction : loan.getAccountActionDates()) {
                    if (lastAction == null || lastAction.before(accountAction.getActionDate())) {
                        lastAction = accountAction.getActionDate();
                    }
                }
                if (lastLoanDate == null || lastLoanDate.before(lastAction)) {
                    lastLoan = loan;
                    lastLoanDate = lastAction;
                }
            }
            if (lastLoan == null || lastLoanDate == null) {
                continue;
            }
            ClientDescriptionDto clientDescription = new ClientDescriptionDto(borrower.getCustomerId(), borrower.getDisplayName(), borrower.getGlobalCustNum(), borrower.getSearchId());
            LoanDetailDto loanDetails = new LoanDetailDto(lastLoan.getGlobalAccountNum(), lastLoan.getLoanOffering().getPrdOfferingName(), lastLoan.getAccountState().getId(), lastLoan.getAccountState().getName(), lastLoan.getLoanBalance().toString(), lastLoan.getTotalAmountDue().toString(), lastLoan.getAccountType().getAccountTypeId(), lastLoan.getTotalAmountInArrears().toString());
            LastRepaymentDto lastRepayment = new LastRepaymentDto(clientDescription, loanDetails, lastLoanDate);
            if (borrower instanceof GroupBO) {
                lastRepayment.setGroup(true);
            }
            lastRepayments.add(lastRepayment);
        }
    }
    return lastRepayments;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanDetailDto(org.mifos.dto.domain.LoanDetailDto) ArrayList(java.util.ArrayList) ClientDescriptionDto(org.mifos.dto.domain.ClientDescriptionDto) Date(java.util.Date) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LastRepaymentDto(org.mifos.dto.domain.LastRepaymentDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) GroupBO(org.mifos.customers.group.business.GroupBO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with CustomerDetailDto

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

the class PentahoParamParser method updatePossibleValuesForParam.

private Map<String, String> updatePossibleValuesForParam(ListParameter paramDefEntry, ParameterContext paramContext, Map<String, AbstractPentahoParameter> selectedValues) throws ReportDataFactoryException {
    Map<String, String> result = new HashMap<String, String>();
    String id;
    if (parameterIsOffice(paramDefEntry.getName())) {
        ParameterValues paramValues = paramDefEntry.getValues(paramContext);
        for (int i = 0; i < paramValues.getRowCount(); i++) {
            String key = String.valueOf(paramValues.getKeyValue(i));
            String value = String.valueOf(paramValues.getTextValue(i));
            result.put(key, value);
        }
    } else if (parameterIsCenter(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*officer$)|(.*officer_id$)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderUser(new Short(id));
                for (CustomerDetailDto office : customerList) {
                    String key = office.getCustomerId().toString();
                    String value = office.getDisplayName();
                    result.put(key, value);
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        } else {
            keyValue = searchKey("(selected_office$)|(.*BRANCH_NAME.*)", selectedValues, paramDefEntry.getName());
            if (!keyValue.equals("")) {
                id = (String) selectedValues.get(keyValue).getParamValue();
                if (!id.equals("-1")) {
                    List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderBranch(new Short(id));
                    for (CustomerDetailDto office : customerList) {
                        String key = office.getCustomerId().toString();
                        String value = office.getDisplayName();
                        result.put(key, value);
                    }
                } else {
                    ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                    for (int i = 0; i < paramValues.getRowCount(); i++) {
                        String key = String.valueOf(paramValues.getKeyValue(i));
                        String value = String.valueOf(paramValues.getTextValue(i));
                        result.put(key, value);
                    }
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        }
        String key = "-1";
        String value = "All";
        result.put(key, value);
    } else if (parameterIsGroup(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*officer*)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveGroupForPentahoReport(new Short(id));
                for (CustomerDetailDto office : customerList) {
                    String key = office.getCustomerId().toString();
                    String value = office.getDisplayName();
                    result.put(key, value);
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        } else {
            ParameterValues paramValues = paramDefEntry.getValues(paramContext);
            for (int i = 0; i < paramValues.getRowCount(); i++) {
                String key = String.valueOf(paramValues.getKeyValue(i));
                String value = String.valueOf(paramValues.getTextValue(i));
                result.put(key, value);
            }
        }
        String key = "-1";
        String value = "All";
        result.put(key, value);
    } else if (parameterIsOfficer(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*office$)|(.*office_id$)|(.*branch_id$)|(.*office$)|(.*selectedBranch.*)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                ChangeAccountStatusDto changeAccountStatusDto = ApplicationContextProvider.getBean(LoanAccountServiceFacade.class).retrieveLoanOfficerDetailsForBranch(new Short(id));
                List<PersonnelDto> officers = changeAccountStatusDto.getLoanOfficers();
                for (PersonnelDto officer : officers) {
                    String key = officer.getPersonnelId().toString();
                    String value = officer.getDisplayName();
                    result.put(key, value);
                }
            }
            String key = "-1";
            String value = "All";
            result.put(key, value);
        }
    } else {
        ParameterValues paramValues = paramDefEntry.getValues(paramContext);
        for (int i = 0; i < paramValues.getRowCount(); i++) {
            String key = String.valueOf(paramValues.getKeyValue(i));
            String value = String.valueOf(paramValues.getTextValue(i));
            result.put(key, value);
        }
    }
    return result;
}
Also used : ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) HashMap(java.util.HashMap) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) ArrayList(java.util.ArrayList) List(java.util.List) ParameterValues(org.pentaho.reporting.engine.classic.core.parameters.ParameterValues) CenterServiceFacade(org.mifos.application.servicefacade.CenterServiceFacade)

Example 13 with CustomerDetailDto

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

the class CenterServiceFacadeWebTier method retrieveCustomersUnderBranch.

@Override
public List<CustomerDetailDto> retrieveCustomersUnderBranch(Short branchId) {
    List<CustomerDetailDto> customers = null;
    try {
        customers = new ArrayList<CustomerDetailDto>();
        List<PersonnelBO> officers = personnelBusinessService.getActiveLoanOfficersUnderOffice(branchId);
        for (PersonnelBO officer : officers) {
            customers.addAll(retrieveCustomersUnderUser(officer.getPersonnelId()));
        }
    } catch (ServiceException e) {
    }
    return customers;
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto)

Example 14 with CustomerDetailDto

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

the class CenterServiceFacadeWebTier method retrieveCustomersUnderUser.

@Override
public List<CustomerDetailDto> retrieveCustomersUnderUser(Short loanOfficerId) {
    PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(loanOfficerId);
    List<CustomerDetailDto> customerList = new ArrayList<CustomerDetailDto>();
    if (ClientRules.getCenterHierarchyExists()) {
        customerList = this.customerDao.findActiveCentersUnderUser(loanOfficer);
    } else {
        customerList = this.customerDao.findGroupsUnderUser(loanOfficer);
    }
    return customerList;
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto)

Example 15 with CustomerDetailDto

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

the class GroupTransferAction method transferToCenter.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToCenter(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupTransferActionForm actionForm = (GroupTransferActionForm) form;
    GroupBO groupInSession = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CustomerDetailDto groupDetail = this.groupServiceFacade.transferGroupToCenter(groupInSession.getGlobalCustNum(), actionForm.getCenterSystemId(), groupInSession.getVersionNo());
    GroupBO group = this.customerDao.findGroupBySystemId(groupDetail.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : GroupTransferActionForm(org.mifos.customers.group.struts.actionforms.GroupTransferActionForm) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupBO(org.mifos.customers.group.business.GroupBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

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