fleetmap-reports 1.0.214 → 1.0.218

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,7 @@
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>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.214",
3
+ "version": "1.0.218",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -23,7 +23,7 @@ function Reports(config, axios) {
23
23
  return require('./speeding-report').createSpeedingReport(from, to, userData, this.traccar, roadSpeedLimits)
24
24
  }
25
25
 
26
- this.speedingReportToPDF = async (userData, reportData) => {
26
+ this.speedingReportToPDF = (userData, reportData) => {
27
27
  return require('./speeding-report').exportSpeedingReportToPDF(userData, reportData)
28
28
  }
29
29
 
package/src/index.test.js CHANGED
@@ -3,42 +3,25 @@ const {SessionApi} = require("traccar-api");
3
3
  const axios = require('axios')
4
4
  const axiosCookieJarSupport = require('axios-cookiejar-support').default;
5
5
  const tough = require('tough-cookie');
6
- const style = require("./reportStyle");
7
6
  const cookieJar = new tough.CookieJar();
8
7
 
9
8
  axiosCookieJarSupport(axios)
10
9
 
11
-
12
- describe('test reports', function() {
13
- this.timeout(9000000)
14
- it('test queue', async () => {
15
- const traccarConfig = {
16
- basePath: 'https://api.fleetmap.io/api',
17
- baseOptions: {
18
- withCredentials: true,
19
- jar: cookieJar
20
- }
10
+ test('speedingReport', async () => {
11
+ const traccarConfig = {
12
+ basePath: 'https://api.pinme.io/api',
13
+ baseOptions: {
14
+ withCredentials: true,
15
+ jar: cookieJar
21
16
  }
17
+ }
22
18
 
23
- await new SessionApi(traccarConfig, null, axios).sessionPost('jppenas@gmail.com', 'penas46881')
24
- const report = new Index(traccarConfig, axios)
25
- const userData = await report.getUserData()
26
- userData.groupByDay = true
27
- const reportData = await report.kmsReport(new Date(2021, 10, 19, 0, 0, 0, 0),
28
- new Date(2021, 10, 21, 23, 59, 59, 0),
29
- userData)
30
-
31
- const reportResult = reportData[0]
32
- reportResult.devices.forEach(d => {
33
- console.log(d.device.name)
34
- d.days.forEach(day => {
35
- console.log(day.date + ' - ' + day.kms)
36
- })
37
- })
38
-
19
+ await new SessionApi(traccarConfig, null, axios).sessionPost('-','-')
20
+ const report = new Index(traccarConfig, axios)
21
+ const userData = await report.getUserData()
39
22
 
40
- const pdf = report.kmsReportToPDF(userData, reportResult)
23
+ await report.speedingReport(new Date(2021, 2, 30, 0, 0, 0, 0),
24
+ new Date(2021, 2, 30, 23, 59, 59, 0),
25
+ userData)
41
26
 
42
- console.log(pdf)
43
- })
44
- })
27
+ }, 10000)
package/src/kms-report.js CHANGED
@@ -6,7 +6,6 @@ const {getStyle} = require("./reportStyle");
6
6
  const {headerFromUser,addTable} = require("./util/pdfDocument");
7
7
  const {getUserPartner} = require("fleetmap-partners");
8
8
  const automaticReports = require("./automaticReports");
9
- const {convertMS} = require("./util/utils");
10
9
 
11
10
 
12
11
  let traccarInstance
@@ -18,7 +17,9 @@ async function createKmsReportByDevice(from, to, userData) {
18
17
  const devicesToProcess = userData.byGroup ? userData.devices.filter(d => !groupIds.includes(d.groupId)) : userData.devices
19
18
 
20
19
  const allData = {
21
- devices: []
20
+ devices: [],
21
+ from: from,
22
+ to: to
22
23
  }
23
24
 
24
25
  devicesToProcess.sort((a, b) => (a.name > b.name) ? 1 : -1)
@@ -130,8 +131,9 @@ async function exportKmsReportToPDF(userData, reportData) {
130
131
  translations.report.distance)
131
132
  }
132
133
  if (kmsData) {
134
+ let first = true
133
135
  const doc = userData.groupByDay ? new jsPDF.jsPDF() : new jsPDF.jsPDF('l')
134
- await headerFromUser(doc, translations.report.titleSpeedingReport, userData.user)
136
+ await headerFromUser(doc, translations.report.titleKmsReport, userData.user)
135
137
 
136
138
  if (userData.groupByDay) {
137
139
  for (const d of kmsData) {
@@ -148,23 +150,23 @@ async function exportKmsReportToPDF(userData, reportData) {
148
150
  doc.setFontSize(13)
149
151
  doc.text(name, 20, space + 20)
150
152
  doc.setFontSize(11)
151
- doc.text(group ? translations.report.group + ': ' + group.name : '', 200, space + 20)
152
- doc.text(new Date(d.from).toLocaleString() + ' - ' + new Date(d.to).toLocaleString(), 20, space + 25)
153
+ doc.text(group ? translations.report.group + ': ' + group.name : '', 150, space + 20)
154
+ doc.text(new Date(reportData.from).toLocaleString() + ' - ' + new Date(reportData.to).toLocaleString(), 20, space + 25)
153
155
 
154
156
  const data = []
155
157
  d.days.forEach(day => {
156
158
  const temp = [
157
- new Date(day).toLocaleDateString(),
158
- (day.kms/1000).toFixed(0)
159
+ new Date(day.date).toLocaleDateString(),
160
+ ((day.kms || 0)/1000).toFixed(0)
159
161
  ]
160
- })
161
162
 
162
- data.push(temp)
163
+ data.push(temp)
164
+ })
163
165
 
164
166
  const footValues = []
165
167
  footValues.push(
166
168
  '',
167
- (d.days.reduce((a, b) => a + b.kms, 0)/1000).toFixed(0)
169
+ (d.days.reduce((a, b) => a + (b.kms || 0), 0)/1000).toFixed(0)
168
170
  )
169
171
 
170
172
  const style = getStyle(getUserPartner(userData.user))
@@ -172,6 +174,7 @@ async function exportKmsReportToPDF(userData, reportData) {
172
174
  addTable(doc, headers, data, footValues, style, 35)
173
175
  }
174
176
  } else {
177
+ const data = []
175
178
  if (userData.byDriver) {
176
179
  reportData.drivers.forEach(d => {
177
180
  const group = userData.groups.find(g => g.drivers.includes(d.driver.id))
@@ -1,10 +0,0 @@
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>
@@ -1,194 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ChangeListManager">
4
- <list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="try catch on pdf addImage">
5
- <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/src/activity-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/activity-report.js" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/src/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.js" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/src/kms-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/kms-report.js" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/src/util/pdfDocument.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/pdfDocument.js" afterDir="false" />
11
- </list>
12
- <option name="SHOW_DIALOG" value="false" />
13
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
- <option name="LAST_RESOLUTION" value="IGNORE" />
16
- </component>
17
- <component name="Git.Settings">
18
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
19
- </component>
20
- <component name="ProjectId" id="20NIxbej0qfi8RaO3jr1XOU0xol" />
21
- <component name="ProjectViewState">
22
- <option name="hideEmptyMiddlePackages" value="true" />
23
- <option name="showLibraryContents" value="true" />
24
- </component>
25
- <component name="PropertiesComponent">
26
- <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
27
- <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
28
- <property name="WebServerToolWindowFactoryState" value="false" />
29
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
30
- <property name="nodejs.mocha.mocha_node_package_dir" value="$PROJECT_DIR$/node_modules/mocha" />
31
- <property name="nodejs_package_manager_path" value="npm" />
32
- <property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
33
- <property name="vue.rearranger.settings.migration" value="true" />
34
- </component>
35
- <component name="RunManager" selected="Mocha.test reports">
36
- <configuration name="here" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
37
- <node-interpreter>project</node-interpreter>
38
- <node-options />
39
- <mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
40
- <working-directory>$PROJECT_DIR$</working-directory>
41
- <pass-parent-env>true</pass-parent-env>
42
- <ui>bdd</ui>
43
- <extra-mocha-options />
44
- <test-kind>SUITE</test-kind>
45
- <test-file>$PROJECT_DIR$/src/index.test.js</test-file>
46
- <test-names>
47
- <name value="here" />
48
- </test-names>
49
- <method v="2" />
50
- </configuration>
51
- <configuration name="report" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
52
- <node-interpreter>project</node-interpreter>
53
- <node-options />
54
- <mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
55
- <working-directory>$PROJECT_DIR$</working-directory>
56
- <pass-parent-env>true</pass-parent-env>
57
- <ui>bdd</ui>
58
- <extra-mocha-options />
59
- <test-kind>SUITE</test-kind>
60
- <test-file>$PROJECT_DIR$/src/index.test.js</test-file>
61
- <test-names>
62
- <name value="report" />
63
- </test-names>
64
- <method v="2" />
65
- </configuration>
66
- <configuration name="speedingReport" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
67
- <node-interpreter>project</node-interpreter>
68
- <node-options />
69
- <mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
70
- <working-directory>$PROJECT_DIR$</working-directory>
71
- <pass-parent-env>true</pass-parent-env>
72
- <ui>bdd</ui>
73
- <extra-mocha-options />
74
- <test-kind>TEST</test-kind>
75
- <test-file>$PROJECT_DIR$/src/index.test.js</test-file>
76
- <test-names>
77
- <name value="speedingReport" />
78
- </test-names>
79
- <method v="2" />
80
- </configuration>
81
- <configuration name="test reports" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
82
- <node-interpreter>project</node-interpreter>
83
- <node-options />
84
- <mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
85
- <working-directory>$PROJECT_DIR$</working-directory>
86
- <pass-parent-env>true</pass-parent-env>
87
- <ui>bdd</ui>
88
- <extra-mocha-options />
89
- <test-kind>SUITE</test-kind>
90
- <test-file>$PROJECT_DIR$/src/index.test.js</test-file>
91
- <test-names>
92
- <name value="test reports" />
93
- </test-names>
94
- <method v="2" />
95
- </configuration>
96
- <configuration name="test reports.test queue" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
97
- <node-interpreter>project</node-interpreter>
98
- <node-options />
99
- <mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
100
- <working-directory>$PROJECT_DIR$</working-directory>
101
- <pass-parent-env>true</pass-parent-env>
102
- <ui>bdd</ui>
103
- <extra-mocha-options />
104
- <test-kind>TEST</test-kind>
105
- <test-file>$PROJECT_DIR$/src/index.test.js</test-file>
106
- <test-names>
107
- <name value="test reports" />
108
- <name value="test queue" />
109
- </test-names>
110
- <method v="2" />
111
- </configuration>
112
- <recent_temporary>
113
- <list>
114
- <item itemvalue="Mocha.test reports" />
115
- <item itemvalue="Mocha.test reports.test queue" />
116
- <item itemvalue="Mocha.speedingReport" />
117
- <item itemvalue="Mocha.report" />
118
- <item itemvalue="Mocha.here" />
119
- </list>
120
- </recent_temporary>
121
- </component>
122
- <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
123
- <component name="TaskManager">
124
- <task active="true" id="Default" summary="Default task">
125
- <changelist id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="" />
126
- <created>1635878866368</created>
127
- <option name="number" value="Default" />
128
- <option name="presentableId" value="Default" />
129
- <updated>1635878866368</updated>
130
- <workItem from="1635878870054" duration="105000" />
131
- <workItem from="1635943211865" duration="371000" />
132
- <workItem from="1636030918716" duration="808000" />
133
- <workItem from="1636366400735" duration="3018000" />
134
- <workItem from="1636371409243" duration="45000" />
135
- <workItem from="1636371621773" duration="4750000" />
136
- <workItem from="1636623371114" duration="675000" />
137
- <workItem from="1636624396937" duration="1987000" />
138
- <workItem from="1636627666406" duration="1616000" />
139
- <workItem from="1636647112207" duration="1748000" />
140
- <workItem from="1636981640447" duration="4315000" />
141
- <workItem from="1637009407292" duration="1470000" />
142
- <workItem from="1637012863006" duration="5376000" />
143
- <workItem from="1637087797229" duration="5701000" />
144
- <workItem from="1637227826845" duration="1275000" />
145
- <workItem from="1637441942952" duration="4543000" />
146
- <workItem from="1637670815688" duration="2973000" />
147
- <workItem from="1637674107929" duration="10975000" />
148
- </task>
149
- <task id="LOCAL-00001" summary="Fix getStyle">
150
- <created>1636983717385</created>
151
- <option name="number" value="00001" />
152
- <option name="presentableId" value="LOCAL-00001" />
153
- <option name="project" value="LOCAL" />
154
- <updated>1636983717385</updated>
155
- </task>
156
- <task id="LOCAL-00002" summary="Fix getStyle in all reports">
157
- <created>1637020728356</created>
158
- <option name="number" value="00002" />
159
- <option name="presentableId" value="LOCAL-00002" />
160
- <option name="project" value="LOCAL" />
161
- <updated>1637020728356</updated>
162
- </task>
163
- <task id="LOCAL-00003" summary="try catch on pdf addImage">
164
- <created>1637247013210</created>
165
- <option name="number" value="00003" />
166
- <option name="presentableId" value="LOCAL-00003" />
167
- <option name="project" value="LOCAL" />
168
- <updated>1637247013211</updated>
169
- </task>
170
- <option name="localTasksCounter" value="4" />
171
- <servers />
172
- </component>
173
- <component name="TypeScriptGeneratedFilesManager">
174
- <option name="version" value="3" />
175
- </component>
176
- <component name="Vcs.Log.Tabs.Properties">
177
- <option name="TAB_STATES">
178
- <map>
179
- <entry key="MAIN">
180
- <value>
181
- <State />
182
- </value>
183
- </entry>
184
- </map>
185
- </option>
186
- <option name="oldMeFiltersMigrated" value="true" />
187
- </component>
188
- <component name="VcsManagerConfiguration">
189
- <MESSAGE value="Fix getStyle" />
190
- <MESSAGE value="Fix getStyle in all reports" />
191
- <MESSAGE value="try catch on pdf addImage" />
192
- <option name="LAST_COMMIT_MESSAGE" value="try catch on pdf addImage" />
193
- </component>
194
- </project>