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