fleetmap-reports 1.0.516 → 1.0.518
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
|
@@ -93,11 +93,16 @@ async function createFuelConsumptionReport (from, to, userData, traccar) {
|
|
|
93
93
|
function getOdooAvgConsumption (refuelingPositions, trips) {
|
|
94
94
|
const odooTotalfuel = refuelingPositions.reduce((a, b) => a + b.diff, 0)
|
|
95
95
|
const totalKms = trips.reduce((a, b) => a + b.distance, 0)
|
|
96
|
-
|
|
96
|
+
|
|
97
|
+
if (totalKms === 0 || odooTotalfuel === 0) { return { byKms: 0, byLiters: 0 } }
|
|
98
|
+
|
|
99
|
+
return { byKms: odooTotalfuel * 100 / (totalKms / 1000), byLiters: (totalKms / 1000) / odooTotalfuel }
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
function getCanAvgConsumption (userData, distance, spentFuel) {
|
|
100
|
-
|
|
103
|
+
if (distance === 0 || spentFuel === 0) { return { byKms: 0, byLiters: 0 } }
|
|
104
|
+
|
|
105
|
+
return { byKms: Math.round(spentFuel * 100 / (distance / 1000)), byLiters: Math.round((distance / 1000) / spentFuel) }
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
function calculateConsumption (userData, d, day, avgConsumption, data) {
|
|
@@ -105,7 +110,7 @@ function calculateConsumption (userData, d, day, avgConsumption, data) {
|
|
|
105
110
|
return automaticReports.calculateXpertSpentFuel(day, data.route)
|
|
106
111
|
}
|
|
107
112
|
if (userData.withOdooServices) {
|
|
108
|
-
return Math.round((avgConsumption * (data.trips.reduce((a, b) => a + b.distance, 0) / 1000)) / 100)
|
|
113
|
+
return Math.round((avgConsumption.byKms * (data.trips.reduce((a, b) => a + b.distance, 0) / 1000)) / 100)
|
|
109
114
|
}
|
|
110
115
|
return automaticReports.calculateSpentFuel(data.trips.reduce((a, b) => a + b.spentFuel, 0), d)
|
|
111
116
|
}
|