fleetmap-reports 2.0.50 → 2.0.52
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/RapportPerformance.xlsx +0 -0
- package/package.json +1 -1
- package/src/activity-report.js +3 -0
- package/src/events-report.js +3 -0
- package/src/fuelconsumption-report.js +3 -0
- package/src/fueldrop-report.js +3 -0
- package/src/idle-report.js +3 -0
- package/src/index.js +21 -0
- package/src/kms-report.js +3 -0
- package/src/location-report.js +3 -0
- package/src/machines-report.js +4 -0
- package/src/partnerReports/dailyuse-report.js +73 -1
- package/src/partnerReports/delayedstart-report.js +69 -0
- package/src/partnerReports/passenger-report.js +46 -0
- package/src/refueling-report.js +3 -0
- package/src/speeding-report.js +3 -0
- package/src/stop-report.js +3 -0
- package/src/tests/dailyuse.test.js +19 -0
- package/src/tests/gpsjump.test.js +23 -0
- package/src/tests/kms.test.js +18 -0
- package/src/tests/zones.test.js +17 -0
- package/src/trip-report.js +3 -0
- package/src/util/traccar.js +2 -2
- package/src/zone-report.js +3 -0
|
Binary file
|
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -803,3 +803,6 @@ function getSumSpentFuel (data, userData) {
|
|
|
803
803
|
exports.createActivityReport = createActivityReport
|
|
804
804
|
exports.exportActivityReportToPDF = exportActivityReportToPDF
|
|
805
805
|
exports.exportActivityReportToExcel = exportActivityReportToExcel
|
|
806
|
+
exports.create = createActivityReport
|
|
807
|
+
exports.exportToPDF = exportActivityReportToPDF
|
|
808
|
+
exports.exportToExcel = exportActivityReportToExcel
|
package/src/events-report.js
CHANGED
|
@@ -336,3 +336,6 @@ function getAlertDate (user, position) {
|
|
|
336
336
|
exports.createEventsReport = createEventsReport
|
|
337
337
|
exports.exportSpeedingReportToPDF = exportSpeedingReportToPDF
|
|
338
338
|
exports.exportSpeedingReportToExcel = exportSpeedingReportToExcel
|
|
339
|
+
exports.create = createEventsReport
|
|
340
|
+
exports.exportToPDF = exportSpeedingReportToPDF
|
|
341
|
+
exports.exportToExcel = exportSpeedingReportToExcel
|
|
@@ -273,3 +273,6 @@ function getTotalAvgConsumption (user, data) {
|
|
|
273
273
|
exports.createFuelConsumptionReport = createFuelConsumptionReport
|
|
274
274
|
exports.exportFuelConsumptionReportToPDF = exportFuelConsumptionReportToPDF
|
|
275
275
|
exports.exportFuelConsumptionReportToExcel = exportFuelConsumptionReportToExcel
|
|
276
|
+
exports.create = createFuelConsumptionReport
|
|
277
|
+
exports.exportToPDF = exportFuelConsumptionReportToPDF
|
|
278
|
+
exports.exportToExcel = exportFuelConsumptionReportToExcel
|
package/src/fueldrop-report.js
CHANGED
|
@@ -123,3 +123,6 @@ function exportFuelDropReportToPDF (userData, reportData) {
|
|
|
123
123
|
exports.createFuelDropReport = createFuelDropReport
|
|
124
124
|
exports.exportFuelDropReportToPDF = exportFuelDropReportToPDF
|
|
125
125
|
exports.exportFuelDropReportToExcel = exportFuelDropReportToExcel
|
|
126
|
+
exports.create = createFuelDropReport
|
|
127
|
+
exports.exportToPDF = exportFuelDropReportToPDF
|
|
128
|
+
exports.exportToExcel = exportFuelDropReportToExcel
|
package/src/idle-report.js
CHANGED
|
@@ -398,3 +398,6 @@ function getIdleEventTime (position, user) {
|
|
|
398
398
|
exports.createIdleReport = createIdleReport
|
|
399
399
|
exports.exportIdleReportToPDF = exportIdleReportToPDF
|
|
400
400
|
exports.exportIdleReportToExcel = exportIdleReportToExcel
|
|
401
|
+
exports.create = createIdleReport
|
|
402
|
+
exports.exportToPDF = exportIdleReportToPDF
|
|
403
|
+
exports.exportToExcel = exportIdleReportToExcel
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ function Reports (config, axios) {
|
|
|
18
18
|
drivers: await this.traccar.drivers.driversGet().then(d => d.data),
|
|
19
19
|
geofences: await this.traccar.geofences.geofencesGet().then(d => d.data),
|
|
20
20
|
byGroup: false,
|
|
21
|
+
allWeek: true,
|
|
21
22
|
dayHours: { startTime: '00:00', endTime: '23:59' }
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -182,5 +183,25 @@ function Reports (config, axios) {
|
|
|
182
183
|
this.stopReportToExcel = (userData, reportData) => {
|
|
183
184
|
return require('./stop-report').exportStopReportToExcel(userData, reportData)
|
|
184
185
|
}
|
|
186
|
+
|
|
187
|
+
this.performanceReport = (from, to, userData) => {
|
|
188
|
+
return require('./partnerReports/performance-report').createPerformanceReport(from, to, userData, this.traccar)
|
|
189
|
+
}
|
|
190
|
+
this.performanceReportToPDF = (userData, reportData) => {
|
|
191
|
+
return require('./partnerReports/performance-report').exportPerformanceReportToPDF(userData, reportData)
|
|
192
|
+
}
|
|
193
|
+
this.performanceReportToExcel = (userData, reportData) => {
|
|
194
|
+
return require('./partnerReports/performance-report').exportPerformanceReportToExcel(userData, reportData)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.dailyUseReport = (from, to, userData) => {
|
|
198
|
+
return require('./partnerReports/dailyuse-report').createDailyUseReport(from, to, userData, this.traccar)
|
|
199
|
+
}
|
|
200
|
+
this.dailyUseReportToPDF = (userData, reportData) => {
|
|
201
|
+
return require('./partnerReports/dailyuse-report').exportDailyUseReportToPDF(userData, reportData)
|
|
202
|
+
}
|
|
203
|
+
this.dailyUseReportToExcel = (userData, reportData) => {
|
|
204
|
+
return require('./partnerReports/dailyuse-report').exportDailyUseReportToExcel(userData, reportData)
|
|
205
|
+
}
|
|
185
206
|
}
|
|
186
207
|
module.exports = Reports
|
package/src/kms-report.js
CHANGED
|
@@ -534,3 +534,6 @@ function getExcelContent (userData, d, translations) {
|
|
|
534
534
|
exports.createKmsReport = createKmsReport
|
|
535
535
|
exports.exportKmsReportToPDF = exportKmsReportToPDF
|
|
536
536
|
exports.exportKmsReportToExcel = exportKmsReportToExcel
|
|
537
|
+
exports.create = createKmsReport
|
|
538
|
+
exports.exportToPDF = exportKmsReportToPDF
|
|
539
|
+
exports.exportToExcel = exportKmsReportToExcel
|
package/src/location-report.js
CHANGED
|
@@ -457,4 +457,7 @@ function getMaxSpeed (data) {
|
|
|
457
457
|
exports.createLocationReport = createLocationReport
|
|
458
458
|
exports.exportLocationReportToPDF = exportLocationReportToPDF
|
|
459
459
|
exports.exportLocationReportToExcel = exportLocationReportToExcel
|
|
460
|
+
exports.create = createLocationReport
|
|
461
|
+
exports.exportToPDF = exportLocationReportToPDF
|
|
462
|
+
exports.exportToExcel = exportLocationReportToExcel
|
|
460
463
|
exports.getDigitalPortValue = getDigitalPortValue
|
package/src/machines-report.js
CHANGED
|
@@ -156,6 +156,7 @@ function calculateIgnitions (routeOfDay) {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
async function exportMachinesReportToPDF (userData, reportData) {
|
|
159
|
+
// eslint-disable-next-line new-cap
|
|
159
160
|
const doc = new jsPDF.jsPDF('l')
|
|
160
161
|
const translations = getTranslations(userData)
|
|
161
162
|
await headerFromUser(doc, translations.report.titleMachinesReport, userData.user)
|
|
@@ -272,3 +273,6 @@ async function exportMachinesReportToExcel (userData, reportData) {
|
|
|
272
273
|
exports.createMachinesReport = createMachinesReport
|
|
273
274
|
exports.exportMachinesReportToPDF = exportMachinesReportToPDF
|
|
274
275
|
exports.exportMachinesReportToExcel = exportMachinesReportToExcel
|
|
276
|
+
exports.create = createMachinesReport
|
|
277
|
+
exports.exportToPDF = exportMachinesReportToPDF
|
|
278
|
+
exports.exportToExcel = exportMachinesReportToExcel
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
const traccarHelper = require('../util/traccar')
|
|
2
2
|
const { isInsideTimetable } = require('../util/trips')
|
|
3
|
-
const { convertFromUTCDate } = require('../util/utils')
|
|
3
|
+
const { convertFromUTCDate, getTranslations, convertMS, convertToLocaleTimeString, isClientSide } = require('../util/utils')
|
|
4
4
|
const automaticReports = require('../automaticReports')
|
|
5
|
+
const jsPDF = require('jspdf')
|
|
6
|
+
const { getStyle } = require('../reportStyle')
|
|
7
|
+
const { getUserPartner } = require('fleetmap-partners')
|
|
8
|
+
const { addTable, headerFromUser } = require('../util/pdfDocument')
|
|
5
9
|
|
|
6
10
|
async function createDailyUseReport (from, to, userData, traccar) {
|
|
7
11
|
const reportData = []
|
|
@@ -77,4 +81,72 @@ function processDeviceData (allInOne, d, userData) {
|
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
async function exportDailyUseReportToPDF (userData, reportData) {
|
|
85
|
+
const translations = getTranslations(userData)
|
|
86
|
+
const timezone = userData.user.attributes.timezone
|
|
87
|
+
const lang = userData.user.attributes.lang || (isClientSide() && navigator.language)
|
|
88
|
+
|
|
89
|
+
const headers = [
|
|
90
|
+
translations.report.vehicle,
|
|
91
|
+
'Immatriculation',
|
|
92
|
+
'Groupe',
|
|
93
|
+
'Matin départ',
|
|
94
|
+
'Matin arrêt',
|
|
95
|
+
'Matin temps',
|
|
96
|
+
'Déjeuner',
|
|
97
|
+
'Après-midi départ',
|
|
98
|
+
'Après-midi arrêt',
|
|
99
|
+
'Après-midi temps',
|
|
100
|
+
'Total temps',
|
|
101
|
+
'Total conduit',
|
|
102
|
+
'Total arrêts',
|
|
103
|
+
'Total kms'
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
const data = []
|
|
107
|
+
reportData.forEach(d => {
|
|
108
|
+
const row = [
|
|
109
|
+
d.device,
|
|
110
|
+
d.licensePlate,
|
|
111
|
+
d.group,
|
|
112
|
+
convertToLocaleTimeString(d.morningStart, lang, timezone, userData.user),
|
|
113
|
+
convertToLocaleTimeString(d.morningEnd, lang, timezone, userData.user),
|
|
114
|
+
convertMS(d.morningTime),
|
|
115
|
+
convertMS(d.lunch),
|
|
116
|
+
convertToLocaleTimeString(d.afternoonStart, lang, timezone, userData.user),
|
|
117
|
+
convertToLocaleTimeString(d.afternoonEnd, lang, timezone, userData.user),
|
|
118
|
+
convertMS(d.afternoonTime),
|
|
119
|
+
convertMS(d.totalTime),
|
|
120
|
+
convertMS(d.totalDrivingTime),
|
|
121
|
+
d.totalStops,
|
|
122
|
+
(d.totalDistance / 100).toFixed(1)
|
|
123
|
+
]
|
|
124
|
+
data.push(row)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const doc = new jsPDF.jsPDF('l')
|
|
128
|
+
await headerFromUser(doc, 'Rapport de Performance', userData.user)
|
|
129
|
+
const style = getStyle(getUserPartner(userData.user))
|
|
130
|
+
|
|
131
|
+
const footValues = []
|
|
132
|
+
|
|
133
|
+
doc.setFontSize(11)
|
|
134
|
+
doc.text(new Date(userData.from).toLocaleString() + ' - ' + new Date(userData.to).toLocaleString(), 20, 33)
|
|
135
|
+
|
|
136
|
+
style.headerFontSize = 8
|
|
137
|
+
style.bodyFontSize = 7
|
|
138
|
+
const columnStyles = {}
|
|
139
|
+
for (let i = 3; i < 14; i++) {
|
|
140
|
+
columnStyles[i] = { halign: 'right' }
|
|
141
|
+
}
|
|
142
|
+
addTable(doc, headers, data, footValues, style, 40, columnStyles)
|
|
143
|
+
return doc
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function exportDailyUseReportToExcel (userData, reportData) {
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
80
150
|
exports.createDailyUseReport = createDailyUseReport
|
|
151
|
+
exports.exportDailyUseReportToPDF = exportDailyUseReportToPDF
|
|
152
|
+
exports.exportDailyUseReportToExcel = exportDailyUseReportToExcel
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const automaticReports = require('../automaticReports')
|
|
2
|
+
const traccarHelper = require('../util/traccar')
|
|
3
|
+
const { getDates, getTranslations } = require('../util/utils')
|
|
4
|
+
const { getUserPartner } = require('fleetmap-partners')
|
|
5
|
+
const { getDataByDay } = require('../util/trips')
|
|
6
|
+
|
|
7
|
+
async function createDelayedStartReport (from, to, userData, traccar) {
|
|
8
|
+
const reportData = []
|
|
9
|
+
|
|
10
|
+
const devices = userData.devices
|
|
11
|
+
|
|
12
|
+
const sliced = automaticReports.sliceArray(devices, 5)
|
|
13
|
+
let deviceCount = 0
|
|
14
|
+
for (const slice of sliced) {
|
|
15
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, false, true, true, false, deviceCount, devices.length)
|
|
16
|
+
|
|
17
|
+
for (const d of slice) {
|
|
18
|
+
const deviceData = await processDeviceData(from, to, allInOne, d, userData, traccar)
|
|
19
|
+
reportData.push(deviceData)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
deviceCount = deviceCount + slice.length
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return reportData
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function processDeviceData (from, to, allInOne, d, userData, traccar) {
|
|
29
|
+
const group = userData.groups.find(g => g.id === d.groupId)
|
|
30
|
+
const trips = allInOne.trips.filter(t => t.deviceId === d.id)
|
|
31
|
+
const translations = getTranslations(userData)
|
|
32
|
+
|
|
33
|
+
const weekDays = [
|
|
34
|
+
translations.report.sunday,
|
|
35
|
+
translations.report.monday,
|
|
36
|
+
translations.report.tuesday,
|
|
37
|
+
translations.report.wednesday,
|
|
38
|
+
translations.report.thursday,
|
|
39
|
+
translations.report.friday,
|
|
40
|
+
translations.report.saturday
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
const dates = getDates(from, to, userData.user.attributes.timezone || getUserPartner(userData.user).timezone)
|
|
44
|
+
|
|
45
|
+
const deviceData = {
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (const date of dates) {
|
|
50
|
+
const { tripsByDay } = await getDataByDay(d, date, { trips }, userData, traccar)
|
|
51
|
+
|
|
52
|
+
if (tripsByDay.length > 0) {
|
|
53
|
+
const startTime = tripsByDay[0].startTime
|
|
54
|
+
const stopTime = tripsByDay[tripsByDay.length].endTime
|
|
55
|
+
|
|
56
|
+
const deviceDayData = {
|
|
57
|
+
device: d.name,
|
|
58
|
+
licensePlate: d.attributes.license_plate,
|
|
59
|
+
group: group ? group.name : '',
|
|
60
|
+
driver: '',
|
|
61
|
+
weekDay: weekDays[new Date(date).getDay()],
|
|
62
|
+
startDate: '',
|
|
63
|
+
startTime: '',
|
|
64
|
+
delayDescription: '',
|
|
65
|
+
stopTime: ''
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
async function createPassengerReport (from, to, userData, traccar) {
|
|
2
|
+
//const allDevices = await traccar.axios.get('/devices').then(d => d.data)
|
|
3
|
+
const devices = userData.devices
|
|
4
|
+
const drivers = await traccar.axios.get('/drivers').then(d => d.data)
|
|
5
|
+
const groups = await traccar.axios.get('/groups').then(d => d.data)
|
|
6
|
+
await Promise.all(groups.map(async g => {
|
|
7
|
+
const driversByGroup = await traccar.axios.get(`/drivers?groupId=${g.id}`).then(d => d.data)
|
|
8
|
+
driversByGroup.forEach(d => {
|
|
9
|
+
const _driver = drivers.find(a => a.id === d.id)
|
|
10
|
+
if (_driver) {
|
|
11
|
+
_driver.groupName = g.name
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}))
|
|
15
|
+
const eventsUrl = `/reports/events?${devices.map(d => 'deviceId=' + d.id).join('&')
|
|
16
|
+
}&from=${from.toISOString()
|
|
17
|
+
}&to=${to.toISOString()
|
|
18
|
+
}`
|
|
19
|
+
const positionsUrl = `/reports/route?${devices.map(d => 'deviceId=' + d.id).join('&')
|
|
20
|
+
}&from=${from.toISOString()
|
|
21
|
+
}&to=${to.toISOString()
|
|
22
|
+
}`
|
|
23
|
+
const events = await traccar.axios.get(eventsUrl).then(d => d.data)
|
|
24
|
+
const positions = await traccar.axios.get(positionsUrl).then(d => d.data)
|
|
25
|
+
events.forEach(e => {
|
|
26
|
+
delete e.attributes
|
|
27
|
+
const driver = getDriver(e, positions, drivers)
|
|
28
|
+
const position = positions.find(p => p.id === e.positionId)
|
|
29
|
+
e.deviceName = devices.find(d => d.id === e.deviceId).name
|
|
30
|
+
e.groupName = driver.groupName || ''
|
|
31
|
+
e.fixtime = position && new Date(position.fixTime)
|
|
32
|
+
e.notes = driver && driver.attributes.notes
|
|
33
|
+
e.driverName = (driver && driver.name) || (position && position.attributes.driverUniqueId)
|
|
34
|
+
})
|
|
35
|
+
return events
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getDriver (event, positions, drivers) {
|
|
39
|
+
const p = positions.find(p => p.id === event.positionId)
|
|
40
|
+
if (!p) { return '' }
|
|
41
|
+
const d = drivers.find(d => d.uniqueId === p.attributes.driverUniqueId)
|
|
42
|
+
if (!d) { return '' }
|
|
43
|
+
return d
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.createPassengerReport = createPassengerReport
|
package/src/refueling-report.js
CHANGED
|
@@ -331,3 +331,6 @@ exports.createRefuelingReport = createRefuelingReport
|
|
|
331
331
|
exports.calculateRefuelingPositions = calculateRefuelingPositions
|
|
332
332
|
exports.exportRefuelingReportToPDF = exportRefuelingReportToPDF
|
|
333
333
|
exports.exportRefuelingReportToExcel = exportRefuelingReportToExcel
|
|
334
|
+
exports.create = createRefuelingReport
|
|
335
|
+
exports.exportToPDF = exportRefuelingReportToPDF
|
|
336
|
+
exports.exportToExcel = exportRefuelingReportToExcel
|
package/src/speeding-report.js
CHANGED
|
@@ -703,4 +703,7 @@ function getMaxSpeed (data) {
|
|
|
703
703
|
exports.createSpeedingReport = createSpeedingReport
|
|
704
704
|
exports.exportSpeedingReportToPDF = exportSpeedingReportToPDF
|
|
705
705
|
exports.exportSpeedingReportToExcel = exportSpeedingReportToExcel
|
|
706
|
+
exports.create = createSpeedingReport
|
|
707
|
+
exports.exportToPDF = exportSpeedingReportToPDF
|
|
708
|
+
exports.exportToExcel = exportSpeedingReportToExcel
|
|
706
709
|
exports.getEvents = getEvents
|
package/src/stop-report.js
CHANGED
|
@@ -237,3 +237,6 @@ function getStopEnd (user, stop) {
|
|
|
237
237
|
exports.createStopReport = createStopReport
|
|
238
238
|
exports.exportStopReportToPDF = exportStopReportToPDF
|
|
239
239
|
exports.exportStopReportToExcel = exportStopReportToExcel
|
|
240
|
+
exports.create = createStopReport
|
|
241
|
+
exports.exportToPDF = exportStopReportToPDF
|
|
242
|
+
exports.exportToExcel = exportStopReportToExcel
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { getReports } = require('./index')
|
|
2
|
+
const assert = require('assert')
|
|
3
|
+
const { createDailyUseReport } = require('../partnerReports/dailyuse-report')
|
|
4
|
+
|
|
5
|
+
describe('dailyuse', function () {
|
|
6
|
+
// eslint-disable-next-line no-undef
|
|
7
|
+
it('dailyuse report', async () => {
|
|
8
|
+
const report = await getReports()
|
|
9
|
+
const userData = await report.getUserData()
|
|
10
|
+
|
|
11
|
+
const data = await createDailyUseReport(
|
|
12
|
+
new Date(Date.UTC(2023, 10, 1, 0, 0, 0, 0)),
|
|
13
|
+
new Date(Date.UTC(2023, 10, 6, 23, 59, 59, 0)),
|
|
14
|
+
userData,
|
|
15
|
+
report.traccar)
|
|
16
|
+
console.log(data)
|
|
17
|
+
assert.equal(data[0].consumption, 19.799999999999997)
|
|
18
|
+
}, 8000000)
|
|
19
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { getReports } = require('./index')
|
|
2
|
+
const assert = require('assert')
|
|
3
|
+
const { convertMS } = require('../util/utils')
|
|
4
|
+
const { createGPSJumpReport } = require('../partnerReports/gpsjump-report')
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line no-undef
|
|
7
|
+
describe('gpsjump', function () {
|
|
8
|
+
// eslint-disable-next-line no-undef
|
|
9
|
+
it('gpsjump report', async () => {
|
|
10
|
+
const report = await getReports()
|
|
11
|
+
const userData = await report.getUserData()
|
|
12
|
+
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
13
|
+
const data = await createGPSJumpReport(
|
|
14
|
+
new Date(Date.UTC(2023, 6, 1, 0, 0, 0, 0)),
|
|
15
|
+
new Date(Date.UTC(2023, 6, 17, 23, 59, 59, 0)),
|
|
16
|
+
userData,
|
|
17
|
+
report.traccar)
|
|
18
|
+
console.log(data)
|
|
19
|
+
assert.equal(data[0].consumption, 19.799999999999997)
|
|
20
|
+
assert.equal(data[0].distance, 326.7657)
|
|
21
|
+
assert.equal(convertMS(data[1].time * 1000, false), '08:19')
|
|
22
|
+
}, 8000000)
|
|
23
|
+
})
|
package/src/tests/kms.test.js
CHANGED
|
@@ -52,4 +52,22 @@ describe('Kms_Reports', function () {
|
|
|
52
52
|
assert.equal(device.days.length, 30) // Total Kms
|
|
53
53
|
assert.equal(device.days[29].kms, 136174.93281451002) // Total Kms
|
|
54
54
|
}, 30000)
|
|
55
|
+
it('KmsReport by driver', async () => {
|
|
56
|
+
const reports = await getReports(process.env.USER_CTM_MOVIFLOTTE, process.env.PASS_CTM_MOVIFLOTTE)
|
|
57
|
+
const userData = await reports.getUserData()
|
|
58
|
+
userData.byDriver = true
|
|
59
|
+
console.log(userData.drivers)
|
|
60
|
+
const data = await reports.kmsReport(new Date(2024, 0, 1, 0, 0, 0), new Date(2024, 0, 31, 23, 59, 59),
|
|
61
|
+
userData)
|
|
62
|
+
assert.equal(data.length, 1)
|
|
63
|
+
}, 3000000)
|
|
64
|
+
it('KmsReport by timezone marrocos', async () => {
|
|
65
|
+
const reports = await getReports(process.env.email, process.env.password)
|
|
66
|
+
const userData = await reports.getUserData()
|
|
67
|
+
userData.groupByDay = true
|
|
68
|
+
const data = await reports.kmsReport(new Date(2024, 0, 31, 23, 0, 0), new Date(2024, 1, 28, 22, 59, 59),
|
|
69
|
+
userData)
|
|
70
|
+
const device = data[0].devices.find(d => d.device.id === 292563)
|
|
71
|
+
assert.equal(device, 1)
|
|
72
|
+
}, 3000000)
|
|
55
73
|
})
|
package/src/tests/zones.test.js
CHANGED
|
@@ -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
|
})
|
package/src/trip-report.js
CHANGED
|
@@ -628,4 +628,7 @@ function getStop (tripEndDate, stops) {
|
|
|
628
628
|
exports.createTripReport = createTripReport
|
|
629
629
|
exports.exportTripReportToPDF = exportTripReportToPDF
|
|
630
630
|
exports.exportTripReportToExcel = exportTripReportToExcel
|
|
631
|
+
exports.create = createTripReport
|
|
632
|
+
exports.exportToPDF = exportTripReportToPDF
|
|
633
|
+
exports.exportToExcel = exportTripReportToExcel
|
|
631
634
|
exports.calculateIdleEvents = calculateIdleEvents
|
package/src/util/traccar.js
CHANGED
|
@@ -135,13 +135,13 @@ async function getSummaryByDay (dates, userData, traccarInstance, allDevices, ig
|
|
|
135
135
|
for (const [index, date] of dates.entries()) {
|
|
136
136
|
let startDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + userData.dayHours.startTime)
|
|
137
137
|
if (index === 0) {
|
|
138
|
-
const _startDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + from.toTimeString().slice(0, 8))
|
|
138
|
+
const _startDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + (isClientSide() ? from.toTimeString().slice(0, 8) : convertFromUTC(from, userData.user.attributes.timezone).toTimeString().slice(0, 8)))
|
|
139
139
|
startDateLocal = startDateLocal.getTime() > _startDateLocal.getTime() ? startDateLocal : _startDateLocal
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
let endDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + userData.dayHours.endTime)
|
|
143
143
|
if (index === dates.length - 1) {
|
|
144
|
-
const _endDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + to.toTimeString().slice(0, 8))
|
|
144
|
+
const _endDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + (isClientSide() ? to.toTimeString().slice(0, 8) : convertFromUTC(to, userData.user.attributes.timezone).toTimeString().slice(0, 8)))
|
|
145
145
|
endDateLocal = endDateLocal.getTime() < _endDateLocal.getTime() ? endDateLocal : _endDateLocal
|
|
146
146
|
}
|
|
147
147
|
|
package/src/zone-report.js
CHANGED
|
@@ -840,4 +840,7 @@ function geofenceExit (user, row) {
|
|
|
840
840
|
exports.createZoneReport = createZoneReport
|
|
841
841
|
exports.exportZoneReportToPDF = exportZoneReportToPDF
|
|
842
842
|
exports.exportZoneReportToExcel = exportZoneReportToExcel
|
|
843
|
+
exports.create = createZoneReport
|
|
844
|
+
exports.exportToPDF = exportZoneReportToPDF
|
|
845
|
+
exports.exportToExcel = exportZoneReportToExcel
|
|
843
846
|
exports.getInAndOutEvents = getInAndOutEvents
|