@shisyamo4131/air-guard-v2-schemas 2.3.7-dev.1 → 2.3.7-dev.3

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": "@shisyamo4131/air-guard-v2-schemas",
3
- "version": "2.3.7-dev.1",
3
+ "version": "2.3.7-dev.3",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/Company.js CHANGED
@@ -109,6 +109,22 @@ export default class Company extends FireModel {
109
109
  prefecture: defAccessor("prefecture"),
110
110
  });
111
111
 
112
+ Object.defineProperties(this, {
113
+ hasBankInfo: {
114
+ enumerable: true,
115
+ configurable: true,
116
+ get() {
117
+ return !!(
118
+ this.bankName &&
119
+ this.branchName &&
120
+ this.accountNumber &&
121
+ this.accountHolder
122
+ );
123
+ },
124
+ set() {},
125
+ },
126
+ });
127
+
112
128
  /*************************************************************************
113
129
  * CUSTOM METHODS FOR siteOrder ARRAY
114
130
  * Note: These methods modify the siteOrder array directly.
package/src/Operation.js CHANGED
@@ -2,9 +2,8 @@
2
2
  * Operation Model ver 1.0.0
3
3
  * @author shisyamo4131
4
4
  * ---------------------------------------------------------------------------
5
- * - Base class of SiteOperationSchedule based on WorkingResult.
6
- * - `dateAt` property indicates the date of operation (placement date)
7
- * used for billing purposes.
5
+ * - Base class of SiteOperationSchedule and OperationResult based on WorkingResult.
6
+ * - `dateAt` property indicates the date of operation (placement date) used for billing purposes.
8
7
  * Actual working day may differ from this date.
9
8
  * - `siteId`, `dateAt`, `shiftType`, and `regulationWorkMinutes` are
10
9
  * automatically synchronized to all assigned employees and outsourcers
@@ -12,27 +11,51 @@
12
11
  * - `startTime`, `endTime`, and `breakMinutes` are NOT synchronized here.
13
12
  * They should be synchronized at `SiteOperationSchedule` level instead.
14
13
  * ---------------------------------------------------------------------------
15
- * @prop {string} siteId - Site document ID (trigger property)
14
+ * @prop {string} siteId
15
+ * - Site document ID (trigger property)
16
16
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
17
- * @prop {number} requiredPersonnel - Required number of personnel
18
- * @prop {boolean} qualificationRequired - Qualification required flag
19
- * @prop {string} workDescription - Work description
20
- * @prop {string} remarks - Remarks
21
- * @prop {Array<OperationDetail>} employees - Assigned employees
17
+ *
18
+ * @prop {number} requiredPersonnel
19
+ * - Required number of personnel
20
+ *
21
+ * @prop {boolean} qualificationRequired
22
+ * - Qualification required flag
23
+ *
24
+ * @prop {string} workDescription
25
+ * - Work description
26
+ *
27
+ * @prop {string} remarks
28
+ * - Remarks
29
+ *
30
+ * @prop {Array<OperationDetail>} employees
31
+ * - Assigned employees
22
32
  * - Array of `OperationDetail` instances representing assigned employees
23
- * @prop {Array<OperationDetail>} outsourcers - Assigned outsourcers
33
+ *
34
+ * @prop {Array<OperationDetail>} outsourcers
35
+ * - Assigned outsourcers
24
36
  * - Array of `OperationDetail` instances representing assigned outsourcers
25
- * ---------------------------------------------------------------------------
26
- * @computed {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
27
- * @computed {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
28
- * @computed {number} employeesCount - Count of assigned employees (read-only)
29
- * @computed {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
30
- * @computed {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
37
+ *
38
+ * @prop {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
39
+ * - Array of employee IDs from `employees` (read-only)
40
+ *
41
+ * @prop {Array<string>} outsourcerIds
42
+ * - Array of outsourcer IDs from `outsourcers` (read-only)
43
+ *
44
+ * @prop {number} employeesCount
45
+ * - Count of assigned employees (read-only)
46
+ *
47
+ * @prop {number} outsourcersCount
48
+ * - Count of assigned outsourcers (sum of amounts) (read-only)
49
+ *
50
+ * @prop {boolean} isPersonnelShortage
51
+ * - Indicates if there is a shortage of personnel (read-only)
31
52
  * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
32
- * @computed {Array<OperationDetail>} workers - Combined array of `employees` and `outsourcers`
53
+ *
54
+ * @prop {Array<OperationDetail>} workers
55
+ * - Combined array of `employees` and `outsourcers`
33
56
  * - Getter: Returns concatenated array of employees and outsourcers
34
57
  * - Setter: Splits array into employees and outsourcers based on `isEmployee` property
35
- * ---------------------------------------------------------------------------
58
+ *
36
59
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
37
60
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
38
61
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -46,6 +69,8 @@
46
69
  * - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
47
70
  * ---------------------------------------------------------------------------
48
71
  * @inherited - The following properties are inherited from WorkingResult:
72
+ * @prop {string} key - Unique key combining `siteId`, `date`, `dayType`, and `shiftType` (override/read-only)
73
+ * - A unique identifier for the working result, combining `siteId`, `date`, `dayType`, and `shiftType`.
49
74
  * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
50
75
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
51
76
  * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
@@ -87,6 +112,8 @@
87
112
  * - Extracted from `endTime`.
88
113
  * @getter {number} endMinute - End minute (0-59) (read-only)
89
114
  * - Extracted from `endTime`.
115
+ * @getter {boolean} isKeyChanged - Flag indicating whether the key has changed compared to previous data (read-only)
116
+ * - Compares the current `key` with the `key` in `_beforeData`.
90
117
  * ---------------------------------------------------------------------------
91
118
  * @method {function} addWorker - Adds a new worker (employee or outsourcer)
92
119
  * - @param {Object} options - Options for adding a worker
@@ -234,6 +261,21 @@ export default class Operation extends WorkingResult {
234
261
  afterInitialize(item = {}) {
235
262
  super.afterInitialize(item);
236
263
 
264
+ /**
265
+ * Override `key` computed property
266
+ * - `key`: Combines `siteId`, `date`, `dayType`, and `shiftType`.
267
+ */
268
+ Object.defineProperties(this, {
269
+ key: {
270
+ configurable: true,
271
+ enumberable: true,
272
+ get() {
273
+ return `${this.siteId}-${this.date}-${this.dayType}-${this.shiftType}`;
274
+ },
275
+ set() {},
276
+ },
277
+ });
278
+
237
279
  /***********************************************************
238
280
  * TRIGGERS FOR SYNCRONIZATION TO EMPLOYEES AND OUTSOURCERS
239
281
  * ---------------------------------------------------------
@@ -581,8 +623,6 @@ export default class Operation extends WorkingResult {
581
623
  enumerable: false,
582
624
  },
583
625
  });
584
- /** Remove unnecessary properties */
585
- delete this.key; // From workingResult.js
586
626
  }
587
627
 
588
628
  /***************************************************************************
@@ -10,8 +10,12 @@
10
10
  * - Automatically updates `billingDateAt` based on `dateAt` and `cutoffDate`.
11
11
  * - Introduces a lock mechanism (`isLocked`) to prevent edits when necessary.
12
12
  *
13
+ * @prop {string} key - Unique key combining `siteId`, `date`, `dayType`, and `shiftType` (override/read-only)
14
+ * - A unique identifier for the working result, combining `siteId`, `date`, `dayType`, and `shiftType`.
15
+ *
13
16
  * @prop {string} siteId - Site document ID (trigger property)
14
17
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
18
+ *
15
19
  * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
16
20
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
17
21
  * - Used to determine `dayType`.
@@ -128,6 +132,8 @@
128
132
  * - Extracted from `endTime`.
129
133
  * @getter {number} endMinute - End minute (0-59) (read-only)
130
134
  * - Extracted from `endTime`.
135
+ * @getter {boolean} isKeyChanged - Flag indicating whether the key has changed compared to previous data (read-only)
136
+ * - Compares the current `key` with the `key` in `_beforeData`.
131
137
  *
132
138
  * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
133
139
  * - Updates `billingDateAt` based on the current `dateAt` and `cutoffDate` values.
@@ -17,6 +17,9 @@
17
17
  * `siteId`, `dateAt`, `shiftType`, and `regulationWorkMinutes` are synchronized
18
18
  * in the parent `Operation` class.
19
19
  *
20
+ * @prop {string} key - Unique key combining `siteId`, `date`, `dayType`, and `shiftType` (override/read-only)
21
+ * - A unique identifier for the working result, combining `siteId`, `date`, `dayType`, and `shiftType`.
22
+ *
20
23
  * @prop {string|null} operationResultId - Associated OperationResult document ID
21
24
  * - If an OperationResult has been created based on this schedule, this property
22
25
  * holds the ID of that OperationResult document.
@@ -149,6 +152,9 @@
149
152
  * @getter {number} endMinute - End minute (0-59) (read-only)
150
153
  * - Extracted from `endTime`.
151
154
  *
155
+ * @getter {boolean} isKeyChanged - Flag indicating whether the key has changed compared to previous data (read-only)
156
+ * - Compares the current `key` with the `key` in `_beforeData`.
157
+ *
152
158
  * @method duplicate - Duplicates the SiteOperationSchedule for specified dates
153
159
  * - Creates new SiteOperationSchedule documents for each specified date,
154
160
  * excluding the original date and avoiding duplicates.
@@ -7,40 +7,41 @@
7
7
  * - `dateAt` is defined as a trigger property. When it is set, `dayType` is automatically updated.
8
8
  * - Subclasses can override `setDateAtCallback` to add custom behavior when `dateAt` changes.
9
9
  * ---------------------------------------------------------------------------
10
- * @props {Date} dateAt - Applicable start date (trigger property)
11
- * @props {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
12
- * @props {string} shiftType - Shift type (`DAY`, `NIGHT`)
13
- * @props {string} startTime - Start time (HH:MM format)
14
- * @props {boolean} isStartNextDay - Next day start flag
10
+ * @prop {Date} dateAt - Applicable start date (trigger property)
11
+ * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
12
+ * @prop {string} shiftType - Shift type (`DAY`, `NIGHT`)
13
+ * @prop {string} startTime - Start time (HH:MM format)
14
+ * @prop {boolean} isStartNextDay - Next day start flag
15
15
  * - `true` if the actual work starts the day after the placement date `dateAt`
16
- * @props {string} endTime - End time (HH:MM format)
17
- * @props {number} breakMinutes - Break time (minutes)
18
- * @props {number} regulationWorkMinutes - Regulation work minutes
16
+ * @prop {string} endTime - End time (HH:MM format)
17
+ * @prop {number} breakMinutes - Break time (minutes)
18
+ * @prop {number} regulationWorkMinutes - Regulation work minutes
19
19
  * - The maximum working time defined by `unitPriceBase` (or `unitPriceQualified`).
20
20
  * - Exceeding this time is considered overtime.
21
- * ---------------------------------------------------------------------------
22
- * @computed {string} key - Unique key combining `date`, `dayType`, and `shiftType` (read-only)
21
+ *
22
+ * @computed
23
+ * @prop {string} key - Unique key combining `date`, `dayType`, and `shiftType` (read-only)
23
24
  * - A unique identifier for the working result, combining `date`, `dayType`, and `shiftType`.
24
- * @computed {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
25
+ * @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
25
26
  * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
26
- * @computed {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
27
+ * @prop {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
27
28
  * - `true` if `startTime` is later than `endTime`
28
- * @computed {Date} startAt - Start date and time (Date object) (read-only)
29
+ * @prop {Date} startAt - Start date and time (Date object) (read-only)
29
30
  * - Returns a Date object with `startTime` set based on `dateAt`.
30
31
  * - If `isStartNextDay` is true, add 1 day.
31
- * @computed {Date} endAt - End date and time (Date object) (read-only)
32
+ * @prop {Date} endAt - End date and time (Date object) (read-only)
32
33
  * - Returns a Date object with `endTime` set based on `dateAt`.
33
34
  * - If `isStartNextDay` is true, add 1 day.
34
35
  * - If `isSpansNextDay` is true, add 1 day.
35
- * @computed {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
36
+ * @prop {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
36
37
  * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
37
38
  * - If the difference between `endAt` and `startAt` is negative, returns 0.
38
39
  * - If `startAt` or `endAt` is not set, returns 0.
39
- * @computed {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
40
+ * @prop {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
40
41
  * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
41
42
  * - If actual working time is less than regulation time (e.g., early leave), it equals `totalWorkMinutes`.
42
43
  * - If actual working time exceeds regulation time (overtime), it equals `regulationWorkMinutes`.
43
- * @computed {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
44
+ * @prop {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
44
45
  * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
45
46
  * - Overtime work is not negative; the minimum is 0.
46
47
  * ---------------------------------------------------------------------------
@@ -52,6 +53,8 @@
52
53
  * - Extracted from `endTime`.
53
54
  * @getter {number} endMinute - End minute (0-59) (read-only)
54
55
  * - Extracted from `endTime`.
56
+ * @getter {boolean} isKeyChanged - Flag indicating whether the key has changed compared to previous data (read-only)
57
+ * - Compares the current `key` with the `key` in `_beforeData`.
55
58
  * ---------------------------------------------------------------------------
56
59
  * @method {function} setDateAtCallback - Callback method called when `dateAt` is set
57
60
  * - Override this method in subclasses to add custom behavior when `dateAt` changes.
@@ -301,4 +304,15 @@ export default class WorkingResult extends FireModel {
301
304
  get endMinute() {
302
305
  return this.endTime ? Number(this.endTime.split(":")[1]) : 0;
303
306
  }
307
+
308
+ /**
309
+ * Returns whether the key has changed compared to the previous data.
310
+ * - Compares the current `key` with the `key` in `_beforeData`.
311
+ * - Returns `true` if they are different, otherwise `false`.
312
+ */
313
+ get isKeyChanged() {
314
+ const current = this.key;
315
+ const before = this._beforeData?.key;
316
+ return current !== before;
317
+ }
304
318
  }