fleetmap-reports 1.0.966 → 1.0.968
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
package/src/index.js
CHANGED
|
@@ -19,6 +19,7 @@ function Reports (config, axios, cookieJar) {
|
|
|
19
19
|
drivers: await this.traccar.drivers.driversGet().then(d => d.data),
|
|
20
20
|
geofences: await this.traccar.geofences.geofencesGet().then(d => d.data),
|
|
21
21
|
byGroup: false,
|
|
22
|
+
allWeek: true,
|
|
22
23
|
dayHours: { startTime: '00:00', endTime: '23:59' }
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -5,7 +5,7 @@ const automaticReports = require('../automaticReports')
|
|
|
5
5
|
const jsPDF = require("jspdf");
|
|
6
6
|
const {getStyle} = require("../reportStyle");
|
|
7
7
|
const {getUserPartner} = require("fleetmap-partners");
|
|
8
|
-
const {addTable} = require("../util/pdfDocument");
|
|
8
|
+
const {addTable, headerFromUser} = require("../util/pdfDocument");
|
|
9
9
|
|
|
10
10
|
async function createDailyUseReport (from, to, userData, traccar) {
|
|
11
11
|
const reportData = []
|
|
@@ -81,7 +81,7 @@ function processDeviceData (allInOne, d, userData) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function exportDailyUseReportToPDF (userData, reportData) {
|
|
84
|
+
async function exportDailyUseReportToPDF (userData, reportData) {
|
|
85
85
|
const translations = getTranslations(userData)
|
|
86
86
|
|
|
87
87
|
const headers = [
|
|
@@ -131,6 +131,7 @@ function exportDailyUseReportToPDF (userData, reportData) {
|
|
|
131
131
|
})
|
|
132
132
|
|
|
133
133
|
const doc = new jsPDF.jsPDF('l')
|
|
134
|
+
await headerFromUser(doc, 'Rapport de Performance', userData.user)
|
|
134
135
|
const style = getStyle(getUserPartner(userData.user))
|
|
135
136
|
|
|
136
137
|
const footValues = []
|
|
@@ -3,7 +3,7 @@ const traccarHelper = require('../util/traccar')
|
|
|
3
3
|
const { getUncompletedTrip } = require('../util/trips')
|
|
4
4
|
const { getEndTripMessages, getCanDriverStyleMessages, parseEndTripMessage, parseCanDriverStyleMessage } = require('../util/xpert')
|
|
5
5
|
const { calculateDistance, getTranslations, convertMS } = require('../util/utils')
|
|
6
|
-
const { addTable } = require('../util/pdfDocument')
|
|
6
|
+
const { addTable, headerFromUser} = require('../util/pdfDocument')
|
|
7
7
|
const jsPDF = require('jspdf')
|
|
8
8
|
const { getStyle } = require('../reportStyle')
|
|
9
9
|
const { getUserPartner } = require('fleetmap-partners')
|
|
@@ -218,7 +218,7 @@ function calculateRPMSections (route, min, max) {
|
|
|
218
218
|
return sections
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
function exportPerformanceReportToPDF (userData, reportData) {
|
|
221
|
+
async function exportPerformanceReportToPDF (userData, reportData) {
|
|
222
222
|
const translations = getTranslations(userData)
|
|
223
223
|
|
|
224
224
|
const headers = [
|
|
@@ -268,6 +268,8 @@ function exportPerformanceReportToPDF (userData, reportData) {
|
|
|
268
268
|
})
|
|
269
269
|
|
|
270
270
|
const doc = new jsPDF.jsPDF('l')
|
|
271
|
+
await headerFromUser(doc, 'Rapport de Performance', userData.user)
|
|
272
|
+
|
|
271
273
|
const style = getStyle(getUserPartner(userData.user))
|
|
272
274
|
|
|
273
275
|
const footValues = []
|
|
@@ -35,8 +35,8 @@ describe('activity report', function () {
|
|
|
35
35
|
const report = await getReports()
|
|
36
36
|
const userData = await report.getUserData()
|
|
37
37
|
userData.groupByDay = true
|
|
38
|
-
const data = await report.activityReport(new Date(
|
|
39
|
-
new Date(
|
|
38
|
+
const data = await report.activityReport(new Date(2023, 9, 1, 0, 0, 0, 0),
|
|
39
|
+
new Date(2023, 9, 20, 23, 59, 59, 0),
|
|
40
40
|
userData)
|
|
41
41
|
assert.equal(data.length, 1)
|
|
42
42
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
package/src/util/trips.js
CHANGED
|
@@ -118,9 +118,8 @@ async function getDataByDay (device, date, data, userData, traccarInstance) {
|
|
|
118
118
|
|
|
119
119
|
const tripsByDay = []
|
|
120
120
|
if (data.trips) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}))
|
|
121
|
+
const filteredTrips = data.trips.filter(t => new Date(t.endTime) > startDate && new Date(t.startTime) < endDate)
|
|
122
|
+
tripsByDay.push(...filteredTrips.map(t => { return { ...t } }))
|
|
124
123
|
|
|
125
124
|
for (const t of tripsByDay) {
|
|
126
125
|
await calculatePartialTrip(device, startDate, endDate, data.route, t, traccarInstance)
|