Subversion Repositories SmartDukaan

Rev

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

Rev 33814 Rev 33815
Line 365... Line 365...
365
            throws Exception {
365
            throws Exception {
366
 
366
 
367
        List<List<?>> rows = new ArrayList<>();
367
        List<List<?>> rows = new ArrayList<>();
368
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
368
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
369
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
369
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
-
 
370
        float openingBalance = 0;
-
 
371
        float openingPendingAmount = 0;
370
        List<WalletSummaryReportModel> walletSummartList = null;
372
        List<WalletSummaryReportModel> walletSummartList = null;
371
        if (isAdmin) {
373
        if (isAdmin) {
372
            if (fofoId == 0)
374
            if (fofoId == 0)
373
                walletSummartList = new ArrayList<>();
375
                walletSummartList = new ArrayList<>();
374
            else
376
            else
-
 
377
 
375
                walletSummartList = fofoOrderRepository.selectWalletSummaryReport(
378
                walletSummartList = fofoOrderRepository.selectWalletSummaryReport(
376
                        fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
379
                        fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
-
 
380
            openingBalance = walletService.getOpeningTill(fofoId, startDate.atStartOfDay());
-
 
381
            Map<Integer, Float> openingAmountMap = transactionService.getPendingIndentValueMap(startDate.atStartOfDay(), Optional.of(fofoId));
-
 
382
            openingPendingAmount = openingAmountMap.get(fofoId) == null ? 0 : openingAmountMap.get(fofoId);
-
 
383
 
377
        } else {
384
        } else {
378
 
385
 
379
            walletSummartList = fofoOrderRepository.selectWalletSummaryReport(
386
            walletSummartList = fofoOrderRepository.selectWalletSummaryReport(
380
                    fofoDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
387
                    fofoDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
-
 
388
 
-
 
389
 
381
        }
390
        }
-
 
391
 
382
        LOGGER.info("walletSummartList {}", fofoId);
392
        LOGGER.info("walletSummartList {}", fofoId);
383
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
393
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
384
        String partnerDetail = null;
394
        String partnerDetail = null;
385
 
-
 
-
 
395
// Headers for the table data
-
 
396
        rows.add(Arrays.asList("Id", "Amount", "Refundable_amount", "Reference", "Reference_type", "Running Balance", "Business_timestamp", "Description"));
386
        for (WalletSummaryReportModel walletSummary : walletSummartList) {
397
        for (WalletSummaryReportModel walletSummary : walletSummartList) {
387
            partnerDetail = walletSummary.getName() + "(" + walletSummary.getCode() + "-" + walletSummary.getPhone() + ")" + "-" + walletSummary.getEmail();
398
            partnerDetail = walletSummary.getName() + "(" + walletSummary.getCode() + "-" + walletSummary.getPhone() + ")" + "-" + walletSummary.getEmail();
388
 
399
 
389
            rows.add(Arrays.asList(
400
            rows.add(Arrays.asList(
390
                    walletSummary.getId(),
401
                    walletSummary.getId(),
391
                    //walletSummary.getCode(),
-
 
392
                    //walletSummary.getName(),
-
 
393
                    //walletSummary.getEmail(),
-
 
394
                    //walletSummary.getPhone(),
-
 
395
                    walletSummary.getAmount(),
402
                    walletSummary.getAmount(),
396
                    walletSummary.getRefundableAmount(),
403
                    walletSummary.getRefundableAmount(),
397
                    walletSummary.getReference(),
404
                    walletSummary.getReference(),
398
                    walletSummary.getReferenceType(),
405
                    walletSummary.getReferenceType(),
399
                    FormattingUtils.format(walletSummary.getBusinessTimestamp()),
406
                    openingBalance + walletSummary.getAmount(),
-
 
407
                    FormattingUtils.format(walletSummary.getBusinessTimestamp() != null ? walletSummary.getBusinessTimestamp() : walletSummary.getTimestamp()),
400
                    walletSummary.getDescription()
408
                    walletSummary.getDescription()
401
            ));
409
            ));
402
 
410
 
403
        }
411
        }
404
 
412
 
-
 
413
 
-
 
414
        float openingBalanceWithOpeningPendingAmount = openingPendingAmount + openingBalance;
405
        org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
415
        org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
406
                .getCSVByteStream(Arrays.asList("Id",
-
 
407
//						"Code",
-
 
408
//						"Name",
-
 
409
//						"Email",
-
 
410
//						"Phone",
-
 
411
                        "Amount", "Refundable_amount",
-
 
412
                        "Reference", "Reference_type", "Business_timestamp", "Description"), rows);
416
                .getCSVByteStream(Arrays.asList("Opening Balance" + openingBalanceWithOpeningPendingAmount), rows);
413
        ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, partnerDetail + " Wallet Statement Report");
417
        ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, partnerDetail + " Wallet Statement Report");
414
 
418
 
415
        return responseEntity;
419
        return responseEntity;
416
 
420
 
417
    }
421
    }
Line 435... Line 439...
435
                //No need to send any data
439
                //No need to send any data
436
                model.addAttribute("walletSummartList", new ArrayList<>());
440
                model.addAttribute("walletSummartList", new ArrayList<>());
437
 
441
 
438
                return "wallet-summary-report";
442
                return "wallet-summary-report";
439
            } else {
443
            } else {
-
 
444
                float openingBalance = walletService.getOpeningTill(fofoId, startDate.atStartOfDay());
-
 
445
                Map<Integer, Float> openingAmountMap = transactionService.getPendingIndentValueMap(startDate.atStartOfDay(), Optional.of(fofoId));
-
 
446
                float openingPendingAmount = openingAmountMap.get(fofoId) == null ? 0 : openingAmountMap.get(fofoId);
-
 
447
 
440
                List<WalletSummaryReportModel> walletSummartList = fofoOrderRepository
448
                List<WalletSummaryReportModel> walletSummartList = fofoOrderRepository
441
                        .selectWalletSummaryReport(fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
449
                        .selectWalletSummaryReport(fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
442
                model.addAttribute("walletSummartList", walletSummartList);
450
                model.addAttribute("walletSummartList", walletSummartList);
-
 
451
                model.addAttribute("openingBalance", (openingBalance + openingPendingAmount));
443
 
452
 
444
                return "wallet-summary-report";
453
                return "wallet-summary-report";
445
            }
454
            }
446
 
455
 
447
        } else {
456
        } else {