fleetmap-reports 1.0.515 → 1.0.516
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 +1 -1
- package/src/index.test.js +5 -20
- package/src/refueling-report.js +11 -9
package/package.json
CHANGED
package/src/index.test.js
CHANGED
|
@@ -351,33 +351,18 @@ describe('Test_Reports', function () {
|
|
|
351
351
|
it('Refueling Report', async () => {
|
|
352
352
|
const report = await getReports()
|
|
353
353
|
const userData = await report.getUserData()
|
|
354
|
-
|
|
354
|
+
userData.withOdooServices = true
|
|
355
355
|
const data = await report.refuelingReport(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
new Date(Date.UTC(2022, 9, 1, 0, 0, 0, 0)),
|
|
357
|
+
new Date(Date.UTC(2022, 9, 31, 23, 59, 59, 0)),
|
|
358
|
+
userData)
|
|
359
359
|
|
|
360
360
|
assert.equal(data.length, 1)
|
|
361
361
|
console.log(data[0])
|
|
362
|
-
const device = data[0].devices.find(d => d.device.id ===
|
|
362
|
+
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
363
363
|
assert.equal(device.refuelings.length, 2)
|
|
364
364
|
}, 30000)
|
|
365
365
|
// eslint-disable-next-line no-undef
|
|
366
|
-
it('Refueling2 Report', async () => {
|
|
367
|
-
const report = await getReports()
|
|
368
|
-
const userData = await report.getUserData()
|
|
369
|
-
|
|
370
|
-
const data = await report.refuelingReport(new Date(2022, 1, 21, 0, 0, 0, 0),
|
|
371
|
-
new Date(2022, 1, 25, 23, 59, 59, 0),
|
|
372
|
-
userData)
|
|
373
|
-
|
|
374
|
-
assert.equal(data.length, 1)
|
|
375
|
-
console.log(data[0])
|
|
376
|
-
const device = data[0].devices.find(d => d.device.id === 16245)
|
|
377
|
-
console.log(device.refuelings)
|
|
378
|
-
assert.equal(device.refuelings.length, 4)
|
|
379
|
-
}, 30000)
|
|
380
|
-
// eslint-disable-next-line no-undef
|
|
381
366
|
it('FuelConsumption Report', async () => {
|
|
382
367
|
const report = await getReports()
|
|
383
368
|
const userData = await report.getUserData()
|
package/src/refueling-report.js
CHANGED
|
@@ -27,7 +27,7 @@ async function createRefuelingReport (from, to, userData, traccar) {
|
|
|
27
27
|
const data = []
|
|
28
28
|
for (const a of arrayOfArrays) {
|
|
29
29
|
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, a, true, false, false, false)
|
|
30
|
-
data.push(allInOne.route)
|
|
30
|
+
data.push(...allInOne.route)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const fuelServicesData = []
|
|
@@ -51,14 +51,16 @@ async function createRefuelingReport (from, to, userData, traccar) {
|
|
|
51
51
|
const refuelingPositions = await this.calculateRefuelingPositions(userData, d, { route: positions, fuelServices: deviceFuelServices })
|
|
52
52
|
|
|
53
53
|
if (userData.drivers.length > 0) {
|
|
54
|
-
refuelingPositions.forEach(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
refuelingPositions.forEach(r => {
|
|
55
|
+
if (r.position) {
|
|
56
|
+
const geofence = findNearestPOI(r.position, userData.geofences)
|
|
57
|
+
if (geofence) {
|
|
58
|
+
r.position.geofenceName = geofence.name
|
|
59
|
+
}
|
|
60
|
+
const driver = userData.drivers.find(d => d.uniqueId === r.position.attributes.driverUniqueId)
|
|
61
|
+
if (driver) {
|
|
62
|
+
r.position.driverName = driver.name
|
|
63
|
+
}
|
|
62
64
|
}
|
|
63
65
|
})
|
|
64
66
|
}
|