Subversion Repositories SmartDukaan

Rev

Rev 33505 | Rev 33827 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33505 Rev 33533
Line 466... Line 466...
466
    }
466
    }
467
 
467
 
468
    @RequestMapping(value = "/getPartnerWiseLoanSummary", method = RequestMethod.GET)
468
    @RequestMapping(value = "/getPartnerWiseLoanSummary", method = RequestMethod.GET)
469
    public String getPartnerWiseLoanSummary(HttpServletRequest request, @RequestParam LoanSummaryType loanSummaryType, Model model) throws ProfitMandiBusinessException {
469
    public String getPartnerWiseLoanSummary(HttpServletRequest request, @RequestParam LoanSummaryType loanSummaryType, Model model) throws ProfitMandiBusinessException {
470
        Map<Integer, FofoReportingModel> fofoReportingModelMap = csService.getPartnerIdSalesHeaders();
470
        Map<Integer, FofoReportingModel> fofoReportingModelMap = csService.getPartnerIdSalesHeaders();
471
        List<Loan> loans = new ArrayList<>();
-
 
472
        List<Loan> activeLoans = loanRepository.selectAllActiveLoan();
471
        List<Loan> loans = loanRepository.selectAllActiveLoan();
473
        if (loanSummaryType.equals(LoanSummaryType.TOTAL_LOAN)) {
472
        if (loanSummaryType.equals(LoanSummaryType.DEFAULT_LOAN)) {
474
            loans.addAll(activeLoans);
-
 
475
        } else if (loanSummaryType.equals(LoanSummaryType.DEFAULT_LOAN)) {
-
 
476
            for (Loan loan : activeLoans) {
-
 
477
                long noOfdaysBetween = ChronoUnit.DAYS.between(loan.getDueDate().toLocalDate(), LocalDateTime.now());
473
            loans = loans.stream().filter(x->x.isDefault()).collect(Collectors.toList());
478
                if (noOfdaysBetween > 15) {
-
 
479
                    loans.add(loan);
-
 
480
                }
-
 
481
            }
-
 
482
 
-
 
483
        } else if (loanSummaryType.equals(LoanSummaryType.DUE_LOAN)) {
474
        } else if (loanSummaryType.equals(LoanSummaryType.DUE_LOAN)) {
484
            for (Loan loan : activeLoans) {
-
 
485
                long noOfdaysBetween = ChronoUnit.DAYS.between(loan.getDueDate().toLocalDate(), LocalDateTime.now());
475
            loans = loans.stream().filter(x->x.isOverdue()).collect(Collectors.toList());
486
                if (noOfdaysBetween <= 15 && noOfdaysBetween >= 0) {
-
 
487
                    loans.add(loan);
-
 
488
                }
-
 
489
            }
-
 
490
        }
476
        }
491
        List<Integer> fofoIds = loans.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
477
        List<Integer> fofoIds = loans.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
492
        Map<Integer, Double> fofoIdLoansMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> x.getPendingAmount().doubleValue())));
478
        Map<Integer, Double> fofoIdLoansMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> x.getPendingAmount().doubleValue())));
493
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
479
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
494
        Map<Integer, Long> loanCountMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
480
        Map<Integer, Long> loanCountMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));