@shisyamo4131/air-guard-v2-schemas 2.3.7-dev.2 → 2.3.7-dev.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 +1 -1
- package/src/Operation.js +60 -20
- package/src/OperationResult.js +15 -8
- package/src/SiteOperationSchedule.js +6 -0
- package/src/WorkingResult.js +31 -17
package/package.json
CHANGED
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
|
|
14
|
+
* @prop {string} siteId
|
|
15
|
+
* - Site document ID (trigger property)
|
|
16
16
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
17
|
-
*
|
|
18
|
-
* @prop {
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @prop {
|
|
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
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* @prop {Array<OperationDetail>} outsourcers
|
|
35
|
+
* - Assigned outsourcers
|
|
24
36
|
* - Array of `OperationDetail` instances representing assigned outsourcers
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
*
|
|
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
|
-
*
|
|
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
|
/***************************************************************************
|
package/src/OperationResult.js
CHANGED
|
@@ -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.
|
|
@@ -535,11 +541,11 @@ export default class OperationResult extends Operation {
|
|
|
535
541
|
}
|
|
536
542
|
|
|
537
543
|
/**
|
|
538
|
-
* Synchronize customerId from siteId
|
|
544
|
+
* Synchronize customerId and apply (re-apply) agreement from siteId
|
|
539
545
|
* @returns {Promise<void>}
|
|
540
546
|
* @throws {Error} If the specified siteId does not exist
|
|
541
547
|
*/
|
|
542
|
-
async
|
|
548
|
+
async _syncCustomerIdAndApplyAgreement() {
|
|
543
549
|
if (!this.siteId) return;
|
|
544
550
|
const siteInstance = new Site();
|
|
545
551
|
const siteExists = await siteInstance.fetch({ docId: this.siteId });
|
|
@@ -549,6 +555,7 @@ export default class OperationResult extends Operation {
|
|
|
549
555
|
);
|
|
550
556
|
}
|
|
551
557
|
this.customerId = siteInstance.customerId;
|
|
558
|
+
this.agreement = siteInstance.getCurrentAgreement(this);
|
|
552
559
|
}
|
|
553
560
|
|
|
554
561
|
/**
|
|
@@ -558,12 +565,12 @@ export default class OperationResult extends Operation {
|
|
|
558
565
|
async beforeCreate() {
|
|
559
566
|
await super.beforeCreate();
|
|
560
567
|
|
|
561
|
-
// Sync customerId
|
|
562
|
-
await this.
|
|
568
|
+
// Sync customerId and apply agreement
|
|
569
|
+
await this._syncCustomerIdAndApplyAgreement();
|
|
563
570
|
}
|
|
564
571
|
|
|
565
572
|
/**
|
|
566
|
-
* Override beforeUpdate to sync customerId if
|
|
573
|
+
* Override beforeUpdate to sync customerId and apply agreement if key changed
|
|
567
574
|
* @returns {Promise<void>}
|
|
568
575
|
*/
|
|
569
576
|
async beforeUpdate() {
|
|
@@ -576,9 +583,9 @@ export default class OperationResult extends Operation {
|
|
|
576
583
|
);
|
|
577
584
|
}
|
|
578
585
|
|
|
579
|
-
// Sync customerId if
|
|
580
|
-
if (this.
|
|
581
|
-
await this.
|
|
586
|
+
// Sync customerId and apply agreement if key changed
|
|
587
|
+
if (this.key === this._beforeData.key) return;
|
|
588
|
+
await this._syncCustomerIdAndApplyAgreement();
|
|
582
589
|
}
|
|
583
590
|
|
|
584
591
|
/**
|
|
@@ -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.
|
package/src/WorkingResult.js
CHANGED
|
@@ -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
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
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
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
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
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
}
|