fleetmap-reports 2.0.71 → 2.0.73
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
package/src/util/fuel.js
CHANGED
|
@@ -27,18 +27,14 @@ function getRefuelingLiters (d, position, diff) {
|
|
|
27
27
|
|
|
28
28
|
function calculateConsumption (d, data, avgConsumption) {
|
|
29
29
|
let fuelConsumption = 0
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fuelConsumption = calculateSpentFuel(spentFuel, d, withFuelUsed)
|
|
39
|
-
} else if (data.route && data.route.length > 1 && data.route[0].attributes.fuelUsed) {
|
|
40
|
-
fuelConsumption = data.route[data.route.length - 1].attributes.fuelUsed - data.route[0].attributes.fuelUsed
|
|
41
|
-
}
|
|
30
|
+
const withFuelUsed = data.route && data.route.find(p => p.attributes.fuelUsed)
|
|
31
|
+
if (data.summary) {
|
|
32
|
+
fuelConsumption = calculateSpentFuel(data.summary.spentFuel, d, withFuelUsed)
|
|
33
|
+
} else if (data.trips && data.stops) {
|
|
34
|
+
const spentFuel = data.trips.reduce((a, b) => a + b.spentFuel, 0) + data.stops.reduce((a, b) => a + b.spentFuel, 0)
|
|
35
|
+
fuelConsumption = calculateSpentFuel(spentFuel, d, withFuelUsed)
|
|
36
|
+
} else if (data.route && data.route.length > 1 && data.route[0].attributes.fuelUsed) {
|
|
37
|
+
fuelConsumption = data.route[data.route.length - 1].attributes.fuelUsed - data.route[0].attributes.fuelUsed
|
|
42
38
|
}
|
|
43
39
|
return fuelConsumption > 0 ? fuelConsumption : 0
|
|
44
40
|
}
|