fleetmap-reports 2.0.38 → 2.0.40

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.38",
3
+ "version": "2.0.40",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@ function sliceArray (longArray, size) {
17
17
 
18
18
  function deviceWithFuelInfo (device) {
19
19
  return device.attributes.odooId || device.attributes.xpert ||
20
- (device.attributes.fuel_low_threshold >= 0 && device.attributes.fuel_high_threshold >= 0 && device.attributes.fuel_tank_capacity)
20
+ device.attributes.fuel_tank_capacity
21
21
  }
22
22
 
23
23
  function calculateXpertDistance (date, positions) {
@@ -159,4 +159,21 @@ describe('zones', function () {
159
159
  console.log(first)
160
160
  assert.equal(first.days[6].distanceOut, 867.0554430738234)
161
161
  }, 4000000)
162
+
163
+ it('works with casais zones in columns 7', async () => {
164
+ const report = await getReports()
165
+ const userData = await report.getUserData()
166
+ userData.zonesByColumn = true
167
+ userData.devices = userData.devices.filter(d => d.id === 81166)
168
+ userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ' ||
169
+ g.name === 'baliza 2 - raio amarelo')
170
+ userData.onlyWithKmsOut = false
171
+ const result = await report.zoneReport(
172
+ new Date(Date.UTC(2023, 9, 9, 0, 0, 0, 0)),
173
+ new Date(Date.UTC(2023, 9, 31, 23, 59, 59, 0)),
174
+ userData)
175
+ const first = result[0].devices[0]
176
+ console.log(first)
177
+ assert.equal(first.days[17].distanceOut, 720.7985320478997)
178
+ }, 4000000)
162
179
  })
@@ -345,6 +345,7 @@ function calculateDistanceOut (zoneInOutDayData, dayRoute, fromByDay, toByDay, f
345
345
  distanceOut = distanceOut + calculateDistance(routeOut, device.attributes['report.ignoreOdometer'])
346
346
  }
347
347
 
348
+ zoneInOutDayData.sort((a, b) => (a.outTime ? new Date(a.outTime.fixTime).getTime() : 0) - (b.outTime ? new Date(b.outTime.fixTime).getTime() : 0))
348
349
  if (zoneInOutDayData[zoneInOutDayData.length - 1].outTime && new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) < toByDay) {
349
350
  // Add distanceOut after last exit
350
351
  distanceOut = distanceOut - zoneInOutDayData[zoneInOutDayData.length - 1][field]