scheduler-node-models 1.1.2 → 1.1.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scheduler-node-models",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -308,6 +308,13 @@ export declare class Employee implements IEmployee {
308
308
  * @returns numeric (float) value for the total leave hours for the period
309
309
  */
310
310
  getLeaveHours(start: Date, end: Date): number;
311
+ /**
312
+ * This function will provide a leave workday with the number of total hours of leave
313
+ * time.
314
+ * @param start The date object for the date to check against
315
+ * @returns A workday object with the leave and hours for the date.
316
+ */
317
+ getLeave(start: Date): Workday;
311
318
  /**
312
319
  * This function will provide a total number of vacation/PTO leave hours for a
313
320
  * particular period of time (Actual Leave Only)
@@ -676,6 +676,12 @@ class Employee {
676
676
  end = new Date(Date.UTC(end.getFullYear(), end.getMonth(), end.getDate()));
677
677
  while (start.getTime() <= end.getTime()) {
678
678
  const wd = this.getWorkdayWOLeaves(start);
679
+ if (this.name.lastname.toLowerCase() === 'erne') {
680
+ const now = new Date();
681
+ if (start.getTime() < now.getTime()) {
682
+ console.log(JSON.stringify(wd));
683
+ }
684
+ }
679
685
  if (wd) {
680
686
  const label = `${wd.workcenter}-${wd.code}`;
681
687
  if (label !== '-') {
@@ -1080,6 +1086,32 @@ class Employee {
1080
1086
  });
1081
1087
  return answer;
1082
1088
  }
1089
+ /**
1090
+ * This function will provide a leave workday with the number of total hours of leave
1091
+ * time.
1092
+ * @param start The date object for the date to check against
1093
+ * @returns A workday object with the leave and hours for the date.
1094
+ */
1095
+ getLeave(start) {
1096
+ const workday = new workday_1.Workday();
1097
+ this.leaves.forEach(lv => {
1098
+ if (lv.leavedate.getUTCFullYear() === start.getUTCFullYear()
1099
+ && lv.leavedate.getUTCMonth() === start.getUTCMonth()
1100
+ && lv.leavedate.getUTCDate() === start.getUTCDate()) {
1101
+ if (workday.code === '') {
1102
+ workday.code = lv.code;
1103
+ workday.hours = lv.hours;
1104
+ }
1105
+ else {
1106
+ if (workday.hours < lv.hours) {
1107
+ workday.code = lv.code;
1108
+ workday.hours += lv.hours;
1109
+ }
1110
+ }
1111
+ }
1112
+ });
1113
+ return workday;
1114
+ }
1083
1115
  /**
1084
1116
  * This function will provide a total number of vacation/PTO leave hours for a
1085
1117
  * particular period of time (Actual Leave Only)