scheduler-node-models 1.0.134 → 1.0.136
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/general/report.d.ts +2 -2
- package/general/report.js +4 -1
- package/package.json +1 -1
- package/scheduler/reports/index.d.ts +2 -0
- package/scheduler/reports/index.js +2 -0
- package/scheduler/reports/leaveReport.d.ts +50 -0
- package/scheduler/reports/leaveReport.js +667 -0
- package/scheduler/reports/leaves.d.ts +22 -0
- package/scheduler/reports/leaves.js +116 -0
- package/scheduler/teams/company/holiday.d.ts +6 -0
- package/scheduler/teams/company/holiday.js +8 -0
package/general/report.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import { Style, Worksheet } from "exceljs";
|
1
|
+
import { RichText, Style, Worksheet } from "exceljs";
|
2
2
|
export declare class Formula {
|
3
3
|
formula: string;
|
4
4
|
constructor(formula: string);
|
5
5
|
}
|
6
6
|
export declare class Report {
|
7
7
|
getCellID(col: string | number, row: number): string;
|
8
|
-
setCell(sheet: Worksheet, begin: string, end: string, style: Partial<Style>, value: string | number | Formula, numFmt?: string): void;
|
8
|
+
setCell(sheet: Worksheet, begin: string, end: string, style: Partial<Style>, value: string | number | Formula | RichText[], numFmt?: string): void;
|
9
9
|
getDateString(date: Date): string;
|
10
10
|
getTimeString(minutes: number): string;
|
11
11
|
getNumberString(value: number, decimal: number): string;
|
package/general/report.js
CHANGED
@@ -48,9 +48,12 @@ class Report {
|
|
48
48
|
if (value instanceof Formula) {
|
49
49
|
sheet.getCell(begin).value = { formula: value.formula };
|
50
50
|
}
|
51
|
-
else {
|
51
|
+
else if (typeof value === 'string' || typeof value === 'number') {
|
52
52
|
sheet.getCell(begin).value = value;
|
53
53
|
}
|
54
|
+
else {
|
55
|
+
sheet.getCell(begin).value = { 'richText': value };
|
56
|
+
}
|
54
57
|
}
|
55
58
|
getDateString(date) {
|
56
59
|
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
package/package.json
CHANGED
@@ -18,3 +18,5 @@ __exportStar(require("./cofsReports"), exports);
|
|
18
18
|
__exportStar(require("./enterpriseSchedule"), exports);
|
19
19
|
__exportStar(require("./scheduleReport"), exports);
|
20
20
|
__exportStar(require("./chargeStatus"), exports);
|
21
|
+
__exportStar(require("./leaveReport"), exports);
|
22
|
+
__exportStar(require("./leaves"), exports);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Workbook, Worksheet } from "exceljs";
|
2
|
+
import { Report } from "../../general";
|
3
|
+
import { Employee, IEmployee } from "../employees";
|
4
|
+
import { IHoliday } from "../teams/company";
|
5
|
+
import { User } from "../../users";
|
6
|
+
import { IWorkcode } from "../labor";
|
7
|
+
export declare class LeaveReport extends Report {
|
8
|
+
private employees;
|
9
|
+
private holidays;
|
10
|
+
private fonts;
|
11
|
+
private fills;
|
12
|
+
private borders;
|
13
|
+
private alignments;
|
14
|
+
private numformats;
|
15
|
+
private workcodes;
|
16
|
+
constructor(holidays: IHoliday[], workcodes: IWorkcode[]);
|
17
|
+
/**
|
18
|
+
* This method is used to start the workbook creation and will call the other functional
|
19
|
+
* sheets to create the report.
|
20
|
+
* @param user The user object for the employee who is creating the report
|
21
|
+
* @param iEmps A list of employee objects to use in creating the report
|
22
|
+
* @param site A string value for the site identifier for the report
|
23
|
+
* @param reqDate A date object for the requested date
|
24
|
+
* @returns The workbook object with the report data.
|
25
|
+
*/
|
26
|
+
create(user: User, iEmps: IEmployee[], site: string, reqDate: Date): Workbook;
|
27
|
+
/**
|
28
|
+
* This function will create the basic style information to be used within the sheet
|
29
|
+
* cells, which consists for font styles, cell fill styles, borders, and alignments for
|
30
|
+
* the text within the cell. Plus a late addition of the various number formats to
|
31
|
+
* present.
|
32
|
+
*/
|
33
|
+
createStyles(): void;
|
34
|
+
/**
|
35
|
+
* This function will create the PTO/Holiday Section
|
36
|
+
* @param workbook The report object in which a sheet is created into.
|
37
|
+
* @param year the integer value for the year of the report
|
38
|
+
*/
|
39
|
+
createLeaveListing(workbook: Workbook, year: number, showHolidays: boolean): void;
|
40
|
+
/**
|
41
|
+
* This function will create the employee's Holidays and PTO report section
|
42
|
+
* @param sheet The worksheet object in which to add this employee's section
|
43
|
+
* @param emp The employee object used to determine the information about the section
|
44
|
+
* @param row The numeric value for the beginning of the section
|
45
|
+
* @param year The numeric value year the report is for.
|
46
|
+
* @param showHoliday A boolean value on whether to show the holidays for not.
|
47
|
+
* @returns the numeric value for the last row of this employee's section
|
48
|
+
*/
|
49
|
+
employeePTOHolidaySection(sheet: Worksheet, emp: Employee, row: number, year: number, showHoliday: boolean): number;
|
50
|
+
}
|
@@ -0,0 +1,667 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.LeaveReport = void 0;
|
4
|
+
const exceljs_1 = require("exceljs");
|
5
|
+
const general_1 = require("../../general");
|
6
|
+
const employees_1 = require("../employees");
|
7
|
+
const company_1 = require("../teams/company");
|
8
|
+
const leaves_1 = require("./leaves");
|
9
|
+
const labor_1 = require("../labor");
|
10
|
+
class LeaveReport extends general_1.Report {
|
11
|
+
employees;
|
12
|
+
holidays;
|
13
|
+
fonts;
|
14
|
+
fills;
|
15
|
+
borders;
|
16
|
+
alignments;
|
17
|
+
numformats;
|
18
|
+
workcodes;
|
19
|
+
constructor(holidays, workcodes) {
|
20
|
+
super();
|
21
|
+
this.employees = [];
|
22
|
+
this.holidays = [];
|
23
|
+
holidays.forEach(hol => {
|
24
|
+
this.holidays.push(new company_1.Holiday(hol));
|
25
|
+
});
|
26
|
+
this.holidays.sort((a, b) => a.compareTo(b));
|
27
|
+
this.fonts = new Map();
|
28
|
+
this.fills = new Map();
|
29
|
+
this.borders = new Map();
|
30
|
+
this.alignments = new Map();
|
31
|
+
this.numformats = new Map();
|
32
|
+
this.workcodes = new Map();
|
33
|
+
if (workcodes.length > 0) {
|
34
|
+
workcodes.forEach(wc => {
|
35
|
+
this.workcodes.set(wc.id, new labor_1.Workcode(wc));
|
36
|
+
});
|
37
|
+
}
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* This method is used to start the workbook creation and will call the other functional
|
41
|
+
* sheets to create the report.
|
42
|
+
* @param user The user object for the employee who is creating the report
|
43
|
+
* @param iEmps A list of employee objects to use in creating the report
|
44
|
+
* @param site A string value for the site identifier for the report
|
45
|
+
* @param reqDate A date object for the requested date
|
46
|
+
* @returns The workbook object with the report data.
|
47
|
+
*/
|
48
|
+
create(user, iEmps, site, reqDate) {
|
49
|
+
const start = new Date(Date.UTC(reqDate.getUTCFullYear(), 0, 1));
|
50
|
+
const end = new Date(Date.UTC(reqDate.getUTCFullYear() + 1, 0, 1));
|
51
|
+
iEmps.forEach(iemp => {
|
52
|
+
const emp = new employees_1.Employee(iemp);
|
53
|
+
if (emp.atSite(site, start, end)) {
|
54
|
+
this.employees.push(emp);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
this.employees.sort((a, b) => a.compareTo(b));
|
58
|
+
const workbook = new exceljs_1.Workbook();
|
59
|
+
workbook.creator = user.getFullName();
|
60
|
+
workbook.created = new Date();
|
61
|
+
this.createStyles();
|
62
|
+
return workbook;
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* This function will create the basic style information to be used within the sheet
|
66
|
+
* cells, which consists for font styles, cell fill styles, borders, and alignments for
|
67
|
+
* the text within the cell. Plus a late addition of the various number formats to
|
68
|
+
* present.
|
69
|
+
*/
|
70
|
+
createStyles() {
|
71
|
+
// set fonts
|
72
|
+
this.fonts.set("bold14", { bold: true, size: 14, color: { argb: 'ff000000' } });
|
73
|
+
this.fonts.set("bold12", { bold: true, size: 12, color: { argb: 'ff000000' } });
|
74
|
+
this.fonts.set("bold10", { bold: true, size: 10, color: { argb: 'ff000000' } });
|
75
|
+
this.fonts.set("nobold10", { bold: false, size: 10, color: { argb: 'ff000000' } });
|
76
|
+
this.fonts.set("bold8", { bold: true, size: 8, color: { argb: 'ff000000' } });
|
77
|
+
this.fonts.set("blue10", { bold: false, size: 10, color: { argb: 'ff00ffff' } });
|
78
|
+
this.fonts.set("noblue10", { bold: false, size: 10, color: { argb: 'ff3366ff' } });
|
79
|
+
this.fonts.set("blue8", { bold: true, size: 8, color: { argb: 'ff3366ff' } });
|
80
|
+
this.fonts.set("white14", { bold: true, size: 14, color: { argb: 'ffffffff' } });
|
81
|
+
this.fonts.set("white10", { bold: true, size: 10, color: { argb: 'ffffffff' } });
|
82
|
+
// set fills
|
83
|
+
this.fills.set('ptoname', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ff00ffff' } });
|
84
|
+
this.fills.set('asof', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ff800000' } });
|
85
|
+
this.fills.set('section', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ffcccccc' } });
|
86
|
+
this.fills.set('white', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ffffffff' } });
|
87
|
+
this.fills.set('dkgray', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ff999999' } });
|
88
|
+
this.fills.set('yellow', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ffffff00' } });
|
89
|
+
this.fills.set('month', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ff009933' } });
|
90
|
+
this.fills.set('ltblue', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ff66ffff' } });
|
91
|
+
this.fills.set('ltbrown', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'fffcd5b4' } });
|
92
|
+
this.fills.set('gray', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ffc0c0c0' } });
|
93
|
+
this.fills.set('ltgray', { type: 'pattern', pattern: 'solid', fgColor: { argb: 'ffbfbfbf' } });
|
94
|
+
// set borders
|
95
|
+
this.borders.set('blackthin', {
|
96
|
+
top: { style: 'thin', color: { argb: 'ff000000' } },
|
97
|
+
left: { style: 'thin', color: { argb: 'ff000000' } },
|
98
|
+
bottom: { style: 'thin', color: { argb: 'ff000000' } },
|
99
|
+
right: { style: 'thin', color: { argb: 'ff000000' } }
|
100
|
+
});
|
101
|
+
this.borders.set('up', {
|
102
|
+
top: { style: 'thick', color: { argb: 'ff000000' } },
|
103
|
+
left: { style: 'thin', color: { argb: 'ff000000' } },
|
104
|
+
bottom: undefined,
|
105
|
+
right: { style: 'thin', color: { argb: 'ff000000' } }
|
106
|
+
});
|
107
|
+
this.borders.set('dn', {
|
108
|
+
top: undefined,
|
109
|
+
left: { style: 'thin', color: { argb: 'ff000000' } },
|
110
|
+
bottom: { style: 'thick', color: { argb: 'ff000000' } },
|
111
|
+
right: { style: 'thin', color: { argb: 'ff000000' } }
|
112
|
+
});
|
113
|
+
this.borders.set('bottom', {
|
114
|
+
top: undefined,
|
115
|
+
left: undefined,
|
116
|
+
bottom: { style: 'thin', color: { argb: 'ff000000' } },
|
117
|
+
right: undefined
|
118
|
+
});
|
119
|
+
// set alignments
|
120
|
+
this.alignments.set('center', { horizontal: 'center', vertical: 'middle', wrapText: true });
|
121
|
+
this.alignments.set('leftctr', { horizontal: 'left', vertical: 'middle', wrapText: true });
|
122
|
+
// set number formats
|
123
|
+
this.numformats.set('num', '0.0;mm/dd/yyy;@');
|
124
|
+
this.numformats.set('int', '0;@');
|
125
|
+
this.numformats.set('bal', '0.0;[Red]-0.0;@');
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* This function will create the PTO/Holiday Section
|
129
|
+
* @param workbook The report object in which a sheet is created into.
|
130
|
+
* @param year the integer value for the year of the report
|
131
|
+
*/
|
132
|
+
createLeaveListing(workbook, year, showHolidays) {
|
133
|
+
const sheetLabel = `${year} PTO-Hol`;
|
134
|
+
const sheet = workbook.addWorksheet(sheetLabel, {
|
135
|
+
pageSetup: {
|
136
|
+
paperSize: undefined,
|
137
|
+
orientation: 'landscape',
|
138
|
+
fitToHeight: 1,
|
139
|
+
fitToWidth: 1,
|
140
|
+
blackAndWhite: false,
|
141
|
+
fitToPage: true,
|
142
|
+
showGridLines: false,
|
143
|
+
horizontalCentered: true,
|
144
|
+
verticalCentered: true
|
145
|
+
},
|
146
|
+
properties: {
|
147
|
+
defaultRowHeight: 20,
|
148
|
+
defaultColWidth: 4,
|
149
|
+
outlineLevelCol: 0
|
150
|
+
},
|
151
|
+
views: [{
|
152
|
+
state: 'frozen',
|
153
|
+
ySplit: 2
|
154
|
+
}]
|
155
|
+
});
|
156
|
+
let extendWidth = 3;
|
157
|
+
if (showHolidays) {
|
158
|
+
extendWidth += 4;
|
159
|
+
}
|
160
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
161
|
+
month: '2-digit',
|
162
|
+
day: '2-digit',
|
163
|
+
year: 'numeric'
|
164
|
+
});
|
165
|
+
const now = new Date();
|
166
|
+
// add current as of reference
|
167
|
+
let style = {
|
168
|
+
fill: this.fills.get('asof'),
|
169
|
+
font: this.fonts.get("bold12"),
|
170
|
+
alignment: this.alignments.get("center"),
|
171
|
+
border: this.borders.get("blackthin")
|
172
|
+
};
|
173
|
+
this.setCell(sheet, this.getCellID(0, 1), this.getCellID(extendWidth, 1), style, formatter.format(now));
|
174
|
+
// set column widths
|
175
|
+
if (showHolidays) {
|
176
|
+
sheet.getColumn(1).width = 4.5;
|
177
|
+
sheet.getColumn(2).width = 13;
|
178
|
+
sheet.getColumn(3).width = 30;
|
179
|
+
sheet.getColumn(4).width = 7;
|
180
|
+
sheet.getColumn(5).width = 30;
|
181
|
+
sheet.getColumn(6).width = 7;
|
182
|
+
sheet.getColumn(7).width = 7;
|
183
|
+
sheet.getColumn(8).width = 7;
|
184
|
+
sheet.getColumn(9).width = 7;
|
185
|
+
}
|
186
|
+
else {
|
187
|
+
sheet.getColumn(1).width = 30;
|
188
|
+
sheet.getColumn(2).width = 7;
|
189
|
+
sheet.getColumn(3).width = 7;
|
190
|
+
sheet.getColumn(4).width = 7;
|
191
|
+
sheet.getColumn(5).width = 7;
|
192
|
+
}
|
193
|
+
let row = 2;
|
194
|
+
this.employees.forEach(emp => {
|
195
|
+
row = this.employeePTOHolidaySection(sheet, emp, row, year, showHolidays) + 1;
|
196
|
+
});
|
197
|
+
}
|
198
|
+
/**
|
199
|
+
* This function will create the employee's Holidays and PTO report section
|
200
|
+
* @param sheet The worksheet object in which to add this employee's section
|
201
|
+
* @param emp The employee object used to determine the information about the section
|
202
|
+
* @param row The numeric value for the beginning of the section
|
203
|
+
* @param year The numeric value year the report is for.
|
204
|
+
* @param showHoliday A boolean value on whether to show the holidays for not.
|
205
|
+
* @returns the numeric value for the last row of this employee's section
|
206
|
+
*/
|
207
|
+
employeePTOHolidaySection(sheet, emp, row, year, showHoliday) {
|
208
|
+
let annual = 0.0;
|
209
|
+
let carry = 0.0;
|
210
|
+
emp.balance.forEach(bal => {
|
211
|
+
if (bal.year === year) {
|
212
|
+
annual = bal.annual;
|
213
|
+
carry = bal.carryover;
|
214
|
+
}
|
215
|
+
});
|
216
|
+
let extendedWidth = 5;
|
217
|
+
if (showHoliday) {
|
218
|
+
extendedWidth += 4;
|
219
|
+
}
|
220
|
+
const tdate = new Date(Date.UTC(year, 5, 1));
|
221
|
+
const std = emp.getStandardWorkday(tdate);
|
222
|
+
let style = {
|
223
|
+
fill: this.fills.get("ptoname"),
|
224
|
+
font: this.fonts.get("bold12"),
|
225
|
+
alignment: this.alignments.get("center"),
|
226
|
+
border: this.borders.get("blackthin")
|
227
|
+
};
|
228
|
+
this.setCell(sheet, this.getCellID(0, row), this.getCellID(extendedWidth - 1, row), style, emp.name.getLastFirst());
|
229
|
+
row++;
|
230
|
+
let col = 0;
|
231
|
+
style = {
|
232
|
+
fill: this.fills.get('section'),
|
233
|
+
font: this.fonts.get('bold10'),
|
234
|
+
alignment: this.alignments.get('center'),
|
235
|
+
border: this.borders.get('blackthin')
|
236
|
+
};
|
237
|
+
if (showHoliday) {
|
238
|
+
this.setCell(sheet, this.getCellID(0, row), this.getCellID(3, row), style, 'Holidays');
|
239
|
+
col = 4;
|
240
|
+
}
|
241
|
+
this.setCell(sheet, this.getCellID(col, row), this.getCellID(col + 4, row), style, 'Leaves');
|
242
|
+
// create holidays and leave months
|
243
|
+
const months = [];
|
244
|
+
for (let i = 0; i < 12; i++) {
|
245
|
+
const dtMonth = new Date(Date.UTC(year, i, 1));
|
246
|
+
months.push(new leaves_1.LeaveMonth(dtMonth, false));
|
247
|
+
}
|
248
|
+
months.sort((a, b) => a.compareTo(b));
|
249
|
+
const holidays = [];
|
250
|
+
this.holidays.forEach(hol => {
|
251
|
+
const dt = hol.getActual(year);
|
252
|
+
if (dt) {
|
253
|
+
holidays.push(new leaves_1.LeaveMonth(dt, false, hol));
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
holidays.push(new leaves_1.LeaveMonth(new Date(0), false, hol));
|
257
|
+
}
|
258
|
+
});
|
259
|
+
holidays.sort((a, b) => a.compareTo(b));
|
260
|
+
// add labels to the sections
|
261
|
+
row++;
|
262
|
+
col = 0;
|
263
|
+
style = {
|
264
|
+
fill: this.fills.get('section'),
|
265
|
+
font: this.fonts.get('bold8'),
|
266
|
+
alignment: this.alignments.get('center'),
|
267
|
+
border: this.borders.get('blackthin')
|
268
|
+
};
|
269
|
+
if (showHoliday) {
|
270
|
+
this.setCell(sheet, this.getCellID(0, row), this.getCellID(0, row), style, '');
|
271
|
+
this.setCell(sheet, this.getCellID(1, row), this.getCellID(1, row), style, 'Reference Date');
|
272
|
+
this.setCell(sheet, this.getCellID(2, row), this.getCellID(2, row), style, 'Hours');
|
273
|
+
const rcell = sheet.getCell(this.getCellID(3, row));
|
274
|
+
rcell.style = {
|
275
|
+
fill: this.fills.get('section'),
|
276
|
+
font: this.fonts.get('bold8'),
|
277
|
+
alignment: this.alignments.get('center'),
|
278
|
+
border: this.borders.get('blackthin')
|
279
|
+
};
|
280
|
+
rcell.value = { 'richText': [
|
281
|
+
{ 'font': { 'size': 8, 'bold': true, 'color': { 'argb': 'ff000000' } }, 'text': 'Date Taken (' },
|
282
|
+
{ 'font': { 'size': 8, 'bold': true, 'color': { 'argb': 'ff3366ff' } }, 'text': 'Projected' },
|
283
|
+
{ 'font': { 'size': 8, 'bold': true, 'color': { 'argb': 'ff000000' } }, 'text': ')' }
|
284
|
+
] };
|
285
|
+
col = 4;
|
286
|
+
}
|
287
|
+
sheet.mergeCells(this.getCellID(col, row), this.getCellID(col + 1, row));
|
288
|
+
let cell = sheet.getCell(this.getCellID(col, row));
|
289
|
+
cell.style = {
|
290
|
+
fill: this.fills.get('section'),
|
291
|
+
font: this.fonts.get('bold8'),
|
292
|
+
alignment: this.alignments.get('center'),
|
293
|
+
border: this.borders.get('blackthin')
|
294
|
+
};
|
295
|
+
cell.value = { 'richText': [
|
296
|
+
{ 'font': { 'size': 8, 'bold': true, 'color': { 'argb': 'ff000000' } }, 'text': 'Leave Taken (' },
|
297
|
+
{ 'font': { 'size': 8, 'bold': true, 'color': { 'argb': 'ff3366ff' } }, 'text': 'Projected' },
|
298
|
+
{ 'font': { 'size': 8, 'bold': true, 'color': { 'argb': 'ff000000' } }, 'text': ')' }
|
299
|
+
] };
|
300
|
+
style = {
|
301
|
+
fill: this.fills.get('section'),
|
302
|
+
font: this.fonts.get('bold8'),
|
303
|
+
alignment: this.alignments.get('center'),
|
304
|
+
border: this.borders.get('blackthin')
|
305
|
+
};
|
306
|
+
this.setCell(sheet, this.getCellID(col + 2, row), this.getCellID(col + 2, row), style, "Taken");
|
307
|
+
style.font = this.fonts.get('bblue8');
|
308
|
+
this.setCell(sheet, this.getCellID(col + 3, row), this.getCellID(col + 3, row), style, "Request");
|
309
|
+
row++;
|
310
|
+
const startAsgmt = emp.assignments[0];
|
311
|
+
const endAsgmt = emp.assignments[emp.assignments.length - 1];
|
312
|
+
// ensure months are clear, plus check if the month should be disabled.
|
313
|
+
months.forEach((month, m) => {
|
314
|
+
const startMonth = new Date(Date.UTC(month.month.getUTCFullYear(), month.month.getUTCMonth() + 1, 1));
|
315
|
+
month.periods = [];
|
316
|
+
month.disabled = (startAsgmt.startDate.getTime() > startMonth.getTime()
|
317
|
+
|| endAsgmt.endDate.getTime() < month.month.getTime());
|
318
|
+
months[m] = month;
|
319
|
+
});
|
320
|
+
// ensure the holidays are clear, plus check if the holiday should be disabled.
|
321
|
+
// Only holidays with id of "H" can be disabled, floating holidays aren't.
|
322
|
+
holidays.forEach((hol, h) => {
|
323
|
+
hol.periods = [];
|
324
|
+
if (hol.holiday && hol.holiday.id.toLowerCase().substring(0, 1) === 'h') {
|
325
|
+
hol.disabled = (startAsgmt.startDate.getTime() > hol.month.getTime()
|
326
|
+
|| endAsgmt.endDate.getTime() < hol.month.getTime());
|
327
|
+
}
|
328
|
+
holidays[h] = hol;
|
329
|
+
});
|
330
|
+
// sort the employee's leaves, then put the ones for the selected year into arrays
|
331
|
+
// for further use.
|
332
|
+
emp.leaves.sort((a, b) => a.compareTo(b));
|
333
|
+
const empHolidays = [];
|
334
|
+
const empOtherLeaves = [];
|
335
|
+
emp.leaves.forEach(lv => {
|
336
|
+
if (lv.leavedate.getUTCFullYear() === year) {
|
337
|
+
if (lv.code.toLowerCase() === 'h') {
|
338
|
+
empHolidays.push(new employees_1.Leave(lv));
|
339
|
+
}
|
340
|
+
else {
|
341
|
+
empOtherLeaves.push(new employees_1.Leave(lv));
|
342
|
+
}
|
343
|
+
}
|
344
|
+
});
|
345
|
+
// next process the employee's holidays into the holidays array
|
346
|
+
// 1. Go through the leaves and place the tagged holidays into the holiday list
|
347
|
+
empHolidays.forEach((empHol, eh) => {
|
348
|
+
if (empHol.tagday && empHol.tagday !== '') {
|
349
|
+
const code = empHol.tagday.substring(0, 1);
|
350
|
+
const num = Number(empHol.tagday.substring(1));
|
351
|
+
holidays.forEach((hol, h) => {
|
352
|
+
if (hol.holiday && hol.holiday.id.toLowerCase() === code
|
353
|
+
&& hol.holiday.sort === num) {
|
354
|
+
hol.periods.push(new leaves_1.LeavePeriod(empHol.code, new Date(empHol.leavedate), empHol.status, new employees_1.Leave(empHol)));
|
355
|
+
empHol.used = true;
|
356
|
+
holidays[h] = hol;
|
357
|
+
empHolidays[eh] = empHol;
|
358
|
+
}
|
359
|
+
});
|
360
|
+
}
|
361
|
+
});
|
362
|
+
// 2. For those not tagged, actuals are listed first.
|
363
|
+
empHolidays.forEach((empHol, eh) => {
|
364
|
+
if (!empHol.used && empHol.status.toLowerCase() === 'actual') {
|
365
|
+
holidays.forEach((hol, h) => {
|
366
|
+
if (hol.holiday && hol.holiday.id.toLowerCase() === 'h'
|
367
|
+
&& !hol.disabled && hol.getHours() + empHol.hours <= 8.0) {
|
368
|
+
hol.periods.push(new leaves_1.LeavePeriod(empHol.code, empHol.leavedate, empHol.status, new employees_1.Leave(empHol)));
|
369
|
+
empHol.used = true;
|
370
|
+
holidays[h] = hol;
|
371
|
+
empHolidays[eh] = empHol;
|
372
|
+
}
|
373
|
+
});
|
374
|
+
}
|
375
|
+
});
|
376
|
+
// 3. Next check for those holidays that match the actual date
|
377
|
+
empHolidays.forEach((empHol, eh) => {
|
378
|
+
if (!empHol.used) {
|
379
|
+
holidays.forEach((hol, h) => {
|
380
|
+
if (hol.holiday && hol.holiday.id.toLowerCase() === 'h'
|
381
|
+
&& hol.month.getTime() === empHol.leavedate.getTime()
|
382
|
+
&& !hol.disabled && hol.getHours() + empHol.hours <= 8.0) {
|
383
|
+
hol.periods.push(new leaves_1.LeavePeriod(empHol.code, empHol.leavedate, empHol.status, new employees_1.Leave(empHol)));
|
384
|
+
empHol.used = true;
|
385
|
+
holidays[h] = hol;
|
386
|
+
empHolidays[eh] = empHol;
|
387
|
+
}
|
388
|
+
});
|
389
|
+
}
|
390
|
+
});
|
391
|
+
// 4. next, with any holidays not already used
|
392
|
+
empHolidays.forEach((empHol, eh) => {
|
393
|
+
if (!empHol.used) {
|
394
|
+
let found = false;
|
395
|
+
holidays.forEach((hol, h) => {
|
396
|
+
if (!found && !hol.disabled) {
|
397
|
+
if (hol.getHours() + empHol.hours <= 8.0) {
|
398
|
+
hol.periods.push(new leaves_1.LeavePeriod(empHol.code, empHol.leavedate, empHol.status, new employees_1.Leave(empHol)));
|
399
|
+
holidays[h] = hol;
|
400
|
+
found = true;
|
401
|
+
empHol.used = true;
|
402
|
+
}
|
403
|
+
}
|
404
|
+
});
|
405
|
+
}
|
406
|
+
});
|
407
|
+
// 5. if there are any unused holidays, plug them into disabled holidays.
|
408
|
+
empHolidays.forEach((empHol, eh) => {
|
409
|
+
if (!empHol.used) {
|
410
|
+
let found = false;
|
411
|
+
holidays.forEach((hol, h) => {
|
412
|
+
if (!found && hol.disabled) {
|
413
|
+
found = true;
|
414
|
+
hol.periods.push(new leaves_1.LeavePeriod(empHol.code, empHol.leavedate, empHol.status, new employees_1.Leave(empHol)));
|
415
|
+
}
|
416
|
+
});
|
417
|
+
}
|
418
|
+
});
|
419
|
+
// next, place the non-holiday leaves into the months they are using in.
|
420
|
+
empOtherLeaves.forEach(lv => {
|
421
|
+
months.forEach((month, m) => {
|
422
|
+
if (month.month.getUTCFullYear() === lv.leavedate.getUTCFullYear()
|
423
|
+
&& month.month.getUTCMonth() === lv.leavedate.getUTCMonth()) {
|
424
|
+
let found = false;
|
425
|
+
month.periods.forEach((prd, p) => {
|
426
|
+
if (!found && prd.addLeave(lv)) {
|
427
|
+
found = true;
|
428
|
+
month.periods[p] = prd;
|
429
|
+
}
|
430
|
+
});
|
431
|
+
if (!found) {
|
432
|
+
month.periods.push(new leaves_1.LeavePeriod(lv.code, lv.leavedate, lv.status, new employees_1.Leave(lv)));
|
433
|
+
}
|
434
|
+
months[m] = month;
|
435
|
+
}
|
436
|
+
});
|
437
|
+
});
|
438
|
+
// now insert the holidays for companies that have holidays designated.
|
439
|
+
const now = new Date();
|
440
|
+
col = 0;
|
441
|
+
if (showHoliday) {
|
442
|
+
holidays.sort((a, b) => a.compareTo(b));
|
443
|
+
holidays.forEach((hol, h) => {
|
444
|
+
hol.periods.sort((a, b) => a.compareTo(b));
|
445
|
+
const holRow = row + h;
|
446
|
+
style = {
|
447
|
+
fill: this.fills.get('white'),
|
448
|
+
font: this.fonts.get('bold10'),
|
449
|
+
alignment: this.alignments.get('center'),
|
450
|
+
border: this.borders.get('blackthin'),
|
451
|
+
numFmt: this.numformats.get('num')
|
452
|
+
};
|
453
|
+
if (hol.disabled) {
|
454
|
+
style.fill = this.fills.get('dkgray');
|
455
|
+
style.font = this.fonts.get('nobold10');
|
456
|
+
}
|
457
|
+
else if (hol.holiday && hol.holiday.getActual(year)
|
458
|
+
&& hol.holiday.getActual(year).getTime() > now.getTime()) {
|
459
|
+
style.fill = this.fills.get('white');
|
460
|
+
style.font = this.fonts.get('nobold10');
|
461
|
+
}
|
462
|
+
this.setCell(sheet, this.getCellID(col, holRow), this.getCellID(col, holRow), style, hol.holiday.toString());
|
463
|
+
if (hol.holiday.getActual(year)) {
|
464
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
465
|
+
month: 'short',
|
466
|
+
day: '2-digit',
|
467
|
+
year: '2-digit'
|
468
|
+
});
|
469
|
+
this.setCell(sheet, this.getCellID(col + 1, holRow), this.getCellID(col + 1, holRow), style, formatter.format(hol.holiday.getActual(year)));
|
470
|
+
}
|
471
|
+
else {
|
472
|
+
this.setCell(sheet, this.getCellID(col + 1, holRow), this.getCellID(col + 1, holRow), style, '');
|
473
|
+
}
|
474
|
+
const cellText = [];
|
475
|
+
hol.periods.forEach((prd, p) => {
|
476
|
+
prd.leaves.forEach((lv, l) => {
|
477
|
+
if (p > 0 || l > 0) {
|
478
|
+
cellText.push({ 'font': { 'size': 10, 'bold': true,
|
479
|
+
'color': { 'argb': 'ff000000' } }, 'text': ',' });
|
480
|
+
}
|
481
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
482
|
+
day: '2-digit',
|
483
|
+
month: 'short'
|
484
|
+
});
|
485
|
+
if (lv.status.toLowerCase() === 'actual') {
|
486
|
+
cellText.push({ 'font': { 'size': 10, 'bold': true,
|
487
|
+
'color': { 'argb': 'ff000000' } }, 'text': formatter.format(lv.leavedate) });
|
488
|
+
if (lv.hours < 8) {
|
489
|
+
cellText.push({ 'font': { 'size': 7, 'bold': true, 'vertAlign': 'superscript',
|
490
|
+
'color': { 'argb': 'ff000000' } }, 'text': `(${lv.hours.toFixed(1)})` });
|
491
|
+
}
|
492
|
+
}
|
493
|
+
else {
|
494
|
+
cellText.push({ 'font': { 'size': 10, 'bold': true,
|
495
|
+
'color': { 'argb': 'ff3366ff' } }, 'text': formatter.format(lv.leavedate) });
|
496
|
+
if (lv.hours < 8) {
|
497
|
+
cellText.push({ 'font': { 'size': 7, 'bold': true, 'vertAlign': 'superscript',
|
498
|
+
'color': { 'argb': 'ff3366ff' } }, 'text': `(${lv.hours.toFixed(1)})` });
|
499
|
+
}
|
500
|
+
}
|
501
|
+
});
|
502
|
+
});
|
503
|
+
this.setCell(sheet, this.getCellID(col + 3, holRow), this.getCellID(col + 3, holRow), {
|
504
|
+
fill: this.fills.get('white'),
|
505
|
+
alignment: this.alignments.get('center'),
|
506
|
+
border: this.borders.get('blackthin')
|
507
|
+
}, cellText);
|
508
|
+
this.setCell(sheet, this.getCellID(col + 3, holRow), this.getCellID(col + 3, holRow), style, hol.getHours());
|
509
|
+
});
|
510
|
+
col = 4;
|
511
|
+
}
|
512
|
+
months.sort((a, b) => a.compareTo(b));
|
513
|
+
months.forEach((month, m) => {
|
514
|
+
const lvRow = row + m;
|
515
|
+
style = {
|
516
|
+
fill: this.fills.get('white'),
|
517
|
+
font: this.fonts.get('nobold10'),
|
518
|
+
alignment: this.alignments.get('leftctr'),
|
519
|
+
border: this.borders.get('blackthin'),
|
520
|
+
numFmt: this.numformats.get('num')
|
521
|
+
};
|
522
|
+
if (month.disabled) {
|
523
|
+
style = {
|
524
|
+
fill: this.fills.get('dkgray'),
|
525
|
+
font: this.fonts.get('nobold10'),
|
526
|
+
alignment: this.alignments.get('leftctr'),
|
527
|
+
border: this.borders.get('blackthin')
|
528
|
+
};
|
529
|
+
}
|
530
|
+
const cellText = [];
|
531
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
532
|
+
month: 'short'
|
533
|
+
});
|
534
|
+
cellText.push({ 'font': { 'size': 10, 'bold': true,
|
535
|
+
'color': { 'argb': 'ffff0000' } }, 'text': `${formatter.format(month.month)}: ` });
|
536
|
+
month.periods.forEach((prd, p) => {
|
537
|
+
if (p > 0) {
|
538
|
+
cellText.push({ 'font': { 'size': 10, 'bold': true,
|
539
|
+
'color': { 'argb': 'ff000000' } }, 'text': ',' });
|
540
|
+
}
|
541
|
+
let text = '';
|
542
|
+
let bHours = false;
|
543
|
+
if (prd.start.getTime() === prd.end.getTime()) {
|
544
|
+
text = `${prd.start.getDate()}-${prd.end.getDate()}`;
|
545
|
+
}
|
546
|
+
else {
|
547
|
+
text = `${prd.start.getDate()}`;
|
548
|
+
if (prd.getHours() < std) {
|
549
|
+
bHours = true;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
let color = 'ff';
|
553
|
+
if (prd.code.toLowerCase() === 'v' && prd.status.toLowerCase() === 'actual') {
|
554
|
+
color += '000000';
|
555
|
+
}
|
556
|
+
else {
|
557
|
+
const wc = this.workcodes.get(prd.code);
|
558
|
+
if (wc) {
|
559
|
+
color += wc.backcolor;
|
560
|
+
}
|
561
|
+
else {
|
562
|
+
color += '000000';
|
563
|
+
}
|
564
|
+
}
|
565
|
+
cellText.push({ 'font': { 'size': 10, 'bold': true, 'color': { 'argb': color } },
|
566
|
+
'text': text });
|
567
|
+
if (bHours) {
|
568
|
+
cellText.push({ 'font': { 'size': 7, 'bold': true, 'vertAlign': 'superscript',
|
569
|
+
'color': { 'argb': color } }, 'text': `(${prd.getHours().toFixed(1)})` });
|
570
|
+
}
|
571
|
+
});
|
572
|
+
this.setCell(sheet, this.getCellID(col, lvRow), this.getCellID(col + 1, lvRow), style, cellText);
|
573
|
+
style = {
|
574
|
+
fill: this.fills.get('white'),
|
575
|
+
font: this.fonts.get('nobold10'),
|
576
|
+
alignment: this.alignments.get('center'),
|
577
|
+
border: this.borders.get('blackthin'),
|
578
|
+
numFmt: this.numformats.get('num')
|
579
|
+
};
|
580
|
+
if (month.disabled) {
|
581
|
+
style.fill = this.fills.get('dkgray');
|
582
|
+
}
|
583
|
+
this.setCell(sheet, this.getCellID(col + 2, lvRow), this.getCellID(col + 2, lvRow), style, month.getHours('v', true));
|
584
|
+
style.font = this.fonts.get('noblue10');
|
585
|
+
this.setCell(sheet, this.getCellID(col + 3, lvRow), this.getCellID(col + 3, lvRow), style, month.getHours('v', false));
|
586
|
+
});
|
587
|
+
// now add the totals section to the employee's chart
|
588
|
+
if (months.length > holidays.length) {
|
589
|
+
row += months.length;
|
590
|
+
}
|
591
|
+
else {
|
592
|
+
row += holidays.length;
|
593
|
+
}
|
594
|
+
style = {
|
595
|
+
fill: this.fills.get('section'),
|
596
|
+
font: this.fonts.get('bold8'),
|
597
|
+
alignment: this.alignments.get('center'),
|
598
|
+
border: this.borders.get('blackthin')
|
599
|
+
};
|
600
|
+
col = 0;
|
601
|
+
if (showHoliday) {
|
602
|
+
this.setCell(sheet, this.getCellID(col, row), this.getCellID(col, row), style, '');
|
603
|
+
this.setCell(sheet, this.getCellID(col + 1, row), this.getCellID(col + 1, row), style, 'Days Left');
|
604
|
+
this.setCell(sheet, this.getCellID(col + 2, row), this.getCellID(col + 2, row), style, 'Hours Left');
|
605
|
+
this.setCell(sheet, this.getCellID(col + 3, row), this.getCellID(col + 3, row), style, 'Total Hours');
|
606
|
+
let daysLeft = 0;
|
607
|
+
let hoursTaken = 0;
|
608
|
+
holidays.forEach(hol => {
|
609
|
+
if (hol.getHours() < 8 && !hol.disabled) {
|
610
|
+
daysLeft++;
|
611
|
+
}
|
612
|
+
if (hol.getHours() > 0) {
|
613
|
+
hoursTaken += hol.getHours();
|
614
|
+
}
|
615
|
+
});
|
616
|
+
const hoursLeft = (holidays.length * 8.0) - hoursTaken;
|
617
|
+
style = {
|
618
|
+
fill: this.fills.get('white'),
|
619
|
+
font: this.fonts.get('bold10'),
|
620
|
+
alignment: this.alignments.get('center'),
|
621
|
+
border: this.borders.get('blackthin'),
|
622
|
+
numFmt: this.numformats.get('int')
|
623
|
+
};
|
624
|
+
this.setCell(sheet, this.getCellID(col, row + 1), this.getCellID(col, row + 1), style, '');
|
625
|
+
this.setCell(sheet, this.getCellID(col + 1, row + 1), this.getCellID(col + 1, row + 1), style, daysLeft);
|
626
|
+
this.setCell(sheet, this.getCellID(col + 2, row + 1), this.getCellID(col + 2, row + 1), style, hoursLeft);
|
627
|
+
this.setCell(sheet, this.getCellID(col + 3, row + 1), this.getCellID(col + 3, row + 1), style, hoursTaken);
|
628
|
+
col = 4;
|
629
|
+
}
|
630
|
+
style = {
|
631
|
+
fill: this.fills.get('section'),
|
632
|
+
font: this.fonts.get('bold8'),
|
633
|
+
alignment: this.alignments.get('center'),
|
634
|
+
border: this.borders.get('blackthin')
|
635
|
+
};
|
636
|
+
this.setCell(sheet, this.getCellID(col, row), this.getCellID(col, row), style, 'Annual Leave');
|
637
|
+
this.setCell(sheet, this.getCellID(col + 1, row), this.getCellID(col + 1, row), style, 'Carry');
|
638
|
+
this.setCell(sheet, this.getCellID(col + 2, row), this.getCellID(col + 2, row), style, 'Total Taken');
|
639
|
+
this.setCell(sheet, this.getCellID(col + 3, row), this.getCellID(col + 3, row), style, 'Request');
|
640
|
+
this.setCell(sheet, this.getCellID(col + 4, row), this.getCellID(col + 4, row), style, 'Balance');
|
641
|
+
let totalTaken = 0;
|
642
|
+
let totalRequested = 0;
|
643
|
+
months.forEach(month => {
|
644
|
+
totalRequested += month.getHours('v', false);
|
645
|
+
totalTaken += month.getHours('v', true);
|
646
|
+
});
|
647
|
+
const balance = (annual + carry) - (totalTaken + totalRequested);
|
648
|
+
style = {
|
649
|
+
fill: this.fills.get('white'),
|
650
|
+
font: this.fonts.get('bold10'),
|
651
|
+
alignment: this.alignments.get('center'),
|
652
|
+
border: this.borders.get('blackthin'),
|
653
|
+
numFmt: this.numformats.get('num')
|
654
|
+
};
|
655
|
+
this.setCell(sheet, this.getCellID(col, row + 1), this.getCellID(col, row + 1), style, annual);
|
656
|
+
this.setCell(sheet, this.getCellID(col + 1, row + 1), this.getCellID(col + 1, row + 1), style, carry);
|
657
|
+
this.setCell(sheet, this.getCellID(col + 2, row + 1), this.getCellID(col + 2, row + 1), style, totalTaken);
|
658
|
+
style.font = this.fonts.get('noblue10');
|
659
|
+
this.setCell(sheet, this.getCellID(col + 3, row + 1), this.getCellID(col + 3, row + 1), style, totalRequested);
|
660
|
+
style.fill = this.fills.get('yellow');
|
661
|
+
style.font = this.fonts.get('nobold10');
|
662
|
+
style.numFmt = this.numformats.get('bal');
|
663
|
+
this.setCell(sheet, this.getCellID(col + 4, row + 1), this.getCellID(col + 4, row + 1), style, balance);
|
664
|
+
return row + 2;
|
665
|
+
}
|
666
|
+
}
|
667
|
+
exports.LeaveReport = LeaveReport;
|
@@ -0,0 +1,22 @@
|
|
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(code: string, start: Date, status: string, leave?: Leave);
|
10
|
+
compareTo(other?: LeavePeriod): number;
|
11
|
+
getHours(type?: string, actual?: boolean): number;
|
12
|
+
addLeave(leave: Leave): boolean;
|
13
|
+
}
|
14
|
+
export declare class LeaveMonth {
|
15
|
+
month: Date;
|
16
|
+
holiday?: Holiday;
|
17
|
+
disabled: boolean;
|
18
|
+
periods: LeavePeriod[];
|
19
|
+
constructor(start: Date, disabled: boolean, holiday?: Holiday);
|
20
|
+
compareTo(other?: LeaveMonth): number;
|
21
|
+
getHours(type?: string, actuals?: boolean): number;
|
22
|
+
}
|
@@ -0,0 +1,116 @@
|
|
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(code, start, status, leave) {
|
13
|
+
this.code = code;
|
14
|
+
this.start = new Date(start);
|
15
|
+
this.end = new Date(start);
|
16
|
+
this.status = status;
|
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
|
+
// the leave's hours and code must equal the previous one, unless this is the
|
51
|
+
// first leave
|
52
|
+
try {
|
53
|
+
if (this.leaves.length === 0) {
|
54
|
+
this.leaves.push(new employees_1.Leave(leave));
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
let add = true;
|
59
|
+
this.leaves.forEach(lv => {
|
60
|
+
if (leave.hours === lv.hours
|
61
|
+
&& leave.code.toLowerCase() !== lv.code.toLowerCase()
|
62
|
+
&& leave.status.toLowerCase() !== lv.code.toLowerCase()
|
63
|
+
&& leave.leavedate.getUTCDate() !== (this.end.getUTCDate() + 1)) {
|
64
|
+
add = false;
|
65
|
+
}
|
66
|
+
});
|
67
|
+
if (add) {
|
68
|
+
this.leaves.push(new employees_1.Leave(leave));
|
69
|
+
this.end = new Date(leave.leavedate);
|
70
|
+
}
|
71
|
+
return add;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
catch (error) {
|
75
|
+
return false;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
exports.LeavePeriod = LeavePeriod;
|
80
|
+
class LeaveMonth {
|
81
|
+
month;
|
82
|
+
holiday;
|
83
|
+
disabled;
|
84
|
+
periods;
|
85
|
+
constructor(start, disabled, holiday) {
|
86
|
+
this.month = new Date(start);
|
87
|
+
this.disabled = disabled;
|
88
|
+
this.periods = [];
|
89
|
+
this.holiday = undefined;
|
90
|
+
if (holiday) {
|
91
|
+
this.holiday = new company_1.Holiday(holiday);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
compareTo(other) {
|
95
|
+
if (other) {
|
96
|
+
if (this.holiday && other.holiday) {
|
97
|
+
if (this.holiday.id.toLowerCase() === other.holiday.id.toLowerCase()) {
|
98
|
+
return (this.holiday.sort < other.holiday.sort) ? -1 : 1;
|
99
|
+
}
|
100
|
+
return (this.holiday.id.toLowerCase() === 'h') ? -1 : 1;
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
return (this.month.getTime() < other.month.getTime()) ? -1 : 1;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
return -1;
|
107
|
+
}
|
108
|
+
getHours(type, actuals) {
|
109
|
+
let hours = 0.0;
|
110
|
+
this.periods.forEach(prd => {
|
111
|
+
hours += prd.getHours(type, actuals);
|
112
|
+
});
|
113
|
+
return hours;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
exports.LeaveMonth = LeaveMonth;
|
@@ -23,6 +23,12 @@ export declare class Holiday implements IHoliday {
|
|
23
23
|
sort: number;
|
24
24
|
actualdates: Date[];
|
25
25
|
constructor(hol?: IHoliday);
|
26
|
+
/**
|
27
|
+
* This function will provide string for the combined id and sort code into a single
|
28
|
+
* string value.
|
29
|
+
* @returns A string value for the id and sort code.
|
30
|
+
*/
|
31
|
+
toString(): string;
|
26
32
|
/**
|
27
33
|
* This function is used in sorting holidays by comparing their ids and sort values
|
28
34
|
* @param other The holiday object used in comparison
|
@@ -27,6 +27,14 @@ class Holiday {
|
|
27
27
|
this.actualdates.sort((a, b) => (a.getTime() < b.getTime()) ? -1 : 1);
|
28
28
|
}
|
29
29
|
}
|
30
|
+
/**
|
31
|
+
* This function will provide string for the combined id and sort code into a single
|
32
|
+
* string value.
|
33
|
+
* @returns A string value for the id and sort code.
|
34
|
+
*/
|
35
|
+
toString() {
|
36
|
+
return `${this.id}${this.sort}`.toUpperCase();
|
37
|
+
}
|
30
38
|
/**
|
31
39
|
* This function is used in sorting holidays by comparing their ids and sort values
|
32
40
|
* @param other The holiday object used in comparison
|