fleetmap-reports 2.0.35 → 2.0.37
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/fuelconsumption-report.js +2 -2
- package/src/util/driver.js +6 -13
package/package.json
CHANGED
|
@@ -136,7 +136,7 @@ function exportFuelConsumptionReportToExcel (userData, reportData) {
|
|
|
136
136
|
data = data.concat(d.days.map((r) => {
|
|
137
137
|
return {
|
|
138
138
|
name: d.device.name,
|
|
139
|
-
date: r.date,
|
|
139
|
+
date: r.date.toLocaleDateString(),
|
|
140
140
|
kms: formatNumber(r.distance / 1000, lang),
|
|
141
141
|
consumption: r.spentFuel > 0 ? formatNumber(r.spentFuel, lang) : 0,
|
|
142
142
|
avg_consumption: formatNumber(lang === 'pt-BR' ? r.avgConsumption.byLiters : r.avgConsumption.byKms, lang),
|
|
@@ -203,7 +203,7 @@ async function exportFuelConsumptionReportToPDF (userData, reportData) {
|
|
|
203
203
|
|
|
204
204
|
d.days.forEach(r =>
|
|
205
205
|
data.push([
|
|
206
|
-
r.date,
|
|
206
|
+
r.date.toLocaleDateString(),
|
|
207
207
|
formatNumber(r.distance / 1000, lang),
|
|
208
208
|
r.spentFuel > 0 ? formatNumber(r.spentFuel, lang) : 0,
|
|
209
209
|
formatNumber(lang === 'pt-BR' ? r.avgConsumption.byLiters : r.avgConsumption.byKms, lang),
|
package/src/util/driver.js
CHANGED
|
@@ -6,20 +6,13 @@ const { isInsideTimetable, isPartialInsideTimetable } = require('./trips')
|
|
|
6
6
|
// get devices used by each driver between two dates
|
|
7
7
|
async function devicesByDriver (traccarInstance, from, to, drivers, devices) {
|
|
8
8
|
const eventsData = await traccar.getEvents(traccarInstance, from, to, devices, ['driverChanged'])
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
for (const d of drivers) {
|
|
12
|
-
const events = eventsData.filter(e => {
|
|
13
|
-
return !d.uniqueId.localeCompare(e.attributes.driverUniqueId, undefined, { sensitivity: 'base' })
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
if (events.length) {
|
|
17
|
-
driversIds.push(d.id)
|
|
18
|
-
}
|
|
9
|
+
const driverUniqueIdsToProcess = new Set(eventsData.map(e => e.attributes.driverUniqueId))
|
|
10
|
+
const driversToProcess = drivers.filter(d => driverUniqueIdsToProcess.has(d.uniqueId))
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
const deviceIdsToProcess = new Set(eventsData.map(e => e.deviceId))
|
|
13
|
+
const devicesToProcess = devices.filter(d => deviceIdsToProcess.has(d.id))
|
|
14
|
+
|
|
15
|
+
return { devices: devicesToProcess, drivers: driversToProcess }
|
|
23
16
|
}
|
|
24
17
|
|
|
25
18
|
async function reportByDriver (devices, traccar, from, to, userData, processor, allInOneData = { route: true, trips: true, stops: true, summary: false }) {
|