fleetmap-reports 2.0.120 → 2.0.121
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
|
@@ -144,7 +144,7 @@ function getDeviceData (allInOne, d) {
|
|
|
144
144
|
const deviceStops = allInOne.stops.filter(t => t.deviceId === d.id)
|
|
145
145
|
|
|
146
146
|
const drivingTime = deviceTrips.reduce((a, b) => a + b.duration, 0)
|
|
147
|
-
const drivingConsumption = calculateConsumption(d, { trips: deviceTrips, stops: [], route: deviceRoute, summary: deviceSummary }
|
|
147
|
+
const drivingConsumption = calculateConsumption(d, { trips: deviceTrips, stops: [], route: deviceRoute, summary: deviceSummary })
|
|
148
148
|
const drivingDistance = deviceSummary ? deviceSummary.distance / 1000 : 0
|
|
149
149
|
const idleTime = deviceTrips.reduce((a, b) => a + (b.idleTime ? b.idleTime : 0), 0) + deviceStops.reduce((a, b) => a + b.engineHours, 0)
|
|
150
150
|
const idleConsumption = deviceSummary && deviceSummary.spentFuel > drivingConsumption ? deviceSummary.spentFuel - drivingConsumption : 0
|
package/src/util/fuel.js
CHANGED
|
@@ -25,13 +25,14 @@ function getRefuelingLiters (d, position, diff) {
|
|
|
25
25
|
return Math.round(diff * d.attributes.fuel_tank_capacity / 100)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function calculateConsumption (d, data
|
|
28
|
+
function calculateConsumption (d, data) {
|
|
29
29
|
let fuelConsumption = 0
|
|
30
30
|
const withFuelUsed = data.route && data.route.find(p => p.attributes.fuelUsed)
|
|
31
31
|
if (data.summary) {
|
|
32
32
|
fuelConsumption = calculateSpentFuel(data.summary.spentFuel, d, withFuelUsed)
|
|
33
|
-
}
|
|
34
|
-
|
|
33
|
+
}
|
|
34
|
+
if (fuelConsumption <= 0 && data.trips && data.stops) {
|
|
35
|
+
const spentFuel = data.trips.reduce((a, b) => a + (b.spentFuel > 0 ? b.spentFuel : 0), 0) + data.stops.reduce((a, b) => a + (b.spentFuel > 0 ? b.spentFuel : 0), 0)
|
|
35
36
|
fuelConsumption = calculateSpentFuel(spentFuel, d, withFuelUsed)
|
|
36
37
|
} else if (data.route && data.route.length > 1 && data.route[0].attributes.fuelUsed) {
|
|
37
38
|
fuelConsumption = data.route[data.route.length - 1].attributes.fuelUsed - data.route[0].attributes.fuelUsed
|