fleetmap-reports 1.0.815 → 1.0.816

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.
@@ -7,6 +7,10 @@ function calculateLastStopTime (stopTime, to, time) {
7
7
  return stopTime + (to.getTime() - new Date(time).getTime())
8
8
  }
9
9
 
10
+ function calculateFirstStopTime (stopTime, from, time) {
11
+ return stopTime + (new Date(time).getTime() - from.getTime())
12
+ }
13
+
10
14
  async function createActivityReport (from, to, userData, traccarInstance) {
11
15
  const unauthorizedGeofences = []
12
16
  const authorizedGeofences = []
@@ -7,13 +7,13 @@ describe('activity report', function () {
7
7
  it('Activity by device', async () => {
8
8
  const report = await getReports()
9
9
  const userData = await report.getUserData()
10
- userData.groupByDay = true
11
- const data = await report.activityReport(new Date(2023, 0, 1, 0, 0, 0, 0),
12
- new Date(2023, 0, 31, 23, 59, 59, 0),
10
+
11
+ const data = await report.activityReport(new Date(2022, 0, 1, 0, 0, 0, 0),
12
+ new Date(2022, 0, 31, 23, 59, 59, 0),
13
13
  userData)
14
14
  assert.equal(data.length, 1)
15
15
  const device = data[0].devices.find(d => d.device.id === 22326)
16
- assert.equal(device.summary[0].startOdometer, 248891759.24)
16
+ assert.equal(device.summary[0].startOdometer, 0)
17
17
  assert.equal(device.summary[0].distance, 0)
18
18
  assert.equal(device.summary[0].startTime, 0)
19
19
  assert.equal(device.summary[0].endTime, 0)
@@ -72,17 +72,4 @@ describe('activity report', function () {
72
72
  console.log(device)
73
73
  assert.equal(device.summary.reduce((a, b) => a + b.convertedSpentFuel, 0), 168.79999999999995)
74
74
  }, 800000)
75
- it('Activity test performance', async () => {
76
- const report = await getReports()
77
- const userData = await report.getUserData()
78
- userData.groupByDay = true
79
- userData.devices = userData.devices.filter(d => d.id === 69114)
80
- const data = await report.activityReport(new Date(2023, 5, 11, 0, 0, 0, 0),
81
- new Date(2023, 6, 11, 23, 59, 59, 0),
82
- userData)
83
- assert.equal(data.length, 1)
84
- const device = data[0].devices.find(d => d.device.id === 69114)
85
- console.log(device)
86
- assert.equal(device.summary.reduce((a, b) => a + b.convertedSpentFuel, 0), 168.79999999999995)
87
- }, 800000)
88
75
  })
@@ -1,16 +1,16 @@
1
1
  require('jspdf-autotable')
2
2
  const { getStyle } = require('../reportStyle')
3
3
  const { getUserPartner } = require('fleetmap-partners')
4
- const { getImgFromUrl } = require('./utils')
4
+ const { getLogoUrl } = require('./utils')
5
5
 
6
- async function header (doc, title, hostname, style, orientation) {
6
+ function header (doc, title, hostname, style, orientation) {
7
7
  doc.setFontSize(16)
8
8
  doc.setFont('helvetica', 'bold')
9
9
  doc.text(title, 15, 15)
10
10
 
11
11
  if (style.imgWidth && style.imgHeight) {
12
12
  try {
13
- const image = await getImgFromUrl(hostname)
13
+ const image = getLogoUrl(hostname)
14
14
  if (image) {
15
15
  doc.addImage(image, 'PNG', (orientation === 'l' ? 220 : 135) + (style.imgWidth < 50 ? 25 : 0), 5, style.imgWidth, style.imgHeight)
16
16
  }
package/src/util/utils.js CHANGED
@@ -253,3 +253,4 @@ exports.calculateDistance = (positions) => {
253
253
  }
254
254
 
255
255
  exports.sortPositions = (a, b) => new Date(a.fixTime).getTime() - new Date(b.fixTime).getTime()
256
+ exports.getLogoUrl = getLogoUrl