fleetmap-reports 1.0.313 → 1.0.317

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.313",
3
+ "version": "1.0.317",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -348,7 +348,7 @@ function exportActivityReportToPDF_Vehicle(doc, translations, reportData, userDa
348
348
  getSumAvgSpeed(reportData.devices, userData),
349
349
  getSumMaxSpeed(reportData.devices, userData),
350
350
  convertMS(reportData.devices.reduce((a, b) => a + b.summary[0].engineHours, 0)),
351
- getSumSpentFuel(reportData.devices, userdata)]
351
+ getSumSpentFuel(reportData.devices, userData)]
352
352
 
353
353
  const style = getStyle(getUserPartner(userData.user))
354
354
  addTable(doc, headers, data, footValues, style, 35)
@@ -45,7 +45,7 @@ async function createTripReportByGroup(from, to, userData, traccarInstance) {
45
45
 
46
46
  if (routes.length > 0) {
47
47
  console.log('Routes:' + routes.length)
48
- groupData.devices = processDevices(from, to, devices, routes)
48
+ groupData.devices = processDevices(from, to, devices, routes, userData)
49
49
 
50
50
  reportData.push(groupData)
51
51
  }
@@ -76,13 +76,13 @@ async function createTripReportByDevice(from, to, devices, userData, traccarInst
76
76
  console.log('Route:' + route.length)
77
77
 
78
78
  if (route.length > 0) {
79
- allData.devices = processDevices(from, to, devices, route)
79
+ allData.devices = processDevices(from, to, devices, route, userData)
80
80
  }
81
81
 
82
82
  return allData
83
83
  }
84
84
 
85
- function processDevices(from, to, devices, routes) {
85
+ function processDevices(from, to, devices, routes, userData) {
86
86
  const devicesResult = []
87
87
 
88
88
  devices.forEach(d => {
@@ -107,10 +107,12 @@ function processDevices(from, to, devices, routes) {
107
107
  }
108
108
  })
109
109
 
110
- if(idleEvents.length) {
110
+ const filteredEvents = idleEvents.filter(e => userData.minimumIdleMinutes ? e.idleTime > userData.minimumIdleMinutes*60*1000 : true)
111
+
112
+ if(filteredEvents.length) {
111
113
  const deviceData = {
112
114
  device: d,
113
- idleEvents: idleEvents
115
+ idleEvents: filteredEvents
114
116
  }
115
117
  devicesResult.push(deviceData)
116
118
  }
@@ -54,7 +54,7 @@ async function createSpeedingReportByGroup(from, to, userData, traccarInstance){
54
54
  devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
55
55
 
56
56
  if (events.length > 0) {
57
- groupData.devices = await processDevices(from, to, devices, events, routes)
57
+ groupData.devices = await processDevices(from, to, devices, events, routes, userData)
58
58
  reportData.push(groupData)
59
59
  }
60
60
  }
@@ -90,7 +90,7 @@ async function createSpeedingReportByDevice(from, to, devices, userData, traccar
90
90
  }
91
91
 
92
92
  return {
93
- devices: await processDevices(from, to, devices, events, routes),
93
+ devices: await processDevices(from, to, devices, events, routes, userData),
94
94
  xpert: devices.filter(d => d && d.attributes && d.attributes.xpert).length > 0
95
95
  }
96
96
  }