fleetmap-reports 2.0.378 → 2.0.379

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": "2.0.378",
3
+ "version": "2.0.379",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -174,7 +174,7 @@ async function createFuelConsumptionReport (from, to, userData, traccar) {
174
174
  const days = daysByDevice.get(d.id) || []
175
175
  for (const date of dates) {
176
176
  const [dayStart, dayEnd] = getDayWindow(date, timezone)
177
- const { tripsByDay, stopsByDay, routeByDay, refuelingPositionsByDay } = await getReportDataByDay(d, dayStart, dayEnd, { trips, stops, route, refuelingPositions })
177
+ const { tripsByDay, stopsByDay, refuelingPositionsByDay } = await getReportDataByDay(d, dayStart, dayEnd, { trips, stops, route, refuelingPositions })
178
178
  const summaryByDay = summary.find(a => a.date === date).summary
179
179
  const summaryByDevice = summaryByDay.find(a => a.deviceId === d.id)
180
180
 
@@ -185,9 +185,13 @@ async function createFuelConsumptionReport (from, to, userData, traccar) {
185
185
  'fuel_high_threshold' in d.attributes &&
186
186
  d.attributes.fuel_tank_capacity
187
187
 
188
+ // For CAN vehicles calculateConsumption reads the "fuelUsed" counter directly from
189
+ // the full chunk route between dayStart/dayEnd, so the day value matches the
190
+ // Manager's "Fuel Used" even when routeByDay itself has too few (or no) fuelUsed
191
+ // readings - e.g. on a day with a refuel or sparse CAN reporting.
188
192
  const spentFuel = hasFuelSensor
189
193
  ? tripsByDay.length > 0 ? calculateTotalFuelFromSensor(tripsByDay, stopsByDay, route, d, firstStopIndex) : 0
190
- : calculateConsumption(d, { trips: tripsByDay, stops: stopsByDay, route: routeByDay, summary: summaryByDevice })
194
+ : calculateConsumption(d, { trips: tripsByDay, stops: stopsByDay, route, summary: summaryByDevice, from: dayStart, to: dayEnd })
191
195
 
192
196
  const dataRow = {
193
197
  date,