fleetmap-reports 1.0.807 → 1.0.809
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 +1 -1
- package/src/activity-report.js +5 -5
- package/src/partnerReports/afriquia.js +2 -4
- package/src/tests/activity.test.js +4 -4
- package/report.pdf +0 -286585
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -51,16 +51,16 @@ async function createActivityReportByGroup (from, to, userData, traccarInstance)
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const response = await traccarInstance.reports.reportsSummaryGet(from, to, null, [g.id])
|
|
54
|
-
const
|
|
54
|
+
const summary = response.data
|
|
55
55
|
|
|
56
56
|
const responseTrips = await traccarInstance.reports.reportsTripsGet(from, to, null, [g.id])
|
|
57
57
|
const trips = responseTrips.data
|
|
58
58
|
|
|
59
59
|
devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
60
60
|
|
|
61
|
-
if (
|
|
62
|
-
console.log('Summary:' +
|
|
63
|
-
groupData.devices = processDevices(from, to, devices, {
|
|
61
|
+
if (summary.length > 0) {
|
|
62
|
+
console.log('Summary:' + summary.length)
|
|
63
|
+
groupData.devices = processDevices(from, to, devices, { summary, trips }, userData)
|
|
64
64
|
|
|
65
65
|
reportData.push(groupData)
|
|
66
66
|
}
|
|
@@ -224,7 +224,7 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
224
224
|
endAddress: trips.length && trips[trips.length - 1].endAddress
|
|
225
225
|
})
|
|
226
226
|
} else {
|
|
227
|
-
summary.push(...data.
|
|
227
|
+
summary.push(...data.summary.filter(s => s.deviceId === d.id))
|
|
228
228
|
|
|
229
229
|
if (summary.length) {
|
|
230
230
|
summary.forEach(s => {
|
|
@@ -7,10 +7,6 @@ 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
|
-
|
|
14
10
|
async function createActivityReport (from, to, userData, traccarInstance) {
|
|
15
11
|
const unauthorizedGeofences = []
|
|
16
12
|
const authorizedGeofences = []
|
|
@@ -126,4 +122,6 @@ async function createActivityReport (from, to, userData, traccarInstance) {
|
|
|
126
122
|
return reportData
|
|
127
123
|
}
|
|
128
124
|
|
|
125
|
+
|
|
126
|
+
|
|
129
127
|
exports.createActivityReport = createActivityReport
|
|
@@ -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
|
-
|
|
11
|
-
const data = await report.activityReport(new Date(
|
|
12
|
-
new Date(
|
|
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),
|
|
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,
|
|
16
|
+
assert.equal(device.summary[0].startOdometer, 248891759.24)
|
|
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)
|