fleetmap-reports 1.0.869 → 1.0.870

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": "1.0.869",
3
+ "version": "1.0.870",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -4,7 +4,7 @@ require('jspdf-autotable')
4
4
  const { getStyle } = require('./reportStyle')
5
5
  const { headerFromUser } = require('./util/pdfDocument')
6
6
  const { getUserPartner } = require('fleetmap-partners')
7
- const { convertToLocaleString, getTranslations } = require('./util/utils')
7
+ const { convertToLocaleString, getTranslations, convertMS } = require('./util/utils')
8
8
  const { devicesToProcess } = require('./util/device')
9
9
  const { isInside } = require('./util/timetable')
10
10
  const { getDigitalPortValue } = require('./location-report')
@@ -139,8 +139,10 @@ async function exportSpeedingReportToPDF (userData, reportData) {
139
139
 
140
140
  const headers = [
141
141
  translations.report.eventType,
142
- translations.report.date,
142
+ translations.report.start,
143
+ translations.report.end,
143
144
  translations.report.address,
145
+ translations.report.duration,
144
146
  translations.report.info
145
147
  ]
146
148
  if (reportData.devices) {
@@ -192,8 +194,10 @@ async function exportSpeedingReportToPDF (userData, reportData) {
192
194
  d.alerts.forEach(a => {
193
195
  const temp = [
194
196
  getEventType(a, translations, d.device),
195
- getAlertDate(userData.user, a),
197
+ getAlertDate(userData.user, a.position),
198
+ getAlertDate(userData.user, a.endPosition),
196
199
  a.geofenceName || (a.position ? a.position.address : ''),
200
+ a.position && a.endPosition ? convertMS(new Date(a.endPosition.fixTime).getTime() - new Date(a.position.fixTime).getTime()) : '',
197
201
  getAlertInfo(userData.drivers, a, d.device, translations)
198
202
  ]
199
203
  data.push(temp)
@@ -254,8 +258,10 @@ function exportSpeedingReportToExcel (userData, reportData) {
254
258
  const headers = [
255
259
  { label: translations.report.vehicle, value: 'name' },
256
260
  { label: translations.report.eventType, value: 'eventType' },
257
- { label: translations.report.date, value: 'fixTime' },
261
+ { label: translations.report.start, value: 'fixTime' },
262
+ { label: translations.report.end, value: 'endFixTime' },
258
263
  { label: translations.report.address, value: 'address' },
264
+ { label: translations.report.duration, value: 'duration' },
259
265
  { label: translations.report.zone, value: 'geofenceName' },
260
266
  { label: translations.report.driver, value: 'driver' },
261
267
  { label: translations.report.info, value: 'info' },
@@ -269,8 +275,10 @@ function exportSpeedingReportToExcel (userData, reportData) {
269
275
  return {
270
276
  name: d.device.name,
271
277
  eventType: getEventType(a, translations, d.device),
272
- fixTime: getAlertDate(userData.user, a),
278
+ fixTime: getAlertDate(userData.user, a.position),
279
+ endFixTime: getAlertDate(userData.user, a.endPosition),
273
280
  address: a.position && a.position.address,
281
+ duration: a.position && a.endPosition ? convertMS(new Date(a.endPosition.fixTime).getTime() - new Date(a.position.fixTime).getTime()) : '',
274
282
  geofenceName: a.geofenceName,
275
283
  info: getAlertInfo(userData.drivers, a, d.device, translations),
276
284
  driver: a.driver,
@@ -316,9 +324,9 @@ function getAlertInfo (drivers, alert, device, translations) {
316
324
  return ''
317
325
  }
318
326
 
319
- function getAlertDate (user, alert) {
320
- if (alert.position) {
321
- return convertToLocaleString(alert.position.fixTime, user.attributes.lang, user.attributes.timezone)
327
+ function getAlertDate (user, position) {
328
+ if (position) {
329
+ return convertToLocaleString(position.fixTime, user.attributes.lang, user.attributes.timezone)
322
330
  }
323
331
  }
324
332