fleetmap-reports 2.0.110 → 2.0.111
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/trip-report.js +11 -6
- package/src/util/trips.js +1 -1
package/package.json
CHANGED
package/src/trip-report.js
CHANGED
|
@@ -175,7 +175,9 @@ async function processDevices (from, to, devices, data, userData, traccar) {
|
|
|
175
175
|
const stops = data.stops.filter(s => s.deviceId === d.id)
|
|
176
176
|
|
|
177
177
|
trips.forEach(trip => {
|
|
178
|
-
|
|
178
|
+
const stop = getStop(new Date(trip.startTime), stops)
|
|
179
|
+
|
|
180
|
+
trip.totalKms = getTripTotalKms(trip, stop)
|
|
179
181
|
|
|
180
182
|
const nearestPOIs = getNearestPOIs(trip.endLon, trip.endLat, userData.geofences)
|
|
181
183
|
if (nearestPOIs.length > 0) {
|
|
@@ -213,8 +215,6 @@ async function processDevices (from, to, devices, data, userData, traccar) {
|
|
|
213
215
|
: 0
|
|
214
216
|
}
|
|
215
217
|
|
|
216
|
-
const stop = getStop(new Date(trip.startTime), stops)
|
|
217
|
-
|
|
218
218
|
if (deviceRoute.some(r => r.attributes.fuel) ||
|
|
219
219
|
automaticReports.deviceWithFuelInfo(d)) {
|
|
220
220
|
trip.fuelConsumption = calculateConsumption(d, { trips: [trip], stops: (stop ? [stop] : []), route: deviceRoute })
|
|
@@ -284,15 +284,15 @@ async function processDrivers (from, to, userData, data) {
|
|
|
284
284
|
|
|
285
285
|
if (trips) {
|
|
286
286
|
trips.forEach(trip => {
|
|
287
|
-
|
|
287
|
+
const stop = data.stops.find(s => s.deviceId === trip.deviceId && (new Date(s.startTime).getTime() === new Date(trip.endTime).getTime()))
|
|
288
|
+
|
|
289
|
+
trip.totalKms = getTripTotalKms(trip, stop)
|
|
288
290
|
|
|
289
291
|
const nearestPOIs = getNearestPOIs(trip.endLon, trip.endLat, userData.geofences)
|
|
290
292
|
if (nearestPOIs.length > 0) {
|
|
291
293
|
trip.endPOIName = nearestPOIs[0].p.name
|
|
292
294
|
}
|
|
293
295
|
|
|
294
|
-
const stop = data.stops.find(s => s.deviceId === trip.deviceId && (new Date(s.startTime).getTime() === new Date(trip.endTime).getTime()))
|
|
295
|
-
|
|
296
296
|
trip.stopEngineHours = getTripIdleTime(trip, idleEvents) + (stop ? stop.engineHours : 0)
|
|
297
297
|
})
|
|
298
298
|
|
|
@@ -311,6 +311,11 @@ async function processDrivers (from, to, userData, data) {
|
|
|
311
311
|
return driversResult
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
function getTripTotalKms (trip, stop) {
|
|
315
|
+
// we need to add stop kms to ensure that the total kms for the day, calculated with the odometer difference, will be equal to the sum of kms of all trips
|
|
316
|
+
return (trip.distance + (stop ? (stop.endOdometer - stop.startOdometer) : 0)) / 1000
|
|
317
|
+
}
|
|
318
|
+
|
|
314
319
|
async function exportTripReportToPDF (userData, reportData) {
|
|
315
320
|
console.log('exportTripReportToPDF')
|
|
316
321
|
|
package/src/util/trips.js
CHANGED
|
@@ -10,7 +10,7 @@ function checkTripsKms (traccarInstance, from, to, devices, data) {
|
|
|
10
10
|
if (trips.length > 0) {
|
|
11
11
|
// Vehicles with imported positions. calculate trip distance with route positions
|
|
12
12
|
trips.forEach(t => {
|
|
13
|
-
if (t.distance === minDistance && t.averageSpeed > minAvgSpeed) {
|
|
13
|
+
if (t.distance === minDistance && t.averageSpeed > minAvgSpeed && data.route.find(p => p.source === 'import')) {
|
|
14
14
|
const tripRoute = data.route.filter(p => p.deviceId === t.deviceId &&
|
|
15
15
|
new Date(p.fixTime).getTime() >= new Date(t.startTime).getTime() &&
|
|
16
16
|
new Date(p.fixTime).getTime() <= new Date(t.endTime).getTime())
|