fleetmap-reports 1.0.959 → 1.0.960

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.959",
3
+ "version": "1.0.960",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -78,4 +78,22 @@ describe('zones', function () {
78
78
  console.log(first)
79
79
  assert.equal(first.days[0].distanceOut, 554.6037095121401)
80
80
  }, 4000000)
81
+
82
+ it('works with casais zones in columns 3', async () => {
83
+ const report = await getReports()
84
+ const userData = await report.getUserData()
85
+ userData.zonesByColumn = true
86
+ userData.devices = userData.devices.filter(d => d.id === 81201)
87
+ userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ' ||
88
+ g.name === 'baliza 2 - raio amarelo')
89
+ userData.onlyWithKmsOut = false
90
+ const result = await report.zoneReport(
91
+ new Date(Date.UTC(2023, 8, 1, 0, 0, 0, 0)),
92
+ new Date(Date.UTC(2023, 8, 10, 23, 59, 59, 0)),
93
+ userData)
94
+ const first = result[0].devices[0]
95
+ console.log(first)
96
+ assert.equal(first.days[0].distanceOut, 294.0468270741282)
97
+ assert.equal(first.days[1].distanceOut, 35.21209134706803)
98
+ }, 4000000)
81
99
  })
@@ -368,12 +368,12 @@ function analyseAlerts (alerts, deviceRoute, userData, from, to, device) {
368
368
  let anyNextIn
369
369
  let distanceOutAny = 0
370
370
  if (zoneInData.length < 2) {
371
- anyNextIn = getAnyNextIn(outDate, alerts, deviceRoute)
371
+ anyNextIn = getAnyNextIn(outDate, alerts, deviceRoute) || to
372
372
  const routeAfterOutAndBeforeAnyNextIn = deviceRoute.filter(p =>
373
373
  new Date(p.fixTime).getTime() >= outDate &&
374
374
  new Date(p.fixTime).getTime() <= anyNextIn
375
375
  )
376
- distanceOutAny = zoneInData.length < 2 ? Math.round(calculateDistance(routeAfterOutAndBeforeAnyNextIn, device.attributes['report.ignoreOdometer'])) : 0
376
+ distanceOutAny = Math.round(calculateDistance(routeAfterOutAndBeforeAnyNextIn, device.attributes['report.ignoreOdometer']))
377
377
  }
378
378
 
379
379
  const inData = zoneInData.find(z => z.geofenceId === a.geofenceId)
@@ -399,7 +399,7 @@ function analyseAlerts (alerts, deviceRoute, userData, from, to, device) {
399
399
  stopped: routeIn.filter(p => !p.attributes.ignition).length > 0,
400
400
  driverName: inData.position.driverName
401
401
  })
402
- zoneInData = zoneInData.filter(z => z.geofenceId === a.geofenceId)
402
+ zoneInData = zoneInData.filter(z => z.geofenceId !== a.geofenceId)
403
403
  } else {
404
404
  const totalInTime = new Date(a.position.fixTime).getTime() - from.getTime()
405
405
  const routeIn = deviceRoute.filter(p =>