fleetmap-reports 2.0.382 → 2.0.384
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/lang/enGB.js +2 -0
- package/lang/esCL.js +2 -0
- package/lang/frFR.json +3 -1
- package/lang/ptBR.js +2 -0
- package/lang/ptPT.js +2 -0
- package/package.json +1 -1
- package/src/fuel-consumption-report.js +16 -2
- package/src/sensor-report.js +4 -4
package/lang/enGB.js
CHANGED
|
@@ -195,6 +195,8 @@ module.exports = {
|
|
|
195
195
|
titleStopReport: 'Stop Report',
|
|
196
196
|
titleDriverRankingReport: 'Driver Ranking Report',
|
|
197
197
|
titleSensorReport: 'Sensor Report',
|
|
198
|
+
sensor: 'Sensor',
|
|
199
|
+
status: 'Status',
|
|
198
200
|
rank: 'Rank',
|
|
199
201
|
grade: 'Grade',
|
|
200
202
|
safetyScore: 'Safety',
|
package/lang/esCL.js
CHANGED
|
@@ -185,6 +185,8 @@ module.exports = {
|
|
|
185
185
|
titleStopReport: 'Informe de Paradas',
|
|
186
186
|
titleDriverRankingReport: 'Informe de Ranking de Conductores',
|
|
187
187
|
titleSensorReport: 'Informe de Sensores',
|
|
188
|
+
sensor: 'Sensor',
|
|
189
|
+
status: 'Estado',
|
|
188
190
|
rank: 'Posición',
|
|
189
191
|
grade: 'Calificación',
|
|
190
192
|
safetyScore: 'Seguridad',
|
package/lang/frFR.json
CHANGED
|
@@ -195,7 +195,9 @@
|
|
|
195
195
|
"titleStopReport": "Arrêter le rapport",
|
|
196
196
|
"titleDelayedStartReport": "Rapport de Departs Tardifs",
|
|
197
197
|
"titleDriverRankingReport": "Rapport d'conducteur",
|
|
198
|
-
"titleSensorReport": "
|
|
198
|
+
"titleSensorReport": "Rapport de capteurs",
|
|
199
|
+
"sensor": "Capteur",
|
|
200
|
+
"status": "État",
|
|
199
201
|
"from": "Dans",
|
|
200
202
|
"to": "Le",
|
|
201
203
|
"headerStartAddress": "lieu de départ",
|
package/lang/ptBR.js
CHANGED
|
@@ -187,6 +187,8 @@ module.exports = {
|
|
|
187
187
|
titleStopReport: 'Relatório de Paragens',
|
|
188
188
|
titleDriverRankingReport: 'Relatório de Ranking de Motoristas',
|
|
189
189
|
titleSensorReport: 'Relatório de Sensores',
|
|
190
|
+
sensor: 'Sensor',
|
|
191
|
+
status: 'Estado',
|
|
190
192
|
rank: 'Posição',
|
|
191
193
|
grade: 'Nota',
|
|
192
194
|
safetyScore: 'Segurança',
|
package/lang/ptPT.js
CHANGED
|
@@ -193,6 +193,8 @@ module.exports = {
|
|
|
193
193
|
titleStopReport: 'Relatório de Paragens',
|
|
194
194
|
titleDriverRankingReport: 'Relatório de Ranking de Condutores',
|
|
195
195
|
titleSensorReport: 'Relatório de Sensores',
|
|
196
|
+
sensor: 'Sensor',
|
|
197
|
+
status: 'Estado',
|
|
196
198
|
rank: 'Posição',
|
|
197
199
|
grade: 'Nota',
|
|
198
200
|
safetyScore: 'Segurança',
|
package/package.json
CHANGED
|
@@ -12,6 +12,8 @@ const { calculateConsumption, calculateTotalFuelFromSensor, shouldUseFuelSensor
|
|
|
12
12
|
const { getSummary } = require('./util/traccar')
|
|
13
13
|
const { calculatePartialTrip } = require('./util/trips')
|
|
14
14
|
|
|
15
|
+
const CHUNK_BOUNDARY_BUFFER_MS = 24 * 60 * 60 * 1000
|
|
16
|
+
|
|
15
17
|
function getReportTimezone (userData) {
|
|
16
18
|
const tz = userData.user.attributes.timezone || getUserPartner(userData.user).timezone
|
|
17
19
|
try {
|
|
@@ -151,8 +153,20 @@ async function createFuelConsumptionReport (from, to, userData, traccar) {
|
|
|
151
153
|
|
|
152
154
|
for (let chunkIndex = 0; chunkIndex < dateGroups.length; chunkIndex++) {
|
|
153
155
|
const dates = dateGroups[chunkIndex]
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
+
const chunkFromBase = chunkIndex === 0 ? from : getDayWindow(dates[0], timezone)[0]
|
|
157
|
+
const chunkToBase = chunkIndex === dateGroups.length - 1 ? to : getDayWindow(dates[dates.length - 1], timezone)[1]
|
|
158
|
+
|
|
159
|
+
// A trip in progress across a chunk boundary would otherwise come back from Traccar
|
|
160
|
+
// truncated to the request window, bypassing the day-boundary proration below (which
|
|
161
|
+
// only triggers when the trip's real end/start still extends past dayStart/dayEnd) -
|
|
162
|
+
// making a day's consumption depend on which chunk it happened to land in. Widening
|
|
163
|
+
// only the internal boundaries (never the report's actual from/to) by a day-long
|
|
164
|
+
// buffer ensures such a trip is always fetched whole here, so it goes through the same
|
|
165
|
+
// getReportDataByDay/calculatePartialTrip proration as any other cross-midnight trip.
|
|
166
|
+
// The date-by-date loop below still only processes this chunk's own `dates`, so no day
|
|
167
|
+
// is ever double-counted.
|
|
168
|
+
const chunkFrom = chunkIndex === 0 ? chunkFromBase : new Date(chunkFromBase.getTime() - CHUNK_BOUNDARY_BUFFER_MS)
|
|
169
|
+
const chunkTo = chunkIndex === dateGroups.length - 1 ? chunkToBase : new Date(chunkToBase.getTime() + CHUNK_BOUNDARY_BUFFER_MS)
|
|
156
170
|
|
|
157
171
|
const allInOne = await traccarHelper.getAllInOne(traccar, chunkFrom, chunkTo, devices, true, true, true, false)
|
|
158
172
|
const summary = await getReportSummaryByDay(dates, userData, traccar, devices, timezone, from, to, firstDate, lastDate)
|
package/src/sensor-report.js
CHANGED
|
@@ -343,16 +343,16 @@ async function exportToPDF (userData, reportData) {
|
|
|
343
343
|
: (userData.groupByDay
|
|
344
344
|
? [
|
|
345
345
|
translations.report.date,
|
|
346
|
-
|
|
346
|
+
translations.report.sensor,
|
|
347
347
|
translations.report.start,
|
|
348
348
|
translations.report.end,
|
|
349
349
|
translations.report.duration
|
|
350
350
|
]
|
|
351
351
|
: [
|
|
352
|
-
|
|
352
|
+
translations.report.sensor,
|
|
353
353
|
translations.report.start,
|
|
354
354
|
translations.report.end,
|
|
355
|
-
|
|
355
|
+
translations.report.status,
|
|
356
356
|
translations.report.duration,
|
|
357
357
|
translations.report.endAddress
|
|
358
358
|
])
|
|
@@ -360,7 +360,7 @@ async function exportToPDF (userData, reportData) {
|
|
|
360
360
|
if (reportDataRows) {
|
|
361
361
|
// eslint-disable-next-line new-cap
|
|
362
362
|
const doc = new jsPDF.jsPDF('l')
|
|
363
|
-
await headerFromUser(doc,
|
|
363
|
+
await headerFromUser(doc, translations.report.titleSensorReport, userData.user)
|
|
364
364
|
|
|
365
365
|
let index = 0
|
|
366
366
|
reportDataRows.forEach(function (d) {
|