fleetmap-reports 1.0.309 → 1.0.310

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.
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="RunConfigurationProducerService">
4
+ <option name="ignoredProducers">
5
+ <set>
6
+ <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
7
+ </set>
8
+ </option>
9
+ </component>
10
+ </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.309",
3
+ "version": "1.0.310",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -138,13 +138,13 @@ async function createActivityReportByDriver(from, to, userData, traccarInstance)
138
138
  to: to
139
139
  }
140
140
 
141
- allData.drivers = processDrivers(from, to, userData.drivers, {trips: tripsData, route: routeData})
141
+ allData.drivers = processDrivers(from, to, userData.drivers, {trips: tripsData, route: routeData}, userData)
142
142
 
143
143
  return allData
144
144
  }
145
145
 
146
146
 
147
- function processDevices(from, to, devices, data) {
147
+ function processDevices(from, to, devices, data, userData) {
148
148
  const devicesResult = []
149
149
 
150
150
  devices.forEach(d => {
@@ -211,7 +211,7 @@ function processDevices(from, to, devices, data) {
211
211
  return devicesResult
212
212
  }
213
213
 
214
- function processDrivers(from, to, drivers, data) {
214
+ function processDrivers(from, to, drivers, data, userData) {
215
215
  console.log(data)
216
216
  const driversResult = []
217
217
  drivers.forEach(d => {
@@ -264,20 +264,20 @@ async function exportActivityReportToPDF(userData, reportData) {
264
264
  await headerFromUser(doc, translations.report.titleActivityReport, userData.user)
265
265
 
266
266
  if(userData.groupByDay && userData.byDriver) {
267
- exportActivityReportToPDF_Driver_GroupByDay(doc, translations, reportData)
267
+ exportActivityReportToPDF_Driver_GroupByDay(doc, translations, reportData, userData)
268
268
  } else if(userData.groupByDay) {
269
- exportActivityReportToPDF_Vehicle_GroupByDay(doc, translations, reportData)
269
+ exportActivityReportToPDF_Vehicle_GroupByDay(doc, translations, reportData, userData)
270
270
  } else if(userData.byDriver) {
271
- exportActivityReportToPDF_Driver(doc, translations, reportData)
271
+ exportActivityReportToPDF_Driver(doc, translations, reportData, userData)
272
272
  } else {
273
- exportActivityReportToPDF_Vehicle(doc, translations, reportData)
273
+ exportActivityReportToPDF_Vehicle(doc, translations, reportData, userData)
274
274
  }
275
275
 
276
276
  return doc
277
277
  }
278
278
  }
279
279
 
280
- function exportActivityReportToPDF_Driver(doc, translations, reportData) {
280
+ function exportActivityReportToPDF_Driver(doc, translations, reportData, userData) {
281
281
  const headers = [translations.report.driver,
282
282
  translations.report.distance,
283
283
  translations.report.speed + ' ' + translations.report.avgSpeed + ' (Km/h)',
@@ -309,7 +309,7 @@ function exportActivityReportToPDF_Driver(doc, translations, reportData) {
309
309
  addTable(doc, headers, data, footValues, style, 35)
310
310
  }
311
311
 
312
- function exportActivityReportToPDF_Vehicle(doc, translations, reportData) {
312
+ function exportActivityReportToPDF_Vehicle(doc, translations, reportData, userData) {
313
313
  const headers = [translations.report.vehicle,
314
314
  translations.report.group,
315
315
  translations.report.distance,
@@ -354,7 +354,7 @@ function exportActivityReportToPDF_Vehicle(doc, translations, reportData) {
354
354
  addTable(doc, headers, data, footValues, style, 35)
355
355
  }
356
356
 
357
- function exportActivityReportToPDF_Vehicle_GroupByDay(doc, translations, reportData) {
357
+ function exportActivityReportToPDF_Vehicle_GroupByDay(doc, translations, reportData, userData) {
358
358
  const headers = [translations.report.date,
359
359
  translations.report.distance,
360
360
  translations.report.start + ' ' + translations.report.odometer,
@@ -420,17 +420,17 @@ function exportActivityReportToPDF_Vehicle_GroupByDay(doc, translations, reportD
420
420
  const footValues = ['Total:' + d.summary.length,
421
421
  (d.summary.reduce((a, b) => a + b.distance, 0) / 1000).toFixed(0),
422
422
  '', '',
423
- getSumAvgSpeed(d.summary),
424
- getSumMaxSpeed(d.summary),
423
+ getSumAvgSpeed(d.summary, userData),
424
+ getSumMaxSpeed(d.summary, userData),
425
425
  convertMS(d.summary.reduce((a, b) => a + b.engineHours, 0)),
426
- getSumSpentFuel(d.summary)]
426
+ getSumSpentFuel(d.summary, userData)]
427
427
 
428
428
  const style = getStyle(getUserPartner(userData.user))
429
429
  addTable(doc, headers, data, footValues, style, 40)
430
430
  })
431
431
  }
432
432
 
433
- function exportActivityReportToExcel_Vehicle_GroupByDay(settings, translations, reportData) {
433
+ function exportActivityReportToExcel_Vehicle_GroupByDay(settings, translations, reportData, userData) {
434
434
  const headers = [{label: translations.report.vehicle, value: 'name'},
435
435
  {label: translations.report.group, value: 'group'},
436
436
  {label: translations.report.date, value: 'date'},
@@ -484,7 +484,7 @@ function exportActivityReportToExcel_Vehicle_GroupByDay(settings, translations,
484
484
  }
485
485
  }
486
486
 
487
- function exportActivityReportToPDF_Driver_GroupByDay(doc, translations, reportData) {
487
+ function exportActivityReportToPDF_Driver_GroupByDay(doc, translations, reportData, userData) {
488
488
  const headers = [translations.report.date,
489
489
  translations.report.distance,
490
490
  translations.report.avgSpeed + ' (Km/h)',
@@ -552,7 +552,7 @@ function exportActivityReportToPDF_Driver_GroupByDay(doc, translations, reportDa
552
552
  })
553
553
  }
554
554
 
555
- function exportActivityReportToExcel_Driver_GroupByDay(settings, translations, reportData) {
555
+ function exportActivityReportToExcel_Driver_GroupByDay(settings, translations, reportData, userData) {
556
556
  const headers = [{label: translations.report.driver, value: 'name'},
557
557
  {label: translations.report.group, value: 'group'},
558
558
  {label: translations.report.date, value: 'date'},
@@ -627,7 +627,7 @@ function exportActivityReportToExcel_Driver(settings, translations, reportData)
627
627
  }
628
628
  }
629
629
 
630
- function exportActivityReportToExcel_Vehicle(settings, translations, reportData) {
630
+ function exportActivityReportToExcel_Vehicle(settings, translations, reportData, userData) {
631
631
  const headers = [{label: translations.report.vehicle, value: 'name'},
632
632
  {label: translations.report.group, value: 'group'},
633
633
  {label: translations.report.distance, value: 'distance'},
@@ -664,9 +664,8 @@ function exportActivityReportToExcel_Vehicle(settings, translations, reportData)
664
664
  }
665
665
  }
666
666
 
667
- function exportActivityReportToExcel(reportUserData, reportData) {
667
+ function exportActivityReportToExcel(userData, reportData) {
668
668
  console.log('Export to Excel')
669
- userData = reportUserData
670
669
  const lang = userData.user.attributes.lang
671
670
  const translations = messages[lang] ? messages[lang] : messages['en-GB']
672
671
 
@@ -676,17 +675,17 @@ function exportActivityReportToExcel(reportUserData, reportData) {
676
675
  }
677
676
 
678
677
  if(userData.groupByDay && userData.byDriver){
679
- return exportActivityReportToExcel_Driver_GroupByDay(settings, translations, reportData)
678
+ return exportActivityReportToExcel_Driver_GroupByDay(settings, translations, reportData, userData)
680
679
  } else if(userData.groupByDay){
681
- return exportActivityReportToExcel_Vehicle_GroupByDay(settings, translations, reportData)
680
+ return exportActivityReportToExcel_Vehicle_GroupByDay(settings, translations, reportData, userData)
682
681
  } else if(userData.byDriver){
683
- return exportActivityReportToExcel_Driver(settings, translations, reportData)
682
+ return exportActivityReportToExcel_Driver(settings, translations, reportData, userData)
684
683
  } else {
685
- return exportActivityReportToExcel_Vehicle(settings, translations, reportData)
684
+ return exportActivityReportToExcel_Vehicle(settings, translations, reportData, userData)
686
685
  }
687
686
  }
688
687
 
689
- function getSumAvgSpeed(data){
688
+ function getSumAvgSpeed(data, userData){
690
689
  const values = data.map(item => {
691
690
  if(userData.groupByDay){
692
691
  return Math.round(item.averageSpeed * 1.85200)
@@ -697,7 +696,7 @@ function getSumAvgSpeed(data){
697
696
  return Math.round((values.reduce((a, b) => a + b, 0)) / values.length)
698
697
  }
699
698
 
700
- function getSumMaxSpeed(data){
699
+ function getSumMaxSpeed(data, userData){
701
700
  const values = data.map(item => {
702
701
  if(userData.groupByDay){
703
702
  return item.maxSpeed
@@ -711,7 +710,7 @@ function getSumMaxSpeed(data){
711
710
  return Math.round(max * 1.85200)
712
711
  }
713
712
 
714
- function getSumSpentFuel(data){
713
+ function getSumSpentFuel(data, userData){
715
714
  const values = data.map(item => {
716
715
  if(userData.groupByDay){
717
716
  return item.convertedSpentFuel >= 0 ? item.convertedSpentFuel : 0
@@ -6,32 +6,26 @@ const {convertToLocaleString, convertMS} = require("./util/utils");
6
6
  const {getStyle} = require("./reportStyle");
7
7
  const {getUserPartner} = require("fleetmap-partners");
8
8
 
9
-
10
- let traccarInstance
11
- let userData
12
-
13
9
  const fileName = 'IdleReport'
14
10
 
15
- async function createIdleReport(from, to, reportUserData, traccar) {
11
+ async function createIdleReport(from, to, userData, traccarInstance) {
16
12
  console.log('Create IdleReport')
17
- userData = reportUserData
18
- traccarInstance = traccar
19
13
  const reportData = []
20
14
 
21
15
  if (userData.byGroup) {
22
16
  console.log("ByGroup")
23
- const allData = await createTripReportByGroup(from, to)
17
+ const allData = await createTripReportByGroup(from, to, userData, traccarInstance)
24
18
  reportData.push(...allData)
25
19
  } else {
26
20
  console.log("ByDevice")
27
- const report = await createTripReportByDevice(from, to)
21
+ const report = await createTripReportByDevice(from, to, userData, traccarInstance)
28
22
  reportData.push(report)
29
23
  }
30
24
 
31
25
  return reportData
32
26
  }
33
27
 
34
- async function createTripReportByGroup(from, to) {
28
+ async function createTripReportByGroup(from, to, userData, traccarInstance) {
35
29
  const reportData = []
36
30
  for (const g of userData.groups) {
37
31
  const devices = userData.devices.filter(d => d.groupId === g.id)
@@ -61,14 +55,13 @@ async function createTripReportByGroup(from, to) {
61
55
  const groupIds = userData.groups.map(g => g.id)
62
56
  const withoutGroupDevices = userData.devices.filter(d => !groupIds.includes(d.groupId))
63
57
 
64
- const allData = await createTripReportByDevice(from, to, withoutGroupDevices)
58
+ const allData = await createTripReportByDevice(from, to, withoutGroupDevices, userData, traccarInstance)
65
59
  reportData.push(allData)
66
60
 
67
61
  return reportData
68
62
  }
69
63
 
70
- async function createTripReportByDevice(from, to) {
71
- const devices = userData.devices
64
+ async function createTripReportByDevice(from, to, devices, userData, traccarInstance) {
72
65
  const allData = {
73
66
  devices: [],
74
67
  from: from,
package/src/kms-report.js CHANGED
@@ -11,37 +11,32 @@ const drivers = require("./util/driver")
11
11
  const { isInsideTimetable, isPartialInsideTimetable} = require("./util/trips")
12
12
  const word = require("./word");
13
13
 
14
- let traccarInstance
15
- let userData
16
-
17
14
  const fileName = 'KmsReport'
18
15
 
19
- async function createKmsReport(from, to, reportUserData, traccar) {
16
+ async function createKmsReport(from, to, userData, traccarInstance) {
20
17
  console.log('Create KmsReport')
21
18
 
22
19
  console.log(from, to)
23
- traccarInstance = traccar
24
- userData = reportUserData
25
20
  const reportData = []
26
21
  if(userData.byDriver){
27
22
  console.log("ByDriver")
28
- const allData = await createKmsReportByDriver(from, to)
23
+ const allData = await createKmsReportByDriver(from, to, userData, traccarInstance)
29
24
  reportData.push(allData)
30
25
  }
31
26
  else if(userData.byGroup){
32
27
  console.log("ByGroup")
33
- const allData = await createKmsReportByGroup(from, to)
28
+ const allData = await createKmsReportByGroup(from, to, userData, traccarInstance)
34
29
  reportData.push(...allData)
35
30
  } else {
36
31
  console.log("ByDevice")
37
- const allData = await createKmsReportByDevice(from, to)
32
+ const allData = await createKmsReportByDevice(from, to, userData, traccarInstance)
38
33
  reportData.push(allData)
39
34
  }
40
35
 
41
36
  return reportData
42
37
  }
43
38
 
44
- async function createKmsReportByDevice(from, to) {
39
+ async function createKmsReportByDevice(from, to, userData, traccarInstance) {
45
40
  const groupIds = userData.groups.map(g => g.id)
46
41
  const devicesToProcess = userData.byGroup ? userData.devices.filter(d => !groupIds.includes(d.groupId)) : userData.devices
47
42
 
@@ -59,13 +54,13 @@ async function createKmsReportByDevice(from, to) {
59
54
 
60
55
  if (tripsData.length > 0) {
61
56
  trips.checkTripsKms(traccarInstance, from, to, devicesToProcess, {trips: tripsData, route: route})
62
- allData.devices = processDevices(from, to, devicesToProcess, {trips: tripsData, route: route})
57
+ allData.devices = processDevices(from, to, devicesToProcess, {trips: tripsData, route: route}, userData)
63
58
  }
64
59
 
65
60
  return allData
66
61
  }
67
62
 
68
- async function createKmsReportByDriver(from, to) {
63
+ async function createKmsReportByDriver(from, to, userData, traccarInstance) {
69
64
  const devices = await drivers.devicesByDriver(traccarInstance, from, to, userData.drivers, userData.devices)
70
65
  console.log(devices.length)
71
66
 
@@ -77,10 +72,10 @@ async function createKmsReportByDriver(from, to) {
77
72
  const tripsData = await traccar.getTrips(traccarInstance, from, to, devices)
78
73
  const routeData = await traccar.getTrips(traccarInstance, from, to, devices)
79
74
 
80
- return { drivers: processDrivers(from, to, userData.drivers, {trips: tripsData, route: routeData}) }
75
+ return { drivers: processDrivers(from, to, userData, {trips: tripsData, route: routeData}) }
81
76
  }
82
77
 
83
- async function createKmsReportByGroup(from, to) {
78
+ async function createKmsReportByGroup(from, to, userData, traccarInstance) {
84
79
  const reportData = []
85
80
  for (const g of userData.groups) {
86
81
  const devices = userData.devices.filter(d => d.groupId === g.id)
@@ -101,7 +96,7 @@ async function createKmsReportByGroup(from, to) {
101
96
 
102
97
  if (tripsData.length > 0) {
103
98
  trips.checkTripsKms(traccarInstance, from, to, devices, {trips: tripsData, route: route})
104
- groupData.devices = processDevices(from, to, devices, {trips: tripsData, route: route})
99
+ groupData.devices = processDevices(from, to, devices, {trips: tripsData, route: route}, userData)
105
100
  }
106
101
 
107
102
  reportData.push(groupData)
@@ -114,10 +109,10 @@ async function createKmsReportByGroup(from, to) {
114
109
  return reportData
115
110
  }
116
111
 
117
- function processDrivers(from, to, drivers, data) {
112
+ function processDrivers(from, to, userData, data) {
118
113
  console.log(data)
119
114
  const driversResult = []
120
- drivers.forEach(d => {
115
+ userData.drivers.forEach(d => {
121
116
  const route = data.route.filter(p => p.attributes.driverUniqueId === d.uniqueId)
122
117
  const trips = data.trips.filter(t => t.driverUniqueId === d.uniqueId
123
118
  && (userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, route)))
@@ -152,7 +147,7 @@ function processDrivers(from, to, drivers, data) {
152
147
  return driversResult
153
148
  }
154
149
 
155
- function processDevices(from, to, devices, data) {
150
+ function processDevices(from, to, devices, data, userData) {
156
151
  const devicesResult = []
157
152
 
158
153
  for (const d of devices) {
@@ -11,37 +11,31 @@ const traccar = require("./util/traccar")
11
11
  const trips = require("./util/trips");
12
12
  const {isInsideTimetable, addNearestPOIs, isPartialInsideTimetable} = require("./util/trips")
13
13
 
14
-
15
- let traccarInstance
16
- let userData
17
-
18
14
  const fileName = 'TripReport'
19
15
 
20
- async function createTripReport(from, to, reportUserData, traccar) {
16
+ async function createTripReport(from, to, userData, traccarInstance) {
21
17
  console.log('Create TripReport')
22
- userData = reportUserData
23
- traccarInstance = traccar
24
18
  const reportData = []
25
19
 
26
20
  if (userData.byDriver) {
27
21
  console.log("ByDriver")
28
- const report = await createTripReportByDriver(from, to)
22
+ const report = await createTripReportByDriver(from, to, userData, traccarInstance)
29
23
  reportData.push(report)
30
24
  }
31
25
  else if (userData.byGroup) {
32
26
  console.log("ByGroup")
33
- const allData = await createTripReportByGroup(from, to)
27
+ const allData = await createTripReportByGroup(from, to, userData, traccarInstance)
34
28
  reportData.push(...allData)
35
29
  } else {
36
30
  console.log("ByDevice")
37
- const report = await createTripReportByDevice(from, to)
31
+ const report = await createTripReportByDevice(from, to, userDatauserData, traccarInstance)
38
32
  reportData.push(report)
39
33
  }
40
34
 
41
35
  return reportData
42
36
  }
43
37
 
44
- async function createTripReportByDevice(from, to) {
38
+ async function createTripReportByDevice(from, to, userData, traccarInstance) {
45
39
  const devices = userData.devices
46
40
  const allData = {
47
41
  devices: [],
@@ -59,13 +53,13 @@ async function createTripReportByDevice(from, to) {
59
53
 
60
54
  if (tripsData.length > 0) {
61
55
  trips.checkTripsKms(traccarInstance, from, to, devices, {trips: tripsData, route: routeData})
62
- allData.devices = processDevices(from, to, devices, {trips: tripsData, stops: stopsData, route: routeData})
56
+ allData.devices = processDevices(from, to, devices, {trips: tripsData, stops: stopsData, route: routeData}, userData)
63
57
  }
64
58
 
65
59
  return allData
66
60
  }
67
61
 
68
- async function createTripReportByGroup(from, to) {
62
+ async function createTripReportByGroup(from, to, userData, traccarInstance) {
69
63
  const reportData = []
70
64
  for (const g of userData.groups) {
71
65
  const devices = userData.devices.filter(d => d.groupId === g.id)
@@ -90,7 +84,7 @@ async function createTripReportByGroup(from, to) {
90
84
 
91
85
  if (tripsData.length > 0) {
92
86
  console.log('Trips:' + tripsData.length)
93
- groupData.devices = processDevices(from, to, devices, {trips: tripsData, stops: stopsData, route: routeData})
87
+ groupData.devices = processDevices(from, to, devices, {trips: tripsData, stops: stopsData, route: routeData}, userData)
94
88
 
95
89
  reportData.push(groupData)
96
90
  }
@@ -100,13 +94,13 @@ async function createTripReportByGroup(from, to) {
100
94
  const groupIds = userData.groups.map(g => g.id)
101
95
  const withoutGroupDevices = userData.devices.filter(d => !groupIds.includes(d.groupId))
102
96
 
103
- const allData = await createTripReportByDevice(from, to, withoutGroupDevices)
97
+ const allData = await createTripReportByDevice(from, to, withoutGroupDevices, userData)
104
98
  reportData.push(allData)
105
99
 
106
100
  return reportData
107
101
  }
108
102
 
109
- async function createTripReportByDriver(from, to){
103
+ async function createTripReportByDriver(from, to, userData, traccarInstance){
110
104
  const devices = await drivers.devicesByDriver(traccarInstance, from, to, userData.drivers, userData.devices)
111
105
  console.log(devices.length)
112
106
 
@@ -118,10 +112,10 @@ async function createTripReportByDriver(from, to){
118
112
  const tripsData = await traccar.getTrips(traccarInstance, from, to, devices)
119
113
  const routeData = await traccar.getRoute(traccarInstance, from, to, devices)
120
114
 
121
- return { drivers: processDrivers(from, to, userData.drivers, {trips: tripsData, route: routeData})}
115
+ return { drivers: processDrivers(from, to, userData, {trips: tripsData, route: routeData})}
122
116
  }
123
117
 
124
- function processDevices(from, to, devices, data) {
118
+ function processDevices(from, to, devices, data, userData) {
125
119
  const devicesResult = []
126
120
 
127
121
  devices.forEach(d => {
@@ -175,10 +169,10 @@ function processDevices(from, to, devices, data) {
175
169
  return devicesResult
176
170
  }
177
171
 
178
- function processDrivers(from, to, drivers, data) {
172
+ function processDrivers(from, to, userData, data) {
179
173
  console.log(data)
180
174
  const driversResult = []
181
- drivers.forEach(d => {
175
+ userData.drivers.forEach(d => {
182
176
  const route = data.route.filter(p => p.attributes.driverUniqueId === d.uniqueId)
183
177
  const trips = data.trips.filter(t => t.driverUniqueId === d.uniqueId
184
178
  && (userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, route)))
@@ -1,7 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <ScalaCodeStyleSettings>
4
- <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
5
- </ScalaCodeStyleSettings>
6
- </code_scheme>
7
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptLibraryMappings">
4
- <file url="file://$PROJECT_DIR$" libraries="{Node.js Core}" />
5
- </component>
6
- </project>