use of org.mifos.dto.domain.CenterDescriptionDto 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;
}
use of org.mifos.dto.domain.CenterDescriptionDto 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;
}
Aggregations