fleetmap-reports 1.0.393 → 1.0.398
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -5
- package/src/index.test.js +340 -328
- package/src/refueling-report.js +149 -147
- package/src/speeding-report.js +112 -111
- package/src/tests/index.js +14 -16
- package/src/util/utils.js +151 -153
- package/src/zone-report.js +6 -5
package/src/index.test.js
CHANGED
|
@@ -1,330 +1,342 @@
|
|
|
1
|
-
const {getReports} = require(
|
|
2
|
-
const assert = require(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
1
|
+
const { getReports } = require('./tests')
|
|
2
|
+
const assert = require('assert')
|
|
3
|
+
|
|
4
|
+
async function getSpeedingReport (report, userData) {
|
|
5
|
+
const data = await report.speedingReport(
|
|
6
|
+
new Date(Date.UTC(2021, 11, 6, 0, 0, 0, 0)),
|
|
7
|
+
new Date(Date.UTC(2021, 11, 8, 23, 59, 59, 0)),
|
|
8
|
+
userData)
|
|
9
|
+
assert.equal(data.length, 1)
|
|
10
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
11
|
+
const totalDistance = device.alerts.reduce((a, b) => a + b.distance, 0)
|
|
12
|
+
const totalEventTime = device.alerts.reduce((a, b) => a + b.eventTime, 0)
|
|
13
|
+
return { device, totalDistance, totalEventTime }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line no-undef
|
|
17
|
+
describe('Test_Reports', function () {
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
19
|
+
it('Speeding by device', async () => {
|
|
20
|
+
const report = await getReports()
|
|
21
|
+
const userData = await report.getUserData()
|
|
22
|
+
const { device, totalDistance, totalEventTime } = await getSpeedingReport(report, userData)
|
|
23
|
+
assert.equal(device.alerts.length, 15) // Total Alerts
|
|
24
|
+
assert.equal(totalDistance, 19.59984677533689) // Total Kms
|
|
25
|
+
assert.equal(totalEventTime, 562000) // Total Duration
|
|
26
|
+
}, 200000)
|
|
27
|
+
// eslint-disable-next-line no-undef
|
|
28
|
+
it('Speeding by device with custom speed', async () => {
|
|
29
|
+
const report = await getReports()
|
|
30
|
+
const userData = await report.getUserData()
|
|
31
|
+
|
|
32
|
+
userData.useVehicleSpeedLimit = false
|
|
33
|
+
userData.customSpeed = 100
|
|
34
|
+
const { device, totalDistance, totalEventTime } = await getSpeedingReport(report, userData)
|
|
35
|
+
assert.equal(device.alerts.length, 24) // Total Alerts
|
|
36
|
+
assert.equal(totalDistance, 49.481065231791064) // Total Kms
|
|
37
|
+
assert.equal(totalEventTime, 1523000) // Total Duration
|
|
38
|
+
}, 20000)
|
|
39
|
+
// eslint-disable-next-line no-undef
|
|
40
|
+
it('Trip by device', async () => {
|
|
41
|
+
const report = await getReports()
|
|
42
|
+
const userData = await report.getUserData()
|
|
43
|
+
|
|
44
|
+
const data = await report.tripReport(new Date(2022, 0, 3, 0, 0, 0, 0),
|
|
45
|
+
new Date(2022, 0, 4, 23, 59, 59, 0),
|
|
46
|
+
userData)
|
|
47
|
+
|
|
48
|
+
assert.equal(data.length, 1)
|
|
49
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
50
|
+
assert.equal(device.trips.length, 7) // Total Trips
|
|
51
|
+
assert.equal(device.totalDistance, 339204.53999999166) // Total Kms
|
|
52
|
+
}, 20000)
|
|
53
|
+
// eslint-disable-next-line no-undef
|
|
54
|
+
it('Trip 2 by device', async () => {
|
|
55
|
+
const report = await getReports()
|
|
56
|
+
const userData = await report.getUserData()
|
|
57
|
+
userData.devices = userData.devices.filter(d => d.id === 11437)
|
|
58
|
+
|
|
59
|
+
const data = await report.tripReport(
|
|
60
|
+
new Date(Date.UTC(2022, 2, 4, 0, 0, 0, 0)),
|
|
61
|
+
new Date(Date.UTC(2022, 2, 4, 23, 59, 59, 0)),
|
|
62
|
+
userData)
|
|
63
|
+
|
|
64
|
+
assert.equal(data.length, 1)
|
|
65
|
+
const device = data[0].devices.find(d => d.device.id === 11437)
|
|
66
|
+
assert.equal(device.trips.length, 5) // Total Trips
|
|
67
|
+
assert.equal(device.totalDistance, 207353.2299999997) // Total Kms
|
|
68
|
+
}, 20000)
|
|
69
|
+
// eslint-disable-next-line no-undef
|
|
70
|
+
it('Trip by device with time period ', async () => {
|
|
71
|
+
const report = await getReports()
|
|
72
|
+
const userData = await report.getUserData()
|
|
73
|
+
|
|
74
|
+
userData.allWeek = false
|
|
75
|
+
userData.weekDays = {
|
|
76
|
+
sunday: true,
|
|
77
|
+
monday: true,
|
|
78
|
+
tuesday: true,
|
|
79
|
+
wednesday: true,
|
|
80
|
+
thursday: true,
|
|
81
|
+
friday: true,
|
|
82
|
+
saturday: true
|
|
83
|
+
}
|
|
84
|
+
userData.dayHours = {
|
|
85
|
+
startTime: '15:00',
|
|
86
|
+
endTime: '19:00'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const data = await report.tripReport(
|
|
90
|
+
new Date(Date.UTC(2022, 0, 3, 0, 0, 0, 0)),
|
|
91
|
+
new Date(Date.UTC(2022, 0, 4, 23, 59, 59, 0)),
|
|
92
|
+
userData)
|
|
93
|
+
|
|
94
|
+
assert.equal(data.length, 1)
|
|
95
|
+
// const device = data[0].devices.find(d => d.device.id === 22326)
|
|
96
|
+
// assert.equal(device.trips.length, 1) // Total Trips
|
|
97
|
+
// assert.equal(device.totalDistance, 172190.92999999225) // Total Kms
|
|
98
|
+
}, 20000)
|
|
99
|
+
// eslint-disable-next-line no-undef
|
|
100
|
+
it('Trip by device with time period 2', async () => {
|
|
101
|
+
const report = await getReports()
|
|
102
|
+
const userData = await report.getUserData()
|
|
103
|
+
|
|
104
|
+
userData.allWeek = false
|
|
105
|
+
userData.weekDays = {
|
|
106
|
+
sunday: true,
|
|
107
|
+
monday: true,
|
|
108
|
+
tuesday: true,
|
|
109
|
+
wednesday: true,
|
|
110
|
+
thursday: true,
|
|
111
|
+
friday: true,
|
|
112
|
+
saturday: true
|
|
113
|
+
}
|
|
114
|
+
userData.dayHours = {
|
|
115
|
+
startTime: '18:00',
|
|
116
|
+
endTime: '09:00'
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const data = await report.tripReport(
|
|
120
|
+
new Date(Date.UTC(2022, 0, 10, 0, 0, 0, 0)),
|
|
121
|
+
new Date(Date.UTC(2022, 0, 14, 23, 59, 59, 0)),
|
|
122
|
+
userData)
|
|
123
|
+
|
|
124
|
+
assert.equal(data.length, 1)
|
|
125
|
+
/* const device = data[0].devices.find(d => d.device.id === 22326)
|
|
126
|
+
assert.equal(device.trips.length, 22) // Total Trips
|
|
127
|
+
assert.equal(device.totalDistance, 214334.7800000161) // Total Kms */
|
|
128
|
+
}, 20000)
|
|
129
|
+
// eslint-disable-next-line no-undef
|
|
130
|
+
it('Location by device', async () => {
|
|
131
|
+
const report = await getReports()
|
|
132
|
+
const userData = await report.getUserData()
|
|
133
|
+
|
|
134
|
+
const data = await report.locationReport(
|
|
135
|
+
new Date(Date.UTC(2022, 0, 4, 0, 0, 0, 0)),
|
|
136
|
+
new Date(Date.UTC(2022, 0, 4, 23, 59, 59, 0)),
|
|
137
|
+
userData)
|
|
138
|
+
|
|
139
|
+
assert.equal(data.length, 1)
|
|
140
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
141
|
+
assert.equal(device.positions.length, 708) // Total Positions
|
|
142
|
+
}, 20000)
|
|
143
|
+
// eslint-disable-next-line no-undef
|
|
144
|
+
it('Location by driver', async () => {
|
|
145
|
+
const report = await getReports()
|
|
146
|
+
const userData = await report.getUserData()
|
|
147
|
+
userData.byDriver = true
|
|
148
|
+
const data = await report.locationReport(new Date(2021, 11, 6, 0, 0, 0, 0),
|
|
149
|
+
new Date(2021, 11, 9, 23, 59, 59, 0),
|
|
150
|
+
userData)
|
|
151
|
+
|
|
152
|
+
assert.equal(data.length, 1)
|
|
153
|
+
const driver = data[0].drivers.find(d => d.driver.id === 14020)
|
|
154
|
+
assert.equal(driver.positions.length, 85) // Total Positions
|
|
155
|
+
}, 20000)
|
|
156
|
+
// eslint-disable-next-line no-undef
|
|
157
|
+
it('KmsReport by device', async () => {
|
|
158
|
+
const reports = await getReports()
|
|
159
|
+
const userData = await reports.getUserData()
|
|
160
|
+
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
161
|
+
const data = await reports.kmsReport(new Date(2021, 10, 1, 0, 0, 0), new Date(2021, 10, 31, 23, 59, 59),
|
|
162
|
+
userData)
|
|
163
|
+
assert.equal(data.length, 1)
|
|
164
|
+
assert.equal(data.length, 1)
|
|
165
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
166
|
+
assert.equal(device.summary.distance, 1193284.3100000024) // Total Kms
|
|
167
|
+
}, 30000)
|
|
168
|
+
// eslint-disable-next-line no-undef
|
|
169
|
+
it('KmsReport byDevice groupByDay', async () => {
|
|
170
|
+
const reports = await getReports()
|
|
171
|
+
const userData = await reports.getUserData()
|
|
172
|
+
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
173
|
+
userData.groupByDay = true
|
|
174
|
+
const data = await reports.kmsReport(new Date(2021, 10, 1, 0, 0, 0), new Date(2021, 10, 10, 23, 59, 59),
|
|
175
|
+
userData)
|
|
176
|
+
assert.equal(data.length, 1)
|
|
177
|
+
assert.equal(data.length, 1)
|
|
178
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
179
|
+
assert.equal(device.days.length, 10) // Total Kms
|
|
180
|
+
assert.equal(device.days[5].kms, 23183.010000005364) // Total Kms
|
|
181
|
+
}, 30000)
|
|
182
|
+
// eslint-disable-next-line no-undef
|
|
183
|
+
it('Idle by device', async () => {
|
|
184
|
+
const report = await getReports()
|
|
185
|
+
const userData = await report.getUserData()
|
|
186
|
+
userData.minimumIdleMinutes = 2
|
|
187
|
+
const data = await report.idleReport(new Date(2022, 0, 3, 0, 0, 0, 0),
|
|
188
|
+
new Date(2022, 0, 7, 23, 59, 59, 0),
|
|
189
|
+
userData)
|
|
190
|
+
assert.equal(data.length, 1)
|
|
191
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
192
|
+
const totalIdleTime = device.idleEvents.reduce((a, b) => a + b.idleTime, 0)
|
|
193
|
+
assert.equal(device.idleEvents.length, 8) // Total Alerts
|
|
194
|
+
assert.equal(totalIdleTime, 1294000) // Total Duration
|
|
195
|
+
}, 20000)
|
|
196
|
+
// eslint-disable-next-line no-undef
|
|
197
|
+
it('Activity by device', async () => {
|
|
198
|
+
const report = await getReports()
|
|
199
|
+
const userData = await report.getUserData()
|
|
200
|
+
|
|
201
|
+
const data = await report.activityReport(new Date(2022, 0, 1, 0, 0, 0, 0),
|
|
202
|
+
new Date(2022, 0, 31, 23, 59, 59, 0),
|
|
203
|
+
userData)
|
|
204
|
+
assert.equal(data.length, 1)
|
|
205
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
206
|
+
assert.equal(device.summary[0].startOdometer, 122502742.59)
|
|
207
|
+
assert.equal(device.summary[0].distance, 1423529.600000009)
|
|
208
|
+
assert.equal(device.summary[0].startTime, '2022-01-01T13:35:47.000+0000')
|
|
209
|
+
assert.equal(device.summary[0].endTime, '2022-01-31T17:36:27.000+0000')
|
|
210
|
+
}, 40000)
|
|
211
|
+
// eslint-disable-next-line no-undef
|
|
212
|
+
it('Activity 2 by device', async () => {
|
|
213
|
+
const report = await getReports()
|
|
214
|
+
const userData = await report.getUserData()
|
|
215
|
+
userData.devices = userData.devices.filter(d => d.id === 11437)
|
|
216
|
+
const data = await report.activityReport(new Date(Date.UTC(2022, 2, 5, 0, 0, 0, 0)),
|
|
217
|
+
new Date(Date.UTC(2022, 2, 5, 23, 59, 59, 0)),
|
|
218
|
+
userData)
|
|
219
|
+
assert.equal(data.length, 1)
|
|
220
|
+
const device = data[0].devices.find(d => d.device.id === 11437)
|
|
221
|
+
assert.equal(device.summary[0].endTime, '2022-03-05T23:59:55.000+0000')
|
|
222
|
+
assert.equal(device.summary[0].distance, 232925.12000000034)
|
|
223
|
+
}, 40000)
|
|
224
|
+
// eslint-disable-next-line no-undef
|
|
225
|
+
it('Activity byDevice groupByDay', async () => {
|
|
226
|
+
const report = await getReports()
|
|
227
|
+
const userData = await report.getUserData()
|
|
228
|
+
userData.groupByDay = true
|
|
229
|
+
const data = await report.activityReport(new Date(2022, 0, 1, 0, 0, 0, 0),
|
|
230
|
+
new Date(2022, 0, 20, 23, 59, 59, 0),
|
|
231
|
+
userData)
|
|
232
|
+
assert.equal(data.length, 1)
|
|
233
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
234
|
+
assert.equal(device.summary[5].startOdometer, 122923290.95)
|
|
235
|
+
assert.equal(device.summary[5].distance, 77020.37999999523)
|
|
236
|
+
assert.equal(device.summary[5].startTime, '2022-01-06T18:35:04.000+0000')
|
|
237
|
+
assert.equal(device.summary[5].endTime, '2022-01-06T19:54:27.000+0000')
|
|
238
|
+
}, 90000)
|
|
239
|
+
// eslint-disable-next-line no-undef
|
|
240
|
+
it('test allinone', async () => {
|
|
241
|
+
console.log('Start')
|
|
242
|
+
const reports = await getReports()
|
|
243
|
+
const userData = await reports.getUserData()
|
|
244
|
+
const r = await require('./util/traccar').getAllInOne(reports.traccar,
|
|
245
|
+
new Date(2022, 1, 1, 0, 0, 0, 0),
|
|
246
|
+
new Date(2022, 1, 4, 23, 59, 59, 0),
|
|
247
|
+
userData.devices,
|
|
248
|
+
false,
|
|
249
|
+
true,
|
|
250
|
+
true,
|
|
251
|
+
false)
|
|
252
|
+
|
|
253
|
+
assert.equal(r.trips.filter(t => t.deviceId === 22327).length, 20)
|
|
254
|
+
assert.equal(r.stops.filter(t => t.deviceId === 22327).length, 21)
|
|
255
|
+
}, 20000)
|
|
256
|
+
// eslint-disable-next-line no-undef
|
|
257
|
+
it('Total KMS', async () => {
|
|
258
|
+
const report = await getReports()
|
|
259
|
+
const userData = await report.getUserData()
|
|
260
|
+
|
|
261
|
+
const tripsReport = await report.tripReport(
|
|
262
|
+
new Date(Date.UTC(2022, 1, 11, 0, 0, 0, 0)),
|
|
263
|
+
new Date(Date.UTC(2022, 1, 14, 23, 59, 59, 0)),
|
|
264
|
+
userData)
|
|
265
|
+
|
|
266
|
+
const kmsReport = await report.kmsReport(
|
|
267
|
+
new Date(Date.UTC(2022, 1, 11, 0, 0, 0, 0)),
|
|
268
|
+
new Date(Date.UTC(2022, 1, 14, 23, 59, 59, 0)),
|
|
269
|
+
userData)
|
|
270
|
+
|
|
271
|
+
assert.equal(tripsReport.length, 1)
|
|
272
|
+
const device1 = tripsReport[0].devices.find(d => d.device.id === 11681)
|
|
273
|
+
assert.equal(device1.trips.length, 44) // Total Trips
|
|
274
|
+
assert.equal(device1.totalDistance, 882.801081530881) // Total Kms
|
|
275
|
+
|
|
276
|
+
const device2 = kmsReport[0].devices.find(d => d.device.id === 11681)
|
|
277
|
+
assert.equal(device2.summary.distance, device1.totalDistance) // Total Kms
|
|
278
|
+
}, 30000)
|
|
279
|
+
// eslint-disable-next-line no-undef
|
|
280
|
+
it('Refueling Report', async () => {
|
|
281
|
+
const report = await getReports()
|
|
282
|
+
const userData = await report.getUserData()
|
|
283
|
+
|
|
284
|
+
const data = await report.refuelingReport(
|
|
285
|
+
new Date(Date.UTC(2022, 1, 2, 0, 0, 0, 0)),
|
|
286
|
+
new Date(Date.UTC(2022, 1, 2, 23, 59, 59, 0)),
|
|
287
|
+
userData)
|
|
288
|
+
|
|
289
|
+
assert.equal(data.length, 1)
|
|
290
|
+
console.log(data[0])
|
|
291
|
+
const device = data[0].devices.find(d => d.device.id === 16245)
|
|
292
|
+
assert.equal(device.refuelings.length, 2)
|
|
293
|
+
}, 30000)
|
|
294
|
+
// eslint-disable-next-line no-undef
|
|
295
|
+
it('Refueling2 Report', async () => {
|
|
296
|
+
const report = await getReports()
|
|
297
|
+
const userData = await report.getUserData()
|
|
298
|
+
|
|
299
|
+
const data = await report.refuelingReport(new Date(2022, 1, 21, 0, 0, 0, 0),
|
|
300
|
+
new Date(2022, 1, 25, 23, 59, 59, 0),
|
|
301
|
+
userData)
|
|
302
|
+
|
|
303
|
+
assert.equal(data.length, 1)
|
|
304
|
+
console.log(data[0])
|
|
305
|
+
const device = data[0].devices.find(d => d.device.id === 16245)
|
|
306
|
+
console.log(device.refuelings)
|
|
307
|
+
assert.equal(device.refuelings.length, 4)
|
|
308
|
+
}, 30000)
|
|
309
|
+
// eslint-disable-next-line no-undef
|
|
310
|
+
it('FuelConsumption Report', async () => {
|
|
311
|
+
const report = await getReports()
|
|
312
|
+
const userData = await report.getUserData()
|
|
313
|
+
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
314
|
+
const data = await report.fuelConsumptionReport(new Date(2022, 0, 1, 0, 0, 0, 0),
|
|
315
|
+
new Date(2022, 0, 10, 23, 59, 59, 0),
|
|
316
|
+
userData)
|
|
317
|
+
|
|
318
|
+
assert.equal(data.length, 1)
|
|
319
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
320
|
+
console.log(device.days)
|
|
321
|
+
assert.equal(device.days.length, 8)
|
|
322
|
+
assert.equal(device.days[0].spentFuel, 2)
|
|
323
|
+
}, 30000)
|
|
324
|
+
// eslint-disable-next-line no-undef
|
|
325
|
+
it('FuelConsumption Odoo Report', async () => {
|
|
326
|
+
const report = await getReports()
|
|
327
|
+
const userData = await report.getUserData()
|
|
328
|
+
userData.withOdooServices = true
|
|
329
|
+
userData.devices = userData.devices.filter(d => d.id === 25508)
|
|
330
|
+
const data = await report.fuelConsumptionReport(
|
|
331
|
+
new Date(Date.UTC(2022, 1, 1, 0, 0, 0, 0)),
|
|
332
|
+
new Date(Date.UTC(2022, 1, 28, 23, 59, 59, 0)),
|
|
333
|
+
userData)
|
|
334
|
+
|
|
335
|
+
assert.equal(data.length, 1)
|
|
336
|
+
const device = data[0].devices.find(d => d.device.id === 25508)
|
|
337
|
+
assert.equal(device.days.length, 25)
|
|
338
|
+
}, 30000)
|
|
339
|
+
/* it('Zone Report', async () => {
|
|
328
340
|
const report = await getReports()
|
|
329
341
|
const userData = await report.getUserData()
|
|
330
342
|
const data = await report.zoneReport(new Date(2022, 3, 25, 0, 0, 0, 0),
|
|
@@ -338,5 +350,5 @@ describe('Test_Reports', function() {
|
|
|
338
350
|
assert.equal(device.geofences[0].outTime.fixTime, '2022-04-26T07:47:35.000+0000')
|
|
339
351
|
assert.equal(device.geofences[0].totalTime, '28770')
|
|
340
352
|
assert.equal(device.geofences[0].geofenceName, 'Casa João')
|
|
341
|
-
}, 30000)*/
|
|
353
|
+
}, 30000) */
|
|
342
354
|
})
|