scheduler-node-models 1.2.122 → 1.2.124
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/config/index.js +1 -0
- package/config/index.js.map +1 -0
- package/config/logPosting.js +1 -0
- package/config/logPosting.js.map +1 -0
- package/config/logging.js +1 -2
- package/config/logging.js.map +1 -0
- package/config/mongoconnect.js +1 -1
- package/config/mongoconnect.js.map +1 -0
- package/config/sqldb.js +2 -34
- package/config/sqldb.js.map +1 -0
- package/general/emailer.js +3 -5
- package/general/emailer.js.map +1 -0
- package/general/general.d.ts +0 -3
- package/general/general.js +1 -0
- package/general/general.js.map +1 -0
- package/general/index.js +1 -0
- package/general/index.js.map +1 -0
- package/general/logger.js +2 -34
- package/general/logger.js.map +1 -0
- package/general/logs.d.ts +0 -30
- package/general/logs.js +1 -24
- package/general/logs.js.map +1 -0
- package/general/notices.d.ts +0 -15
- package/general/notices.js +1 -11
- package/general/notices.js.map +1 -0
- package/general/report.js +1 -0
- package/general/report.js.map +1 -0
- package/general/viewstate.js +1 -0
- package/general/viewstate.js.map +1 -0
- package/index.js +1 -1
- package/index.js.map +1 -0
- package/metrics/images.d.ts +0 -6
- package/metrics/images.js +1 -3
- package/metrics/images.js.map +1 -0
- package/metrics/index.js +1 -0
- package/metrics/index.js.map +1 -0
- package/metrics/mission.d.ts +0 -6
- package/metrics/mission.js +1 -3
- package/metrics/mission.js.map +1 -0
- package/metrics/missionSensorOutage.js +1 -0
- package/metrics/missionSensorOutage.js.map +1 -0
- package/metrics/missionsensor.d.ts +0 -22
- package/metrics/missionsensor.js +1 -19
- package/metrics/missionsensor.js.map +1 -0
- package/metrics/outage.d.ts +0 -8
- package/metrics/outage.js +1 -5
- package/metrics/outage.js.map +1 -0
- package/metrics/systemdata/classifications.d.ts +0 -6
- package/metrics/systemdata/classifications.js +1 -3
- package/metrics/systemdata/classifications.js.map +1 -0
- package/metrics/systemdata/communications.d.ts +0 -6
- package/metrics/systemdata/communications.js +1 -3
- package/metrics/systemdata/communications.js.map +1 -0
- package/metrics/systemdata/dcgs.d.ts +0 -7
- package/metrics/systemdata/dcgs.js +1 -3
- package/metrics/systemdata/dcgs.js.map +1 -0
- package/metrics/systemdata/exploitations.d.ts +0 -6
- package/metrics/systemdata/exploitations.js +1 -3
- package/metrics/systemdata/exploitations.js.map +1 -0
- package/metrics/systemdata/groundSystems.d.ts +0 -46
- package/metrics/systemdata/groundSystems.js +1 -39
- package/metrics/systemdata/groundSystems.js.map +1 -0
- package/metrics/systemdata/index.js +1 -0
- package/metrics/systemdata/index.js.map +1 -0
- package/metrics/systemdata/platform.d.ts +0 -49
- package/metrics/systemdata/platform.js +1 -37
- package/metrics/systemdata/platform.js.map +1 -0
- package/metrics/systemdata/systeminfo.d.ts +0 -5
- package/metrics/systemdata/systeminfo.js +1 -0
- package/metrics/systemdata/systeminfo.js.map +1 -0
- package/package.json +1 -1
- package/scheduler/employees/assignment.d.ts +2 -103
- package/scheduler/employees/assignment.js +1 -102
- package/scheduler/employees/assignment.js.map +1 -0
- package/scheduler/employees/balance.d.ts +0 -23
- package/scheduler/employees/balance.js +1 -19
- package/scheduler/employees/balance.js.map +1 -0
- package/scheduler/employees/companyinfo.d.ts +0 -7
- package/scheduler/employees/companyinfo.js +1 -4
- package/scheduler/employees/companyinfo.js.map +1 -0
- package/scheduler/employees/contact.d.ts +0 -22
- package/scheduler/employees/contact.js +1 -18
- package/scheduler/employees/contact.js.map +1 -0
- package/scheduler/employees/employee.d.ts +0 -363
- package/scheduler/employees/employee.js +1 -418
- package/scheduler/employees/employee.js.map +1 -0
- package/scheduler/employees/employeename.d.ts +0 -31
- package/scheduler/employees/employeename.js +1 -28
- package/scheduler/employees/employeename.js.map +1 -0
- package/scheduler/employees/index.js +1 -0
- package/scheduler/employees/index.js.map +1 -0
- package/scheduler/employees/labor.d.ts +0 -21
- package/scheduler/employees/labor.js +1 -18
- package/scheduler/employees/labor.js.map +1 -0
- package/scheduler/employees/leave.d.ts +0 -35
- package/scheduler/employees/leave.js +1 -32
- package/scheduler/employees/leave.js.map +1 -0
- package/scheduler/employees/leaverequest.d.ts +0 -62
- package/scheduler/employees/leaverequest.js +1 -52
- package/scheduler/employees/leaverequest.js.map +1 -0
- package/scheduler/employees/specialty.d.ts +0 -21
- package/scheduler/employees/specialty.js +1 -18
- package/scheduler/employees/specialty.js.map +1 -0
- package/scheduler/employees/variation.d.ts +0 -61
- package/scheduler/employees/variation.js +1 -57
- package/scheduler/employees/variation.js.map +1 -0
- package/scheduler/employees/web.js +1 -0
- package/scheduler/employees/web.js.map +1 -0
- package/scheduler/employees/work.d.ts +0 -58
- package/scheduler/employees/work.js +1 -46
- package/scheduler/employees/work.js.map +1 -0
- package/scheduler/employees/workday.d.ts +0 -61
- package/scheduler/employees/workday.js +1 -51
- package/scheduler/employees/workday.js.map +1 -0
- package/scheduler/ingest/excelRow.d.ts +0 -14
- package/scheduler/ingest/excelRow.js +1 -4
- package/scheduler/ingest/excelRow.js.map +1 -0
- package/scheduler/ingest/excelRowIngest.d.ts +0 -7
- package/scheduler/ingest/excelRowIngest.js +1 -17
- package/scheduler/ingest/excelRowIngest.js.map +1 -0
- package/scheduler/ingest/index.js +1 -0
- package/scheduler/ingest/index.js.map +1 -0
- package/scheduler/ingest/sapIngest.js +1 -9
- package/scheduler/ingest/sapIngest.js.map +1 -0
- package/scheduler/ingest/web.js +1 -0
- package/scheduler/ingest/web.js.map +1 -0
- package/scheduler/labor/index.js +1 -0
- package/scheduler/labor/index.js.map +1 -0
- package/scheduler/labor/laborcode.js +1 -0
- package/scheduler/labor/laborcode.js.map +1 -0
- package/scheduler/labor/workcode.js +1 -0
- package/scheduler/labor/workcode.js.map +1 -0
- package/scheduler/sites/index.js +1 -0
- package/scheduler/sites/index.js.map +1 -0
- package/scheduler/sites/reports/cofsReport.d.ts +0 -16
- package/scheduler/sites/reports/cofsReport.js +1 -19
- package/scheduler/sites/reports/cofsReport.js.map +1 -0
- package/scheduler/sites/reports/forecast.d.ts +0 -28
- package/scheduler/sites/reports/forecast.js +1 -37
- package/scheduler/sites/reports/forecast.js.map +1 -0
- package/scheduler/sites/reports/index.js +1 -0
- package/scheduler/sites/reports/index.js.map +1 -0
- package/scheduler/sites/reports/period.js +1 -0
- package/scheduler/sites/reports/period.js.map +1 -0
- package/scheduler/sites/reports/section.d.ts +0 -35
- package/scheduler/sites/reports/section.js +1 -34
- package/scheduler/sites/reports/section.js.map +1 -0
- package/scheduler/sites/reports/web.js +1 -0
- package/scheduler/sites/reports/web.js.map +1 -0
- package/scheduler/sites/site.d.ts +0 -17
- package/scheduler/sites/site.js +1 -14
- package/scheduler/sites/site.js.map +1 -0
- package/scheduler/sites/web/index.js +1 -0
- package/scheduler/sites/web/index.js.map +1 -0
- package/scheduler/sites/web/requests.js +1 -0
- package/scheduler/sites/web/requests.js.map +1 -0
- package/scheduler/sites/workcenters/index.js +1 -0
- package/scheduler/sites/workcenters/index.js.map +1 -0
- package/scheduler/sites/workcenters/position.d.ts +0 -11
- package/scheduler/sites/workcenters/position.js +1 -8
- package/scheduler/sites/workcenters/position.js.map +1 -0
- package/scheduler/sites/workcenters/shift.d.ts +0 -11
- package/scheduler/sites/workcenters/shift.js +1 -8
- package/scheduler/sites/workcenters/shift.js.map +1 -0
- package/scheduler/sites/workcenters/workcenter.d.ts +0 -22
- package/scheduler/sites/workcenters/workcenter.js +1 -21
- package/scheduler/sites/workcenters/workcenter.js.map +1 -0
- package/scheduler/teams/company/company.d.ts +0 -66
- package/scheduler/teams/company/company.js +1 -61
- package/scheduler/teams/company/company.js.map +1 -0
- package/scheduler/teams/company/holiday.d.ts +0 -38
- package/scheduler/teams/company/holiday.js +1 -35
- package/scheduler/teams/company/holiday.js.map +1 -0
- package/scheduler/teams/company/index.js +1 -0
- package/scheduler/teams/company/index.js.map +1 -0
- package/scheduler/teams/company/modperiod.d.ts +0 -9
- package/scheduler/teams/company/modperiod.js +1 -4
- package/scheduler/teams/company/modperiod.js.map +1 -0
- package/scheduler/teams/contact.d.ts +0 -6
- package/scheduler/teams/contact.js +1 -3
- package/scheduler/teams/contact.js.map +1 -0
- package/scheduler/teams/index.js +1 -0
- package/scheduler/teams/index.js.map +1 -0
- package/scheduler/teams/specialty.d.ts +0 -6
- package/scheduler/teams/specialty.js +1 -3
- package/scheduler/teams/specialty.js.map +1 -0
- package/scheduler/teams/team.d.ts +0 -60
- package/scheduler/teams/team.js +1 -60
- package/scheduler/teams/team.js.map +1 -0
- package/scheduler/teams/web.js +1 -0
- package/scheduler/teams/web.js.map +1 -0
- package/scheduler/web/index.js +1 -0
- package/scheduler/web/index.js.map +1 -0
- package/scheduler/web/initial.js +1 -0
- package/scheduler/web/initial.js.map +1 -0
- package/users/index.js +1 -0
- package/users/index.js.map +1 -0
- package/users/permission.d.ts +0 -3
- package/users/permission.js +1 -0
- package/users/permission.js.map +1 -0
- package/users/question.d.ts +2 -17
- package/users/question.js +17 -13
- package/users/question.js.map +1 -0
- package/users/user.d.ts +5 -79
- package/users/user.js +51 -72
- package/users/user.js.map +1 -0
- package/users/web.d.ts +0 -25
- package/users/web.js +1 -0
- package/users/web.js.map +1 -0
|
@@ -142,34 +142,19 @@ class Employee {
|
|
|
142
142
|
}
|
|
143
143
|
return -1;
|
|
144
144
|
}
|
|
145
|
-
/**
|
|
146
|
-
* This function will clone this object, but remove all the work and user objects
|
|
147
|
-
* so they aren't saved in the database. They are saved in other collections.
|
|
148
|
-
* @returns An employee object for saving to the database
|
|
149
|
-
*/
|
|
150
145
|
cloneForSave() {
|
|
151
146
|
const result = new Employee(this);
|
|
152
147
|
result.work = undefined;
|
|
153
148
|
result.user = undefined;
|
|
154
149
|
return result;
|
|
155
150
|
}
|
|
156
|
-
/**
|
|
157
|
-
* This function is designed to remove old data from this employee object. It will
|
|
158
|
-
* remove old variations, leaves, leave requests, and leave balances, if they are
|
|
159
|
-
* older than the date given.
|
|
160
|
-
* @param date This date value is used for comparison, for anything before this date.
|
|
161
|
-
* @returns A boolean value to indicate to the calling function whether or not to
|
|
162
|
-
* remove this employee.
|
|
163
|
-
*/
|
|
164
151
|
purge(date) {
|
|
165
|
-
// purge old variations
|
|
166
152
|
this.variations.sort((a, b) => a.compareTo(b));
|
|
167
153
|
for (let v = this.variations.length - 1; v >= 0; v--) {
|
|
168
154
|
if (this.variations[v].enddate.getTime() < date.getTime()) {
|
|
169
155
|
this.variations.splice(v, 1);
|
|
170
156
|
}
|
|
171
157
|
}
|
|
172
|
-
// purge old leaves and leave requests(based on request's end date)
|
|
173
158
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
174
159
|
for (let l = this.leaves.length - 1; l >= 0; l--) {
|
|
175
160
|
if (this.leaves[l].leavedate.getTime() < date.getTime()) {
|
|
@@ -181,28 +166,16 @@ class Employee {
|
|
|
181
166
|
this.requests.splice(l, 1);
|
|
182
167
|
}
|
|
183
168
|
}
|
|
184
|
-
// purge old leave balances
|
|
185
169
|
this.balances.sort((a, b) => a.compareTo(b));
|
|
186
170
|
for (let b = this.balances.length - 1; b >= 0; b--) {
|
|
187
171
|
if (this.balances[b].year < date.getUTCFullYear()) {
|
|
188
172
|
this.balances.splice(b, 1);
|
|
189
173
|
}
|
|
190
174
|
}
|
|
191
|
-
// return as to whether the employee quit before date
|
|
192
175
|
this.assignments.sort((a, b) => a.compareTo(b));
|
|
193
176
|
const last = this.assignments[this.assignments.length - 1];
|
|
194
177
|
return (last.endDate.getTime() < date.getTime());
|
|
195
178
|
}
|
|
196
|
-
/**********************************************************************************
|
|
197
|
-
* This is the assignments section for modifying the assignment list.
|
|
198
|
-
**********************************************************************************/
|
|
199
|
-
/**
|
|
200
|
-
* Remove Leaves between and including dates.
|
|
201
|
-
* @param start The date for the start of the removal
|
|
202
|
-
* @param end The date for the end of the removal
|
|
203
|
-
* @param reqID (Optional) the string value for a possible request identifier
|
|
204
|
-
* @param includeActuals (Optional) the boolean value to delete actuals
|
|
205
|
-
*/
|
|
206
179
|
removeLeaves(start, end, reqID = '', includeActuals = true) {
|
|
207
180
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
208
181
|
for (let l = this.leaves.length - 1; l >= 0; l--) {
|
|
@@ -236,12 +209,6 @@ class Employee {
|
|
|
236
209
|
}
|
|
237
210
|
}
|
|
238
211
|
}
|
|
239
|
-
/**
|
|
240
|
-
* This function is used to determine if the employee is active on the date given.
|
|
241
|
-
* @param date The date object used to determine whether or not the employee was active
|
|
242
|
-
* on this date.
|
|
243
|
-
* @returns A boolean value for whether or not the employee was active.
|
|
244
|
-
*/
|
|
245
212
|
isActive(date) {
|
|
246
213
|
let result = false;
|
|
247
214
|
this.assignments.forEach(a => {
|
|
@@ -251,16 +218,6 @@ class Employee {
|
|
|
251
218
|
});
|
|
252
219
|
return result;
|
|
253
220
|
}
|
|
254
|
-
/**
|
|
255
|
-
* This function is used to determine if the employee is active during a particular
|
|
256
|
-
* period of time at a site and workcenter.
|
|
257
|
-
* @param site The string value to designate the site.
|
|
258
|
-
* @param wkctr The string value to designate the workcenter.
|
|
259
|
-
* @param start The date object for the start of the requested period.
|
|
260
|
-
* @param end The date object for the end of the requested period.
|
|
261
|
-
* @returns The boolean value to indicate the employee was working at the site and
|
|
262
|
-
* workcenter during the period.
|
|
263
|
-
*/
|
|
264
221
|
isAssigned(site, wkctr, start, end) {
|
|
265
222
|
let result = false;
|
|
266
223
|
this.assignments.forEach(a => {
|
|
@@ -277,15 +234,6 @@ class Employee {
|
|
|
277
234
|
});
|
|
278
235
|
return result;
|
|
279
236
|
}
|
|
280
|
-
/**
|
|
281
|
-
* This function is used to determine if the employee is active at a site during a
|
|
282
|
-
* period of time.
|
|
283
|
-
* @param site The string value to designate the site.
|
|
284
|
-
* @param start The date object for the start of the requested period.
|
|
285
|
-
* @param end The date object for the end of the requested period.
|
|
286
|
-
* @returns The boolean value to indicate the employee was working at the site during
|
|
287
|
-
* the period.
|
|
288
|
-
*/
|
|
289
237
|
atSite(site, start, end) {
|
|
290
238
|
let result = false;
|
|
291
239
|
this.assignments.forEach(a => {
|
|
@@ -301,20 +249,7 @@ class Employee {
|
|
|
301
249
|
});
|
|
302
250
|
return result;
|
|
303
251
|
}
|
|
304
|
-
/**
|
|
305
|
-
* This general function is used to get the employee's workday for a date. There are
|
|
306
|
-
* three possible types of request: general, actuals, and without leave. It will
|
|
307
|
-
* provide the workday, if the employee will work or was working on the date.
|
|
308
|
-
* @param date The date object representing the date to check against.
|
|
309
|
-
* @param type The string value for the type of request to conduct: general, actuals
|
|
310
|
-
* or noleaves.
|
|
311
|
-
* @param labor An array of Employee Labor Codes to compare against in the "actuals"
|
|
312
|
-
* type request.
|
|
313
|
-
* @returns A workday object for the work to be or was performed. Will return undefined
|
|
314
|
-
* for a day not working or on leave.
|
|
315
|
-
*/
|
|
316
252
|
getWorkday(date, type = 'general', labor) {
|
|
317
|
-
// calls one of three child functions (private) to provide the data
|
|
318
253
|
switch (type.toLowerCase()) {
|
|
319
254
|
case "actuals":
|
|
320
255
|
return this.getWorkdayActual(date, labor);
|
|
@@ -326,26 +261,17 @@ class Employee {
|
|
|
326
261
|
return this.getWorkdayGeneral(date);
|
|
327
262
|
}
|
|
328
263
|
}
|
|
329
|
-
/**
|
|
330
|
-
* This private function will provide the employee's workday based on assignment, then
|
|
331
|
-
* variation and lastly leaves. Actual work hours are used for dates where they are
|
|
332
|
-
* before or on the date of the newest work record.
|
|
333
|
-
* @param date The date object used for comparison
|
|
334
|
-
* @returns A workday object or undefined for the employee's workday on the date.
|
|
335
|
-
*/
|
|
336
264
|
getWorkdayGeneral(date) {
|
|
337
265
|
let wday;
|
|
338
266
|
let stdWorkday = 8.0;
|
|
339
267
|
let work = 0.0;
|
|
340
268
|
let siteid = '';
|
|
341
269
|
let lastWorked = new Date(0);
|
|
342
|
-
// first get the standard workday hours;
|
|
343
270
|
this.assignments.forEach(asgmt => {
|
|
344
271
|
if (asgmt.useSiteAssignment(this.site, date)) {
|
|
345
272
|
stdWorkday = asgmt.getStandardWorkHours();
|
|
346
273
|
}
|
|
347
274
|
});
|
|
348
|
-
// check work records for work hours
|
|
349
275
|
if (this.work) {
|
|
350
276
|
this.work.forEach(wk => {
|
|
351
277
|
if (wk.useWork(date) && wk.modtime) {
|
|
@@ -356,14 +282,12 @@ class Employee {
|
|
|
356
282
|
}
|
|
357
283
|
});
|
|
358
284
|
}
|
|
359
|
-
// now get the normal workday based on assignment
|
|
360
285
|
this.assignments.forEach(asgmt => {
|
|
361
286
|
if (asgmt.useAssignment(date)) {
|
|
362
287
|
wday = asgmt.getWorkday(date);
|
|
363
288
|
siteid = asgmt.site;
|
|
364
289
|
}
|
|
365
290
|
});
|
|
366
|
-
// next, check for variation on date
|
|
367
291
|
this.variations.forEach(vari => {
|
|
368
292
|
if (vari.useVariation(date)) {
|
|
369
293
|
wday = vari.getWorkday(date);
|
|
@@ -381,7 +305,6 @@ class Employee {
|
|
|
381
305
|
wday.hours = work;
|
|
382
306
|
return wday;
|
|
383
307
|
}
|
|
384
|
-
// lastly check leave list
|
|
385
308
|
this.leaves.forEach(lv => {
|
|
386
309
|
if (lv.useLeave(date)
|
|
387
310
|
&& (lv.hours > stdWorkday / 2 || lv.status.toLowerCase() === 'actual')) {
|
|
@@ -395,15 +318,6 @@ class Employee {
|
|
|
395
318
|
});
|
|
396
319
|
return wday;
|
|
397
320
|
}
|
|
398
|
-
/**
|
|
399
|
-
* This private function provides the employee's workday for a particular date, but
|
|
400
|
-
* only provides leaves if the labor codes provided is a primary code for the
|
|
401
|
-
* employee.
|
|
402
|
-
* @param date The date object to compare for the workday.
|
|
403
|
-
* @param labor The charge number and extension array for comparison against the
|
|
404
|
-
* employee's labor codes to determine if it is a primary code.
|
|
405
|
-
* @returns A workday object or undefined for the employee's workday on the date.
|
|
406
|
-
*/
|
|
407
321
|
getWorkdayActual(date, labor) {
|
|
408
322
|
let wday;
|
|
409
323
|
let siteid = '';
|
|
@@ -455,24 +369,17 @@ class Employee {
|
|
|
455
369
|
}
|
|
456
370
|
return wday;
|
|
457
371
|
}
|
|
458
|
-
/**
|
|
459
|
-
* This private function provides the employee's workday without leaves in consideration.
|
|
460
|
-
* @param date The date object used for comparison
|
|
461
|
-
* @returns A workday object or undefined for the employee's workday on the date.
|
|
462
|
-
*/
|
|
463
372
|
getWorkdayWOLeaves(date, useWork) {
|
|
464
373
|
let wday;
|
|
465
374
|
let stdWorkday = 8.0;
|
|
466
375
|
let work = 0.0;
|
|
467
376
|
let siteid = '';
|
|
468
377
|
let lastWorked = new Date(0);
|
|
469
|
-
// first get the standard workday hours;
|
|
470
378
|
this.assignments.forEach(asgmt => {
|
|
471
379
|
if (asgmt.useSiteAssignment(this.site, date)) {
|
|
472
380
|
stdWorkday = asgmt.getStandardWorkHours();
|
|
473
381
|
}
|
|
474
382
|
});
|
|
475
|
-
// check work records for work hours
|
|
476
383
|
if (this.work) {
|
|
477
384
|
this.work.forEach(wk => {
|
|
478
385
|
if (wk.useWork(date) && wk.modtime) {
|
|
@@ -483,14 +390,12 @@ class Employee {
|
|
|
483
390
|
}
|
|
484
391
|
});
|
|
485
392
|
}
|
|
486
|
-
// now get the normal workday based on assignment
|
|
487
393
|
this.assignments.forEach(asgmt => {
|
|
488
394
|
if (asgmt.useAssignment(date)) {
|
|
489
395
|
wday = asgmt.getWorkday(date);
|
|
490
396
|
siteid = asgmt.site;
|
|
491
397
|
}
|
|
492
398
|
});
|
|
493
|
-
// next, check for variation on date
|
|
494
399
|
this.variations.forEach(vari => {
|
|
495
400
|
if (vari.useVariation(date)) {
|
|
496
401
|
wday = vari.getWorkday(date);
|
|
@@ -513,12 +418,6 @@ class Employee {
|
|
|
513
418
|
}
|
|
514
419
|
return wday;
|
|
515
420
|
}
|
|
516
|
-
/**
|
|
517
|
-
* This function provides the employee's standard workday hours, which is based on a
|
|
518
|
-
* 40-hour work week divided by number of days worked in the work week.
|
|
519
|
-
* @param date The date object used to determine the assignment to use.
|
|
520
|
-
* @returns The float number value for the number of hours normal for each day's work.
|
|
521
|
-
*/
|
|
522
421
|
getStandardWorkday(date) {
|
|
523
422
|
let answer = 8.0;
|
|
524
423
|
this.assignments.forEach(asgmt => {
|
|
@@ -528,16 +427,6 @@ class Employee {
|
|
|
528
427
|
});
|
|
529
428
|
return answer;
|
|
530
429
|
}
|
|
531
|
-
/**
|
|
532
|
-
* This function will add a new work assignment to the employee's assignment list. It
|
|
533
|
-
* will assign the employee to a site and workcenter on a particular date. It is
|
|
534
|
-
* assumed that this is the last assignment in the list, the end date is set to
|
|
535
|
-
* 12/31/9999. It also sets the previous assignment to the end date of the start date
|
|
536
|
-
* value minus one day.
|
|
537
|
-
* @param site The string value for the site to assign the employee to.
|
|
538
|
-
* @param wkctr The string value for the workcenter to assign the employee to.
|
|
539
|
-
* @param start The date object used to mark the start of the assignment
|
|
540
|
-
*/
|
|
541
430
|
addAssignment(site, wkctr, start) {
|
|
542
431
|
let max = -1;
|
|
543
432
|
this.assignments.sort((a, b) => a.compareTo(b));
|
|
@@ -549,7 +438,6 @@ class Employee {
|
|
|
549
438
|
const lastAsgmt = this.assignments[this.assignments.length - 1];
|
|
550
439
|
lastAsgmt.endDate = new Date(start.getTime() - (24 * 3600000));
|
|
551
440
|
this.assignments[this.assignments.length - 1] = lastAsgmt;
|
|
552
|
-
// create new assignment
|
|
553
441
|
const newAsgmt = new assignment_1.Assignment({
|
|
554
442
|
id: max + 1,
|
|
555
443
|
site: site,
|
|
@@ -558,24 +446,12 @@ class Employee {
|
|
|
558
446
|
endDate: new Date(Date.UTC(9999, 11, 31)),
|
|
559
447
|
schedules: []
|
|
560
448
|
});
|
|
561
|
-
// add a new work schedule of seven days with the employee working days (M-F).
|
|
562
449
|
newAsgmt.addSchedule(7);
|
|
563
450
|
for (let d = 1; d < 6; d++) {
|
|
564
451
|
newAsgmt.changeWorkday(0, d, wkctr, 'D', 8.0);
|
|
565
452
|
}
|
|
566
453
|
this.assignments.push(newAsgmt);
|
|
567
454
|
}
|
|
568
|
-
/**
|
|
569
|
-
* This method will be used to update an assignment already in the employee's
|
|
570
|
-
* list. It can throw errors for assignment not found and for missing data
|
|
571
|
-
* expected for the field to be update.
|
|
572
|
-
* @param id A numeric value for the assignment to update
|
|
573
|
-
* @param field A string value for the field to update
|
|
574
|
-
* @param value A string value for the update to the required field
|
|
575
|
-
* @param schedule (Optional) A numeric value for the assignment schedule to be updated
|
|
576
|
-
* @param workday (Optional) A numeric value for the assignment schedule workday to
|
|
577
|
-
* be updated.
|
|
578
|
-
*/
|
|
579
455
|
updateAssignment(id, field, value, schedule, workday) {
|
|
580
456
|
let found = false;
|
|
581
457
|
this.assignments.sort((a, b) => a.compareTo(b));
|
|
@@ -650,10 +526,6 @@ class Employee {
|
|
|
650
526
|
throw new Error('Assignment not found');
|
|
651
527
|
}
|
|
652
528
|
}
|
|
653
|
-
/**
|
|
654
|
-
* The function will remove a particular assignment from the assignment list
|
|
655
|
-
* @param id The numeric identifier for the assignment to remove.
|
|
656
|
-
*/
|
|
657
529
|
removeAssignment(id) {
|
|
658
530
|
this.assignments.sort((a, b) => a.compareTo(b));
|
|
659
531
|
let pos = -1;
|
|
@@ -681,15 +553,7 @@ class Employee {
|
|
|
681
553
|
this.assignments.splice(pos, 1);
|
|
682
554
|
}
|
|
683
555
|
}
|
|
684
|
-
/**
|
|
685
|
-
* This method is used to add a new variation to the employee. It will determine the
|
|
686
|
-
* new variation's identifier and add that along with site and start date to the new
|
|
687
|
-
* variation. The variation's enddate will match the start date at this time.
|
|
688
|
-
* @param site A string value for the site identifier.
|
|
689
|
-
* @param start A data value for the start of this variation.
|
|
690
|
-
*/
|
|
691
556
|
addVariation(site, start) {
|
|
692
|
-
// start by getting and determing the next variation id number.
|
|
693
557
|
let newID = -1;
|
|
694
558
|
this.variations.forEach(vari => {
|
|
695
559
|
if (vari.id > newID) {
|
|
@@ -705,16 +569,6 @@ class Employee {
|
|
|
705
569
|
this.variations.push(newVari);
|
|
706
570
|
this.variations.sort((a, b) => a.compareTo(b));
|
|
707
571
|
}
|
|
708
|
-
/**
|
|
709
|
-
* This method will update the selected variation with an update a single
|
|
710
|
-
* field in the selected variation. If the variation isn't found, an error
|
|
711
|
-
* will be transmitted to the requestor.
|
|
712
|
-
* @param varID A numeric value for the variation to change.
|
|
713
|
-
* @param field A string value for the data member to change.
|
|
714
|
-
* @param value A string value representing the data member's new value.
|
|
715
|
-
* @param workday (Optional) a numeric value for the workday to update if the update
|
|
716
|
-
* field is in a variation workday.
|
|
717
|
-
*/
|
|
718
572
|
updateVariation(varID, field, value, workday) {
|
|
719
573
|
this.variations.sort((a, b) => a.compareTo(b));
|
|
720
574
|
let found = false;
|
|
@@ -760,12 +614,6 @@ class Employee {
|
|
|
760
614
|
throw new Error('Variation not found');
|
|
761
615
|
}
|
|
762
616
|
}
|
|
763
|
-
/**
|
|
764
|
-
* This method will be used to convert a date string in the format of 2006-01-02 to
|
|
765
|
-
* a Date object with that date.
|
|
766
|
-
* @param date A string value in the correct format
|
|
767
|
-
* @returns
|
|
768
|
-
*/
|
|
769
617
|
getDateFromString(date) {
|
|
770
618
|
const reDateFormat = new RegExp('^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$');
|
|
771
619
|
if (reDateFormat.test(date)) {
|
|
@@ -780,11 +628,6 @@ class Employee {
|
|
|
780
628
|
throw new Error('Date not in correct format (yyyy-mm-dd)');
|
|
781
629
|
}
|
|
782
630
|
}
|
|
783
|
-
/**
|
|
784
|
-
* This method will be used to remove a single variation from the employee's variation
|
|
785
|
-
* list. An error will be thrown if the variation is not found.
|
|
786
|
-
* @param varID A numeric value for the identifier of the variation to delete.
|
|
787
|
-
*/
|
|
788
631
|
removeVariation(varID) {
|
|
789
632
|
let found = -1;
|
|
790
633
|
this.variations.forEach((vari, v) => {
|
|
@@ -799,15 +642,6 @@ class Employee {
|
|
|
799
642
|
throw new Error('Variation not found');
|
|
800
643
|
}
|
|
801
644
|
}
|
|
802
|
-
/**
|
|
803
|
-
* This function will determine if a labor code (charge number and extension) is the
|
|
804
|
-
* employee's primary code for the date given.
|
|
805
|
-
* @param date The date object used for comparison.
|
|
806
|
-
* @param labor The labor code object to provide the charge number/extension for
|
|
807
|
-
* comparison.
|
|
808
|
-
* @returns A boolean value for whether or not the labor code is a primary one used
|
|
809
|
-
* by the employee.
|
|
810
|
-
*/
|
|
811
645
|
isPrimaryCode(date, labor) {
|
|
812
646
|
let answer = false;
|
|
813
647
|
this.assignments.forEach(asgmt => {
|
|
@@ -822,12 +656,6 @@ class Employee {
|
|
|
822
656
|
});
|
|
823
657
|
return answer;
|
|
824
658
|
}
|
|
825
|
-
/**
|
|
826
|
-
* This function will find out if the employee is assigned a particular labor code
|
|
827
|
-
* @param chargeNumber The string value for the charge number to check for
|
|
828
|
-
* @param extension The string value for the extension to check for.
|
|
829
|
-
* @returns The boolean value for assignment of the charge number/extension.
|
|
830
|
-
*/
|
|
831
659
|
hasLaborCode(chargeNumber, extension) {
|
|
832
660
|
let found = false;
|
|
833
661
|
this.assignments.forEach(asgmt => {
|
|
@@ -840,14 +668,6 @@ class Employee {
|
|
|
840
668
|
});
|
|
841
669
|
return found;
|
|
842
670
|
}
|
|
843
|
-
/**
|
|
844
|
-
* This function will check if the employee is assigned a particular charge number/
|
|
845
|
-
* extension on a particular date.
|
|
846
|
-
* @param date The date object used for the date to check.
|
|
847
|
-
* @param chgNo The string value for the charge number to check for
|
|
848
|
-
* @param extension The string value for the extension to check for.
|
|
849
|
-
* @returns The boolean value for assignment of the charge number/extension.
|
|
850
|
-
*/
|
|
851
671
|
hasLaborCodeOnDate(date, chgNo, ext) {
|
|
852
672
|
let found = false;
|
|
853
673
|
this.assignments.forEach(asgmt => {
|
|
@@ -862,14 +682,6 @@ class Employee {
|
|
|
862
682
|
});
|
|
863
683
|
return found;
|
|
864
684
|
}
|
|
865
|
-
/**
|
|
866
|
-
* This function is used to determine a workcenter and shift code for work during a
|
|
867
|
-
* period of time.
|
|
868
|
-
* @param start The date object for the start of the period.
|
|
869
|
-
* @param end The date object for the end of the period.
|
|
870
|
-
* @returns A workday object containing the workcenter and shift code to use for the
|
|
871
|
-
* period.
|
|
872
|
-
*/
|
|
873
685
|
getAssignmentForPeriod(start, end) {
|
|
874
686
|
const assigned = new Map();
|
|
875
687
|
start = new Date(Date.UTC(start.getFullYear(), start.getMonth(), start.getDate()));
|
|
@@ -914,21 +726,10 @@ class Employee {
|
|
|
914
726
|
hours: 0.0
|
|
915
727
|
});
|
|
916
728
|
}
|
|
917
|
-
/**
|
|
918
|
-
* This function will retrieve and provide the number of forecasted hours from this
|
|
919
|
-
* employee for a time period and labor code.
|
|
920
|
-
* @param labor The company labor code object for the labor codes to check against
|
|
921
|
-
* @param start The date object for the start of the period
|
|
922
|
-
* @param end The date object for the end of the period
|
|
923
|
-
* @param codes A list of compare code objects used for verifying correct codes and
|
|
924
|
-
* whether or not they are leave codes.
|
|
925
|
-
* @returns A numeric (float) value for the number of hours the employee is forecast.
|
|
926
|
-
*/
|
|
927
729
|
getForecastHours(labor, start, end, codes) {
|
|
928
730
|
let answer = 0.0;
|
|
929
731
|
start = new Date(Date.UTC(start.getFullYear(), start.getMonth(), start.getDate()));
|
|
930
732
|
end = new Date(Date.UTC(end.getFullYear(), end.getMonth(), end.getDate()));
|
|
931
|
-
// Check for assignment during period
|
|
932
733
|
let found = false;
|
|
933
734
|
this.assignments.forEach(asgmt => {
|
|
934
735
|
if (asgmt.useAssignment(start, end, labor)) {
|
|
@@ -938,32 +739,22 @@ class Employee {
|
|
|
938
739
|
if (!found) {
|
|
939
740
|
return 0.0;
|
|
940
741
|
}
|
|
941
|
-
// check if labor code is applicable during period
|
|
942
742
|
if (!labor.startDate || !labor.endDate
|
|
943
743
|
|| labor.endDate.getTime() < start.getTime()
|
|
944
744
|
|| labor.startDate.getTime() > end.getTime()) {
|
|
945
745
|
return 0.0;
|
|
946
746
|
}
|
|
947
|
-
// determine last worked day from work records
|
|
948
747
|
let lastWorked = new Date(0);
|
|
949
748
|
if (this.work && this.work.length > 0) {
|
|
950
749
|
this.work.sort((a, b) => a.compareTo(b));
|
|
951
750
|
lastWorked = new Date(this.work[this.work.length - 1].dateworked);
|
|
952
751
|
}
|
|
953
|
-
// check leaves for a date greater than lastworked
|
|
954
752
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
955
753
|
this.leaves.forEach(lv => {
|
|
956
754
|
if (lv.status.toLowerCase() === 'actual' && lv.leavedate.getTime() > lastWorked.getTime()) {
|
|
957
755
|
lastWorked = new Date(lv.leavedate);
|
|
958
756
|
}
|
|
959
757
|
});
|
|
960
|
-
// now step through the days of the period to:
|
|
961
|
-
// 1) see if they had worked any charge numbers during
|
|
962
|
-
// the period, if working add 0 hours
|
|
963
|
-
// 2) see if they were supposed to be working on this
|
|
964
|
-
// date, compare workday code to workcodes to ensure
|
|
965
|
-
// they weren't on leave. If not on leave, add
|
|
966
|
-
// assigned hours.
|
|
967
758
|
let current = new Date(start);
|
|
968
759
|
while (current.getTime() <= end.getTime()) {
|
|
969
760
|
if (current.getTime() > lastWorked.getTime()) {
|
|
@@ -991,18 +782,6 @@ class Employee {
|
|
|
991
782
|
}
|
|
992
783
|
return answer;
|
|
993
784
|
}
|
|
994
|
-
/**************************************************************************************
|
|
995
|
-
* Work Records section
|
|
996
|
-
**************************************************************************************/
|
|
997
|
-
/**
|
|
998
|
-
* This function will provide the total number of hours of actual work for the period
|
|
999
|
-
* given
|
|
1000
|
-
* @param start The date object for the start of the period
|
|
1001
|
-
* @param end The date object for the end of the period
|
|
1002
|
-
* @param chgno (Optional) The string value for the charge number
|
|
1003
|
-
* @param ext (Optional) The string value for the charge number extension
|
|
1004
|
-
* @returns The numeric value for the total hours of actual work
|
|
1005
|
-
*/
|
|
1006
785
|
getWorkedHours(start, end, chgno, ext) {
|
|
1007
786
|
start = new Date(Date.UTC(start.getFullYear(), start.getMonth(), start.getDate()));
|
|
1008
787
|
end = new Date(Date.UTC(end.getFullYear(), end.getMonth(), end.getDate()));
|
|
@@ -1026,10 +805,6 @@ class Employee {
|
|
|
1026
805
|
}
|
|
1027
806
|
return answer;
|
|
1028
807
|
}
|
|
1029
|
-
/**
|
|
1030
|
-
* This function will provide the date for the last work record in the object
|
|
1031
|
-
* @returns A date object for the last worked day.
|
|
1032
|
-
*/
|
|
1033
808
|
getLastWorkday() {
|
|
1034
809
|
let answer = new Date(0);
|
|
1035
810
|
if (this.work && this.work.length > 0) {
|
|
@@ -1039,12 +814,6 @@ class Employee {
|
|
|
1039
814
|
}
|
|
1040
815
|
return answer;
|
|
1041
816
|
}
|
|
1042
|
-
/**
|
|
1043
|
-
* This function will provide the number of modified time hours for a period of time.
|
|
1044
|
-
* @param start The date object for the start of the period.
|
|
1045
|
-
* @param end The date object for the end of the period.
|
|
1046
|
-
* @returns The numeric (float) value for the number of hours of modified time.
|
|
1047
|
-
*/
|
|
1048
817
|
getModTime(start, end) {
|
|
1049
818
|
let answer = 0.0;
|
|
1050
819
|
this.work?.forEach(wk => {
|
|
@@ -1067,15 +836,6 @@ class Employee {
|
|
|
1067
836
|
});
|
|
1068
837
|
return answer;
|
|
1069
838
|
}
|
|
1070
|
-
/**************************************************************************************
|
|
1071
|
-
* Leave Balance Section - it provides the employee's starting leave balance and the
|
|
1072
|
-
* number of hours provided for the year.
|
|
1073
|
-
**************************************************************************************/
|
|
1074
|
-
/**
|
|
1075
|
-
* This function will add a new leave balance object to the leave balance list. It will
|
|
1076
|
-
* only add a new leave balance object if the object for the year doesn't already exist.
|
|
1077
|
-
* @param year The numeric (int) value for the year the balances are for.
|
|
1078
|
-
*/
|
|
1079
839
|
createLeaveBalance(year) {
|
|
1080
840
|
let found = false;
|
|
1081
841
|
let lastAnnual = 0.0;
|
|
@@ -1115,13 +875,6 @@ class Employee {
|
|
|
1115
875
|
throw new Error('Leave Balance year already exists');
|
|
1116
876
|
}
|
|
1117
877
|
}
|
|
1118
|
-
/**
|
|
1119
|
-
* This function is used to update a leave balance object with a new annual year and
|
|
1120
|
-
* carry over amount.
|
|
1121
|
-
* @param year The numeric value for the year used as a key value
|
|
1122
|
-
* @param field The string value for the field to update
|
|
1123
|
-
* @param carry The numeric value for the number of hours for that field.
|
|
1124
|
-
*/
|
|
1125
878
|
updateLeaveBalance(year, field, value) {
|
|
1126
879
|
let found = false;
|
|
1127
880
|
for (let lb = 0; lb < this.balances.length && !found; lb++) {
|
|
@@ -1143,10 +896,6 @@ class Employee {
|
|
|
1143
896
|
}
|
|
1144
897
|
this.balances.sort((a, b) => a.compareTo(b));
|
|
1145
898
|
}
|
|
1146
|
-
/**
|
|
1147
|
-
* This function will remove a leave balance from the employee's leave balance list.
|
|
1148
|
-
* @param year The numeric value for the year of the leave balance (primary key).
|
|
1149
|
-
*/
|
|
1150
899
|
deleteLeaveBalance(year) {
|
|
1151
900
|
let found = -1;
|
|
1152
901
|
this.balances.forEach((bal, i) => {
|
|
@@ -1161,23 +910,6 @@ class Employee {
|
|
|
1161
910
|
throw new Error('Leave Balance year not found');
|
|
1162
911
|
}
|
|
1163
912
|
}
|
|
1164
|
-
/**
|
|
1165
|
-
* This is the employee leave section.
|
|
1166
|
-
*/
|
|
1167
|
-
/**
|
|
1168
|
-
* This function will add a new leave day to the employee's leave list. It first checks
|
|
1169
|
-
* for a leave on the date and code given and will modify leave's other data. If not
|
|
1170
|
-
* found in the list, it will add the leave to the list, then sort the leaves.
|
|
1171
|
-
* @param id The numeric value for the leave, normally zero for new leave
|
|
1172
|
-
* @param date The date object to give the date the leave
|
|
1173
|
-
* @param code The string value representing the work/leave code for this leave
|
|
1174
|
-
* @param status The string value for the status of this leave.
|
|
1175
|
-
* @param hours The numeric value for the number of hours (float)
|
|
1176
|
-
* @param requestid The string value for the associated request reference, may be an
|
|
1177
|
-
* empty string.
|
|
1178
|
-
* @param holCode (Optional) A reference string for the holiday the leave is associated
|
|
1179
|
-
* with.
|
|
1180
|
-
*/
|
|
1181
913
|
addLeave(id, date, code, status, hours, requestid, holCode) {
|
|
1182
914
|
let found = false;
|
|
1183
915
|
let max = 0;
|
|
@@ -1215,13 +947,6 @@ class Employee {
|
|
|
1215
947
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
1216
948
|
}
|
|
1217
949
|
}
|
|
1218
|
-
/**
|
|
1219
|
-
* This function will update a single field within the leave, based on leave's identifier.
|
|
1220
|
-
* @param id The numeric value for the leave.
|
|
1221
|
-
* @param field The string value for the associated data member to update
|
|
1222
|
-
* @param value The string value for the updated value.
|
|
1223
|
-
* @returns The updated leave object.
|
|
1224
|
-
*/
|
|
1225
950
|
updateLeave(id, field, value) {
|
|
1226
951
|
let answer = undefined;
|
|
1227
952
|
this.leaves.forEach((lv, l) => {
|
|
@@ -1254,11 +979,6 @@ class Employee {
|
|
|
1254
979
|
});
|
|
1255
980
|
return answer;
|
|
1256
981
|
}
|
|
1257
|
-
/**
|
|
1258
|
-
* This function will remove a leave day from the employee's leave list, base on
|
|
1259
|
-
* numeric identifier.
|
|
1260
|
-
* @param id numeric value for the identifier.
|
|
1261
|
-
*/
|
|
1262
982
|
deleteLeave(id) {
|
|
1263
983
|
let found = -1;
|
|
1264
984
|
this.leaves.forEach((lv, l) => {
|
|
@@ -1270,13 +990,6 @@ class Employee {
|
|
|
1270
990
|
this.leaves.splice(found, 1);
|
|
1271
991
|
}
|
|
1272
992
|
}
|
|
1273
|
-
/**
|
|
1274
|
-
* This function will provide a total number of leave hours for a particular period of
|
|
1275
|
-
* time (Actual Leave Only)
|
|
1276
|
-
* @param start The date object for the start of the time period
|
|
1277
|
-
* @param end The date object for the end of the time period
|
|
1278
|
-
* @returns numeric (float) value for the total leave hours for the period
|
|
1279
|
-
*/
|
|
1280
993
|
getLeaveHours(start, end) {
|
|
1281
994
|
let answer = 0.0;
|
|
1282
995
|
this.leaves.forEach(lv => {
|
|
@@ -1288,12 +1001,6 @@ class Employee {
|
|
|
1288
1001
|
});
|
|
1289
1002
|
return answer;
|
|
1290
1003
|
}
|
|
1291
|
-
/**
|
|
1292
|
-
* This function will provide a leave workday with the number of total hours of leave
|
|
1293
|
-
* time.
|
|
1294
|
-
* @param start The date object for the date to check against
|
|
1295
|
-
* @returns A workday object with the leave and hours for the date.
|
|
1296
|
-
*/
|
|
1297
1004
|
getLeave(start) {
|
|
1298
1005
|
const workday = new workday_1.Workday();
|
|
1299
1006
|
this.leaves.forEach(lv => {
|
|
@@ -1314,13 +1021,6 @@ class Employee {
|
|
|
1314
1021
|
});
|
|
1315
1022
|
return workday;
|
|
1316
1023
|
}
|
|
1317
|
-
/**
|
|
1318
|
-
* This function will provide a total number of vacation/PTO leave hours for a
|
|
1319
|
-
* particular period of time (Actual Leave Only)
|
|
1320
|
-
* @param start The date object for the start of the time period
|
|
1321
|
-
* @param end The date object for the end of the time period
|
|
1322
|
-
* @returns numeric (float) value for the total leave hours for the period
|
|
1323
|
-
*/
|
|
1324
1024
|
getPTOHours(start, end) {
|
|
1325
1025
|
let answer = 0.0;
|
|
1326
1026
|
this.leaves.forEach(lv => {
|
|
@@ -1333,22 +1033,9 @@ class Employee {
|
|
|
1333
1033
|
});
|
|
1334
1034
|
return answer;
|
|
1335
1035
|
}
|
|
1336
|
-
/**
|
|
1337
|
-
* This will be the Leave Request section
|
|
1338
|
-
*/
|
|
1339
|
-
/**
|
|
1340
|
-
* This function will create a new leave request for the employee
|
|
1341
|
-
* @param start The date object for the start of the leave request period
|
|
1342
|
-
* @param end The date object for the end of the leave request period
|
|
1343
|
-
* @param code the string value for the code to the primary leave type to use
|
|
1344
|
-
* @param comment The string vlue for any comment to use
|
|
1345
|
-
* @returns The new leave request object or undefined if not created.
|
|
1346
|
-
*/
|
|
1347
1036
|
createLeaveRequest(start, end, code, comment) {
|
|
1348
1037
|
start = new Date(Date.UTC(start.getFullYear(), start.getMonth(), start.getDate()));
|
|
1349
1038
|
end = new Date(Date.UTC(end.getFullYear(), end.getMonth(), end.getDate()));
|
|
1350
|
-
// first check to see if the period is covered by a current leave request and return
|
|
1351
|
-
// this object. if The comment is not empty, add it to the request.
|
|
1352
1039
|
let answer = undefined;
|
|
1353
1040
|
this.requests.forEach((req, r) => {
|
|
1354
1041
|
if (req.startdate.getTime() === start.getTime()
|
|
@@ -1364,7 +1051,6 @@ class Employee {
|
|
|
1364
1051
|
answer = new leaverequest_1.LeaveRequest(req);
|
|
1365
1052
|
}
|
|
1366
1053
|
});
|
|
1367
|
-
// if not found, create a new leave request
|
|
1368
1054
|
if (!answer) {
|
|
1369
1055
|
const id = new mongodb_1.ObjectId().toString();
|
|
1370
1056
|
answer = new leaverequest_1.LeaveRequest({
|
|
@@ -1395,15 +1081,6 @@ class Employee {
|
|
|
1395
1081
|
}
|
|
1396
1082
|
return answer;
|
|
1397
1083
|
}
|
|
1398
|
-
/**
|
|
1399
|
-
* This function is used to update a leave request of the employee, by identifier,
|
|
1400
|
-
* field to update and the value to update to.
|
|
1401
|
-
* @param id The string value representing the identifier
|
|
1402
|
-
* @param field The string value for the field to update.
|
|
1403
|
-
* @param value The string value to use in the update.
|
|
1404
|
-
* @returns An interface of the consisting of a email message, leave request, and an
|
|
1405
|
-
* error message.
|
|
1406
|
-
*/
|
|
1407
1084
|
updateLeaveRequest(id, field, value) {
|
|
1408
1085
|
const answer = {
|
|
1409
1086
|
message: '',
|
|
@@ -1415,17 +1092,11 @@ class Employee {
|
|
|
1415
1092
|
switch (field.toLowerCase()) {
|
|
1416
1093
|
case "startdate":
|
|
1417
1094
|
case "start":
|
|
1418
|
-
// parse the value to make a date object, then make sure the date is a UTC
|
|
1419
|
-
// value
|
|
1420
1095
|
let date = new Date(Date.parse(value));
|
|
1421
1096
|
date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
1422
|
-
// check to see if the dates are outside the original start and end dates,
|
|
1423
|
-
// which invalidates the leave request and places back in the draft status
|
|
1424
|
-
// and removes any current approved leaves to be removed.
|
|
1425
1097
|
if (date.getTime() < req.startdate.getTime()
|
|
1426
1098
|
|| date.getTime() > req.enddate.getTime()) {
|
|
1427
1099
|
if (req.status.toLowerCase() === 'approved') {
|
|
1428
|
-
// remove the approved leaves from the leaves list.
|
|
1429
1100
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
1430
1101
|
let count = 0;
|
|
1431
1102
|
let startpos = -1;
|
|
@@ -1450,8 +1121,6 @@ class Employee {
|
|
|
1450
1121
|
}
|
|
1451
1122
|
else {
|
|
1452
1123
|
if (req.status.toLowerCase() === 'approved') {
|
|
1453
|
-
// remove approved leaves from before the new date that have the
|
|
1454
|
-
// request identifier
|
|
1455
1124
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
1456
1125
|
let count = 0;
|
|
1457
1126
|
let startpos = -1;
|
|
@@ -1482,17 +1151,11 @@ class Employee {
|
|
|
1482
1151
|
break;
|
|
1483
1152
|
case "enddate":
|
|
1484
1153
|
case "end":
|
|
1485
|
-
// parse the value to make a date object, then make sure the date is a UTC
|
|
1486
|
-
// value
|
|
1487
1154
|
date = new Date(Date.parse(value));
|
|
1488
1155
|
date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
1489
|
-
// check to see if the dates are outside the original start and end dates,
|
|
1490
|
-
// which invalidates the leave request and places back in the draft status
|
|
1491
|
-
// and removes any current approved leaves to be removed.
|
|
1492
1156
|
if (date.getTime() < req.startdate.getTime()
|
|
1493
1157
|
|| date.getTime() > req.enddate.getTime()) {
|
|
1494
1158
|
if (req.status.toLowerCase() === 'approved') {
|
|
1495
|
-
// remove the approved leaves from the leaves list.
|
|
1496
1159
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
1497
1160
|
let count = 0;
|
|
1498
1161
|
let startpos = -1;
|
|
@@ -1517,8 +1180,6 @@ class Employee {
|
|
|
1517
1180
|
}
|
|
1518
1181
|
else {
|
|
1519
1182
|
if (req.status.toLowerCase() === 'approved') {
|
|
1520
|
-
// remove approved leaves from before the new date that have the
|
|
1521
|
-
// request identifier
|
|
1522
1183
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
1523
1184
|
let count = 0;
|
|
1524
1185
|
let startpos = -1;
|
|
@@ -1549,21 +1210,15 @@ class Employee {
|
|
|
1549
1210
|
break;
|
|
1550
1211
|
case 'dates':
|
|
1551
1212
|
const values = value.split('|');
|
|
1552
|
-
// parse the value to make a date object, then make sure the date is a UTC
|
|
1553
|
-
// value
|
|
1554
1213
|
let newstart = new Date(Date.parse(values[0]));
|
|
1555
1214
|
newstart = new Date(Date.UTC(newstart.getFullYear(), newstart.getMonth(), newstart.getDate()));
|
|
1556
1215
|
let newend = new Date(Date.parse(values[1]));
|
|
1557
1216
|
newend = new Date(Date.UTC(newend.getFullYear(), newend.getMonth(), newend.getDate()));
|
|
1558
|
-
// check to see if the dates are outside the original start and end dates,
|
|
1559
|
-
// which invalidates the leave request and places back in the draft status
|
|
1560
|
-
// and removes any current approved leaves to be removed.
|
|
1561
1217
|
if (newstart.getTime() < req.startdate.getTime()
|
|
1562
1218
|
|| newstart.getTime() > req.enddate.getTime()
|
|
1563
1219
|
|| newend.getTime() < req.startdate.getTime()
|
|
1564
1220
|
|| newend.getTime() > req.enddate.getTime()) {
|
|
1565
1221
|
if (req.status.toLowerCase() === 'approved') {
|
|
1566
|
-
// remove the approved leaves from the leaves list.
|
|
1567
1222
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
1568
1223
|
let count = 0;
|
|
1569
1224
|
let startpos = -1;
|
|
@@ -1588,8 +1243,6 @@ class Employee {
|
|
|
1588
1243
|
}
|
|
1589
1244
|
else {
|
|
1590
1245
|
if (req.status.toLowerCase() === 'approved') {
|
|
1591
|
-
// remove approved leaves from before the new date that have the
|
|
1592
|
-
// request identifier
|
|
1593
1246
|
this.leaves.sort((a, b) => a.compareTo(b));
|
|
1594
1247
|
let startcount = 0;
|
|
1595
1248
|
let startpos = -1;
|
|
@@ -1771,17 +1424,6 @@ class Employee {
|
|
|
1771
1424
|
});
|
|
1772
1425
|
return answer;
|
|
1773
1426
|
}
|
|
1774
|
-
/**
|
|
1775
|
-
* This function is used to approve a requested leave request. When approved it updates
|
|
1776
|
-
* the leave list of the employee, plus if the request is a mod time request, it creates
|
|
1777
|
-
* the variation for the mod time.
|
|
1778
|
-
* @param id The string value for the identifier for the leave request.
|
|
1779
|
-
* @param approver The string value for the identifier for the employee who approved
|
|
1780
|
-
* this request.
|
|
1781
|
-
* @param leavecodes A list of workcode associated with types of leaves.
|
|
1782
|
-
* @returns A change leave request response containing any message to email and this
|
|
1783
|
-
* leave request.
|
|
1784
|
-
*/
|
|
1785
1427
|
approveLeaveRequest(id, approver, leavecodes) {
|
|
1786
1428
|
const answer = {
|
|
1787
1429
|
message: '',
|
|
@@ -1822,8 +1464,6 @@ class Employee {
|
|
|
1822
1464
|
answer.leaverequest = req;
|
|
1823
1465
|
}
|
|
1824
1466
|
else {
|
|
1825
|
-
// a mod time request will create a variation rather than leave objects
|
|
1826
|
-
// check if there is a variation for this period first and modify it
|
|
1827
1467
|
let found = false;
|
|
1828
1468
|
this.variations.forEach((vari, v) => {
|
|
1829
1469
|
if (vari.startdate.getTime() === req.startdate.getTime()
|
|
@@ -1869,7 +1509,6 @@ class Employee {
|
|
|
1869
1509
|
});
|
|
1870
1510
|
}
|
|
1871
1511
|
});
|
|
1872
|
-
// if no variation, add a new one.
|
|
1873
1512
|
if (!found) {
|
|
1874
1513
|
let max = 0;
|
|
1875
1514
|
this.variations.forEach(vari => {
|
|
@@ -1897,11 +1536,6 @@ class Employee {
|
|
|
1897
1536
|
});
|
|
1898
1537
|
return answer;
|
|
1899
1538
|
}
|
|
1900
|
-
/**
|
|
1901
|
-
* This function will remove a leave request from the employee's list, plus if the
|
|
1902
|
-
* request has an approved status, it will remove any associated leaves and variations.
|
|
1903
|
-
* @param id The string value for the identifier for the leave request.
|
|
1904
|
-
*/
|
|
1905
1539
|
deleteLeaveRequest(id) {
|
|
1906
1540
|
let req = this.requests.find(r => r.id === id);
|
|
1907
1541
|
if (req) {
|
|
@@ -1925,18 +1559,6 @@ class Employee {
|
|
|
1925
1559
|
}
|
|
1926
1560
|
}
|
|
1927
1561
|
}
|
|
1928
|
-
/***************************************************************************************
|
|
1929
|
-
* Employee's contact information section
|
|
1930
|
-
**************************************************************************************/
|
|
1931
|
-
/**
|
|
1932
|
-
* This function will either add a new contact information or update one with the
|
|
1933
|
-
* provided type id.
|
|
1934
|
-
* @param typeid The numeric value for the type of contact information corresponding
|
|
1935
|
-
* to the team's contact information types.
|
|
1936
|
-
* @param value The string value for the contact information value
|
|
1937
|
-
* @param sortid The numeric value for the sort order for this object, gotten from the
|
|
1938
|
-
* team's contact information types.
|
|
1939
|
-
*/
|
|
1940
1562
|
addContactInfo(typeid, value, sortid) {
|
|
1941
1563
|
let found = false;
|
|
1942
1564
|
let next = -1;
|
|
@@ -1960,11 +1582,6 @@ class Employee {
|
|
|
1960
1582
|
this.contactinfo.sort((a, b) => a.compareTo(b));
|
|
1961
1583
|
}
|
|
1962
1584
|
}
|
|
1963
|
-
/**
|
|
1964
|
-
* This function will re-sort the employee's contact information based on the team's
|
|
1965
|
-
* contact information types' sort order.
|
|
1966
|
-
* @param teamcontacts A map of the team's contact information types sort order.
|
|
1967
|
-
*/
|
|
1968
1585
|
resortContactInfo(teamcontacts) {
|
|
1969
1586
|
this.contactinfo.forEach((ci, c) => {
|
|
1970
1587
|
const tc = teamcontacts.get(ci.typeid);
|
|
@@ -1973,10 +1590,6 @@ class Employee {
|
|
|
1973
1590
|
});
|
|
1974
1591
|
this.contactinfo.sort((a, b) => a.compareTo(b));
|
|
1975
1592
|
}
|
|
1976
|
-
/**
|
|
1977
|
-
* This function will remove an employee's contact information by type id.
|
|
1978
|
-
* @param type The numeric value for the type of contact information to remove.
|
|
1979
|
-
*/
|
|
1980
1593
|
deleteContactInfoByType(type) {
|
|
1981
1594
|
let found = -1;
|
|
1982
1595
|
this.contactinfo.forEach((ci, c) => {
|
|
@@ -1988,10 +1601,6 @@ class Employee {
|
|
|
1988
1601
|
this.contactinfo.splice(found, 1);
|
|
1989
1602
|
}
|
|
1990
1603
|
}
|
|
1991
|
-
/**
|
|
1992
|
-
* This function will remove an employee's contact information by identifier.
|
|
1993
|
-
* @param id The numeric value for the identifier for the contact info.
|
|
1994
|
-
*/
|
|
1995
1604
|
deleteContactInfo(id) {
|
|
1996
1605
|
let found = -1;
|
|
1997
1606
|
this.contactinfo.forEach((ci, c) => {
|
|
@@ -2003,14 +1612,6 @@ class Employee {
|
|
|
2003
1612
|
this.contactinfo.splice(found, 1);
|
|
2004
1613
|
}
|
|
2005
1614
|
}
|
|
2006
|
-
/**
|
|
2007
|
-
* This function is used to update for add a specialty to the employee's list.
|
|
2008
|
-
* @param specid numeric value for the specialty identifier from the team's specialty
|
|
2009
|
-
* list.
|
|
2010
|
-
* @param qualified boolean value to signify if the employee is qualified in it
|
|
2011
|
-
* @param sort numeric value for the sort position, copied from the team's specialty
|
|
2012
|
-
* list.
|
|
2013
|
-
*/
|
|
2014
1615
|
addSpecialty(specid, qualified, sort) {
|
|
2015
1616
|
let found = false;
|
|
2016
1617
|
let next = -1;
|
|
@@ -2034,11 +1635,6 @@ class Employee {
|
|
|
2034
1635
|
this.specialties.sort((a, b) => a.compareTo(b));
|
|
2035
1636
|
}
|
|
2036
1637
|
}
|
|
2037
|
-
/**
|
|
2038
|
-
* This function will reassign the employee's specialties with the sort values for the
|
|
2039
|
-
* team specialties, then re-sort them.
|
|
2040
|
-
* @param teamspecs The Map of the team specialties sort number by specialty id.
|
|
2041
|
-
*/
|
|
2042
1638
|
resortSpecialties(teamspecs) {
|
|
2043
1639
|
this.specialties.forEach((spc, s) => {
|
|
2044
1640
|
const ts = teamspecs.get(spc.specialtyid);
|
|
@@ -2047,10 +1643,6 @@ class Employee {
|
|
|
2047
1643
|
});
|
|
2048
1644
|
this.specialties.sort((a, b) => a.compareTo(b));
|
|
2049
1645
|
}
|
|
2050
|
-
/**
|
|
2051
|
-
* This function will remove an employee's specialty by identifier.
|
|
2052
|
-
* @param id The numeric value for the employee's specialty identifier.
|
|
2053
|
-
*/
|
|
2054
1646
|
deleteSpecialty(id) {
|
|
2055
1647
|
let found = -1;
|
|
2056
1648
|
this.specialties.forEach((spc, s) => {
|
|
@@ -2063,10 +1655,6 @@ class Employee {
|
|
|
2063
1655
|
}
|
|
2064
1656
|
this.specialties.sort((a, b) => a.compareTo(b));
|
|
2065
1657
|
}
|
|
2066
|
-
/**
|
|
2067
|
-
* This function will remove an employee's specialty by specialty type
|
|
2068
|
-
* @param type The numeric value associated with the team's specialty identifer.
|
|
2069
|
-
*/
|
|
2070
1658
|
deleteSpecialtyByType(type) {
|
|
2071
1659
|
let found = -1;
|
|
2072
1660
|
this.specialties.forEach((spc, s) => {
|
|
@@ -2079,12 +1667,6 @@ class Employee {
|
|
|
2079
1667
|
}
|
|
2080
1668
|
this.specialties.sort((a, b) => a.compareTo(b));
|
|
2081
1669
|
}
|
|
2082
|
-
/**
|
|
2083
|
-
* This function will provide a boolean answer as to whether the employee is qualified
|
|
2084
|
-
* in a particular specialty skill.
|
|
2085
|
-
* @param spec The numeric value for the specialty to search for.
|
|
2086
|
-
* @returns boolean value for the employee's qualified to this skill.
|
|
2087
|
-
*/
|
|
2088
1670
|
hasSpecialty(spec) {
|
|
2089
1671
|
let answer = false;
|
|
2090
1672
|
this.specialties.forEach(spc => {
|
|
@@ -2096,3 +1678,4 @@ class Employee {
|
|
|
2096
1678
|
}
|
|
2097
1679
|
}
|
|
2098
1680
|
exports.Employee = Employee;
|
|
1681
|
+
//# sourceMappingURL=employee.js.map
|