fleetmap-reports 1.0.274 → 1.0.275

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.
@@ -1,9 +1,11 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
- <list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="fix kms report by group">
4
+ <list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="fix convert date to localeString">
5
+ <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/src/activity-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/activity-report.js" afterDir="false" />
5
7
  <change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/src/util/utils.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/utils.js" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/src/kms-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/kms-report.js" afterDir="false" />
7
9
  </list>
8
10
  <option name="SHOW_DIALOG" value="false" />
9
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -227,7 +229,11 @@
227
229
  <workItem from="1641740608739" duration="1844000" />
228
230
  <workItem from="1641775506363" duration="646000" />
229
231
  <workItem from="1641819557952" duration="1678000" />
230
- <workItem from="1641910746496" duration="1137000" />
232
+ <workItem from="1641910746496" duration="1819000" />
233
+ <workItem from="1641921254910" duration="614000" />
234
+ <workItem from="1641991863387" duration="626000" />
235
+ <workItem from="1641992769870" duration="96000" />
236
+ <workItem from="1641992912450" duration="1045000" />
231
237
  </task>
232
238
  <task id="LOCAL-00001" summary="Fix getStyle">
233
239
  <created>1636983717385</created>
@@ -411,7 +417,14 @@
411
417
  <option name="project" value="LOCAL" />
412
418
  <updated>1641820626240</updated>
413
419
  </task>
414
- <option name="localTasksCounter" value="27" />
420
+ <task id="LOCAL-00027" summary="fix convert date to localeString">
421
+ <created>1641912050985</created>
422
+ <option name="number" value="00027" />
423
+ <option name="presentableId" value="LOCAL-00027" />
424
+ <option name="project" value="LOCAL" />
425
+ <updated>1641912050985</updated>
426
+ </task>
427
+ <option name="localTasksCounter" value="28" />
415
428
  <servers />
416
429
  </component>
417
430
  <component name="TypeScriptGeneratedFilesManager">
@@ -441,7 +454,6 @@
441
454
  <option name="oldMeFiltersMigrated" value="true" />
442
455
  </component>
443
456
  <component name="VcsManagerConfiguration">
444
- <MESSAGE value="Fix getStyle" />
445
457
  <MESSAGE value="Fix getStyle in all reports" />
446
458
  <MESSAGE value="try catch on pdf addImage" />
447
459
  <MESSAGE value="Kms report grouped by day" />
@@ -466,6 +478,7 @@
466
478
  <MESSAGE value="check if weekDays parameter is set" />
467
479
  <MESSAGE value="fix trip report" />
468
480
  <MESSAGE value="fix kms report by group" />
469
- <option name="LAST_COMMIT_MESSAGE" value="fix kms report by group" />
481
+ <MESSAGE value="fix convert date to localeString" />
482
+ <option name="LAST_COMMIT_MESSAGE" value="fix convert date to localeString" />
470
483
  </component>
471
484
  </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.274",
3
+ "version": "1.0.275",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -9,6 +9,7 @@ const {getStyle} = require("./reportStyle")
9
9
  const {getUserPartner} = require("fleetmap-partners")
10
10
  const traccar = require("./util/traccar")
11
11
  const {createKmsReport} = require("./kms-report");
12
+ const {isInsideTimetable} = require("./util/trips");
12
13
 
13
14
  let traccarInstance
14
15
  let userData
@@ -214,50 +215,19 @@ function processDrivers(from, to, drivers, data) {
214
215
  if(userData.groupByDay) {
215
216
  const dates = getDates(from, to)
216
217
  for(const date of dates){
217
- if(userData.allWeek || !userData.weekDays){
218
- const fromByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
219
- const toByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
220
-
221
- const tripsByDay = trips.filter(t => new Date(t.startTime) > fromByDay && new Date(t.endTime) < toByDay)
222
-
223
- driverData.summary.push({
224
- date: date,
225
- distance: tripsByDay.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0),
226
- engineHours: tripsByDay.reduce((a, b) => a + b.duration, 0),
227
- maxSpeed: tripsByDay.reduce((a, b) => Math.max(a, b.maxSpeed), 0),
228
- averageSpeed: tripsByDay.length > 0 ? Math.round(tripsByDay.reduce((a, b) => a + b.averageSpeed, 0) / tripsByDay.length) : 0,
229
- })
230
- } else {
231
- if((date.getDay() === 0 && userData.weekDays.sunday) ||
232
- (date.getDay() === 1 && userData.weekDays.monday) ||
233
- (date.getDay() === 2 && userData.weekDays.tuesday) ||
234
- (date.getDay() === 3 && userData.weekDays.wednesday) ||
235
- (date.getDay() === 4 && userData.weekDays.thursday) ||
236
- (date.getDay() === 5 && userData.weekDays.friday) ||
237
- (date.getDay() === 6 && userData.weekDays.saturday)) {
238
-
239
- const fromByDay = new Date(new Date(date).toISOString().split('T')[0] + ' ' + userData.dayHours.startTime)
240
- const toByDay = new Date(new Date(date).toISOString().split('T')[0] + ' ' + userData.dayHours.endTime)
241
-
242
- const tripsByDay = trips.filter(t => new Date(t.startTime) > fromByDay && new Date(t.endTime) < toByDay)
243
-
244
- driverData.summary.push({
245
- date: date,
246
- distance: tripsByDay.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0),
247
- engineHours: tripsByDay.reduce((a, b) => a + b.duration, 0),
248
- maxSpeed: tripsByDay.reduce((a, b) => Math.max(a, b.maxSpeed), 0),
249
- averageSpeed: tripsByDay.length > 0 ? Math.round(tripsByDay.reduce((a, b) => a + b.averageSpeed, 0) / tripsByDay.length) : 0,
250
- })
251
- }else {
252
- driverData.summary.push({
253
- date: date,
254
- distance: 0,
255
- engineHours: 0,
256
- maxSpeed: 0,
257
- averageSpeed: 0,
258
- })
259
- }
260
- }
218
+ const fromByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
219
+ const toByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
220
+
221
+ const tripsByDay = trips.filter(t => (new Date(t.startTime) > fromByDay && new Date(t.endTime) < toByDay)
222
+ && (userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData)))
223
+
224
+ driverData.summary.push({
225
+ date: date,
226
+ distance: tripsByDay.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0),
227
+ engineHours: tripsByDay.reduce((a, b) => a + b.duration, 0),
228
+ maxSpeed: tripsByDay.reduce((a, b) => Math.max(a, b.maxSpeed), 0),
229
+ averageSpeed: tripsByDay.length > 0 ? Math.round(tripsByDay.reduce((a, b) => a + b.averageSpeed, 0) / tripsByDay.length) : 0,
230
+ })
261
231
  }
262
232
  } else {
263
233
  driverData.summary.push({
package/src/kms-report.js CHANGED
@@ -8,6 +8,7 @@ const traccar = require("./util/traccar");
8
8
  const {getDates} = require("./util/utils");
9
9
  const trips = require("./util/trips");
10
10
  const drivers = require("./util/driver");
11
+ const {isInsideTimetable} = require("./util/trips");
11
12
 
12
13
 
13
14
  let traccarInstance
@@ -124,41 +125,16 @@ function processDrivers(from, to, drivers, data) {
124
125
  driverData.days = []
125
126
  const dates = getDates(from, to)
126
127
  for(const date of dates){
127
- if(userData.allWeek || !userData.weekDays){
128
- const fromByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
129
- const toByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
128
+ const fromByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
129
+ const toByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
130
130
 
131
- const tripsByDay = trips.filter(t => new Date(t.startTime) > fromByDay && new Date(t.endTime) < toByDay)
131
+ const tripsByDay = trips.filter(t => (new Date(t.startTime) > fromByDay && new Date(t.endTime) < toByDay)
132
+ && (userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData)))
132
133
 
133
- driverData.days.push({
134
- date: date,
135
- kms: tripsByDay.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0)
136
- })
137
- } else {
138
- if((date.getDay() === 0 && userData.weekDays.sunday) ||
139
- (date.getDay() === 1 && userData.weekDays.monday) ||
140
- (date.getDay() === 2 && userData.weekDays.tuesday) ||
141
- (date.getDay() === 3 && userData.weekDays.wednesday) ||
142
- (date.getDay() === 4 && userData.weekDays.thursday) ||
143
- (date.getDay() === 5 && userData.weekDays.friday) ||
144
- (date.getDay() === 6 && userData.weekDays.saturday)) {
145
-
146
- const fromByDay = new Date(new Date(date).toISOString().split('T')[0] + ' ' + userData.dayHours.startTime)
147
- const toByDay = new Date(new Date(date).toISOString().split('T')[0] + ' ' + userData.dayHours.endTime)
148
-
149
- const tripsByDay = trips.filter(t => new Date(t.startTime) > fromByDay && new Date(t.endTime) < toByDay)
150
-
151
- driverData.days.push({
152
- date: date,
153
- kms: tripsByDay.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0)
154
- })
155
- }else {
156
- driverData.days.push({
157
- date: date,
158
- kms: 0
159
- })
160
- }
161
- }
134
+ driverData.days.push({
135
+ date: date,
136
+ kms: tripsByDay.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0)
137
+ })
162
138
  }
163
139
  } else {
164
140
  driverData.summary = {