scheduler-node-models 1.2.30 → 1.2.32

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.2.30",
3
+ "version": "1.2.32",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -302,11 +302,10 @@ export declare class Employee implements IEmployee {
302
302
  * This function is used to update a leave balance object with a new annual year and
303
303
  * carry over amount.
304
304
  * @param year The numeric value for the year used as a key value
305
- * @param annual The numeric value for the employee's annual leave amount in hours.
306
- * @param carry The numeric value for the number of hours the employee brings forward
307
- * to this year.
305
+ * @param field The string value for the field to update
306
+ * @param carry The numeric value for the number of hours for that field.
308
307
  */
309
- updateLeaveBalance(year: number, annual: number, carry: number): void;
308
+ updateLeaveBalance(year: number, field: string, value: number): void;
310
309
  /**
311
310
  * This function will remove a leave balance from the employee's leave balance list.
312
311
  * @param year The numeric value for the year of the leave balance (primary key).
@@ -1103,30 +1103,35 @@ class Employee {
1103
1103
  this.balances.push(bal);
1104
1104
  this.balances.sort((a, b) => a.compareTo(b));
1105
1105
  }
1106
+ else {
1107
+ throw new Error('Leave Balance year already exists');
1108
+ }
1106
1109
  }
1107
1110
  /**
1108
1111
  * This function is used to update a leave balance object with a new annual year and
1109
1112
  * carry over amount.
1110
1113
  * @param year The numeric value for the year used as a key value
1111
- * @param annual The numeric value for the employee's annual leave amount in hours.
1112
- * @param carry The numeric value for the number of hours the employee brings forward
1113
- * to this year.
1114
+ * @param field The string value for the field to update
1115
+ * @param carry The numeric value for the number of hours for that field.
1114
1116
  */
1115
- updateLeaveBalance(year, annual, carry) {
1117
+ updateLeaveBalance(year, field, value) {
1116
1118
  let found = false;
1117
1119
  for (let lb = 0; lb < this.balances.length && !found; lb++) {
1118
1120
  if (this.balances[lb].year === year) {
1119
- this.balances[lb].annual = annual;
1120
- this.balances[lb].carryover = carry;
1121
+ found = true;
1122
+ switch (field.toLowerCase()) {
1123
+ case "annual":
1124
+ this.balances[lb].annual = value;
1125
+ break;
1126
+ case 'carry':
1127
+ case 'carryover':
1128
+ this.balances[lb].carryover = value;
1129
+ break;
1130
+ }
1121
1131
  }
1122
1132
  }
1123
1133
  if (!found) {
1124
- const lb = new balance_1.AnnualLeave({
1125
- year: year,
1126
- annual: annual,
1127
- carryover: carry
1128
- });
1129
- this.balances.push(lb);
1134
+ throw new Error('Leave Balance year not found');
1130
1135
  }
1131
1136
  this.balances.sort((a, b) => a.compareTo(b));
1132
1137
  }
@@ -1144,6 +1149,9 @@ class Employee {
1144
1149
  if (found >= 0) {
1145
1150
  this.balances.splice(found, 1);
1146
1151
  }
1152
+ else {
1153
+ throw new Error('Leave Balance year not found');
1154
+ }
1147
1155
  }
1148
1156
  /**
1149
1157
  * This is the employee leave section.