fleetmap-reports 1.0.770 → 1.0.771

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.770",
3
+ "version": "1.0.771",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -135,6 +135,6 @@ describe('trips', function () {
135
135
 
136
136
  assert.equal(data.length, 1)
137
137
  const device = data[0].devices.find(d => d.device.id === 69114)
138
- assert.equal(device.trips.reduce((a, b) => a + b.spentFuel, 0), 153.6999999999998) // Total Trips
138
+ assert.equal(device.trips.reduce((a, b) => a + b.fuelConsumption, 0), 167.69999999999987) // Total Trips
139
139
  }, 30000)
140
140
  })
@@ -167,14 +167,14 @@ function processDevices (from, to, devices, data, userData, traccar) {
167
167
  trip.endPOIName = nearestPOIs[0].p.name
168
168
  }
169
169
 
170
+ const stop = getStop(new Date(trip.startTime), stops)
171
+
170
172
  if ((deviceRoute[0].protocol === 'teltonika' && deviceRoute.some(r => r.attributes.fuel)) ||
171
173
  automaticReports.deviceWithFuelInfo(d)) {
172
- trip.fuelConsumption = trip.spentFuel
174
+ trip.fuelConsumption = trip.spentFuel + (stop ? stop.spentFuel : 0)
173
175
  trip.avgFuelConsumption = trip.totalKms > 0 ? trip.fuelConsumption * 100 / trip.totalKms : 0
174
176
  }
175
177
 
176
- const stop = getStop(new Date(trip.startTime), stops)
177
-
178
178
  if (stop && !trip.endTimeIsOut) {
179
179
  trip.stopDuration = calculateStopDuration(stop)
180
180
  trip.stopEngineHours = trip.idleTime + stop.engineHours