PageSourceSearch

https://cdkarportal.com/js/reports/DealerDailyPaidReportCtrl.js

js cdkarportal.com collected 2026-10-07 20:57:11 UTC 6,044 bytes, 146 lines download raw bytes

1angular.module('arPortal').controller('DealerDailyPaidReportCtrl',
2    ['$scope', 'ReportsSvc', 'GridSvc', 'overUnderPaidGridData', /*'startDate',*/ '$location', '$route', 'csvService',
3    function($scope, ReportsSvc, GridSvc, overUnderPaidGridData, /*startDate,*/ $location, $route, csvService) {
4      var startDate = ReportsSvc.startDate;
5      $scope.csvService = csvService;
6      $scope.allItems = [];
7      $scope.detailsViewData = {};
8      $scope.detailsViewData.totalPaid = null;
9
10      $scope.paidItems = [];
11
12      function parsePaidItems(gridData) {
13        angular.forEach(gridData, function(item) {
14          var aggregateItem = {};
15          aggregateItem.portalCustomerName = item.portalCustomerName;
16          aggregateItem.customerNumber = item.customerAccountControlNumber;
17          aggregateItem.oldCustomerNumber = item.oldCustomerAccountControlNumber;
18          aggregateItem.customerAccountName = item.customerAccountName;
19          aggregateItem.userName = item.paymentTransactionUserFirstName + ' ' + item.paymentTransactionUserLastName;
20          aggregateItem.userPhone = item.paymentTransactionUserPhone;
21          aggregateItem.userEmail = item.paymentTransactionUserEmail;
22
23          aggregateItem.datePaid = item.paymentTransactionCreated; // invoiceDate,statementDate
24          aggregateItem.confirmationNumber = item.paymentTransactionReferenceNumber;
25          aggregateItem.invoiceNumber = item.invoiceRemoteId;
26          aggregateItem.amountPaid = item.paymentTransactionItemAmount;
27
28          $scope.paidItems.push(aggregateItem);
29        });
30      }
31
32      function filterInvoicesByStartDate() {
33            // Remove out of range invoices
34        var filteredInvoices = [];
35        angular.forEach($scope.allItems, function(item) {
36          if (item && item.datePaid) {
37                    // Paid-Over-Under invoice
38            var invoiceDate = new Date(item.datePaid).setHours(0, 0, 0, 0);
39            var searchDate = new Date(startDate).setHours(0, 0, 0, 0);
40
41            if (invoiceDate == searchDate) {
42              filteredInvoices.push(item);
43            }
44          }
45          else {
46                    // Disputed invoice
47            filteredInvoices.push(item);
48          }
49        });
50        $scope.allItems = filteredInvoices;
51      }
52
53      function processInvoiceItems() {
54        parsePaidItems(overUnderPaidGridData);
55        if ($scope.paidItems.length >= 1) {
56          pushItems($scope.allItems, $scope.paidItems);
57        }
58
59        filterInvoicesByStartDate();
60        if ($scope.allItems.length >= 1) {
61          $scope.detailsViewData.totalPaid = calcTotal($scope.allItems);
62        }
63      }
64
65      processInvoiceItems();
66
67      function pushItems(arry, items) {
68        for (var i = 0; i < items.length; i++) {
69          var item = items[i];
70          arry.push(item);
71        }
72      }
73
74      function calcTotal(items) {
75        Math.round = (function() {
76          var originalRound = Math.round;
77          return function(number, precision) {
78            precision = Math.abs(parseInt(precision)) || 0;
79            var multiplier = Math.pow(10, precision);
80            return (originalRound(number * multiplier) / multiplier);
81          };
82        })();
83
84        var total = 0.00;
85        if (typeof items === 'undefined' || items === null) { return total; }
86        for (var i = 0; i < items.length; i++) {
87          total += items[i].amountPaid;
88        }
89        return Math.round(total, 2);
90      }
91
92      $scope.fetchCsv = function() {
93        ReportsSvc.fetchPaidInvoicesWithTotalCsv(
94                $route.current.params.dealerId,
95                $route.current.params.startDate,
96                $route.current.params.endDate,
97                $route.current.params.portalCustomers,
98                $route.current.params.customerAccounts
99            );
100      };
101
102      var dateCellTemplate = '<div class="ngCellText" style="text-align:center;">{{row.getProperty(col.field) | date:"MM/dd/yyyy"}}</div>';
103      var amountCellTemplate = '<div class="ngCellText" style="text-align:right;">{{row.getProperty(col.field) | currency}}</div>';
104
105      var columnDefs = [
106            {field: 'portalCustomerName', displayName: 'AR Portal <br>Customer Name', headerClass: 'grid-header-center'},
107            {field: 'customerNumber', displayName: 'Customer <br>Account #', headerClass: 'grid-header-center'},
108            {field: 'oldCustomerNumber', displayName: 'Old Customer <br>Account #', headerClass: 'grid-header-center'},
109            {field: 'customerAccountName', displayName: 'Customer <br>Account Name', headerClass: 'grid-header-center'},
110            {field: 'datePaid', displayName: 'Date Paid', headerClass: 'grid-header-center', cellTemplate: dateCellTemplate, cellFilter: 'date:"MM/dd/yyyy"'},
111            {field: 'confirmationNumber', displayName: 'Transaction ID', headerClass: 'grid-header-center'},
112            {field: 'invoiceNumber', displayName: 'Invoice #', headerClass: 'grid-header-center'},
113            {field: 'amountPaid', displayName: 'Amount Paid', headerClass: 'grid-header-center', cellTemplate: amountCellTemplate}
114      ];
115
116      $scope.gridOptions = GridSvc.config($scope, $scope.allItems, columnDefs)
117            .withScopeOpts({
118              headerRowHeight: 60,
119              pagingOptions: {pageSizes: [25, 50, 100, 200], pageSize: 50, currentPage: 1}
120            })
121            .build();
122      GridSvc.initWatches($scope);
123
124        // CIARP-130
125        // Begin code to support client-side csv
126
127      var renderCsv = csvService.getRender(columnDefs);
128      var totalsLine = {
129        cells: [
130            ['string', 'Total Paid:'],
131            ['currency', $scope.detailsViewData.totalPaid]
132        ],
133        align: 'right'
134      };
135      var customLines = [totalsLine];
136      renderCsv($scope.allItems, customLines);
137
138        // End code to support client-side csv
139
140        /**
141         * FIXME
142         */
143      $scope.returnToSetup = function() {
144        $location.url('/reports/dealer/dailypaidreportsetup');
145      };
146    }]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.