fleetmap-reports 1.0.588 → 1.0.590

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.588",
3
+ "version": "1.0.590",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -167,6 +167,7 @@ async function exportFuelConsumptionReportToPDF (userData, reportData) {
167
167
  const translations = getTranslations(userData)
168
168
  const lang = getLanguage(userData)
169
169
 
170
+ // eslint-disable-next-line new-cap
170
171
  const doc = new jsPDF.jsPDF('l')
171
172
  await headerFromUser(doc, translations.report.titleFuelConsumptionReport, userData.user)
172
173
 
@@ -262,7 +262,7 @@ async function exportTripReportToPDF (userData, reportData) {
262
262
  ]
263
263
 
264
264
  if (tripsData) {
265
- const withFuelData = tripsData.reduce((a, b) => a || b.totalFuelConsumption !== undefined)
265
+ const withFuelData = tripsData.find(t => t.totalFuelConsumption !== undefined)
266
266
 
267
267
  if (withFuelData) {
268
268
  headers.push(translations.report.consumption,
@@ -320,7 +320,7 @@ async function exportTripReportToPDF (userData, reportData) {
320
320
 
321
321
  temp.push(convertMS(a.stopEngineHours),
322
322
  convertMS(a.stopDuration),
323
- Intl.NumberFormat(userData.user.attributes.lang, { maximumFractionDigits: 2 }).format(a.totalKms),
323
+ Intl.NumberFormat(userData.user.attributes.lang, { maximumFractionDigits: 1 }).format(a.totalKms),
324
324
  Math.round(a.averageSpeed * 1.85200),
325
325
  Math.round(a.maxSpeed * 1.85200))
326
326
 
@@ -364,8 +364,12 @@ async function exportTripReportToPDF (userData, reportData) {
364
364
  7: { halign: 'right' },
365
365
  8: { halign: 'right' },
366
366
  9: { halign: 'right' },
367
- 10: { halign: 'right' },
368
- 11: { halign: 'right' }
367
+ ...(withFuelData
368
+ ? {
369
+ 10: { halign: 'right' },
370
+ 11: { halign: 'right' }
371
+ }
372
+ : {})
369
373
  })
370
374
  })
371
375
  return doc
@@ -399,7 +403,7 @@ function exportTripReportToExcel (userData, reportData) {
399
403
 
400
404
  let data = []
401
405
  if (tripsData) {
402
- const withFuelData = tripsData.reduce((a, b) => a || b.totalFuelConsumption !== undefined)
406
+ const withFuelData = tripsData.find(b => b.totalFuelConsumption !== undefined)
403
407
 
404
408
  if (withFuelData) {
405
409
  headers.push({ label: translations.report.consumption, value: 'consumption' },
@@ -486,7 +490,7 @@ function getSumTotalKms (user, data) {
486
490
  const values = data.map(item => {
487
491
  return item.totalKms ? parseFloat(item.totalKms) : 0
488
492
  })
489
- return Intl.NumberFormat(user.attributes.lang, { maximumFractionDigits: 2 }).format(values.reduce((a, b) => a + b, 0))
493
+ return Intl.NumberFormat(user.attributes.lang, { maximumFractionDigits: 1 }).format(values.reduce((a, b) => a + b, 0))
490
494
  }
491
495
 
492
496
  function getSumAvgSpeed (data) {