scheduler-node-models 1.2.19 → 1.2.21

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 (33) hide show
  1. package/general/reportStyle.d.ts +0 -0
  2. package/general/reportStyle.js +1 -0
  3. package/metrics/reports/drawSummary.d.ts +24 -0
  4. package/metrics/reports/drawSummary.js +311 -0
  5. package/metrics/reports/index.d.ts +5 -0
  6. package/metrics/reports/index.js +21 -0
  7. package/metrics/reports/missionDay.d.ts +8 -0
  8. package/metrics/reports/missionDay.js +23 -0
  9. package/metrics/reports/missionSummary.d.ts +25 -0
  10. package/metrics/reports/missionSummary.js +421 -0
  11. package/metrics/reports/missionType.d.ts +20 -0
  12. package/metrics/reports/missionType.js +314 -0
  13. package/metrics/reports/outageDay.d.ts +8 -0
  14. package/metrics/reports/outageDay.js +23 -0
  15. package/package.json +3 -2
  16. package/scheduler/employees/variation.d.ts +14 -6
  17. package/scheduler/employees/variation.js +18 -6
  18. package/scheduler/employees/web.d.ts +15 -0
  19. package/scheduler/employees/workday.js +23 -0
  20. package/scheduler/reports/chargeStatus.d.ts +66 -0
  21. package/scheduler/reports/chargeStatus.js +752 -0
  22. package/scheduler/reports/cofsReports.d.ts +11 -0
  23. package/scheduler/reports/cofsReports.js +36 -0
  24. package/scheduler/reports/enterpriseSchedule.d.ts +18 -0
  25. package/scheduler/reports/enterpriseSchedule.js +159 -0
  26. package/scheduler/reports/index.d.ts +6 -0
  27. package/scheduler/reports/index.js +22 -0
  28. package/scheduler/reports/leaveReport.d.ts +52 -0
  29. package/scheduler/reports/leaveReport.js +755 -0
  30. package/scheduler/reports/leaves.d.ts +24 -0
  31. package/scheduler/reports/leaves.js +110 -0
  32. package/scheduler/reports/scheduleReport.d.ts +17 -0
  33. package/scheduler/reports/scheduleReport.js +311 -0
@@ -0,0 +1,24 @@
1
+ import { Leave } from "../employees";
2
+ import { Holiday } from "../teams/company";
3
+ export declare class LeavePeriod {
4
+ code: string;
5
+ start: Date;
6
+ end: Date;
7
+ status: string;
8
+ leaves: Leave[];
9
+ constructor(leave?: Leave);
10
+ compareTo(other?: LeavePeriod): number;
11
+ getHours(type?: string, actual?: boolean): number;
12
+ addLeave(leave: Leave): void;
13
+ }
14
+ export declare class LeaveMonth {
15
+ month: Date;
16
+ holiday?: Holiday;
17
+ disabled: boolean;
18
+ periods: LeavePeriod[];
19
+ standard: number;
20
+ constructor(start: Date, std: number, disabled: boolean, holiday?: Holiday);
21
+ compareTo(other?: LeaveMonth): number;
22
+ getHours(type?: string, actuals?: boolean): number;
23
+ addLeave(leave: Leave): void;
24
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LeaveMonth = exports.LeavePeriod = void 0;
4
+ const employees_1 = require("../employees");
5
+ const company_1 = require("../teams/company");
6
+ class LeavePeriod {
7
+ code;
8
+ start;
9
+ end;
10
+ status;
11
+ leaves;
12
+ constructor(leave) {
13
+ this.code = (leave) ? leave.code : '';
14
+ this.start = (leave) ? new Date(leave.leavedate) : new Date(0);
15
+ this.end = (leave) ? new Date(leave.leavedate) : new Date(0);
16
+ this.status = (leave) ? leave.status : 'approved';
17
+ this.leaves = [];
18
+ if (leave) {
19
+ this.leaves.push(new employees_1.Leave(leave));
20
+ }
21
+ }
22
+ compareTo(other) {
23
+ if (other) {
24
+ return (this.start.getTime() < other.start.getTime()) ? -1 : 1;
25
+ }
26
+ return -1;
27
+ }
28
+ getHours(type, actual) {
29
+ let hours = 0.0;
30
+ if (type && type.toLowerCase() === 'v') {
31
+ this.leaves.forEach(lv => {
32
+ if (lv.code.toLowerCase() === 'v') {
33
+ if (actual && lv.status.toLowerCase() === 'actual') {
34
+ hours += lv.hours;
35
+ }
36
+ else if (!actual && lv.status.toLowerCase() !== 'actual') {
37
+ hours += lv.hours;
38
+ }
39
+ }
40
+ });
41
+ }
42
+ else {
43
+ this.leaves.forEach(lv => {
44
+ hours += lv.hours;
45
+ });
46
+ }
47
+ return hours;
48
+ }
49
+ addLeave(leave) {
50
+ this.leaves.push(new employees_1.Leave(leave));
51
+ this.end = new Date(leave.leavedate);
52
+ }
53
+ }
54
+ exports.LeavePeriod = LeavePeriod;
55
+ class LeaveMonth {
56
+ month;
57
+ holiday;
58
+ disabled;
59
+ periods;
60
+ standard;
61
+ constructor(start, std, disabled, holiday) {
62
+ this.month = new Date(start);
63
+ this.standard = std;
64
+ this.disabled = disabled;
65
+ this.periods = [];
66
+ this.holiday = undefined;
67
+ if (holiday) {
68
+ this.holiday = new company_1.Holiday(holiday);
69
+ }
70
+ }
71
+ compareTo(other) {
72
+ if (other) {
73
+ if (this.holiday && other.holiday) {
74
+ if (this.holiday.id.toLowerCase() === other.holiday.id.toLowerCase()) {
75
+ return (this.holiday.sort < other.holiday.sort) ? -1 : 1;
76
+ }
77
+ return (this.holiday.id.toLowerCase() === 'h') ? -1 : 1;
78
+ }
79
+ else {
80
+ return (this.month.getTime() < other.month.getTime()) ? -1 : 1;
81
+ }
82
+ }
83
+ return -1;
84
+ }
85
+ getHours(type, actuals) {
86
+ let hours = 0.0;
87
+ this.periods.forEach(prd => {
88
+ hours += prd.getHours(type, actuals);
89
+ });
90
+ return hours;
91
+ }
92
+ addLeave(leave) {
93
+ let bAdded = false;
94
+ if (leave.hours === this.standard) {
95
+ this.periods.forEach((prd, p) => {
96
+ if (!bAdded && leave.code.toLowerCase() === prd.code.toLowerCase()
97
+ && leave.status.toLowerCase() === prd.status.toLowerCase()
98
+ && leave.leavedate.getDate() === prd.end.getDate() + 1) {
99
+ bAdded = true;
100
+ prd.addLeave(leave);
101
+ this.periods[p] = prd;
102
+ }
103
+ });
104
+ }
105
+ if (!bAdded) {
106
+ this.periods.push(new LeavePeriod(leave));
107
+ }
108
+ }
109
+ }
110
+ exports.LeaveMonth = LeaveMonth;
@@ -0,0 +1,17 @@
1
+ import { Workbook, Worksheet } from "exceljs";
2
+ import { Report } from "../../general";
3
+ import { Workcode } from "../labor";
4
+ import { ISite } from "../sites";
5
+ import { Employee, IEmployee } from "../employees";
6
+ import { User } from "../../users";
7
+ export declare class ScheduleReport extends Report {
8
+ private styles;
9
+ private workcodes;
10
+ private site;
11
+ constructor(workcodes: Map<string, Workcode>, isite: ISite);
12
+ create(user: User, year: number, site: string, iEmps: IEmployee[]): Workbook;
13
+ createStyles(): void;
14
+ addMonth(workbook: Workbook, start: Date, iEmps: IEmployee[]): void;
15
+ createEmployeeRow(sheet: Worksheet, start: Date, end: Date, row: number, emp: Employee): void;
16
+ createLegendSheet(workbook: Workbook): void;
17
+ }
@@ -0,0 +1,311 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduleReport = void 0;
4
+ const exceljs_1 = require("exceljs");
5
+ const general_1 = require("../../general");
6
+ const sites_1 = require("../sites");
7
+ const employees_1 = require("../employees");
8
+ class ScheduleReport extends general_1.Report {
9
+ styles;
10
+ workcodes;
11
+ site;
12
+ constructor(workcodes, isite) {
13
+ super();
14
+ this.styles = new Map();
15
+ this.workcodes = workcodes;
16
+ this.site = new sites_1.Site(isite);
17
+ }
18
+ create(user, year, site, iEmps) {
19
+ const workbook = new exceljs_1.Workbook();
20
+ workbook.creator = user.getFullName();
21
+ workbook.created = new Date();
22
+ this.createStyles();
23
+ let start = new Date(Date.UTC(year, 0, 1));
24
+ const end = new Date(Date.UTC(year, 11, 31, 59, 59, 59));
25
+ while (start.getTime() < end.getTime()) {
26
+ this.addMonth(workbook, start, iEmps);
27
+ start = new Date(Date.UTC(start.getFullYear(), start.getMonth() + 1, 1));
28
+ }
29
+ this.createLegendSheet(workbook);
30
+ const sheet = workbook.getWorksheet('Sheet1');
31
+ if (sheet) {
32
+ workbook.removeWorksheet(sheet.id);
33
+ }
34
+ return workbook;
35
+ }
36
+ createStyles() {
37
+ // set style
38
+ this.workcodes.forEach((wc, key) => {
39
+ if (wc.backcolor.toLowerCase() !== 'ffffff') {
40
+ const style = {
41
+ fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: `ff${wc.backcolor}` } },
42
+ font: { bold: true, size: 11, color: { argb: `ff${wc.textcolor}` } },
43
+ alignment: { horizontal: 'center', vertical: 'middle', wrapText: true },
44
+ border: {
45
+ top: { style: 'thin', color: { argb: 'ff000000' } },
46
+ left: { style: 'thin', color: { argb: 'ff000000' } },
47
+ bottom: { style: 'thin', color: { argb: 'ff000000' } },
48
+ right: { style: 'thin', color: { argb: 'ff000000' } }
49
+ }
50
+ };
51
+ this.styles.set(wc.id, style);
52
+ }
53
+ });
54
+ let style = {
55
+ fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: `ffc0c0c0` } },
56
+ font: { bold: true, size: 11, color: { argb: `ff000000` } },
57
+ alignment: { horizontal: 'center', vertical: 'middle', wrapText: true },
58
+ border: {
59
+ top: { style: 'thin', color: { argb: 'ff000000' } },
60
+ left: { style: 'thin', color: { argb: 'ff000000' } },
61
+ bottom: { style: 'thin', color: { argb: 'ff000000' } },
62
+ right: { style: 'thin', color: { argb: 'ff000000' } }
63
+ }
64
+ };
65
+ this.styles.set('evenday', style);
66
+ this.styles.set('oddday', {
67
+ fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: `ffffffff` } },
68
+ font: { bold: true, size: 11, color: { argb: `ff000000` } },
69
+ alignment: { horizontal: 'center', vertical: 'middle', wrapText: true },
70
+ border: {
71
+ top: { style: 'thin', color: { argb: 'ff000000' } },
72
+ left: { style: 'thin', color: { argb: 'ff000000' } },
73
+ bottom: { style: 'thin', color: { argb: 'ff000000' } },
74
+ right: { style: 'thin', color: { argb: 'ff000000' } }
75
+ }
76
+ });
77
+ this.styles.set('evenend', {
78
+ fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: `ff00e6e6` } },
79
+ font: { bold: true, size: 11, color: { argb: `ff000000` } },
80
+ alignment: { horizontal: 'center', vertical: 'middle', wrapText: true },
81
+ border: {
82
+ top: { style: 'thin', color: { argb: 'ff000000' } },
83
+ left: { style: 'thin', color: { argb: 'ff000000' } },
84
+ bottom: { style: 'thin', color: { argb: 'ff000000' } },
85
+ right: { style: 'thin', color: { argb: 'ff000000' } }
86
+ }
87
+ });
88
+ this.styles.set('oddend', {
89
+ fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: `ffccffff` } },
90
+ font: { bold: true, size: 11, color: { argb: `ff000000` } },
91
+ alignment: { horizontal: 'center', vertical: 'middle', wrapText: true },
92
+ border: {
93
+ top: { style: 'thin', color: { argb: 'ff000000' } },
94
+ left: { style: 'thin', color: { argb: 'ff000000' } },
95
+ bottom: { style: 'thin', color: { argb: 'ff000000' } },
96
+ right: { style: 'thin', color: { argb: 'ff000000' } }
97
+ }
98
+ });
99
+ this.styles.set('month', {
100
+ fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: `ffde5d12` } },
101
+ font: { bold: true, size: 11, color: { argb: `ff000000` } },
102
+ alignment: { horizontal: 'center', vertical: 'middle', wrapText: true },
103
+ border: {
104
+ top: { style: 'thin', color: { argb: 'ff000000' } },
105
+ left: { style: 'thin', color: { argb: 'ff000000' } },
106
+ bottom: { style: 'thin', color: { argb: 'ff000000' } },
107
+ right: { style: 'thin', color: { argb: 'ff000000' } }
108
+ }
109
+ });
110
+ this.styles.set('wkctr', {
111
+ fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: `ff000000` } },
112
+ font: { bold: true, size: 11, color: { argb: `ffffffff` } },
113
+ alignment: { horizontal: 'center', vertical: 'middle', wrapText: true },
114
+ border: {
115
+ top: { style: 'thin', color: { argb: 'ff000000' } },
116
+ left: { style: 'thin', color: { argb: 'ff000000' } },
117
+ bottom: { style: 'thin', color: { argb: 'ff000000' } },
118
+ right: { style: 'thin', color: { argb: 'ff000000' } }
119
+ }
120
+ });
121
+ }
122
+ addMonth(workbook, start, iEmps) {
123
+ const startDate = new Date(start);
124
+ const endDate = new Date(Date.UTC(start.getFullYear(), start.getMonth() + 1, 1));
125
+ const months = ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July',
126
+ 'August', 'September', 'October', 'November', 'December'];
127
+ const weekdays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
128
+ // first ensure the workcenter positions and shifts are clear of employees
129
+ this.site.workcenters.forEach(wkctr => {
130
+ wkctr.positions?.forEach((pos, p) => {
131
+ pos.employees = [];
132
+ wkctr.positions[p] = pos;
133
+ });
134
+ wkctr.shifts?.forEach((shft, s) => {
135
+ shft.employees = [];
136
+ wkctr.shifts[s] = shft;
137
+ });
138
+ });
139
+ iEmps.forEach(iEmp => {
140
+ const emp = new employees_1.Employee(iEmp);
141
+ if (emp.atSite(this.site.id, startDate, endDate)) {
142
+ let position = false;
143
+ this.site.workcenters.forEach((wkctr, w) => {
144
+ wkctr.positions?.forEach((pos, p) => {
145
+ pos.assigned.forEach(asgn => {
146
+ if (asgn === emp.id) {
147
+ position = true;
148
+ pos.employees?.push(emp);
149
+ }
150
+ });
151
+ if (position) {
152
+ wkctr.positions[p] = pos;
153
+ this.site.workcenters[w] = wkctr;
154
+ }
155
+ });
156
+ });
157
+ if (!position) {
158
+ const wd = emp.getAssignmentForPeriod(startDate, endDate);
159
+ this.site.workcenters.forEach((wkctr, w) => {
160
+ if (wkctr.id.toLowerCase() === wd.workcenter.toLowerCase()) {
161
+ wkctr.shifts?.forEach((shft, s) => {
162
+ let bShift = false;
163
+ shft.associatedCodes.forEach(code => {
164
+ if (code.toLowerCase() === wd.code.toLowerCase()) {
165
+ bShift = true;
166
+ }
167
+ });
168
+ if (bShift) {
169
+ shft.employees?.push(emp);
170
+ wkctr.shifts[s] = shft;
171
+ this.site.workcenters[w] = wkctr;
172
+ }
173
+ });
174
+ }
175
+ });
176
+ }
177
+ }
178
+ });
179
+ const sheetLabel = `${months[startDate.getMonth()]}`
180
+ + `${startDate.getFullYear().toString().substring(2)}`;
181
+ // add a worksheet to the workbook and set the page options (landscape, etc)
182
+ const sheet = workbook.addWorksheet(sheetLabel, {
183
+ pageSetup: {
184
+ paperSize: undefined,
185
+ orientation: 'landscape',
186
+ fitToHeight: 1,
187
+ fitToWidth: 1,
188
+ blackAndWhite: false,
189
+ fitToPage: true,
190
+ showGridLines: false,
191
+ horizontalCentered: true,
192
+ verticalCentered: true
193
+ }
194
+ });
195
+ sheet.properties.defaultRowHeight = 20;
196
+ sheet.properties.defaultColWidth = 4;
197
+ // set all the column widths for the month with the first column width of 17.0
198
+ // and days of the month at 4.0
199
+ sheet.getColumn(1).width = 17.0;
200
+ const endofMonth = (new Date(endDate.getTime() - (24 * 3600000))).getDate();
201
+ const now = new Date();
202
+ let style = this.styles.get('month');
203
+ this.setCell(sheet, this.getCellID(0, 1), this.getCellID(0, 1), style, months[startDate.getMonth()]);
204
+ const formatter = new Intl.DateTimeFormat('en-US', {
205
+ month: '2-digit',
206
+ day: '2-digit',
207
+ year: 'numeric'
208
+ });
209
+ this.setCell(sheet, this.getCellID(0, 2), this.getCellID(0, 2), style, formatter.format(now));
210
+ let current = new Date(startDate);
211
+ while (current.getTime() < endDate.getTime()) {
212
+ let styleID = 'evenday';
213
+ if (current.getDay() === 0 || current.getDay() === 6) {
214
+ styleID = 'evenend';
215
+ }
216
+ style = this.styles.get(styleID);
217
+ let cellID = this.getCellID(current.getDate(), 1);
218
+ this.setCell(sheet, cellID, cellID, style, weekdays[current.getDay()]);
219
+ cellID = this.getCellID(current.getDate(), 2);
220
+ this.setCell(sheet, cellID, cellID, style, current.getDate());
221
+ current = new Date(current.getTime() + (24 * 3600000));
222
+ }
223
+ // now add row for workcenter header, then the employees under that workcenter
224
+ let row = 2;
225
+ this.site.workcenters.forEach(wkctr => {
226
+ row++;
227
+ style = this.styles.get('wkctr');
228
+ this.setCell(sheet, this.getCellID(0, row), this.getCellID(endofMonth, row), style, wkctr.name);
229
+ // sort positions, then add a row for each employee for the positions.
230
+ if (wkctr.positions && wkctr.positions.length > 0) {
231
+ wkctr.positions.sort((a, b) => a.compareTo(b));
232
+ wkctr.positions.forEach(pos => {
233
+ if (pos.employees && pos.employees.length > 0) {
234
+ pos.employees.sort((a, b) => a.compareTo(b));
235
+ pos.employees.forEach(emp => {
236
+ row++;
237
+ this.createEmployeeRow(sheet, startDate, endDate, row, emp);
238
+ });
239
+ }
240
+ });
241
+ }
242
+ if (wkctr.shifts && wkctr.shifts.length > 0) {
243
+ wkctr.shifts.forEach(shft => {
244
+ if (shft.employees && shft.employees.length > 0) {
245
+ shft.employees.sort((a, b) => a.compareTo(b));
246
+ shft.employees.forEach(emp => {
247
+ row++;
248
+ this.createEmployeeRow(sheet, startDate, endDate, row, emp);
249
+ });
250
+ }
251
+ });
252
+ }
253
+ });
254
+ }
255
+ createEmployeeRow(sheet, start, end, row, emp) {
256
+ let styleID = 'oddday';
257
+ if (row % 2 === 0) {
258
+ styleID = 'evenday';
259
+ }
260
+ const lastWorked = emp.getLastWorkday();
261
+ let style = this.styles.get(styleID);
262
+ const name = `${emp.name.lastname}, ${emp.name.firstname.substring(0, 1)}`;
263
+ this.setCell(sheet, this.getCellID(0, row), this.getCellID(0, row), style, name);
264
+ let current = new Date(start);
265
+ while (current.getTime() < end.getTime()) {
266
+ let stID = styleID;
267
+ let code = '';
268
+ const wd = emp.getWorkday(current);
269
+ if (wd && wd.code !== '') {
270
+ code = wd.code.toUpperCase();
271
+ if (this.styles.has(wd.code)) {
272
+ stID = wd.code;
273
+ }
274
+ }
275
+ if (stID === 'oddday' || stID === 'evenday') {
276
+ if (current.getDay() === 0 || current.getDay() === 6) {
277
+ stID = (row % 2 === 0) ? 'evenend' : 'oddend';
278
+ }
279
+ }
280
+ style = this.styles.get(stID);
281
+ const cellID = this.getCellID(current.getDate(), row);
282
+ this.setCell(sheet, cellID, cellID, style, code);
283
+ current = new Date(current.getTime() + (24 * 3600000));
284
+ }
285
+ }
286
+ createLegendSheet(workbook) {
287
+ const sheet = workbook.addWorksheet('Legend', {
288
+ pageSetup: {
289
+ paperSize: undefined,
290
+ orientation: 'landscape',
291
+ fitToHeight: 1,
292
+ fitToWidth: 1,
293
+ blackAndWhite: false,
294
+ fitToPage: true,
295
+ showGridLines: false
296
+ }
297
+ });
298
+ sheet.getColumn(1).width = 30;
299
+ let row = 0;
300
+ this.workcodes.forEach(wc => {
301
+ if (wc.backcolor.toLowerCase() !== 'ffffff') {
302
+ row++;
303
+ sheet.getRow(row).height = 20;
304
+ const style = this.styles.get(wc.id);
305
+ const cellID = this.getCellID(1, row);
306
+ this.setCell(sheet, cellID, cellID, style, wc.title);
307
+ }
308
+ });
309
+ }
310
+ }
311
+ exports.ScheduleReport = ScheduleReport;