fleetmap-reports 1.0.420 → 1.0.423
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 +15 -0
- package/src/trip-report.js +6 -2
package/package.json
CHANGED
package/src/index.test.js
CHANGED
|
@@ -52,6 +52,21 @@ describe('Test_Reports', function () {
|
|
|
52
52
|
assert.equal(device.trips[1].endPOIName, undefined)
|
|
53
53
|
assert.equal(device.totalDistance, 339204.53999999166) // Total Kms
|
|
54
54
|
}, 20000)
|
|
55
|
+
it('Trip without addresses', async () => {
|
|
56
|
+
const report = await getReports()
|
|
57
|
+
const userData = await report.getUserData()
|
|
58
|
+
|
|
59
|
+
const data = await report.tripReport(new Date(2022, 4, 27, 0, 0, 0, 0),
|
|
60
|
+
new Date(2022, 4, 27, 23, 59, 59, 0),
|
|
61
|
+
userData)
|
|
62
|
+
|
|
63
|
+
assert.equal(data.length, 1)
|
|
64
|
+
const device = data[0].devices.find(d => d.device.id === 25808)
|
|
65
|
+
assert.equal(device.trips.length, 11) // Total Trips
|
|
66
|
+
console.log(device.trips[0])
|
|
67
|
+
assert.equal(device.trips[0].endAddress, 'Rua Cláudio Manoel 184-314;Vera Cruz;Vera Cruz;96880-000;BR\n')
|
|
68
|
+
assert.equal(device.trips[1].endPOIName, undefined)
|
|
69
|
+
}, 20000)
|
|
55
70
|
// eslint-disable-next-line no-undef
|
|
56
71
|
it('Trip 2 by device', async () => {
|
|
57
72
|
const report = await getReports()
|
package/src/trip-report.js
CHANGED
|
@@ -59,7 +59,7 @@ async function createTripReportByDevice (from, to, userData, traccar) {
|
|
|
59
59
|
trips: tripsData,
|
|
60
60
|
stops: stopsData,
|
|
61
61
|
route: routeData
|
|
62
|
-
}, userData))
|
|
62
|
+
}, userData, traccar))
|
|
63
63
|
}
|
|
64
64
|
deviceCount = deviceCount + slice.length
|
|
65
65
|
}
|
|
@@ -121,7 +121,7 @@ async function createTripReportByDriver (from, to, userData, traccar) {
|
|
|
121
121
|
return { drivers: processDrivers(from, to, userData, { trips: tripsData, route: routeData }) }
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
function processDevices (from, to, devices, data, userData) {
|
|
124
|
+
function processDevices (from, to, devices, data, userData, traccar) {
|
|
125
125
|
const devicesResult = []
|
|
126
126
|
|
|
127
127
|
devices.forEach(d => {
|
|
@@ -157,6 +157,10 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
157
157
|
trip.stopDuration = 0
|
|
158
158
|
trip.stopEngineHours = 0
|
|
159
159
|
}
|
|
160
|
+
if (trip.endAddress === null) {
|
|
161
|
+
traccar.axios.get(`/server/geocode?latitude=${trip.latitude}&longitude=${trip.longitude}`)
|
|
162
|
+
.then(d => { trip.endAddress = d.data })
|
|
163
|
+
}
|
|
160
164
|
})
|
|
161
165
|
|
|
162
166
|
if (trips.length > 0) {
|