fleetmap-reports 2.0.352 → 2.0.353

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": "2.0.352",
3
+ "version": "2.0.353",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,8 +1,9 @@
1
1
  const refuelingReport = require('./refueling-report')
2
2
  const traccarHelper = require('./util/traccar')
3
3
  const odoo = require('./util/odoo')
4
+ const automaticReports = require('./automaticReports')
4
5
  const { devicesToProcess } = require('./util/device')
5
- const { getTranslations, convertToLocaleString, getLanguage, convertMS, formatNumber, getDates } = require('./util/utils')
6
+ const { getTranslations, convertToLocaleString, getLanguage, convertMS, formatNumber, getDates, isClientSide, executeServerSide } = require('./util/utils')
6
7
  const { getStyle } = require('./reportStyle')
7
8
  const { getUserPartner } = require('fleetmap-partners')
8
9
  const { addTable, headerFromUser } = require('./util/pdfDocument')
@@ -24,6 +25,16 @@ async function createFuelConsumptionReport (from, to, userData, traccar) {
24
25
 
25
26
  const devices = devicesToProcess(userData)
26
27
 
28
+ allData.totalDevices = 0
29
+
30
+ if (isClientSide() && (devices.length > 50 || ((new Date(to).getTime() - new Date(from).getTime()) > (1000 * 60 * 60 * 24 * 15)))) {
31
+ const sliced = automaticReports.sliceArray(devices, 1)
32
+ allData.devices = await executeServerSide('fuel-consumption-report', sliced, from, to, userData, devices.length, traccar)
33
+ allData.totalDevices = allData.devices.length
34
+ reportData.push(allData)
35
+ return reportData
36
+ }
37
+
27
38
  const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, true, true, false)
28
39
  const dates = getDates(from, to, userData.user.attributes.timezone || getUserPartner(userData.user).timezone)
29
40
  const summary = await getSummaryByDay(dates, userData, traccar, devices, true, from, to)
@@ -37,8 +48,6 @@ async function createFuelConsumptionReport (from, to, userData, traccar) {
37
48
  return reportData
38
49
  }
39
50
 
40
- allData.totalDevices = 0
41
-
42
51
  for (const d of devices) {
43
52
  const stops = allInOne.stops.filter(t => t.deviceId === d.id)
44
53
  const trips = allInOne.trips.filter(t => t.deviceId === d.id)
@@ -43,10 +43,6 @@ async function header (doc, title, hostname, style, orientation) {
43
43
  doc.setFont('helvetica', 'bold')
44
44
  doc.text(title, 15, 15)
45
45
 
46
- doc.setFontSize(8)
47
- doc.setFont('helvetica', 'normal')
48
- doc.text(new Date().toLocaleString(), 15, 21)
49
-
50
46
  if (style.imgWidth && style.imgHeight) {
51
47
  try {
52
48
  const image = await getImgFromUrl(hostname)
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(git add *)",
5
- "Bash(git commit -m ' *)",
6
- "Bash(npm publish *)"
7
- ]
8
- }
9
- }