Search in sources :

Example 71 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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)

Example 72 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class PersonnelRESTController method getLastRepayments.

@RequestMapping(value = "personnel/id-current/last-repayments", method = RequestMethod.GET)
@ResponseBody
public List<LastRepaymentDto> getLastRepayments() {
    List<LastRepaymentDto> lastRepayments = new ArrayList<LastRepaymentDto>();
    PersonnelBO loanOfficer = personnelDao.findPersonnelById(getCurrentPersonnel().getPersonnelId());
    List<CustomerBO> borrowers = new ArrayList<CustomerBO>();
    for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(loanOfficer)) {
        borrowers.add(customerDao.findGroupBySystemId(group.getGlobalCustNum()));
        for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsUnderParent(group.getSearchId(), loanOfficer.getOffice().getOfficeId())) {
            borrowers.add(client);
        }
    }
    for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsWithoutGroupForLoanOfficer(loanOfficer.getPersonnelId(), loanOfficer.getOffice().getOfficeId())) {
        borrowers.add(client);
    }
    for (CustomerBO borrower : borrowers) {
        List<LoanBO> loans = borrower.getOpenLoanAccountsAndGroupLoans();
        if (loans != null && loans.size() != 0) {
            LoanBO lastLoan = null;
            Date lastLoanDate = null;
            for (LoanBO loan : loans) {
                Date lastAction = null;
                for (AccountActionDateEntity accountAction : loan.getAccountActionDates()) {
                    if (lastAction == null || lastAction.before(accountAction.getActionDate())) {
                        lastAction = accountAction.getActionDate();
                    }
                }
                if (lastLoanDate == null || lastLoanDate.before(lastAction)) {
                    lastLoan = loan;
                    lastLoanDate = lastAction;
                }
            }
            if (lastLoan == null || lastLoanDate == null) {
                continue;
            }
            ClientDescriptionDto clientDescription = new ClientDescriptionDto(borrower.getCustomerId(), borrower.getDisplayName(), borrower.getGlobalCustNum(), borrower.getSearchId());
            LoanDetailDto loanDetails = new LoanDetailDto(lastLoan.getGlobalAccountNum(), lastLoan.getLoanOffering().getPrdOfferingName(), lastLoan.getAccountState().getId(), lastLoan.getAccountState().getName(), lastLoan.getLoanBalance().toString(), lastLoan.getTotalAmountDue().toString(), lastLoan.getAccountType().getAccountTypeId(), lastLoan.getTotalAmountInArrears().toString());
            LastRepaymentDto lastRepayment = new LastRepaymentDto(clientDescription, loanDetails, lastLoanDate);
            if (borrower instanceof GroupBO) {
                lastRepayment.setGroup(true);
            }
            lastRepayments.add(lastRepayment);
        }
    }
    return lastRepayments;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanDetailDto(org.mifos.dto.domain.LoanDetailDto) ArrayList(java.util.ArrayList) ClientDescriptionDto(org.mifos.dto.domain.ClientDescriptionDto) Date(java.util.Date) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LastRepaymentDto(org.mifos.dto.domain.LastRepaymentDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) GroupBO(org.mifos.customers.group.business.GroupBO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 73 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class ApprovalController method list.

@RequestMapping("restApprovalList.ftl")
public ModelAndView list() {
    ModelAndView mav = new ModelAndView("approval/list");
    List<BreadCrumbsLinks> breadcrumbs = new AdminBreadcrumbBuilder().withLink("View REST Approval List", "").build();
    mav.addObject("isApprovalRequired", RESTConfigKey.isApprovalRequired(configurationServiceFacade));
    mav.addObject("breadcrumbs", breadcrumbs);
    mav.addObject("waitingForApprovalList", approvalService.getAllWaiting());
    mav.addObject("approvedList", approvalService.getAllNotWaiting());
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) BreadCrumbsLinks(org.mifos.ui.core.controller.BreadCrumbsLinks) AdminBreadcrumbBuilder(org.mifos.ui.core.controller.AdminBreadcrumbBuilder) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 74 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class ApprovalController method details.

@RequestMapping("restApproval/id-{id}/details.ftl")
public ModelAndView details(@PathVariable Long id) {
    ModelAndView mav = new ModelAndView("approval/details");
    mav.addObject("waitingForApprovalList", approvalService.getAllWaiting());
    RESTApprovalEntity approval = approvalService.getDetails(id);
    mav.addObject("approval", approval);
    PersonnelInformationDto p = personnelServiceFacade.getPersonnelInformationDto(approval.getCreatedBy().longValue(), null);
    mav.addObject("createdBy", p.getDisplayName());
    if (!approval.getState().equals(ApprovalState.WAITING)) {
        p = personnelServiceFacade.getPersonnelInformationDto(approval.getApprovedBy().longValue(), null);
        mav.addObject("approvedBy", p.getDisplayName());
    }
    return mav;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 75 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class JSONAjaxController method deleteCacheDir.

@RequestMapping("jsonAjax.ftl")
public ModelAndView deleteCacheDir(HttpServletResponse response) {
    ModelAndView mav;
    if (TestMode.MAIN == testingService.getTestMode()) {
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
        mav = new ModelAndView("pageNotFound");
    } else {
        mav = new ModelAndView("jsonAjax");
    }
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1964 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)459 ModelAndView (org.springframework.web.servlet.ModelAndView)413 ApiOperation (io.swagger.annotations.ApiOperation)305 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)234 ArrayList (java.util.ArrayList)197 HashMap (java.util.HashMap)155 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)124 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)124 IOException (java.io.IOException)97 ResponseEntity (org.springframework.http.ResponseEntity)92 Date (java.util.Date)83 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)80 DBObject (com.mongodb.DBObject)71 BasicDBObject (com.mongodb.BasicDBObject)67 InputStream (java.io.InputStream)66 Aggregation.newAggregation (org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation)64 HttpServletResponse (javax.servlet.http.HttpServletResponse)59 User (org.hisp.dhis.user.User)59 List (java.util.List)53