fleetmap-reports 1.0.779 → 1.0.781
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/util/fuel.js +14 -17
package/package.json
CHANGED
package/src/util/fuel.js
CHANGED
|
@@ -23,24 +23,21 @@ function getRefuelingLiters (d, position, diff) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function calculateConsumption (d, data, avgConsumption) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (data.route && data.route.length > 1 && data.route[0].attributes.fuelUsed) {
|
|
42
|
-
return data.route[data.route.length - 1].attributes.fuelUsed - data.route[0].attributes.fuelUsed
|
|
26
|
+
let fuelConsumption = 0
|
|
27
|
+
if (useOdooFuelData(d, data.route) && avgConsumption) {
|
|
28
|
+
fuelConsumption = (avgConsumption.byKms * (data.trips.reduce((a, b) => a + b.distance, 0) / 1000) / 100)
|
|
29
|
+
} else {
|
|
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
|
|
38
|
+
}
|
|
43
39
|
}
|
|
40
|
+
return fuelConsumption > 0 ? fuelConsumption : 0
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
function calculateSpentFuel (value, device, withFuelUsed) {
|