fleetmap-reports 2.0.36 → 2.0.38
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/trip-report.js +23 -11
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/trip-report.js
CHANGED
|
@@ -183,21 +183,33 @@ async function processDevices (from, to, devices, data, userData, traccar) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
if (userData.includeTemperature) {
|
|
186
|
-
const tripRoute = deviceRoute.filter(p => trip.startTime <= p.fixTime && trip.endTime >= p.fixTime
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
const tripRoute = deviceRoute.filter(p => trip.startTime <= p.fixTime && trip.endTime >= p.fixTime)
|
|
187
|
+
|
|
188
|
+
const temperatureValues = tripRoute.map(p => {
|
|
189
|
+
for (let i = 1; i <= 3; i++) {
|
|
190
|
+
const temp = 'temp' + i
|
|
191
|
+
if (p.attributes[temp] && parseFloat(p.attributes[temp]) !== 175) {
|
|
192
|
+
return parseFloat(p.attributes[temp])
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return undefined
|
|
197
|
+
}).filter(a => a !== undefined)
|
|
198
|
+
|
|
199
|
+
trip.maxTemp = temperatureValues.length > 0
|
|
200
|
+
? temperatureValues.reduce((a, b) => {
|
|
201
|
+
return a > b ? a : b
|
|
190
202
|
})
|
|
191
203
|
: 0
|
|
192
|
-
trip.minTemp =
|
|
193
|
-
?
|
|
194
|
-
return a
|
|
204
|
+
trip.minTemp = temperatureValues.length > 0
|
|
205
|
+
? temperatureValues.reduce((a, b) => {
|
|
206
|
+
return a < b ? a : b
|
|
195
207
|
})
|
|
196
208
|
: 0
|
|
197
|
-
trip.avgTemp =
|
|
198
|
-
? (
|
|
199
|
-
return a + b
|
|
200
|
-
}, 0)) /
|
|
209
|
+
trip.avgTemp = temperatureValues.length > 0
|
|
210
|
+
? (temperatureValues.reduce((a, b) => {
|
|
211
|
+
return a + b
|
|
212
|
+
}, 0)) / temperatureValues.length
|
|
201
213
|
: 0
|
|
202
214
|
}
|
|
203
215
|
|