Search in sources :

Example 1 with OverdueLoan

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

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

Aggregations

OverdueCustomer (org.mifos.dto.domain.OverdueCustomer)2 OverdueLoan (org.mifos.dto.domain.OverdueLoan)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 GroupBO (org.mifos.customers.group.business.GroupBO)1 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)1 Money (org.mifos.framework.util.helpers.Money)1