Search in sources :

Example 1 with ClientDescriptionDto

use of org.mifos.dto.domain.ClientDescriptionDto 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 2 with ClientDescriptionDto

use of org.mifos.dto.domain.ClientDescriptionDto 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)

Example 3 with ClientDescriptionDto

use of org.mifos.dto.domain.ClientDescriptionDto 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)

Aggregations

ClientBO (org.mifos.customers.client.business.ClientBO)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 ClientDescriptionDto (org.mifos.dto.domain.ClientDescriptionDto)3 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)3 CustomerBO (org.mifos.customers.business.CustomerBO)2 CenterDescriptionDto (org.mifos.dto.domain.CenterDescriptionDto)2 CustomerHierarchyDto (org.mifos.dto.domain.CustomerHierarchyDto)2 GroupDescriptionDto (org.mifos.dto.domain.GroupDescriptionDto)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 GroupBO (org.mifos.customers.group.business.GroupBO)1 LastRepaymentDto (org.mifos.dto.domain.LastRepaymentDto)1 LoanDetailDto (org.mifos.dto.domain.LoanDetailDto)1