scheduler-node-models 1.2.87 → 1.2.89
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/package.json
CHANGED
|
@@ -10,9 +10,10 @@ export declare class ExcelRowIngest {
|
|
|
10
10
|
site: Site;
|
|
11
11
|
company: string;
|
|
12
12
|
docDate: Date;
|
|
13
|
+
results: ExcelRow[];
|
|
13
14
|
constructor(date: Date, files?: File[], team?: ITeam, site?: ISite, company?: string);
|
|
14
15
|
Process(): Promise<ExcelRow[]>;
|
|
15
|
-
processFile(file: File): Promise<
|
|
16
|
+
processFile(file: File): Promise<void>;
|
|
16
17
|
/**
|
|
17
18
|
* This function is used to provide a list of labor codes for a particular date and
|
|
18
19
|
* for site and company
|
|
@@ -21,5 +22,5 @@ export declare class ExcelRowIngest {
|
|
|
21
22
|
* @returns A list of labor codes that can be assigned to an employee.
|
|
22
23
|
*/
|
|
23
24
|
getForecast(date: Date): Promise<LaborCode[]>;
|
|
24
|
-
readCell(row: Row, c: number, colDate: Date, emp: Employee): Promise<
|
|
25
|
+
readCell(row: Row, c: number, colDate: Date, emp: Employee): Promise<void>;
|
|
25
26
|
}
|
|
@@ -12,28 +12,28 @@ class ExcelRowIngest {
|
|
|
12
12
|
site;
|
|
13
13
|
company;
|
|
14
14
|
docDate;
|
|
15
|
+
results;
|
|
15
16
|
constructor(date, files, team, site, company) {
|
|
16
17
|
this.files = (files) ? files : [];
|
|
17
18
|
this.team = (team) ? new teams_1.Team(team) : new teams_1.Team();
|
|
18
19
|
this.site = (site) ? new sites_1.Site(site) : new sites_1.Site();
|
|
19
20
|
this.company = (company) ? company : '';
|
|
20
21
|
this.docDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), 1));
|
|
22
|
+
this.results = [];
|
|
21
23
|
}
|
|
22
24
|
async Process() {
|
|
23
|
-
|
|
25
|
+
this.results = [];
|
|
24
26
|
if (this.files.length > 0) {
|
|
25
27
|
const allfiles = this.files.map(async (file, f) => {
|
|
26
|
-
|
|
27
|
-
console.log(results.length);
|
|
28
|
-
result.push(...results);
|
|
28
|
+
await this.processFile(file);
|
|
29
29
|
});
|
|
30
30
|
await Promise.allSettled(allfiles);
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
console.log(this.results.length);
|
|
33
|
+
this.results.sort((a, b) => a.compareTo(b));
|
|
34
|
+
return this.results;
|
|
34
35
|
}
|
|
35
36
|
async processFile(file) {
|
|
36
|
-
const result = [];
|
|
37
37
|
// convert the file into a buffer to allow the exceljs library to create an excel
|
|
38
38
|
// document to read through.
|
|
39
39
|
const filereader = file.stream().getReader();
|
|
@@ -61,10 +61,7 @@ class ExcelRowIngest {
|
|
|
61
61
|
const emp = this.site.employees.find(e => e.name.getLastFirst().toLowerCase() === name.toLowerCase());
|
|
62
62
|
if (emp) {
|
|
63
63
|
const rowPromises = monthDates.map(async (day, d) => {
|
|
64
|
-
|
|
65
|
-
if (results.hours >= 0.0) {
|
|
66
|
-
result.push(results);
|
|
67
|
-
}
|
|
64
|
+
await this.readCell(row, d + 3, day, emp);
|
|
68
65
|
});
|
|
69
66
|
await Promise.allSettled(rowPromises);
|
|
70
67
|
}
|
|
@@ -79,9 +76,6 @@ class ExcelRowIngest {
|
|
|
79
76
|
else {
|
|
80
77
|
throw new Error('No worksheet');
|
|
81
78
|
}
|
|
82
|
-
result.sort((a, b) => a.compareTo(b));
|
|
83
|
-
console.log(`result: ${result.length}`);
|
|
84
|
-
return result;
|
|
85
79
|
}
|
|
86
80
|
/**
|
|
87
81
|
* This function is used to provide a list of labor codes for a particular date and
|
|
@@ -102,7 +96,6 @@ class ExcelRowIngest {
|
|
|
102
96
|
return laborcodes;
|
|
103
97
|
}
|
|
104
98
|
async readCell(row, c, colDate, emp) {
|
|
105
|
-
let answer = new excelRow_1.ExcelRow;
|
|
106
99
|
// create test patterns for hours, if value doesn't match the hours pattern, it will
|
|
107
100
|
// be assumed to be a leave code
|
|
108
101
|
const hPattern = "^[0-9]{1,2}(\.[0-9]+)?$";
|
|
@@ -137,7 +130,7 @@ class ExcelRowIngest {
|
|
|
137
130
|
eRow.extension = laborcode.extension;
|
|
138
131
|
eRow.premium = '1';
|
|
139
132
|
eRow.hours = Number(sValue);
|
|
140
|
-
|
|
133
|
+
this.results.push(new excelRow_1.ExcelRow(eRow));
|
|
141
134
|
}
|
|
142
135
|
}
|
|
143
136
|
else {
|
|
@@ -145,19 +138,17 @@ class ExcelRowIngest {
|
|
|
145
138
|
// create the excel row with the employee's standard workday.
|
|
146
139
|
this.team.workcodes.forEach(wc => {
|
|
147
140
|
if (wc.isLeave && wc.altcode
|
|
148
|
-
&& sValue.toLowerCase() === wc.altcode) {
|
|
141
|
+
&& sValue.toLowerCase() === wc.altcode.toLowerCase()) {
|
|
149
142
|
const eRow = new excelRow_1.ExcelRow();
|
|
150
143
|
eRow.date = new Date(colDate);
|
|
151
144
|
eRow.employee = emp.companyinfo.employeeid;
|
|
152
145
|
eRow.code = wc.id;
|
|
153
146
|
eRow.hours = emp.getStandardWorkday(colDate);
|
|
154
|
-
|
|
147
|
+
this.results.push(new excelRow_1.ExcelRow(eRow));
|
|
155
148
|
}
|
|
156
149
|
});
|
|
157
150
|
}
|
|
158
151
|
}
|
|
159
|
-
console.log(JSON.stringify(answer));
|
|
160
|
-
return answer;
|
|
161
152
|
}
|
|
162
153
|
}
|
|
163
154
|
exports.ExcelRowIngest = ExcelRowIngest;
|