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());
}
}
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;
}
Aggregations