fleetmap-reports 1.0.893 → 1.0.896

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.893",
3
+ "version": "1.0.896",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -399,7 +399,7 @@ function exportActivityReportToPDFVehicle (doc, translations, reportData, userDa
399
399
  translations.report.spentFuel]
400
400
 
401
401
  doc.setFontSize(10)
402
- doc.text(convertToLocaleString(reportData.from, lang, timezone) + ' - ' + convertToLocaleString(reportData.to, lang, timezone), 20, 30)
402
+ doc.text(convertToLocaleString(reportData.from, lang, timezone, userData.user) + ' - ' + convertToLocaleString(reportData.to, lang, timezone, userData.user), 20, 30)
403
403
 
404
404
  const data = []
405
405
  reportData.devices.forEach(d => {
@@ -132,7 +132,7 @@ async function processDevices (from, to, devices, userData, data) {
132
132
  geofencesData.push({
133
133
  geofenceId: geofence.id,
134
134
  geofenceName: geofence.name,
135
- days: userData.onlyWithKmsOut ? dataByDay.filter(d => d.distanceOut >= 0.5) : dataByDay
135
+ days: filterResult(dataByDay, userData)
136
136
  })
137
137
  }
138
138
 
@@ -207,7 +207,7 @@ async function processDevices (from, to, devices, userData, data) {
207
207
  from,
208
208
  to,
209
209
  tripsBetweenZones: true,
210
- geofences: userData.onlyWithKmsOut ? tripsBetweenZones.filter(a => a.distanceOut) : tripsBetweenZones
210
+ geofences: filterResult(tripsBetweenZones, userData)
211
211
  })
212
212
  }
213
213
  } else {
@@ -215,7 +215,7 @@ async function processDevices (from, to, devices, userData, data) {
215
215
  device: d,
216
216
  from,
217
217
  to,
218
- geofences: userData.onlyWithKmsOut ? zoneInOutData.filter(a => a.distanceOut) : zoneInOutData
218
+ geofences: filterResult(zoneInOutData, userData)
219
219
  })
220
220
  }
221
221
  }
@@ -225,6 +225,11 @@ async function processDevices (from, to, devices, userData, data) {
225
225
  return devicesResult
226
226
  }
227
227
 
228
+ function filterResult (result, userData) {
229
+ result = userData.onlyWithKmsOut ? result.filter(a => a.distanceOut >= 0.5) : result
230
+ return userData.onlyWithKmsIn ? result.filter(a => a.distanceIn === undefined || a.distanceIn >= 0.5) : result
231
+ }
232
+
228
233
  function calculateTimeIn (zoneInOutDayData, fromByDay, from, toByDay, to) {
229
234
  let timeIn = zoneInOutDayData.length ? zoneInOutDayData.reduce((a, b) => a + (b.totalInTime || 0), 0) : 0
230
235