fleetmap-reports 1.0.850 → 1.0.852

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.850",
3
+ "version": "1.0.852",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,13 @@
1
+ const baseURL = 'https://api.carbone.io/render'
2
+
3
+ const axios = require('axios').create({
4
+ baseURL,
5
+ headers: {
6
+ Authorization: `Bearer ${process.env.CARBONE_API_KEY}`
7
+ }
8
+ })
9
+
10
+ exports.getPdf = async (template, body) => {
11
+ const { data } = await axios.post(template, body).then(r => r.data)
12
+ return `${baseURL}/${data.renderId}`
13
+ }
package/src/index.js CHANGED
@@ -182,5 +182,6 @@ function Reports (config, axios, cookieJar) {
182
182
  this.stopReportToExcel = (userData, reportData) => {
183
183
  return require('./stop-report').exportStopReportToExcel(userData, reportData)
184
184
  }
185
+ this.getPdf = require('./carbone').getPdf
185
186
  }
186
187
  module.exports = Reports
@@ -0,0 +1,20 @@
1
+ const carbone = require('../carbone')
2
+
3
+ // eslint-disable-next-line no-undef
4
+ describe('test carbone', function () {
5
+ // eslint-disable-next-line no-undef
6
+ // eslint-disable-next-line no-undef
7
+ it('works', async () => {
8
+ try {
9
+ console.log(
10
+ await carbone.getPdf('a7322d5a19b6a37c3ceee4719ed701876a27e288f8b9b58b7e0f8c13b7f01bbb',
11
+ {
12
+ data: 1,
13
+ convertTo: 'pdf'
14
+ }))
15
+ } catch (e) {
16
+ console.error(e && e.response && e.response.data)
17
+ throw e
18
+ }
19
+ })
20
+ })
@@ -3,20 +3,15 @@ const assert = require('assert')
3
3
  // eslint-disable-next-line no-undef
4
4
  describe('zones', function () {
5
5
  // eslint-disable-next-line no-undef
6
- it('works with ellca', async () => {
6
+ it('works tripsBetweenZones', async () => {
7
7
  const report = await getReports()
8
8
  const userData = await report.getUserData()
9
- const ellca = require('./ellca.json')
10
- userData.devices = userData.devices.filter(d => ellca.find(e => e === d.name))
11
- console.log(userData.devices.length)
12
- console.log(userData.devices.map(d => d.id))
13
- userData.geofences = userData.geofences.filter(g => g.name === 'Geofence Ellca 2')
14
- console.log(userData.geofences)
9
+ userData.tripsBetweenZones = true
15
10
  const result = await report.zoneReport(
16
- new Date(Date.UTC(2022, 6, 24, 0, 0, 0, 0)),
17
- new Date(Date.UTC(2022, 6, 25, 23, 59, 59, 0)),
11
+ new Date(Date.UTC(2023, 6, 24, 0, 0, 0, 0)),
12
+ new Date(Date.UTC(2023, 6, 25, 23, 59, 59, 0)),
18
13
  userData)
19
- console.log('result', result)
14
+ console.log(await report.zoneReportToPDF(userData, result[0]))
20
15
  }, 4000000)
21
16
 
22
17
  // eslint-disable-next-line no-undef
@@ -170,7 +170,7 @@ function processDevices (from, to, devices, data, userData, traccar) {
170
170
 
171
171
  const stop = getStop(new Date(trip.startTime), stops)
172
172
 
173
- if ((deviceRoute[0].protocol === 'teltonika' && deviceRoute.some(r => r.attributes.fuel)) ||
173
+ if (deviceRoute.some(r => r.attributes.fuel) ||
174
174
  automaticReports.deviceWithFuelInfo(d)) {
175
175
  trip.fuelConsumption = calculateConsumption(d, { trips: [trip], stops: (stop ? [stop] : []), route: deviceRoute })
176
176
  trip.avgFuelConsumption = trip.totalKms > 0 ? trip.fuelConsumption * 100 / trip.totalKms : 0
@@ -1,46 +0,0 @@
1
- [
2
- "KRS5330",
3
- "LTR6D02",
4
- "LTS8J58",
5
- "LUA4F53",
6
- "LUN9B64",
7
- "RJN0J89",
8
- "RJP0I18",
9
- "RJY4A56",
10
- "RKT2C85",
11
- "RKU3F60",
12
- "EPA5I95",
13
- "ESV3G14",
14
- "FKT3J22",
15
- "JAD3F55",
16
- "JAJ1C36",
17
- "KRX2869",
18
- "KXG9094",
19
- "KZA5664",
20
- "KZA5940",
21
- "LMT4A13",
22
- "LTY8D84",
23
- "RIP4C67",
24
- "RIZ0H12",
25
- "RJA0F90",
26
- "RJG4J53",
27
- "RJH4J70",
28
- "RJJ5E13",
29
- "RJK9F52",
30
- "RJL1E23",
31
- "RJL1E26",
32
- "RJM5G37",
33
- "RJN9G45",
34
- "RJP3C03",
35
- "RJR4G53",
36
- "RJV8G79",
37
- "RJY4A55",
38
- "RKC9H45",
39
- "RKG0I43",
40
- "RKG3D47",
41
- "RKK9G32",
42
- "RKR3I02",
43
- "RKR3I09",
44
- "RKR3I10",
45
- "RKS1A72"
46
- ]