fleetmap-reports 1.0.576 → 1.0.578
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/fuel.test.js +23 -0
- package/src/index.test.js +12 -3
- package/src/location-report.js +1 -1
- package/src/trip-report.js +4 -1
package/package.json
CHANGED
package/src/fuel.test.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
const { getReports } = require('./tests')
|
|
3
|
+
const assert = require('assert')
|
|
4
|
+
|
|
5
|
+
const deviceId = 122575
|
|
6
|
+
// eslint-disable-next-line no-undef
|
|
7
|
+
describe('Test_Reports', function () {
|
|
8
|
+
it('Trip by device', async () => {
|
|
9
|
+
console.log('trip by device')
|
|
10
|
+
this.timeout(2000000)
|
|
11
|
+
const report = await getReports()
|
|
12
|
+
const userData = await report.getUserData()
|
|
13
|
+
|
|
14
|
+
const data = await report.tripReport(new Date(2023, 0, 26, 0, 0, 0, 0),
|
|
15
|
+
new Date(2023, 0, 26, 23, 59, 59, 0),
|
|
16
|
+
userData)
|
|
17
|
+
|
|
18
|
+
assert.equal(data.length, 1)
|
|
19
|
+
const device = data[0].devices.find(d => d.device.id === deviceId)
|
|
20
|
+
assert.equal(device.trips.length, 9) // Total Trips
|
|
21
|
+
console.log(device.trips)
|
|
22
|
+
}, 30000)
|
|
23
|
+
})
|
package/src/index.test.js
CHANGED
|
@@ -360,18 +360,27 @@ describe('Test_Reports', function () {
|
|
|
360
360
|
}, 30000)
|
|
361
361
|
// eslint-disable-next-line no-undef
|
|
362
362
|
it('FuelConsumption Report', async () => {
|
|
363
|
+
const device1 = 22326
|
|
364
|
+
const device2 = 122575
|
|
363
365
|
const report = await getReports()
|
|
364
366
|
const userData = await report.getUserData()
|
|
365
|
-
|
|
366
|
-
|
|
367
|
+
const devices = userData.devices
|
|
368
|
+
userData.devices = devices.filter(d => d.id === device1)
|
|
369
|
+
let data = await report.fuelConsumptionReport(new Date(2022, 0, 1, 0, 0, 0, 0),
|
|
367
370
|
new Date(2022, 0, 10, 23, 59, 59, 0),
|
|
368
371
|
userData)
|
|
369
372
|
|
|
370
373
|
assert.equal(data.length, 1)
|
|
371
|
-
|
|
374
|
+
let device = data[0].devices.find(d => d.device.id === device1)
|
|
372
375
|
console.log(device.days)
|
|
373
376
|
assert.equal(device.days.length, 8)
|
|
374
377
|
assert.equal(device.days[0].spentFuel, 2)
|
|
378
|
+
userData.devices = devices.filter(d => d.id === device2)
|
|
379
|
+
data = await report.fuelConsumptionReport(new Date(2023, 0, 26, 0, 0, 0, 0),
|
|
380
|
+
new Date(2023, 0, 26, 23, 59, 59, 0),
|
|
381
|
+
userData)
|
|
382
|
+
device = data[0].devices.find(d => d.device.id === device2)
|
|
383
|
+
console.log(device.days)
|
|
375
384
|
}, 30000)
|
|
376
385
|
// eslint-disable-next-line no-undef
|
|
377
386
|
it('FuelConsumption Odoo Report', async () => {
|
package/src/location-report.js
CHANGED
|
@@ -306,7 +306,7 @@ function getTempValue (row) {
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
function getDigitalPort1Label (row, translations, dAttributes) {
|
|
309
|
-
return dAttributes.sensor1 || translations.report.digital_ports1
|
|
309
|
+
return (dAttributes && dAttributes.sensor1) || translations.report.digital_ports1
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
function getDigitalPort2Label (row, translations) {
|
package/src/trip-report.js
CHANGED
|
@@ -163,7 +163,10 @@ function processDevices (from, to, devices, data, userData, traccar) {
|
|
|
163
163
|
addNearestPOIs(trips, userData)
|
|
164
164
|
|
|
165
165
|
trips.forEach(trip => {
|
|
166
|
-
if (
|
|
166
|
+
if (deviceRoute[0].protocol === 'teltonika') {
|
|
167
|
+
trip.fuelConsumption = trip.spentFuel
|
|
168
|
+
trip.avgFuelConsumption = trip.totalKms > 0 ? Math.round(trip.fuelConsumption * 100 / trip.totalKms) : 0
|
|
169
|
+
} else if (automaticReports.deviceWithFuelInfo(d)) {
|
|
167
170
|
trip.fuelConsumption = Math.round((trip.spentFuel * d.attributes.fuel_tank_capacity) / 100)
|
|
168
171
|
trip.avgFuelConsumption = trip.totalKms > 0 ? Math.round(trip.fuelConsumption * 100 / trip.totalKms) : 0
|
|
169
172
|
} else {
|