1angular.module('MoonrockApps') 2.factory("APARDashboardFactory", function($resource, $q) { 3 4 return { 5 api: $resource('/api/export/:_id', { id: '@_id' }, { 6 'getAPDraftCount': { 7 url: '/api/apar.dash.ap.draft/:company/:consultant', 8 isArray: false, 9 method: 'GET' 10 }, 11 'getAPSubmittedCount': { 12 url: '/api/apar.dash.ap.submitted/:company/:consultant', 13 isArray: false, 14 method: 'GET' 15 }, 16 'getAPRejectedCount': { 17 url: '/api/apar.dash.ap.rejected/:company/:consultant', 18 isArray: false, 19 method: 'GET' 20 }, 21 'getAPProcessCount': { 22 url: '/api/apar.dash.ap.process/:company/:consultant', 23 isArray: false, 24 method: 'GET' 25 }, 26 'getAPPayCount': { 27 url: '/api/apar.dash.ap.pay/:company/:consultant', 28 isArray: false, 29 method: 'GET' 30 }, 31 'getAPExportCount': { 32 url: '/api/apar.dash.ap.export/:company/:consultant', 33 isArray: false, 34 method: 'GET' 35 }, 36 'getARExportCount': { 37 url: '/api/apar.dash.ar.export/:company/:consultant', 38 isArray: false, 39 method: 'GET' 40 }, 41 'getRecentAPInvoices': { 42 url: '/api/apar.dash.ap.recent/:company/:consultant', 43 isArray: true, 44 method: 'GET' 45 }, 46 'getRecentARInvoices': { 47 url: '/api/apar.dash.ar.recent/:company/:consultant', 48 isArray: true, 49 method: 'GET' 50 }, 51 'compareAPARInvoices': { 52 url: '/api/apar.dash.datapoint.invoice/:company', 53 isArray: true, 54 method: 'GET' 55 }, 56 'consultantAPInvoices': { 57 url: '/api/apar.dash.datapoint.apinvoice/:company/:consultant', 58 isArray: true, 59 method: 'GET' 60 } 61 }), 62 63 testFn: function () { 64 var deferred = $q.defer(); 65 this.api.query().$promise 66 .then(function(items) { 67 console.log('*** total items: ' + items.length.toString()); 68 deferred.resolve('*** total items: ' + items.length.toString()); 69 }) 70 .catch(function(response) { 71 console.log(response); 72 deferred.reject(response); 73 }); 74 return deferred.promise; 75 }, 76 77 getAPARDataPoints: function(company) { 78 var deferred = $q.defer(); 79 this.api.compareAPARInvoices({ company: company }).$promise 80 .then(function(result) { 81 var labels = []; 82 var series = ['AP Total', 'AR Total']; 83 var arData = []; 84 var apData = []; 85 var datapoints = result.slice(-12); 86 87 datapoints.forEach(function(item) { 88 labels.push(item.arDate); 89 arData.push(item.artotal); 90 apData.push(item.aptotal); 91 }); 92 93 deferred.resolve({ series: series, labels: labels, data: [apData, arData] }); 94 }) 95 .catch(function(response) { 96 console.log(response); 97 deferred.reject(response); 98 }); 99 return deferred.promise; 100 }, 101 102 getConsultantDataPoints: function(company, consultant) { 103 var deferred = $q.defer(); 104 this.api.consultantAPInvoices({ company: company, consultant: consultant }).$promise 105 .then(function(result) { 106 var labels = []; 107 var series = ['AP Total']; 108 var apData = []; 109 var datapoints = result; //result.slice(-12); 110 111 datapoints.forEach(function(item) { 112 labels.push(item.date); 113 apData.push(item.total); 114 }); 115 116 deferred.resolve({ series: series, labels: labels, data: [apData] }); 117 }) 118 .catch(function(response) { 119 console.log(response); 120 deferred.reject(response); 121 }); 122 return deferred.promise; 123 } 124 125 126 }; 127});
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.