fleetmap-reports 2.0.353 → 2.0.354

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.353",
3
+ "version": "2.0.354",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@ async function createFuelConsumptionReport (from, to, userData, traccar) {
29
29
 
30
30
  if (isClientSide() && (devices.length > 50 || ((new Date(to).getTime() - new Date(from).getTime()) > (1000 * 60 * 60 * 24 * 15)))) {
31
31
  const sliced = automaticReports.sliceArray(devices, 1)
32
- allData.devices = await executeServerSide('fuel-consumption-report', sliced, from, to, userData, devices.length, traccar)
32
+ allData.devices = await executeServerSide('fuel-consumption-report', sliced, from, to, userData, devices.length, traccar, 5)
33
33
  allData.totalDevices = allData.devices.length
34
34
  reportData.push(allData)
35
35
  return reportData
@@ -153,7 +153,7 @@ function exportFuelConsumptionReportToExcel (userData, reportData) {
153
153
  data = data.concat(d.days.map((r) => {
154
154
  return {
155
155
  name: d.device.name,
156
- date: r.date.toLocaleDateString(),
156
+ date: new Date(r.date).toLocaleDateString(),
157
157
  kms: formatNumber(r.distance / 1000),
158
158
  consumption: r.spentFuel > 0 ? formatNumber(r.spentFuel) : 0,
159
159
  avg_consumption: formatNumber(lang === 'pt-BR' ? r.avgConsumption.byLiters : r.avgConsumption.byKms),
@@ -220,7 +220,7 @@ async function exportFuelConsumptionReportToPDF (userData, reportData) {
220
220
 
221
221
  d.days.forEach(r =>
222
222
  data.push([
223
- r.date.toLocaleDateString(),
223
+ new Date(r.date).toLocaleDateString(),
224
224
  formatNumber(r.distance / 1000),
225
225
  r.spentFuel > 0 ? formatNumber(r.spentFuel) : 0,
226
226
  formatNumber(lang === 'pt-BR' ? r.avgConsumption.byLiters : r.avgConsumption.byKms),
package/src/util/utils.js CHANGED
@@ -259,7 +259,10 @@ async function executeServerSide (type, sliced, from, to, userData, totalItems,
259
259
  },
260
260
  cookie
261
261
  }, { withCredentials: true }).then(d => {
262
- reportData.push(...(userData.byDriver ? d.data[0].drivers : d.data[0].devices))
262
+ const result = d.data[0]
263
+ if (result) {
264
+ reportData.push(...((userData.byDriver ? result.drivers : result.devices) || []))
265
+ }
263
266
  })
264
267
  itemsCount = itemsCount + items.length
265
268
  } catch (e) {