Search in sources :

Example 1 with OverdueCustomer

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

the class PersonnelRESTController method addClientIfHasOverdueLoan.

private void addClientIfHasOverdueLoan(CustomerBO client, List<OverdueCustomer> overdueCustomers) {
    OverdueCustomer customerToAdd = null;
    Money amount = null;
    List<LoanBO> loans = client.isGroup() ? client.getOpenLoanAccountsAndGroupLoans() : client.getOpenLoanAccounts();
    for (LoanBO loan : loans) {
        if (loan.getTotalAmountInArrears() != null && loan.getTotalAmountInArrears().isNonZero()) {
            LoanInformationDto loanInfo = loanAccountServiceFacade.retrieveLoanInformation(loan.getGlobalAccountNum());
            if (loanInfo.isDisbursed()) {
                if (customerToAdd == null) {
                    customerToAdd = createOverdueCustomer(client);
                    overdueCustomers.add(customerToAdd);
                }
                Money partialAmount = loan.getRemainingPrincipalAmount();
                OverdueLoan overdueLoan = new OverdueLoan(loan.getTotalAmountInArrears().toString(), loan.getGlobalAccountNum(), loanInfo.getPrdOfferingName(), loan.getAccountState().getName(), new Integer(loan.getAccountState().getId()), loan.getTotalRepayableAmount().toString(), partialAmount.toString());
                if (amount == null) {
                    amount = partialAmount;
                } else {
                    amount = amount.add(partialAmount);
                }
                customerToAdd.getOverdueLoans().add(overdueLoan);
            }
        }
    }
    if (customerToAdd != null) {
        customerToAdd.setTotalCapitalOutstanding(amount == null ? "0" : amount.toString());
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) OverdueLoan(org.mifos.dto.domain.OverdueLoan) OverdueCustomer(org.mifos.dto.domain.OverdueCustomer)

Example 2 with OverdueCustomer

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

the class PersonnelRESTController method createOverdueCustomer.

private OverdueCustomer createOverdueCustomer(CustomerBO client) {
    OverdueCustomer overdueCustomer = new OverdueCustomer();
    overdueCustomer.setDisplayName(client.getDisplayName());
    overdueCustomer.setGlobalCustNum(client.getGlobalCustNum());
    overdueCustomer.setOverdueLoans(new ArrayList<OverdueLoan>());
    overdueCustomer.setPhoneNumber(client.getAddress().getPhoneNumber());
    overdueCustomer.setAddress(client.getDisplayAddress());
    if (client instanceof GroupBO) {
        overdueCustomer.setGroup(true);
    }
    return overdueCustomer;
}
Also used : GroupBO(org.mifos.customers.group.business.GroupBO) OverdueLoan(org.mifos.dto.domain.OverdueLoan) OverdueCustomer(org.mifos.dto.domain.OverdueCustomer)

Example 3 with OverdueCustomer

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

the class PersonnelRESTController method getOverdueBorrowersUnderPersonnel.

@RequestMapping(value = "personnel/id-current/overdue_borrowers", method = RequestMethod.GET)
@ResponseBody
public OverdueCustomer[] getOverdueBorrowersUnderPersonnel() {
    List<OverdueCustomer> overdueCustomers = new ArrayList<OverdueCustomer>();
    PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(getCurrentPersonnel().getPersonnelId());
    for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(loanOfficer)) {
        addClientIfHasOverdueLoan(customerDao.findGroupBySystemId(group.getGlobalCustNum()), overdueCustomers);
        for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsUnderParent(group.getSearchId(), loanOfficer.getOffice().getOfficeId())) {
            addClientIfHasOverdueLoan(client, overdueCustomers);
        }
    }
    for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsWithoutGroupForLoanOfficer(loanOfficer.getPersonnelId(), loanOfficer.getOffice().getOfficeId())) {
        addClientIfHasOverdueLoan(client, overdueCustomers);
    }
    return overdueCustomers.toArray(new OverdueCustomer[] {});
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) OverdueCustomer(org.mifos.dto.domain.OverdueCustomer) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

OverdueCustomer (org.mifos.dto.domain.OverdueCustomer)3 OverdueLoan (org.mifos.dto.domain.OverdueLoan)2 ArrayList (java.util.ArrayList)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 ClientBO (org.mifos.customers.client.business.ClientBO)1 GroupBO (org.mifos.customers.group.business.GroupBO)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)1 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)1 Money (org.mifos.framework.util.helpers.Money)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1