scheduler-node-models 1.1.37 → 1.1.44

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.
Files changed (151) hide show
  1. package/package.json +6 -6
  2. package/general/emailer.d.ts +0 -1
  3. package/general/emailer.js +0 -31
  4. package/general/general.d.ts +0 -12
  5. package/general/general.js +0 -2
  6. package/general/index.d.ts +0 -5
  7. package/general/index.js +0 -21
  8. package/general/logger.d.ts +0 -10
  9. package/general/logger.js +0 -90
  10. package/general/report.d.ts +0 -25
  11. package/general/report.js +0 -76
  12. package/general/reportStyle.d.ts +0 -0
  13. package/general/reportStyle.js +0 -1
  14. package/general/viewstate.d.ts +0 -5
  15. package/general/viewstate.js +0 -9
  16. package/index.d.ts +0 -0
  17. package/index.js +0 -1
  18. package/metrics/images.d.ts +0 -22
  19. package/metrics/images.js +0 -33
  20. package/metrics/index.d.ts +0 -5
  21. package/metrics/index.js +0 -21
  22. package/metrics/mission.d.ts +0 -47
  23. package/metrics/mission.js +0 -81
  24. package/metrics/missionSensorOutage.d.ts +0 -11
  25. package/metrics/missionSensorOutage.js +0 -14
  26. package/metrics/missionsensor.d.ts +0 -67
  27. package/metrics/missionsensor.js +0 -128
  28. package/metrics/outage.d.ts +0 -43
  29. package/metrics/outage.js +0 -55
  30. package/metrics/reports/drawSummary.d.ts +0 -24
  31. package/metrics/reports/drawSummary.js +0 -311
  32. package/metrics/reports/index.d.ts +0 -5
  33. package/metrics/reports/index.js +0 -21
  34. package/metrics/reports/missionDay.d.ts +0 -8
  35. package/metrics/reports/missionDay.js +0 -23
  36. package/metrics/reports/missionSummary.d.ts +0 -25
  37. package/metrics/reports/missionSummary.js +0 -421
  38. package/metrics/reports/missionType.d.ts +0 -20
  39. package/metrics/reports/missionType.js +0 -314
  40. package/metrics/reports/outageDay.d.ts +0 -8
  41. package/metrics/reports/outageDay.js +0 -23
  42. package/metrics/systemdata/classifications.d.ts +0 -18
  43. package/metrics/systemdata/classifications.js +0 -23
  44. package/metrics/systemdata/communications.d.ts +0 -21
  45. package/metrics/systemdata/communications.js +0 -40
  46. package/metrics/systemdata/dcgs.d.ts +0 -19
  47. package/metrics/systemdata/dcgs.js +0 -29
  48. package/metrics/systemdata/exploitations.d.ts +0 -18
  49. package/metrics/systemdata/exploitations.js +0 -23
  50. package/metrics/systemdata/groundSystems.d.ts +0 -86
  51. package/metrics/systemdata/groundSystems.js +0 -143
  52. package/metrics/systemdata/index.d.ts +0 -7
  53. package/metrics/systemdata/index.js +0 -23
  54. package/metrics/systemdata/platform.d.ts +0 -124
  55. package/metrics/systemdata/platform.js +0 -176
  56. package/metrics/systemdata/systeminfo.d.ts +0 -28
  57. package/metrics/systemdata/systeminfo.js +0 -64
  58. package/scheduler/employees/assignment.d.ts +0 -139
  59. package/scheduler/employees/assignment.js +0 -304
  60. package/scheduler/employees/balance.d.ts +0 -35
  61. package/scheduler/employees/balance.js +0 -39
  62. package/scheduler/employees/companyinfo.d.ts +0 -16
  63. package/scheduler/employees/companyinfo.js +0 -6
  64. package/scheduler/employees/contact.d.ts +0 -36
  65. package/scheduler/employees/contact.js +0 -40
  66. package/scheduler/employees/employee.d.ts +0 -427
  67. package/scheduler/employees/employee.js +0 -1887
  68. package/scheduler/employees/employeename.d.ts +0 -48
  69. package/scheduler/employees/employeename.js +0 -97
  70. package/scheduler/employees/index.d.ts +0 -14
  71. package/scheduler/employees/index.js +0 -30
  72. package/scheduler/employees/labor.d.ts +0 -31
  73. package/scheduler/employees/labor.js +0 -39
  74. package/scheduler/employees/leave.d.ts +0 -58
  75. package/scheduler/employees/leave.js +0 -73
  76. package/scheduler/employees/leaverequest.d.ts +0 -105
  77. package/scheduler/employees/leaverequest.js +0 -226
  78. package/scheduler/employees/specialty.d.ts +0 -35
  79. package/scheduler/employees/specialty.js +0 -40
  80. package/scheduler/employees/variation.d.ts +0 -80
  81. package/scheduler/employees/variation.js +0 -132
  82. package/scheduler/employees/web.d.ts +0 -6
  83. package/scheduler/employees/web.js +0 -2
  84. package/scheduler/employees/work.d.ts +0 -96
  85. package/scheduler/employees/work.js +0 -133
  86. package/scheduler/employees/workday.d.ts +0 -91
  87. package/scheduler/employees/workday.js +0 -170
  88. package/scheduler/labor/index.d.ts +0 -2
  89. package/scheduler/labor/index.js +0 -18
  90. package/scheduler/labor/laborcode.d.ts +0 -33
  91. package/scheduler/labor/laborcode.js +0 -55
  92. package/scheduler/labor/workcode.d.ts +0 -28
  93. package/scheduler/labor/workcode.js +0 -35
  94. package/scheduler/reports/chargeStatus.d.ts +0 -66
  95. package/scheduler/reports/chargeStatus.js +0 -752
  96. package/scheduler/reports/cofsReports.d.ts +0 -11
  97. package/scheduler/reports/cofsReports.js +0 -36
  98. package/scheduler/reports/enterpriseSchedule.d.ts +0 -18
  99. package/scheduler/reports/enterpriseSchedule.js +0 -159
  100. package/scheduler/reports/index.d.ts +0 -6
  101. package/scheduler/reports/index.js +0 -22
  102. package/scheduler/reports/leaveReport.d.ts +0 -52
  103. package/scheduler/reports/leaveReport.js +0 -755
  104. package/scheduler/reports/leaves.d.ts +0 -24
  105. package/scheduler/reports/leaves.js +0 -110
  106. package/scheduler/reports/scheduleReport.d.ts +0 -17
  107. package/scheduler/reports/scheduleReport.js +0 -311
  108. package/scheduler/sites/index.d.ts +0 -1
  109. package/scheduler/sites/index.js +0 -17
  110. package/scheduler/sites/reports/cofsReport.d.ts +0 -41
  111. package/scheduler/sites/reports/cofsReport.js +0 -104
  112. package/scheduler/sites/reports/forecast.d.ts +0 -57
  113. package/scheduler/sites/reports/forecast.js +0 -205
  114. package/scheduler/sites/reports/index.d.ts +0 -4
  115. package/scheduler/sites/reports/index.js +0 -20
  116. package/scheduler/sites/reports/period.d.ts +0 -11
  117. package/scheduler/sites/reports/period.js +0 -27
  118. package/scheduler/sites/reports/section.d.ts +0 -63
  119. package/scheduler/sites/reports/section.js +0 -186
  120. package/scheduler/sites/site.d.ts +0 -39
  121. package/scheduler/sites/site.js +0 -68
  122. package/scheduler/sites/workcenters/index.d.ts +0 -3
  123. package/scheduler/sites/workcenters/index.js +0 -19
  124. package/scheduler/sites/workcenters/position.d.ts +0 -27
  125. package/scheduler/sites/workcenters/position.js +0 -36
  126. package/scheduler/sites/workcenters/shift.d.ts +0 -32
  127. package/scheduler/sites/workcenters/shift.js +0 -47
  128. package/scheduler/sites/workcenters/workcenter.d.ts +0 -43
  129. package/scheduler/sites/workcenters/workcenter.js +0 -123
  130. package/scheduler/teams/company/company.d.ts +0 -99
  131. package/scheduler/teams/company/company.js +0 -256
  132. package/scheduler/teams/company/holiday.d.ts +0 -61
  133. package/scheduler/teams/company/holiday.js +0 -116
  134. package/scheduler/teams/company/index.d.ts +0 -3
  135. package/scheduler/teams/company/index.js +0 -19
  136. package/scheduler/teams/company/modperiod.d.ts +0 -21
  137. package/scheduler/teams/company/modperiod.js +0 -24
  138. package/scheduler/teams/contact.d.ts +0 -18
  139. package/scheduler/teams/contact.js +0 -23
  140. package/scheduler/teams/index.d.ts +0 -3
  141. package/scheduler/teams/index.js +0 -19
  142. package/scheduler/teams/specialty.d.ts +0 -18
  143. package/scheduler/teams/specialty.js +0 -23
  144. package/scheduler/teams/team.d.ts +0 -95
  145. package/scheduler/teams/team.js +0 -351
  146. package/users/index.d.ts +0 -2
  147. package/users/index.js +0 -18
  148. package/users/user.d.ts +0 -130
  149. package/users/user.js +0 -256
  150. package/users/web.d.ts +0 -48
  151. package/users/web.js +0 -2
@@ -1,3 +0,0 @@
1
- export * from './position';
2
- export * from './shift';
3
- export * from './workcenter';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./position"), exports);
18
- __exportStar(require("./shift"), exports);
19
- __exportStar(require("./workcenter"), exports);
@@ -1,27 +0,0 @@
1
- import { Employee } from "../../employees";
2
- /**
3
- * This interface defines the data members for a duty position
4
- */
5
- export interface IPosition {
6
- id: string;
7
- name: string;
8
- sort: number;
9
- assigned: string[];
10
- }
11
- /**
12
- * This class implements the basic duty position definition plus actions.
13
- */
14
- export declare class Position implements IPosition {
15
- id: string;
16
- name: string;
17
- sort: number;
18
- assigned: string[];
19
- employees?: Employee[];
20
- constructor(pos?: IPosition);
21
- /**
22
- * This function will be used to sort duty positions within a list
23
- * @param other A position object to compare against this one.
24
- * @returns A numeric value for its relative position to the other.
25
- */
26
- compareTo(other?: Position): number;
27
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Position = void 0;
4
- /**
5
- * This class implements the basic duty position definition plus actions.
6
- */
7
- class Position {
8
- id;
9
- name;
10
- sort;
11
- assigned;
12
- employees;
13
- constructor(pos) {
14
- this.id = (pos) ? pos.id : '';
15
- this.name = (pos) ? pos.name : '';
16
- this.sort = (pos) ? pos.sort : 0;
17
- this.assigned = [];
18
- if (pos) {
19
- pos.assigned.forEach(emp => {
20
- this.assigned.push(emp);
21
- });
22
- }
23
- }
24
- /**
25
- * This function will be used to sort duty positions within a list
26
- * @param other A position object to compare against this one.
27
- * @returns A numeric value for its relative position to the other.
28
- */
29
- compareTo(other) {
30
- if (other) {
31
- return (this.sort < other.sort) ? -1 : 1;
32
- }
33
- return -1;
34
- }
35
- }
36
- exports.Position = Position;
@@ -1,32 +0,0 @@
1
- import { Employee } from "../../employees";
2
- /**
3
- * This interface defines the data members associated with a shift
4
- */
5
- export interface IShift {
6
- id: string;
7
- name: string;
8
- sort: number;
9
- associatedCodes: string[];
10
- payCode: number;
11
- minimums: number;
12
- }
13
- /**
14
- * This class definition implements the basic shift object plus actions.
15
- */
16
- export declare class Shift implements IShift {
17
- id: string;
18
- name: string;
19
- sort: number;
20
- associatedCodes: string[];
21
- payCode: number;
22
- minimums: number;
23
- employees?: Employee[];
24
- constructor(shft?: IShift);
25
- /**
26
- * This function will be used to sort this shift with others.
27
- * @param other A Shift object to compare against
28
- * @returns A numeric value for the relative position to the other.
29
- */
30
- compareTo(other?: Shift): number;
31
- belowMinimums(): boolean;
32
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Shift = void 0;
4
- /**
5
- * This class definition implements the basic shift object plus actions.
6
- */
7
- class Shift {
8
- id;
9
- name;
10
- sort;
11
- associatedCodes;
12
- payCode;
13
- minimums;
14
- employees;
15
- constructor(shft) {
16
- this.id = (shft) ? shft.id : '';
17
- this.name = (shft) ? shft.name : '';
18
- this.sort = (shft) ? shft.sort : 0;
19
- this.associatedCodes = [];
20
- if (shft) {
21
- shft.associatedCodes.forEach(code => {
22
- this.associatedCodes.push(code);
23
- });
24
- this.associatedCodes.sort();
25
- }
26
- this.payCode = (shft) ? shft.payCode : 1;
27
- this.minimums = (shft) ? shft.minimums : 1;
28
- }
29
- /**
30
- * This function will be used to sort this shift with others.
31
- * @param other A Shift object to compare against
32
- * @returns A numeric value for the relative position to the other.
33
- */
34
- compareTo(other) {
35
- if (other) {
36
- return (this.sort < other.sort) ? -1 : 1;
37
- }
38
- return -1;
39
- }
40
- belowMinimums() {
41
- if (this.employees) {
42
- return this.employees.length < this.minimums;
43
- }
44
- return (this.minimums > 0);
45
- }
46
- }
47
- exports.Shift = Shift;
@@ -1,43 +0,0 @@
1
- import { Employee } from "../../employees";
2
- import { IPosition, Position } from "./position";
3
- import { IShift, Shift } from "./shift";
4
- /**
5
- * This interface will define a workcenter.
6
- */
7
- export interface IWorkcenter {
8
- id: string;
9
- name: string;
10
- sort: number;
11
- shifts?: IShift[];
12
- positions?: IPosition[];
13
- }
14
- /**
15
- * This class defines a workcenter with its data members and actions
16
- */
17
- export declare class Workcenter implements IWorkcenter {
18
- id: string;
19
- name: string;
20
- sort: number;
21
- shifts?: Shift[];
22
- positions?: Position[];
23
- constructor(wc?: IWorkcenter);
24
- /**
25
- * This function is used to sort this workcenter in relation to another
26
- * @param other The workcenter object used in comparison.
27
- * @returns A numeric value for the relative position between two workcenters.
28
- */
29
- compareTo(other?: Workcenter): number;
30
- /**
31
- * This function will be used to assign the employee to either a position or a shift
32
- * based the positions assignment list or their workday code.
33
- * @param emp The employee object to assign to one of the workcenter's postions or
34
- * shifts.
35
- * @param date The date object to used to find the employee's workday.
36
- */
37
- assign(emp: Employee, date: Date): void;
38
- /**
39
- * This function will clear the employees' lists from the workcenter positions and
40
- * shifts.
41
- */
42
- clearEmployees(): void;
43
- }
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Workcenter = void 0;
4
- const employees_1 = require("../../employees");
5
- const position_1 = require("./position");
6
- const shift_1 = require("./shift");
7
- /**
8
- * This class defines a workcenter with its data members and actions
9
- */
10
- class Workcenter {
11
- id;
12
- name;
13
- sort;
14
- shifts;
15
- positions;
16
- constructor(wc) {
17
- this.id = (wc) ? wc.id : '';
18
- this.name = (wc) ? wc.name : '';
19
- this.sort = (wc) ? wc.sort : 0;
20
- if (wc && wc.shifts && wc.shifts.length > 0) {
21
- this.shifts = [];
22
- wc.shifts.forEach(shft => {
23
- if (this.shifts) {
24
- this.shifts.push(new shift_1.Shift(shft));
25
- }
26
- });
27
- this.shifts.sort((a, b) => a.compareTo(b));
28
- }
29
- if (wc && wc.positions && wc.positions.length > 0) {
30
- this.positions = [];
31
- wc.positions.forEach(pos => {
32
- this.positions?.push(new position_1.Position(pos));
33
- });
34
- this.positions.sort((a, b) => a.compareTo(b));
35
- }
36
- }
37
- /**
38
- * This function is used to sort this workcenter in relation to another
39
- * @param other The workcenter object used in comparison.
40
- * @returns A numeric value for the relative position between two workcenters.
41
- */
42
- compareTo(other) {
43
- if (other) {
44
- return (this.sort < other.sort) ? -1 : 1;
45
- }
46
- return -1;
47
- }
48
- /**
49
- * This function will be used to assign the employee to either a position or a shift
50
- * based the positions assignment list or their workday code.
51
- * @param emp The employee object to assign to one of the workcenter's postions or
52
- * shifts.
53
- * @param date The date object to used to find the employee's workday.
54
- */
55
- assign(emp, date) {
56
- // first check to see if the employee is assigned to a position
57
- let bPosition = false;
58
- if (this.positions) {
59
- this.positions.forEach((pos, p) => {
60
- pos.assigned.forEach(asgn => {
61
- if (emp.id === asgn) {
62
- bPosition = true;
63
- if (!pos.employees) {
64
- pos.employees = [];
65
- pos.employees.push(new employees_1.Employee(emp));
66
- }
67
- else {
68
- pos.employees.push(new employees_1.Employee(emp));
69
- pos.employees.sort((a, b) => a.compareTo(b));
70
- }
71
- }
72
- });
73
- if (bPosition && this.positions) {
74
- this.positions[p] = pos;
75
- }
76
- });
77
- }
78
- // if not assigned to a position, find their shift and assign to a shift.
79
- if (!bPosition && this.shifts) {
80
- let wd = emp.getWorkday(date);
81
- this.shifts.forEach((shft, s) => {
82
- shft.associatedCodes.forEach(cd => {
83
- if (cd.toLowerCase() === wd?.code.toLowerCase()) {
84
- if (!shft.employees) {
85
- shft.employees = [];
86
- shft.employees.push(new employees_1.Employee(emp));
87
- }
88
- else {
89
- shft.employees.push(new employees_1.Employee(emp));
90
- shft.employees.sort((a, b) => a.compareTo(b));
91
- }
92
- }
93
- });
94
- if (this.shifts) {
95
- this.shifts[s] = shft;
96
- }
97
- });
98
- }
99
- }
100
- /**
101
- * This function will clear the employees' lists from the workcenter positions and
102
- * shifts.
103
- */
104
- clearEmployees() {
105
- if (this.positions) {
106
- this.positions.forEach((pos, p) => {
107
- pos.employees = undefined;
108
- if (this.positions) {
109
- this.positions[p] = pos;
110
- }
111
- });
112
- }
113
- if (this.shifts) {
114
- this.shifts.forEach((shft, s) => {
115
- shft.employees = undefined;
116
- if (this.shifts) {
117
- this.shifts[s] = shft;
118
- }
119
- });
120
- }
121
- }
122
- }
123
- exports.Workcenter = Workcenter;
@@ -1,99 +0,0 @@
1
- import { Holiday, HolidayType, IHoliday } from "./holiday";
2
- import { IModPeriod, ModPeriod } from "./modperiod";
3
- /**
4
- * This interface defines the data members to describe the company information. The
5
- * ingest type, period, start day, and password information are necessary to ingess the
6
- * company's timecard information for various reports.
7
- */
8
- export interface ICompany {
9
- id: string;
10
- name: string;
11
- ingest: string;
12
- ingestPeriod?: number;
13
- startDay?: number;
14
- ingestPwd: string;
15
- holidays?: IHoliday[];
16
- modperiods?: IModPeriod[];
17
- }
18
- /**
19
- * This class definition implements the company interface, plus necessary actions to
20
- * manipulate the object.
21
- */
22
- export declare class Company implements ICompany {
23
- id: string;
24
- name: string;
25
- ingest: string;
26
- ingestPeriod?: number | undefined;
27
- startDay?: number | undefined;
28
- ingestPwd: string;
29
- holidays: Holiday[];
30
- modperiods: ModPeriod[];
31
- constructor(co?: ICompany);
32
- /**
33
- * This function is used in sorting this company with another.
34
- * @param other The company object used in the comparison.
35
- * @returns a numeric value to show relative position between the objects
36
- */
37
- compareTo(other?: Company): number;
38
- /**
39
- * This function is used to purge any old data from the company record, mainly holiday
40
- * actual dates.
41
- * @param date A date object used as the cutoff date.
42
- */
43
- purge(date: Date): void;
44
- /**
45
- * The function checks the company's list of mod periods to see if one of them fits
46
- * within its start and end dates.
47
- * @param date The date object for checking mod periods.
48
- * @returns A boolean value to indicate if the list contains a mod period for the date.
49
- */
50
- hasModPeriod(date: Date): boolean;
51
- /**
52
- * This function will add a new mod period to the company's mod period list.
53
- * @param year numeric value for the full year.
54
- * @param start The date object to specify the first day of the company's mod period.
55
- * @param end The date object to specify the last day of the company's mod period.
56
- */
57
- addModPeriod(year: number, start: Date, end: Date): void;
58
- /**
59
- * This function is used update either the start or end dates.
60
- * @param year A numeric value for the mod period's year value
61
- * @param field A string value to designate which date field to update
62
- * @param value A date object used in the update.
63
- */
64
- updateModPeriod(year: number, field: string, value: Date): void;
65
- /**
66
- * This function will remove a mod period from the company's list.
67
- * @param year a numeric value for the year to delete.
68
- */
69
- deleteModPeriod(year: number): void;
70
- /**
71
- * This function checks whether a particular holiday based on a combined identifier of
72
- * holiday type and a sort value is present in the company's list.
73
- * @param type The holiday type value for comparison to the list
74
- * @param sort A numeric value for the second part of the identifier.
75
- * @returns A boolean value to signify if the holiday is present in the company's list.
76
- */
77
- hasHoliday(type: HolidayType, sort: number): boolean;
78
- /**
79
- * This function will add a new holiday, after checking for the name given.
80
- * @param type The holiday type value for the new holiday
81
- * @param name A string value for the name of the new holiday
82
- * @returns A holiday object with the type and name.
83
- */
84
- addHoliday(type: HolidayType, name: string): Holiday;
85
- /**
86
- * This function is used to update a company holiday.
87
- * @param type The holiday type value for the holiday to update
88
- * @param sort The sort value for the holiday to update
89
- * @param field The string value to point to which field to update within the holiday.
90
- * @param value The string value for the new value to update to.
91
- */
92
- updateHoliday(type: HolidayType, sort: number, field: string, value: string): void;
93
- /**
94
- * This function will remove the company holiday based on the type and identifier.
95
- * @param type The holiday type to look for
96
- * @param sort The numeric identifier for the holiday type.
97
- */
98
- deleteHoliday(type: HolidayType, sort: number): void;
99
- }
@@ -1,256 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Company = void 0;
4
- const holiday_1 = require("./holiday");
5
- const modperiod_1 = require("./modperiod");
6
- /**
7
- * This class definition implements the company interface, plus necessary actions to
8
- * manipulate the object.
9
- */
10
- class Company {
11
- id;
12
- name;
13
- ingest;
14
- ingestPeriod;
15
- startDay;
16
- ingestPwd;
17
- holidays;
18
- modperiods;
19
- constructor(co) {
20
- this.id = (co) ? co.id : '';
21
- this.name = (co) ? co.name : '';
22
- this.ingest = (co) ? co.ingest : 'mexcel';
23
- this.ingestPeriod = (co && co.ingestPeriod) ? co.ingestPeriod : 0;
24
- this.startDay = (co && co.startDay) ? co.startDay : 0;
25
- this.ingestPwd = (co) ? co.ingestPwd : '';
26
- this.holidays = [];
27
- if (co && co.holidays && co.holidays.length > 0) {
28
- co.holidays.forEach(hol => {
29
- this.holidays.push(new holiday_1.Holiday(hol));
30
- });
31
- this.holidays.sort((a, b) => a.compareTo(b));
32
- }
33
- this.modperiods = [];
34
- if (co && co.modperiods && co.modperiods.length > 0) {
35
- co.modperiods.forEach(mod => {
36
- this.modperiods.push(new modperiod_1.ModPeriod(mod));
37
- });
38
- this.modperiods.sort((a, b) => a.compareTo(b));
39
- }
40
- }
41
- /**
42
- * This function is used in sorting this company with another.
43
- * @param other The company object used in the comparison.
44
- * @returns a numeric value to show relative position between the objects
45
- */
46
- compareTo(other) {
47
- if (other) {
48
- return (this.name.toLowerCase() < other.name.toLowerCase()) ? -1 : 1;
49
- }
50
- return -1;
51
- }
52
- /**
53
- * This function is used to purge any old data from the company record, mainly holiday
54
- * actual dates.
55
- * @param date A date object used as the cutoff date.
56
- */
57
- purge(date) {
58
- this.holidays.forEach((hol, h) => {
59
- hol.purge(date);
60
- this.holidays[h] = hol;
61
- });
62
- for (let m = this.modperiods.length - 1; m >= 0; m--) {
63
- if (this.modperiods[m].year < date.getFullYear()) {
64
- this.modperiods.splice(m, 1);
65
- }
66
- }
67
- }
68
- /**
69
- * The function checks the company's list of mod periods to see if one of them fits
70
- * within its start and end dates.
71
- * @param date The date object for checking mod periods.
72
- * @returns A boolean value to indicate if the list contains a mod period for the date.
73
- */
74
- hasModPeriod(date) {
75
- let answer = false;
76
- this.modperiods.forEach(mod => {
77
- if (date.getTime() >= mod.start.getTime() || date.getTime() <= mod.end.getTime()) {
78
- answer = true;
79
- }
80
- });
81
- return answer;
82
- }
83
- /**
84
- * This function will add a new mod period to the company's mod period list.
85
- * @param year numeric value for the full year.
86
- * @param start The date object to specify the first day of the company's mod period.
87
- * @param end The date object to specify the last day of the company's mod period.
88
- */
89
- addModPeriod(year, start, end) {
90
- let found = false;
91
- this.modperiods.forEach((mod, m) => {
92
- if (mod.year === year) {
93
- mod.start = new Date(start);
94
- mod.end = new Date(end);
95
- this.modperiods[m] = mod;
96
- found = true;
97
- }
98
- });
99
- if (!found) {
100
- this.modperiods.push(new modperiod_1.ModPeriod({
101
- year: year,
102
- start: new Date(start),
103
- end: new Date(end)
104
- }));
105
- this.modperiods.sort((a, b) => a.compareTo(b));
106
- }
107
- }
108
- /**
109
- * This function is used update either the start or end dates.
110
- * @param year A numeric value for the mod period's year value
111
- * @param field A string value to designate which date field to update
112
- * @param value A date object used in the update.
113
- */
114
- updateModPeriod(year, field, value) {
115
- this.modperiods.forEach((mod, m) => {
116
- if (mod.year === year) {
117
- switch (field.toLowerCase()) {
118
- case "start":
119
- mod.start = new Date(value);
120
- break;
121
- case "end":
122
- mod.end = new Date(value);
123
- break;
124
- }
125
- this.modperiods[m] = mod;
126
- }
127
- });
128
- }
129
- /**
130
- * This function will remove a mod period from the company's list.
131
- * @param year a numeric value for the year to delete.
132
- */
133
- deleteModPeriod(year) {
134
- let found = -1;
135
- this.modperiods.forEach((mod, m) => {
136
- if (mod.year === year) {
137
- found = m;
138
- }
139
- });
140
- if (found >= 0) {
141
- this.modperiods.splice(found, 1);
142
- }
143
- }
144
- /**
145
- * This function checks whether a particular holiday based on a combined identifier of
146
- * holiday type and a sort value is present in the company's list.
147
- * @param type The holiday type value for comparison to the list
148
- * @param sort A numeric value for the second part of the identifier.
149
- * @returns A boolean value to signify if the holiday is present in the company's list.
150
- */
151
- hasHoliday(type, sort) {
152
- let answer = false;
153
- this.holidays.forEach(hol => {
154
- if (hol.id === type && hol.sort === sort) {
155
- answer = true;
156
- }
157
- });
158
- return answer;
159
- }
160
- /**
161
- * This function will add a new holiday, after checking for the name given.
162
- * @param type The holiday type value for the new holiday
163
- * @param name A string value for the name of the new holiday
164
- * @returns A holiday object with the type and name.
165
- */
166
- addHoliday(type, name) {
167
- let max = 0;
168
- let holiday = new holiday_1.Holiday();
169
- this.holidays.forEach(hol => {
170
- if (hol.id === type && max < hol.sort) {
171
- max = hol.sort;
172
- }
173
- if (hol.name.toLowerCase() === name.toLowerCase()) {
174
- holiday = new holiday_1.Holiday(hol);
175
- }
176
- });
177
- if (holiday.sort === 0) {
178
- holiday = new holiday_1.Holiday({
179
- id: type,
180
- name: name,
181
- sort: max + 1
182
- });
183
- this.holidays.push(holiday);
184
- }
185
- return holiday;
186
- }
187
- /**
188
- * This function is used to update a company holiday.
189
- * @param type The holiday type value for the holiday to update
190
- * @param sort The sort value for the holiday to update
191
- * @param field The string value to point to which field to update within the holiday.
192
- * @param value The string value for the new value to update to.
193
- */
194
- updateHoliday(type, sort, field, value) {
195
- this.holidays.sort((a, b) => a.compareTo(b));
196
- this.holidays.forEach((hol, h) => {
197
- if (hol.id === type && hol.sort === sort) {
198
- switch (field.toLowerCase()) {
199
- case "name":
200
- hol.name = value;
201
- break;
202
- case "move":
203
- if (value.toLowerCase().substring(0, 2) === 'up') {
204
- if (h > 0) {
205
- const otherHol = this.holidays[h - 1];
206
- if (otherHol.id === hol.id) {
207
- const temp = otherHol.sort;
208
- otherHol.sort = hol.sort;
209
- hol.sort = temp;
210
- this.holidays[h - 1] = otherHol;
211
- }
212
- }
213
- }
214
- else {
215
- if (h < this.holidays.length - 1) {
216
- const otherHol = this.holidays[h + 1];
217
- if (otherHol.id === hol.id) {
218
- const temp = otherHol.sort;
219
- otherHol.sort = hol.sort;
220
- hol.sort = temp;
221
- this.holidays[h - 1] = otherHol;
222
- }
223
- }
224
- }
225
- break;
226
- case "addactual":
227
- const newActual = new Date(Date.parse(value));
228
- hol.addActual(newActual);
229
- break;
230
- case "deleteactual":
231
- const oldActual = new Date(Date.parse(value));
232
- hol.deleteActual(oldActual);
233
- break;
234
- }
235
- this.holidays[h] = hol;
236
- }
237
- });
238
- }
239
- /**
240
- * This function will remove the company holiday based on the type and identifier.
241
- * @param type The holiday type to look for
242
- * @param sort The numeric identifier for the holiday type.
243
- */
244
- deleteHoliday(type, sort) {
245
- let found = -1;
246
- this.holidays.forEach((hol, h) => {
247
- if (hol.id === type && hol.sort === sort) {
248
- found = h;
249
- }
250
- });
251
- if (found >= 0) {
252
- this.holidays.splice(found, 1);
253
- }
254
- }
255
- }
256
- exports.Company = Company;