fleetmap-reports 1.0.560 → 1.0.562

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.560",
3
+ "version": "1.0.562",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -7,6 +7,7 @@ const { getUserPartner } = require('fleetmap-partners')
7
7
  const { convertToLocaleString, getTranslations } = require('./util/utils')
8
8
  const { devicesToProcess } = require('./util/device')
9
9
  const { isInside } = require('./util/timetable')
10
+ const { getDigitalPortValue } = require('./location-report')
10
11
 
11
12
  const fileName = 'EventReport'
12
13
 
@@ -175,7 +176,7 @@ async function exportSpeedingReportToPDF (userData, reportData) {
175
176
  a.type === 'alarm' ? translations.report['event_' + a.attributes.alarm] : translations.report['event_' + a.type],
176
177
  getAlertDate(userData.user, a),
177
178
  a.geofenceName || (a.position ? a.position.address : ''),
178
- getAlertInfo(userData.drivers, a)
179
+ getAlertInfo(userData.drivers, a, d.device, translations)
179
180
  ]
180
181
  data.push(temp)
181
182
  })
@@ -228,7 +229,9 @@ function exportSpeedingReportToExcel (userData, reportData) {
228
229
  { label: translations.report.date, value: 'fixTime' },
229
230
  { label: translations.report.address, value: 'address' },
230
231
  { label: translations.report.driver, value: 'driver' },
231
- { label: translations.report.info, value: 'info' }
232
+ { label: translations.report.info, value: 'info' },
233
+ { label: 'Latitude', value: 'latitude' },
234
+ { label: 'Longitude', value: 'longitude' }
232
235
  ]
233
236
  let data = []
234
237
  if (reportData.devices) {
@@ -240,7 +243,9 @@ function exportSpeedingReportToExcel (userData, reportData) {
240
243
  fixTime: getAlertDate(userData.user, a),
241
244
  address: a.geofenceName || (a.position ? a.position.address : ''),
242
245
  info: getAlertInfo(userData.drivers, a),
243
- driver: a.driver
246
+ driver: a.driver,
247
+ latitude: a.position && a.position.latitude,
248
+ longitude: a.position && a.position.longitude
244
249
  }
245
250
  }))
246
251
  })
@@ -264,7 +269,10 @@ function deviceName (device) {
264
269
  return device.name + (device.attributes.license_plate ? ', ' + device.attributes.license_plate : '') + (device.model ? ', ' + device.model : '')
265
270
  }
266
271
 
267
- function getAlertInfo (drivers, alert) {
272
+ function getAlertInfo (drivers, alert, device, translations) {
273
+ if (alert.type === 'alarm' && alert.position) {
274
+ getDigitalPortValue(alert.position, 1, translations, device.attributes)
275
+ }
268
276
  if (alert.type === 'deviceOverspeed') {
269
277
  return Math.round(alert.attributes.speed * 1.85200) + ' Km/h'
270
278
  }
@@ -107,7 +107,7 @@ async function createLocationReportByDevice (from, to, userData, traccar) {
107
107
  return allData
108
108
  }
109
109
 
110
- function processDevices (from, to, devices, data, userData) {
110
+ function processDevices (from, to, devices, data) {
111
111
  const devicesResult = []
112
112
 
113
113
  for (const d of devices) {
@@ -313,7 +313,7 @@ function getDigitalPort2Label (row, translations) {
313
313
  return row.attributes.door2 || translations.report.digital_ports2
314
314
  }
315
315
 
316
- function getDigitalPortValue (row, index, translations, dAttributes) {
316
+ export function getDigitalPortValue (row, index, translations, dAttributes) {
317
317
  switch (index) {
318
318
  case 1:
319
319
  if (row.attributes && row.attributes.door1 !== undefined) {