Subversion Repositories SmartDukaan

Rev

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

Rev 34011 Rev 34066
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import com.spice.profitmandi.common.enumuration.ReporticoProject;
3
import com.spice.profitmandi.common.enumuration.ReporticoProject;
4
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
5
import com.spice.profitmandi.common.model.CustomRetailer;
5
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
6
import com.spice.profitmandi.common.model.ProfitMandiConstants;
6
import com.spice.profitmandi.common.model.ReporticoUrlInfo;
7
import com.spice.profitmandi.common.model.ReporticoUrlInfo;
7
import com.spice.profitmandi.common.services.ReporticoService;
8
import com.spice.profitmandi.common.services.ReporticoService;
8
import com.spice.profitmandi.common.util.FileUtil;
9
import com.spice.profitmandi.common.util.FileUtil;
9
import com.spice.profitmandi.common.util.FormattingUtils;
10
import com.spice.profitmandi.common.util.FormattingUtils;
10
import com.spice.profitmandi.dao.entity.auth.AuthUser;
11
import com.spice.profitmandi.dao.entity.auth.AuthUser;
-
 
12
import com.spice.profitmandi.dao.entity.cs.Position;
11
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
13
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
12
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
14
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
13
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
15
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
14
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
16
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
15
import com.spice.profitmandi.dao.model.*;
17
import com.spice.profitmandi.dao.model.*;
16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
18
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
17
import com.spice.profitmandi.dao.repository.cs.CsService;
19
import com.spice.profitmandi.dao.repository.cs.CsService;
-
 
20
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
18
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
21
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
19
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
22
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
20
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
23
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
21
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
24
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
22
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
25
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
Line 88... Line 91...
88
    private UserWalletHistoryRepository userWalletHistoryRepository;
91
    private UserWalletHistoryRepository userWalletHistoryRepository;
89
    @Autowired
92
    @Autowired
90
    private TransactionService transactionService;
93
    private TransactionService transactionService;
91
    @Autowired
94
    @Autowired
92
    private LoanStatementRepository loanStatementRepository;
95
    private LoanStatementRepository loanStatementRepository;
-
 
96
    @Autowired
-
 
97
    PositionRepository positionRepository;
93
 
98
 
94
    @PostMapping(value = "/reports/{projectName}/{fileName}")
99
    @PostMapping(value = "/reports/{projectName}/{fileName}")
95
    public ResponseEntity<?> fetchReport(HttpServletRequest request, @PathVariable String fileName,
100
    public ResponseEntity<?> fetchReport(HttpServletRequest request, @PathVariable String fileName,
96
                                         @PathVariable ReporticoProject projectName, @RequestBody Map<String, String> paramsMap)
101
                                         @PathVariable ReporticoProject projectName, @RequestBody Map<String, String> paramsMap)
97
            throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
102
            throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
Line 144... Line 149...
144
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
149
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
145
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
150
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
146
        LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
151
        LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
147
        List<CollectionSummary> collectionSummaryList = orderRepository.selectCollectionSummary(fofoDetails.getFofoId(), currentStartMonth, currentDate);
152
        List<CollectionSummary> collectionSummaryList = orderRepository.selectCollectionSummary(fofoDetails.getFofoId(), currentStartMonth, currentDate);
148
        Logger.info("CollectionSummaryList {}", collectionSummaryList);
153
        Logger.info("CollectionSummaryList {}", collectionSummaryList);
-
 
154
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
155
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
156
        boolean isRBM = positions.stream()
-
 
157
                .anyMatch(position ->
-
 
158
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
159
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
160
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
161
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
162
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
163
                try {
-
 
164
                    return retailerService.getFofoRetailers(true).get(x);
-
 
165
                } catch (ProfitMandiBusinessException e) {
-
 
166
                    // TODO Auto-generated catch block
-
 
167
                    return null;
-
 
168
                }
-
 
169
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
170
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
171
        }
-
 
172
        model.addAttribute("isRBM", isRBM);
149
        model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
173
        model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
150
        model.addAttribute("endDate", LocalDate.now());
174
        model.addAttribute("endDate", LocalDate.now());
151
        model.addAttribute("collectionSummaryList", collectionSummaryList);
175
        model.addAttribute("collectionSummaryList", collectionSummaryList);
152
        model.addAttribute("isAdmin", isAdmin);
176
        model.addAttribute("isAdmin", isAdmin);
153
        return "partner-collection-summary";
177
        return "partner-collection-summary";
Line 163... Line 187...
163
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
187
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
164
        if (isAdmin) {
188
        if (isAdmin) {
165
            startDate = LocalDate.now().minusDays(30);
189
            startDate = LocalDate.now().minusDays(30);
166
            endDate = LocalDate.now();
190
            endDate = LocalDate.now();
167
        }
191
        }
-
 
192
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
193
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
194
        boolean isRBM = positions.stream()
-
 
195
                .anyMatch(position ->
-
 
196
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
197
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
198
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
199
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
200
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
201
                try {
-
 
202
                    return retailerService.getFofoRetailers(true).get(x);
-
 
203
                } catch (ProfitMandiBusinessException e) {
-
 
204
                    // TODO Auto-generated catch block
-
 
205
                    return null;
-
 
206
                }
-
 
207
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
208
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
209
        }
-
 
210
        model.addAttribute("isRBM", isRBM);
168
        model.addAttribute("startDate", startDate);
211
        model.addAttribute("startDate", startDate);
169
        model.addAttribute("endDate", endDate);
212
        model.addAttribute("endDate", endDate);
170
        model.addAttribute("isAdmin", isAdmin);
213
        model.addAttribute("isAdmin", isAdmin);
171
 
214
 
172
 
215
 
Line 233... Line 276...
233
        if (startDate == null) {
276
        if (startDate == null) {
234
            startDate = LocalDate.now().minusDays(30);
277
            startDate = LocalDate.now().minusDays(30);
235
 
278
 
236
        }
279
        }
237
        endDate = LocalDate.now();
280
        endDate = LocalDate.now();
-
 
281
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
282
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
283
        boolean isRBM = positions.stream()
-
 
284
                .anyMatch(position ->
-
 
285
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
286
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
287
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
288
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
289
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
290
                try {
-
 
291
                    return retailerService.getFofoRetailers(true).get(x);
-
 
292
                } catch (ProfitMandiBusinessException e) {
-
 
293
                    // TODO Auto-generated catch block
-
 
294
                    return null;
-
 
295
                }
-
 
296
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
297
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
298
        }
-
 
299
        model.addAttribute("isRBM", isRBM);
238
        model.addAttribute("startDate", startDate);
300
        model.addAttribute("startDate", startDate);
239
        model.addAttribute("endDate", endDate);
301
        model.addAttribute("endDate", endDate);
240
        model.addAttribute("isAdmin", isAdmin);
302
        model.addAttribute("isAdmin", isAdmin);
241
        LOGGER.info("q {}, starDate - {}, endDate - {}", fofoId, startDate, endDate);
303
        LOGGER.info("q {}, starDate - {}, endDate - {}", fofoId, startDate, endDate);
242
        if (isAdmin) {
304
        if (isAdmin) {
Line 269... Line 331...
269
        if (startDate == null) {
331
        if (startDate == null) {
270
 
332
 
271
            startDate = LocalDate.now().minusDays(30);
333
            startDate = LocalDate.now().minusDays(30);
272
            endDate = LocalDate.now();
334
            endDate = LocalDate.now();
273
        }
335
        }
-
 
336
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
337
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
338
        boolean isRBM = positions.stream()
-
 
339
                .anyMatch(position ->
-
 
340
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
341
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
342
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
343
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
344
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
345
                try {
-
 
346
                    return retailerService.getFofoRetailers(true).get(x);
-
 
347
                } catch (ProfitMandiBusinessException e) {
-
 
348
                    // TODO Auto-generated catch block
-
 
349
                    return null;
-
 
350
                }
-
 
351
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
352
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
353
        }
-
 
354
        model.addAttribute("isRBM", isRBM);
274
        model.addAttribute("startDate", startDate);
355
        model.addAttribute("startDate", startDate);
275
        model.addAttribute("endDate", endDate);
356
        model.addAttribute("endDate", endDate);
276
        model.addAttribute("isAdmin", isAdmin);
357
        model.addAttribute("isAdmin", isAdmin);
277
 
358
 
278
        // List<List<?>> rows = new ArrayList<>();
359
        // List<List<?>> rows = new ArrayList<>();
Line 391... Line 472...
391
 
472
 
392
        LOGGER.info("walletSummartList {}", fofoId);
473
        LOGGER.info("walletSummartList {}", fofoId);
393
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
474
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
394
        String partnerDetail = null;
475
        String partnerDetail = null;
395
// Headers for the table data
476
// Headers for the table data
-
 
477
        rows.add(Arrays.asList(
-
 
478
//                "Id","Business_timestamp",
396
        rows.add(Arrays.asList("Id", "Amount", "Refundable_amount", "Reference", "Reference_type", "Running Balance", "Business_timestamp", "timestamp", "Description"));
479
                "timestamp", "Reference_type", "Reference", "Amount", "Refundable_amount", "Running Balance", "Description"));
397
        for (WalletSummaryReportModel walletSummary : walletSummartList) {
480
        for (WalletSummaryReportModel walletSummary : walletSummartList) {
398
            partnerDetail = walletSummary.getName() + "(" + walletSummary.getCode() + "-" + walletSummary.getPhone() + ")" + "-" + walletSummary.getEmail();
481
            partnerDetail = walletSummary.getName() + "(" + walletSummary.getCode() + "-" + walletSummary.getPhone() + ")" + "-" + walletSummary.getEmail();
399
 
482
 
400
            rows.add(Arrays.asList(
483
            rows.add(Arrays.asList(
401
                    walletSummary.getId(),
484
//                    walletSummary.getId(),
-
 
485
//                    FormattingUtils.format(walletSummary.getBusinessTimestamp() != null ? walletSummary.getBusinessTimestamp() : walletSummary.getTimestamp()),
-
 
486
                    walletSummary.getTimestamp(),
-
 
487
                    walletSummary.getReferenceType(),
-
 
488
                    walletSummary.getReference(),
402
                    walletSummary.getAmount(),
489
                    walletSummary.getAmount(),
403
                    walletSummary.getRefundableAmount(),
490
                    walletSummary.getRefundableAmount(),
404
                    walletSummary.getReference(),
-
 
405
                    walletSummary.getReferenceType(),
-
 
406
                    openingBalance + walletSummary.getAmount(),
491
                    openingBalance + walletSummary.getAmount(),
407
                    FormattingUtils.format(walletSummary.getBusinessTimestamp() != null ? walletSummary.getBusinessTimestamp() : walletSummary.getTimestamp()),
-
 
408
                    walletSummary.getTimestamp(),
-
 
409
                    walletSummary.getDescription()
492
                    walletSummary.getDescription()
410
            ));
493
            ));
411
 
494
 
412
        }
495
        }
413
 
496
 
Line 447... Line 530...
447
                LOGGER.info("endDate - " + endDate.atTime(LocalTime.MAX));
530
                LOGGER.info("endDate - " + endDate.atTime(LocalTime.MAX));
448
            }
531
            }
449
        } else {
532
        } else {
450
            walletSummartList = fofoOrderRepository.selectWalletSummaryReport(loginDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
533
            walletSummartList = fofoOrderRepository.selectWalletSummaryReport(loginDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
451
        }
534
        }
-
 
535
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
536
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
537
        boolean isRBM = positions.stream()
-
 
538
                .anyMatch(position ->
-
 
539
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
540
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
541
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
542
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
543
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
544
                try {
-
 
545
                    return retailerService.getFofoRetailers(true).get(x);
-
 
546
                } catch (ProfitMandiBusinessException e) {
-
 
547
                    // TODO Auto-generated catch block
-
 
548
                    return null;
-
 
549
                }
-
 
550
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
551
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
552
        }
-
 
553
        model.addAttribute("isRBM", isRBM);
-
 
554
 
452
        LOGGER.info("walletSummartList {}", walletSummartList);
555
        LOGGER.info("walletSummartList {}", walletSummartList);
453
        model.addAttribute("walletSummartList", walletSummartList);
556
        model.addAttribute("walletSummartList", walletSummartList);
454
        model.addAttribute("openingBalance", (openingBalance + openingPendingAmount));
557
        model.addAttribute("openingBalance", (openingBalance + openingPendingAmount));
455
        model.addAttribute("startDate", startDate);
558
        model.addAttribute("startDate", startDate);
456
        model.addAttribute("endDate", endDate);
559
        model.addAttribute("endDate", endDate);
Line 467... Line 570...
467
        List<WalletSummaryReportModel> walletSummartList = new ArrayList<>();
570
        List<WalletSummaryReportModel> walletSummartList = new ArrayList<>();
468
        if (!isAdmin) {
571
        if (!isAdmin) {
469
            walletSummartList = fofoOrderRepository
572
            walletSummartList = fofoOrderRepository
470
                    .selectWalletSummaryReport(fofoDetails.getFofoId(), startDate, endDate);
573
                    .selectWalletSummaryReport(fofoDetails.getFofoId(), startDate, endDate);
471
        }
574
        }
-
 
575
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
576
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
577
        boolean isRBM = positions.stream()
-
 
578
                .anyMatch(position ->
-
 
579
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
580
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
581
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
582
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
583
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
584
                try {
-
 
585
                    return retailerService.getFofoRetailers(true).get(x);
-
 
586
                } catch (ProfitMandiBusinessException e) {
-
 
587
                    // TODO Auto-generated catch block
-
 
588
                    return null;
-
 
589
                }
-
 
590
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
591
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
592
        }
-
 
593
        model.addAttribute("isRBM", isRBM);
-
 
594
 
472
        LOGGER.info("walletSummartList {}", walletSummartList);
595
        LOGGER.info("walletSummartList {}", walletSummartList);
473
        model.addAttribute("startDate", startDate.toLocalDate());
596
        model.addAttribute("startDate", startDate.toLocalDate());
474
        model.addAttribute("endDate", endDate.toLocalDate());
597
        model.addAttribute("endDate", endDate.toLocalDate());
475
        model.addAttribute("walletSummartList", walletSummartList);
598
        model.addAttribute("walletSummartList", walletSummartList);
476
        model.addAttribute("isAdmin", isAdmin);
599
        model.addAttribute("isAdmin", isAdmin);
Line 480... Line 603...
480
 
603
 
481
    @RequestMapping(value = "/pendingIndentReport", method = RequestMethod.GET)
604
    @RequestMapping(value = "/pendingIndentReport", method = RequestMethod.GET)
482
    public String getPendingIndentReport(HttpServletRequest request, Model model) throws Exception {
605
    public String getPendingIndentReport(HttpServletRequest request, Model model) throws Exception {
483
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
606
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
484
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
607
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
-
 
608
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
609
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
610
        boolean isRBM = positions.stream()
-
 
611
                .anyMatch(position ->
-
 
612
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
613
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
614
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
615
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
616
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
617
                try {
-
 
618
                    return retailerService.getFofoRetailers(true).get(x);
-
 
619
                } catch (ProfitMandiBusinessException e) {
-
 
620
                    // TODO Auto-generated catch block
-
 
621
                    return null;
-
 
622
                }
-
 
623
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
624
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
625
        }
-
 
626
        model.addAttribute("isRBM", isRBM);
485
 
627
 
486
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
628
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
487
        LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
629
        LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
488
 
630
 
489
        List<PendingIndentReportModel> pendingIndentReports = fofoOrderRepository
631
        List<PendingIndentReportModel> pendingIndentReports = fofoOrderRepository
Line 511... Line 653...
511
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
653
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
512
        if (startDate == null) {
654
        if (startDate == null) {
513
            startDate = LocalDate.now().minusDays(30);
655
            startDate = LocalDate.now().minusDays(30);
514
            endDate = LocalDate.now();
656
            endDate = LocalDate.now();
515
        }
657
        }
-
 
658
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
659
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
660
        boolean isRBM = positions.stream()
-
 
661
                .anyMatch(position ->
-
 
662
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
663
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
664
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
665
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
666
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
667
                try {
-
 
668
                    return retailerService.getFofoRetailers(true).get(x);
-
 
669
                } catch (ProfitMandiBusinessException e) {
-
 
670
                    // TODO Auto-generated catch block
-
 
671
                    return null;
-
 
672
                }
-
 
673
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
674
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
675
        }
-
 
676
        model.addAttribute("isRBM", isRBM);
-
 
677
 
516
        model.addAttribute("startDate", startDate);
678
        model.addAttribute("startDate", startDate);
517
        model.addAttribute("endDate", endDate);
679
        model.addAttribute("endDate", endDate);
518
        model.addAttribute("isAdmin", isAdmin);
680
        model.addAttribute("isAdmin", isAdmin);
519
        if (isAdmin) {
681
        if (isAdmin) {
520
            if (fofoId == 0) {
682
            if (fofoId == 0) {
Line 591... Line 753...
591
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
753
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
592
        if (startDate == null) {
754
        if (startDate == null) {
593
            startDate = LocalDate.now().minusDays(30);
755
            startDate = LocalDate.now().minusDays(30);
594
            endDate = LocalDate.now();
756
            endDate = LocalDate.now();
595
        }
757
        }
-
 
758
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
759
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
760
        boolean isRBM = positions.stream()
-
 
761
                .anyMatch(position ->
-
 
762
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
763
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
764
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
765
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
766
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
767
                try {
-
 
768
                    return retailerService.getFofoRetailers(true).get(x);
-
 
769
                } catch (ProfitMandiBusinessException e) {
-
 
770
                    // TODO Auto-generated catch block
-
 
771
                    return null;
-
 
772
                }
-
 
773
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
774
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
775
        }
-
 
776
        model.addAttribute("isRBM", isRBM);
596
        model.addAttribute("startDate", startDate);
777
        model.addAttribute("startDate", startDate);
597
        model.addAttribute("endDate", endDate);
778
        model.addAttribute("endDate", endDate);
598
        model.addAttribute("isAdmin", isAdmin);
779
        model.addAttribute("isAdmin", isAdmin);
599
        //LOGGER.info("schemePayoutReports {}", schemePayoutReports);
780
        //LOGGER.info("schemePayoutReports {}", schemePayoutReports);
600
        List<SchemePayoutReportModel> schemePayoutReports = fofoOrderRepository
781
        List<SchemePayoutReportModel> schemePayoutReports = fofoOrderRepository
Line 617... Line 798...
617
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
798
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
618
        if (startDate == null) {
799
        if (startDate == null) {
619
            startDate = LocalDate.now().minusDays(30);
800
            startDate = LocalDate.now().minusDays(30);
620
            endDate = LocalDate.now();
801
            endDate = LocalDate.now();
621
        }
802
        }
-
 
803
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
804
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
805
        boolean isRBM = positions.stream()
-
 
806
                .anyMatch(position ->
-
 
807
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
808
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
809
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
810
            List<Integer> fofoIds = pp.get(authUser.getId());
-
 
811
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
812
                try {
-
 
813
                    return retailerService.getFofoRetailers(true).get(x);
-
 
814
                } catch (ProfitMandiBusinessException e) {
-
 
815
                    // TODO Auto-generated catch block
-
 
816
                    return null;
-
 
817
                }
-
 
818
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
819
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
820
        }
-
 
821
 
-
 
822
        model.addAttribute("isRBM", isRBM);
622
        model.addAttribute("startDate", startDate);
823
        model.addAttribute("startDate", startDate);
623
        model.addAttribute("endDate", endDate);
824
        model.addAttribute("endDate", endDate);
624
        model.addAttribute("isAdmin", isAdmin);
825
        model.addAttribute("isAdmin", isAdmin);
625
 
826
 
626
        LOGGER.info("q {}, starDate - {}, endDate - {}", fofoId, startDate, endDate);
827
        LOGGER.info("q {}, starDate - {}, endDate - {}", fofoId, startDate, endDate);
Line 651... Line 852...
651
 
852
 
652
    @RequestMapping(value = "/offerPayoutReport", method = RequestMethod.GET)
853
    @RequestMapping(value = "/offerPayoutReport", method = RequestMethod.GET)
653
    public String getOfferPayoutReport(HttpServletRequest request, Model model, @RequestParam(required = false) LocalDate startDate, @RequestParam(required = false) LocalDate endDate) throws Exception {
854
    public String getOfferPayoutReport(HttpServletRequest request, Model model, @RequestParam(required = false) LocalDate startDate, @RequestParam(required = false) LocalDate endDate) throws Exception {
654
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
855
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
655
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
856
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
-
 
857
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
858
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
859
        boolean isRBM = positions.stream()
-
 
860
                .anyMatch(position ->
-
 
861
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
862
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
863
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
864
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
865
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
866
                try {
-
 
867
                    return retailerService.getFofoRetailers(true).get(x);
-
 
868
                } catch (ProfitMandiBusinessException e) {
-
 
869
                    // TODO Auto-generated catch block
-
 
870
                    return null;
-
 
871
                }
-
 
872
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
873
            model.addAttribute("customRetailersMap", customRetailersMap);
656
 
874
        }
-
 
875
        model.addAttribute("isRBM", isRBM);
657
        if (startDate == null) {
876
        if (startDate == null) {
658
            startDate = LocalDate.now().minusDays(30);
877
            startDate = LocalDate.now().minusDays(30);
659
            endDate = LocalDate.now();
878
            endDate = LocalDate.now();
660
        }
879
        }
661
        model.addAttribute("startDate", startDate);
880
        model.addAttribute("startDate", startDate);
Line 681... Line 900...
681
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
900
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
682
        if (startDate == null) {
901
        if (startDate == null) {
683
            startDate = LocalDate.now().minusDays(30);
902
            startDate = LocalDate.now().minusDays(30);
684
            endDate = LocalDate.now();
903
            endDate = LocalDate.now();
685
        }
904
        }
-
 
905
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
906
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
907
        boolean isRBM = positions.stream()
-
 
908
                .anyMatch(position ->
-
 
909
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
910
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
911
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
912
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
913
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
914
                try {
-
 
915
                    return retailerService.getFofoRetailers(true).get(x);
-
 
916
                } catch (ProfitMandiBusinessException e) {
-
 
917
                    // TODO Auto-generated catch block
-
 
918
                    return null;
-
 
919
                }
-
 
920
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
921
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
922
        }
-
 
923
        model.addAttribute("isRBM", isRBM);
686
        model.addAttribute("startDate", startDate);
924
        model.addAttribute("startDate", startDate);
687
        model.addAttribute("endDate", endDate);
925
        model.addAttribute("endDate", endDate);
688
        model.addAttribute("isAdmin", isAdmin);
926
        model.addAttribute("isAdmin", isAdmin);
689
        LOGGER.info("q {}, starDate - {}, endDate - {}", fofoId, startDate, endDate);
927
        LOGGER.info("q {}, starDate - {}, endDate - {}", fofoId, startDate, endDate);
690
        if (isAdmin) {
928
        if (isAdmin) {
Line 740... Line 978...
740
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
978
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
741
        if (startDate == null) {
979
        if (startDate == null) {
742
            startDate = LocalDate.now().minusDays(30);
980
            startDate = LocalDate.now().minusDays(30);
743
            endDate = LocalDate.now();
981
            endDate = LocalDate.now();
744
        }
982
        }
-
 
983
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
984
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
985
        boolean isRBM = positions.stream()
-
 
986
                .anyMatch(position ->
-
 
987
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
988
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
989
        if (pp.containsKey(authUser.getId())) {
-
 
990
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
991
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
992
                try {
-
 
993
                    return retailerService.getFofoRetailer(x);
-
 
994
                } catch (ProfitMandiBusinessException e) {
-
 
995
                    // TODO Auto-generated catch block
-
 
996
                    return null;
-
 
997
                }
-
 
998
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
999
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
1000
        }
-
 
1001
 
-
 
1002
        model.addAttribute("isRBM", isRBM);
745
        model.addAttribute("startDate", startDate);
1003
        model.addAttribute("startDate", startDate);
746
        model.addAttribute("endDate", endDate);
1004
        model.addAttribute("endDate", endDate);
747
        model.addAttribute("isAdmin", isAdmin);
1005
        model.addAttribute("isAdmin", isAdmin);
748
        List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
1006
        List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
749
                startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
1007
                startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
Line 764... Line 1022...
764
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
1022
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
765
        if (startDate == null) {
1023
        if (startDate == null) {
766
            startDate = LocalDate.now().minusDays(30);
1024
            startDate = LocalDate.now().minusDays(30);
767
            endDate = LocalDate.now();
1025
            endDate = LocalDate.now();
768
        }
1026
        }
-
 
1027
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
-
 
1028
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
1029
        boolean isRBM = positions.stream()
-
 
1030
                .anyMatch(position ->
-
 
1031
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
1032
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
1033
        if (pp.containsKey(authUser.getId())) {
-
 
1034
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
1035
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
1036
                try {
-
 
1037
                    return retailerService.getFofoRetailer(x);
-
 
1038
                } catch (ProfitMandiBusinessException e) {
-
 
1039
                    // TODO Auto-generated catch block
-
 
1040
                    return null;
-
 
1041
                }
-
 
1042
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
1043
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
1044
        }
-
 
1045
 
-
 
1046
        model.addAttribute("isRBM", isRBM);
769
        model.addAttribute("startDate", startDate);
1047
        model.addAttribute("startDate", startDate);
770
        model.addAttribute("endDate", endDate);
1048
        model.addAttribute("endDate", endDate);
771
        model.addAttribute("isAdmin", isAdmin);
1049
        model.addAttribute("isAdmin", isAdmin);
772
        if (isAdmin) {
1050
        if (isAdmin) {
773
            if (fofoId == 0) {
1051
            if (fofoId == 0) {
Line 1063... Line 1341...
1063
                                   @RequestParam(required = false) LocalDate endDate)
1341
                                   @RequestParam(required = false) LocalDate endDate)
1064
            throws Exception {
1342
            throws Exception {
1065
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1343
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1066
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1344
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1067
 
1345
 
-
 
1346
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
1347
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
1348
        boolean isRBM = positions.stream()
-
 
1349
                .anyMatch(position ->
-
 
1350
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
1351
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
1352
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
1353
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
-
 
1354
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
-
 
1355
                try {
-
 
1356
                    return retailerService.getFofoRetailers(true).get(x);
-
 
1357
                } catch (ProfitMandiBusinessException e) {
-
 
1358
                    // TODO Auto-generated catch block
-
 
1359
                    return null;
-
 
1360
                }
-
 
1361
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
1362
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
1363
        }
-
 
1364
 
1068
        model.addAttribute("isAdmin", isAdmin);
1365
        model.addAttribute("isAdmin", isAdmin);
-
 
1366
        model.addAttribute("isRBM", isRBM);
1069
 
1367
 
1070
        return "partner-account-statement";
1368
        return "partner-account-statement";
1071
 
1369
 
1072
    }
1370
    }
1073
 
1371
 
Line 1136... Line 1434...
1136
    @RequestMapping(value = "/loan/loan-statement", method = RequestMethod.GET)
1434
    @RequestMapping(value = "/loan/loan-statement", method = RequestMethod.GET)
1137
    public String loanStatement(HttpServletRequest request, Model model)
1435
    public String loanStatement(HttpServletRequest request, Model model)
1138
            throws Exception {
1436
            throws Exception {
1139
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1437
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1140
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1438
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
-
 
1439
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
-
 
1440
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
-
 
1441
        boolean isRBM = positions.stream()
-
 
1442
                .anyMatch(position ->
-
 
1443
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
-
 
1444
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
1445
        if (isRBM && pp.containsKey(authUser.getId())) {
-
 
1446
            List<Integer> fofoIds = pp.get(authUser.getId());
-
 
1447
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(fofoId -> {
-
 
1448
                try {
-
 
1449
                    return retailerService.getFofoRetailers(true).get(fofoId);
-
 
1450
                } catch (ProfitMandiBusinessException e) {
-
 
1451
                    // TODO Auto-generated catch block
-
 
1452
                    return null;
-
 
1453
                }
-
 
1454
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
1455
            model.addAttribute("customRetailersMap", customRetailersMap);
1141
 
1456
        }
-
 
1457
        model.addAttribute("isRBM", isRBM);
1142
        model.addAttribute("isAdmin", isAdmin);
1458
        model.addAttribute("isAdmin", isAdmin);
1143
 
1459
 
1144
        return "partner-loan-statement";
1460
        return "partner-loan-statement";
1145
 
1461
 
1146
    }
1462
    }