Subversion Repositories SmartDukaan

Rev

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

Rev 36198 Rev 36513
Line 496... Line 496...
496
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
496
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
497
        String partnerDetail = null;
497
        String partnerDetail = null;
498
// Headers for the table data
498
// Headers for the table data
499
        rows.add(Arrays.asList(
499
        rows.add(Arrays.asList(
500
                "Timestamp", "Reference_type", "Reference", "Amount", "Running Balance", "Description"));
500
                "Timestamp", "Reference_type", "Reference", "Amount", "Running Balance", "Description"));
501
        double runningBalance = openingBalance;
-
 
502
        for (
501
        for (
503
                WalletSummaryReportModel walletSummary : walletSummaryList) {
502
                WalletSummaryReportModel walletSummary : walletSummaryList) {
504
            runningBalance += walletSummary.getAmount();
-
 
505
            partnerDetail = walletSummary.getName() + "(" + walletSummary.getCode() + "-" + walletSummary.getPhone() + ")" + "-" + walletSummary.getEmail();
503
            partnerDetail = walletSummary.getName() + "(" + walletSummary.getCode() + "-" + walletSummary.getPhone() + ")" + "-" + walletSummary.getEmail();
506
 
504
 
507
            rows.add(Arrays.asList(
505
            rows.add(Arrays.asList(
508
                    FormattingUtils.format(walletSummary.getTimestamp()),
506
                    FormattingUtils.format(walletSummary.getTimestamp()),
509
                    walletSummary.getReferenceType(),
507
                    walletSummary.getReferenceType(),
510
                    walletSummary.getReference(),
508
                    walletSummary.getReference(),
511
                    walletSummary.getAmount(),
509
                    walletSummary.getAmount(),
512
                    runningBalance,
510
                    walletSummary.getRunningBalance(),
513
                    walletSummary.getDescription()
511
                    walletSummary.getDescription()
514
            ));
512
            ));
515
 
513
 
516
        }
514
        }
517
 
515
 
Line 535... Line 533...
535
            startDate = LocalDate.now().minusDays(30);
533
            startDate = LocalDate.now().minusDays(30);
536
        }
534
        }
537
        if (endDate == null) {
535
        if (endDate == null) {
538
            endDate = LocalDate.now();
536
            endDate = LocalDate.now();
539
        }
537
        }
540
        List<WalletSummaryReportModel> walletSummartList = new ArrayList<>();
538
        List<WalletSummaryReportModel> walletSummaryList = new ArrayList<>();
541
        float openingBalance = 0;
539
        float openingBalance = 0;
542
        float openingPendingAmount = 0;
540
        float openingPendingAmount = 0;
543
        if (isAdmin) {
541
        if (isAdmin) {
544
            if (fofoId > 0) {
542
            if (fofoId > 0) {
545
                openingBalance = walletService.getOpeningTill(fofoId, startDate.atStartOfDay());
543
                openingBalance = walletService.getOpeningTill(fofoId, startDate.atStartOfDay());
546
                Map<Integer, Float> openingAmountMap = transactionService.getPendingIndentValueMap(startDate.atStartOfDay(), Optional.of(fofoId));
544
                Map<Integer, Float> openingAmountMap = transactionService.getPendingIndentValueMap(startDate.atStartOfDay(), Optional.of(fofoId));
547
                openingPendingAmount = openingAmountMap.get(fofoId) == null ? 0 : openingAmountMap.get(fofoId);
545
                openingPendingAmount = openingAmountMap.get(fofoId) == null ? 0 : openingAmountMap.get(fofoId);
548
                walletSummartList = fofoOrderRepository.selectWalletSummaryReport(fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
546
                walletSummaryList = fofoOrderRepository.selectWalletSummaryReport(fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
549
                LOGGER.info("startDate - " + startDate.atStartOfDay());
547
                LOGGER.info("startDate - " + startDate.atStartOfDay());
550
                LOGGER.info("endDate - " + endDate.atTime(LocalTime.MAX));
548
                LOGGER.info("endDate - " + endDate.atTime(LocalTime.MAX));
551
            }
549
            }
552
        } else {
550
        } else {
553
            walletSummartList = fofoOrderRepository.selectWalletSummaryReport(loginDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
551
            walletSummaryList = fofoOrderRepository.selectWalletSummaryReport(loginDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
554
        }
552
        }
555
        boolean isRBM = false;
553
        boolean isRBM = false;
556
        if (isAdmin) {
554
        if (isAdmin) {
557
            AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
555
            AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
558
            List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
556
            List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
Line 573... Line 571...
573
                model.addAttribute("customRetailersMap", customRetailersMap);
571
                model.addAttribute("customRetailersMap", customRetailersMap);
574
            }
572
            }
575
        }
573
        }
576
        model.addAttribute("isRBM", isRBM);
574
        model.addAttribute("isRBM", isRBM);
577
 
575
 
578
        LOGGER.info("walletSummartList {}", walletSummartList);
576
        LOGGER.info("walletSummaryList {}", walletSummaryList);
579
        model.addAttribute("walletSummartList", walletSummartList);
577
        model.addAttribute("walletSummaryList", walletSummaryList);
580
        model.addAttribute("openingBalance", (openingBalance + openingPendingAmount));
578
        model.addAttribute("openingBalance", (openingBalance + openingPendingAmount));
581
        model.addAttribute("startDate", startDate);
579
        model.addAttribute("startDate", startDate);
582
        model.addAttribute("endDate", endDate);
580
        model.addAttribute("endDate", endDate);
583
        model.addAttribute("isAdmin", isAdmin);
581
        model.addAttribute("isAdmin", isAdmin);
584
        model.addAttribute("userWallet", userWallet);
582
        model.addAttribute("userWallet", userWallet);
Line 589... Line 587...
589
    public String getWalletSummaryReport(HttpServletRequest request, Model model) throws Exception {
587
    public String getWalletSummaryReport(HttpServletRequest request, Model model) throws Exception {
590
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
588
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
591
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
589
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
592
        LocalDateTime startDate = LocalDateTime.now().minusDays(30);
590
        LocalDateTime startDate = LocalDateTime.now().minusDays(30);
593
        LocalDateTime endDate = LocalDateTime.now();
591
        LocalDateTime endDate = LocalDateTime.now();
594
        List<WalletSummaryReportModel> walletSummartList = new ArrayList<>();
592
        List<WalletSummaryReportModel> walletSummaryList = new ArrayList<>();
595
        if (!isAdmin) {
593
        if (!isAdmin) {
596
            walletSummartList = fofoOrderRepository
594
            walletSummaryList = fofoOrderRepository
597
                    .selectWalletSummaryReport(fofoDetails.getFofoId(), startDate, endDate);
595
                    .selectWalletSummaryReport(fofoDetails.getFofoId(), startDate, endDate);
598
        }
596
        }
599
        boolean isRBM = false;
597
        boolean isRBM = false;
600
        if (isAdmin) {
598
        if (isAdmin) {
601
            AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
599
            AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
Line 617... Line 615...
617
                model.addAttribute("customRetailersMap", customRetailersMap);
615
                model.addAttribute("customRetailersMap", customRetailersMap);
618
            }
616
            }
619
        }
617
        }
620
        model.addAttribute("isRBM", isRBM);
618
        model.addAttribute("isRBM", isRBM);
621
 
619
 
622
        LOGGER.info("walletSummartList {}", walletSummartList);
620
        LOGGER.info("walletSummaryList {}", walletSummaryList);
623
        model.addAttribute("startDate", startDate.toLocalDate());
621
        model.addAttribute("startDate", startDate.toLocalDate());
624
        model.addAttribute("endDate", endDate.toLocalDate());
622
        model.addAttribute("endDate", endDate.toLocalDate());
625
        model.addAttribute("walletSummartList", walletSummartList);
623
        model.addAttribute("walletSummaryList", walletSummaryList);
626
        model.addAttribute("isAdmin", isAdmin);
624
        model.addAttribute("isAdmin", isAdmin);
627
 
625
 
628
        return "wallet-summary-report";
626
        return "wallet-summary-report";
629
    }
627
    }
630
 
628