@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.0 → 1.3.1-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": "1.3.1-dev.0",
3
+ "version": "1.3.1-dev.3",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/Agreement.js CHANGED
@@ -4,13 +4,13 @@
4
4
  * ---------------------------------------------------------------------------
5
5
  * A class to manage agreement details based on WorkingResult.
6
6
  * ---------------------------------------------------------------------------
7
- * @props {number} unitPriceBase - Base unit price (JPY)
8
- * @props {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
9
- * @props {number} unitPriceQualified - Qualified unit price (JPY)
10
- * @props {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
11
- * @props {string} billingUnitType - Billing unit type
12
- * @props {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
13
- * @props {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
7
+ * @prop {number} unitPriceBase - Base unit price (JPY)
8
+ * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
9
+ * @prop {number} unitPriceQualified - Qualified unit price (JPY)
10
+ * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
11
+ * @prop {string} billingUnitType - Billing unit type
12
+ * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
13
+ * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
14
14
  * - The cutoff date for billing, using values defined in the CutoffDate utility class.
15
15
  * ---------------------------------------------------------------------------
16
16
  * @getter {Object} prices - Object containing price-related properties (read-only)
@@ -20,15 +20,15 @@
20
20
  * unitPriceQualified, overtimeUnitPriceQualified, billingUnitType, includeBreakInBilling
21
21
  * ---------------------------------------------------------------------------
22
22
  * @inherited - The following properties are inherited from WorkingResult:
23
- * @props {Date} dateAt - Applicable start date (trigger property)
24
- * @props {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
25
- * @props {string} shiftType - Shift type (`DAY`, `NIGHT`)
26
- * @props {string} startTime - Start time (HH:MM format)
27
- * @props {boolean} isStartNextDay - Next day start flag
23
+ * @prop {Date} dateAt - Applicable start date (trigger property)
24
+ * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
25
+ * @prop {string} shiftType - Shift type (`DAY`, `NIGHT`)
26
+ * @prop {string} startTime - Start time (HH:MM format)
27
+ * @prop {boolean} isStartNextDay - Next day start flag
28
28
  * - `true` if the actual work starts the day after the placement date `dateAt`
29
- * @props {string} endTime - End time (HH:MM format)
30
- * @props {number} breakMinutes - Break time (minutes)
31
- * @props {number} regulationWorkMinutes - Regulation work minutes
29
+ * @prop {string} endTime - End time (HH:MM format)
30
+ * @prop {number} breakMinutes - Break time (minutes)
31
+ * @prop {number} regulationWorkMinutes - Regulation work minutes
32
32
  * - The maximum working time defined by `unitPriceBase` (or `unitPriceQualified`).
33
33
  * - Exceeding this time is considered overtime.
34
34
  * ---------------------------------------------------------------------------
@@ -1,7 +1,8 @@
1
1
  /*****************************************************************************
2
- * OperationBilling Model ver 1.0.0
2
+ * OperationBilling Model
3
+ * @version 1.0.0
3
4
  * @author shisyamo4131
4
- * ---------------------------------------------------------------------------
5
+ *
5
6
  * - Extends OperationResult class to represent the billing of an operation.
6
7
  * - This class provides the same functionality as OperationResult but with a different semantic meaning
7
8
  * focused on billing operations rather than general operation results.
@@ -9,50 +10,13 @@
9
10
  * - The `className` is set to "稼働請求" (Operation Billing) to distinguish it from OperationResult.
10
11
  * - The `create` method is overridden to indicate that creation of OperationBilling instances
11
12
  * is not implemented, as billing records are typically generated through the OperationResult class.
12
- * ---------------------------------------------------------------------------
13
- * @inherited - The following properties are inherited from OperationResult:
14
- * @prop {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
15
- * - If this OperationBilling was created from a SiteOperationSchedule, this property holds that ID.
16
- * - If this property is set, the instance cannot be deleted.
17
- * @prop {boolean} useAdjustedQuantity - Flag to indicate if adjusted quantities are used for billing
18
- * @prop {number} adjustedQuantityBase - Adjusted quantity for base workers
19
- * - Quantity used for billing base workers when `useAdjustedQuantity` is true.
20
- * @prop {number} adjustedOvertimeBase - Adjusted overtime for base workers
21
- * - Overtime used for billing base workers when `useAdjustedQuantity` is true.
22
- * @prop {number} adjustedQuantityQualified - Adjusted quantity for qualified workers
23
- * - Quantity used for billing qualified workers when `useAdjustedQuantity` is true.
24
- * @prop {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
25
- * - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
26
- * @prop {Date} billingDateAt - Billing date
27
- * - The date used for billing purposes.
28
- * @prop {boolean} isLocked - Lock flag
29
- * - When set to true, the OperationBilling is locked from edits exept for editing as OperationBilling.
30
- * ---------------------------------------------------------------------------
31
- * @inherited - The following properties are inherited from Operation (via OperationResult):
13
+ *
32
14
  * @prop {string} siteId - Site document ID (trigger property)
33
15
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
34
- * @prop {number} requiredPersonnel - Required number of personnel
35
- * @prop {boolean} qualificationRequired - Qualification required flag
36
- * @prop {string} workDescription - Work description
37
- * @prop {string} remarks - Remarks
38
- * @prop {Array<OperationResultDetail>} employees - Assigned employees
39
- * - Array of `OperationResultDetail` instances representing assigned employees
40
- * @prop {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
41
- * - Array of `OperationResultDetail` instances representing assigned outsourcers
42
- * ---------------------------------------------------------------------------
43
- * @inherited - The following properties are inherited from Agreement (via OperationResult):
44
- * @prop {number} unitPriceBase - Base unit price (JPY)
45
- * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
46
- * @prop {number} unitPriceQualified - Qualified unit price (JPY)
47
- * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
48
- * @prop {string} billingUnitType - Billing unit type
49
- * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
50
- * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
51
- * - The cutoff date for billing, using values defined in the CutoffDate utility class.
52
- * ---------------------------------------------------------------------------
53
- * @inherited - The following properties are inherited from WorkingResult (via OperationResult):
54
16
  * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
55
17
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
18
+ * - Used to determine `dayType`.
19
+ * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
56
20
  * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
57
21
  * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
58
22
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
@@ -64,52 +28,93 @@
64
28
  * @prop {number} regulationWorkMinutes - Regulation work minutes (trigger property)
65
29
  * - Indicates the maximum working time treated as regular working hours.
66
30
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
67
- * ---------------------------------------------------------------------------
68
- * @inherited - The following computed properties are inherited from OperationResult:
69
- * @computed {Object} statistics - Statistics of workers (read-only)
70
- * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
71
- * - Structure: { base: {...}, qualified: {...}, total: {...} }
72
- * @computed {Object} sales - Sales amounts (read-only)
73
- * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
74
- * - Structure: { base: {...}, qualified: {...} }
75
- * @computed {number} salesAmount - Total sales amount (read-only)
76
- * - Sum of sales amounts for base and qualified workers with rounding applied.
77
- * @computed {number} tax - Calculated tax amount (read-only)
78
- * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
79
- * @computed {number} billingAmount - Total billing amount including tax (read-only)
80
- * - Sum of `salesAmount` and `tax`.
81
- * ---------------------------------------------------------------------------
82
- * @inherited - The following computed properties are inherited from Operation (via OperationResult):
83
- * @computed {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
84
- * @computed {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
85
- * @computed {number} employeesCount - Count of assigned employees (read-only)
86
- * @computed {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
87
- * @computed {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
88
- * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
89
- * @computed {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers` (read-only)
31
+ * @prop {number} requiredPersonnel - Required number of personnel
32
+ * @prop {boolean} qualificationRequired - Qualification required flag
33
+ * @prop {string} workDescription - Work description
34
+ * @prop {string} remarks - Remarks
35
+ * @prop {Array<OperationResultDetail>} employees - Assigned employees
36
+ * - Array of `OperationResultDetail` instances representing assigned employees
37
+ * @prop {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
38
+ * - Array of `OperationResultDetail` instances representing assigned outsourcers
39
+ * @prop {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers`
90
40
  * - Getter: Returns concatenated array of employees and outsourcers
91
41
  * - Setter: Splits array into employees and outsourcers based on `isEmployee` property
92
- * ---------------------------------------------------------------------------
93
- * @inherited - The following computed properties are inherited from WorkingResult (via OperationResult):
94
- * @computed {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
42
+ * @prop {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
43
+ * - If this OperationResult was created from a SiteOperationSchedule, this property holds that ID.
44
+ * - If this property is set, the instance cannot be deleted.
45
+ * @prop {boolean} useAdjustedQuantity - Flag to indicate if adjusted quantities are used for billing
46
+ * @prop {number} adjustedQuantityBase - Adjusted quantity for base workers
47
+ * - Quantity used for billing base workers when `useAdjustedQuantity` is true.
48
+ * @prop {number} adjustedOvertimeBase - Adjusted overtime for base workers
49
+ * - Overtime used for billing base workers when `useAdjustedQuantity` is true.
50
+ * @prop {number} adjustedQuantityQualified - Adjusted quantity for qualified workers
51
+ * - Quantity used for billing qualified workers when `useAdjustedQuantity` is true.
52
+ * @prop {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
53
+ * - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
54
+ * @prop {Date} billingDateAt - Billing date
55
+ * - The date used for billing purposes.
56
+ * @prop {boolean} isLocked - Lock flag
57
+ * - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
58
+ * @prop {Agreement|null} agreement - Associated Agreement object
59
+ *
60
+ * @readonly
61
+ * @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
95
62
  * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
96
- * @computed {Date} startAt - Start date and time (Date object) (read-only)
63
+ * @prop {Date} startAt - Start date and time (Date object) (read-only)
97
64
  * - Returns a Date object with `startTime` set based on `dateAt`.
98
65
  * - If `isStartNextDay` is true, add 1 day.
99
- * @computed {Date} endAt - End date and time (Date object) (read-only)
66
+ * @prop {Date} endAt - End date and time (Date object) (read-only)
100
67
  * - Returns a Date object with `endTime` set based on `dateAt`.
101
68
  * - If `isStartNextDay` is true, add 1 day.
102
69
  * - If `isSpansNextDay` is true, add 1 day.
103
- * @computed {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
70
+ * @prop {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
104
71
  * - `true` if `startTime` is later than `endTime`
105
- * @computed {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
72
+ * @prop {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
106
73
  * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
107
- * @computed {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
74
+ * @prop {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
108
75
  * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
109
- * @computed {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
76
+ * @prop {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
110
77
  * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
111
- * ---------------------------------------------------------------------------
112
- * @inherited - The following getter properties are inherited from Operation (via OperationResult):
78
+ * @prop {boolean} hasAgreement - Indicates if an Agreement is associated (read-only)
79
+ * @prop {boolean} isValid - Indicates if the OperationResult is valid (read-only)
80
+ * - Valid if either an Agreement is associated or adjusted quantities are not used.
81
+ * - If `hasAgreement` is true, always valid.
82
+ * @prop {Object} statistics - Statistics of workers (read-only)
83
+ * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
84
+ * - Structure: { base: {...}, qualified: {...}, total: {...} }
85
+ * - Each category contains: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
86
+ * - Each category also has an 'ojt' subcategory with the same structure.
87
+ * @prop {Object} sales - Sales amounts (read-only)
88
+ * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
89
+ * - Structure: { base: {...}, qualified: {...} }
90
+ * - Each category contains: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
91
+ * - Calculations respect `useAdjustedQuantity`, `billingUnitType`, and `includeBreakInBilling` settings.
92
+ * @prop {number} salesAmount - Total sales amount (read-only)
93
+ * - Sum of sales amounts for base and qualified workers with rounding applied.
94
+ * @prop {number} tax - Calculated tax amount (read-only)
95
+ * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
96
+ * @prop {number} billingAmount - Total billing amount including tax (read-only)
97
+ * - Sum of `salesAmount` and `tax`.
98
+ * @prop {string} billingMonth - Billing month in YYYY-MM format (read-only)
99
+ * @prop {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
100
+ * @prop {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
101
+ * @prop {number} employeesCount - Count of assigned employees (read-only)
102
+ * @prop {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
103
+ * @prop {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
104
+ * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
105
+ *
106
+ * @inherited - The following properties are inherited from Agreement (via Operation):
107
+ * @prop {number} unitPriceBase - Base unit price (JPY)
108
+ * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
109
+ * @prop {number} unitPriceQualified - Qualified unit price (JPY)
110
+ * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
111
+ * @prop {string} billingUnitType - Billing unit type
112
+ * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
113
+ * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
114
+ * - The cutoff date for billing, using values defined in the CutoffDate utility class.
115
+ * - Used to calculate `billingDateAt`.
116
+ * - When `cutoffDate` or `dateAt` changes, `billingDateAt` is automatically updated.
117
+ *
113
118
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
114
119
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
115
120
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -121,8 +126,6 @@
121
126
  * - Workers that exist in `_beforeData` but not in current data
122
127
  * @getter {Array<OperationResultDetail>} updatedWorkers - An array of workers that have been updated (read-only)
123
128
  * - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
124
- * ---------------------------------------------------------------------------
125
- * @inherited - The following getter properties are inherited from WorkingResult (via OperationResult):
126
129
  * @getter {number} startHour - Start hour (0-23) (read-only)
127
130
  * - Extracted from `startTime`.
128
131
  * @getter {number} startMinute - Start minute (0-59) (read-only)
@@ -131,53 +134,51 @@
131
134
  * - Extracted from `endTime`.
132
135
  * @getter {number} endMinute - End minute (0-59) (read-only)
133
136
  * - Extracted from `endTime`.
134
- * ---------------------------------------------------------------------------
135
- * @inherited - The following methods are inherited from OperationResult:
136
- * @method {function} beforeDelete - Override method to prevent deletion with siteOperationScheduleId
137
+ *
138
+ * @method beforeDelete - Override method to prevent deletion with siteOperationScheduleId
137
139
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
138
140
  * - Throws an error if deletion is attempted on an instance created from SiteOperationSchedule.
139
- * ---------------------------------------------------------------------------
140
- * @inherited - The following methods are inherited from Operation (via OperationResult):
141
- * @method {function} addWorker - Adds a new worker (employee or outsourcer)
141
+ * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
142
+ * - Updates `billingDateAt` based on the current `dateAt` and `cutoffDate` values.
143
+ * @method addWorker - Adds a new worker (employee or outsourcer)
142
144
  * - @param {Object} options - Options for adding a worker
143
145
  * - @param {string} options.id - The worker ID (employeeId or outsourcerId)
144
146
  * - @param {boolean} [options.isEmployee=true] - Whether the worker is an employee
145
147
  * - @param {number} [index=0] - Insertion position. If -1, adds to the end
146
- * @method {function} moveWorker - Moves the position of a worker (employee or outsourcer)
148
+ * @method moveWorker - Moves the position of a worker (employee or outsourcer)
147
149
  * - @param {Object} options - Options for changing worker position
148
150
  * - @param {number} options.oldIndex - The original index
149
151
  * - @param {number} options.newIndex - The new index
150
152
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
151
- * @method {function} changeWorker - Changes the details of a worker
153
+ * @method changeWorker - Changes the details of a worker
152
154
  * - @param {Object} newWorker - New worker object
153
- * @method {function} removeWorker - Removes a worker (employee or outsourcer)
155
+ * @method removeWorker - Removes a worker (employee or outsourcer)
154
156
  * - @param {Object} options - Options for removing a worker
155
157
  * - @param {string} options.workerId - The ID of the employee or outsourcer
156
158
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
157
- * @method {function} setSiteIdCallback - Callback method called when `siteId` is set
159
+ * @method setSiteIdCallback - Callback method called when `siteId` is set
158
160
  * - Override this method in subclasses to add custom behavior when `siteId` changes.
159
161
  * - By default, does nothing.
160
162
  * - @param {string} v - The new `siteId` value
161
- * @method {function} setShiftTypeCallback - Callback method called when `shiftType` is set
163
+ * @method setShiftTypeCallback - Callback method called when `shiftType` is set
162
164
  * - Override this method in subclasses to add custom behavior when `shiftType` changes.
163
165
  * - By default, does nothing.
164
166
  * - @param {string} v - The new `shiftType` value
165
- * @method {function} setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
167
+ * @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
166
168
  * - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
167
169
  * - By default, does nothing.
168
170
  * - @param {number} v - The new `regulationWorkMinutes` value
171
+ *
169
172
  * @static
170
173
  * @method groupKeyDivider
171
- * Returns an array dividing the key into siteId, shiftType, and date.
172
- * @param {Object|string} key - The combined key string or object
173
- * @returns {Array<string>} - Array containing [siteId, shiftType, date]
174
- * @throws {Error} - If the key is invalid.
175
- * ---------------------------------------------------------------------------
176
- * @inherited - The following method is inherited from WorkingResult (via OperationResult):
177
- * @method {function} setDateAtCallback - Callback method called when `dateAt` is set
178
- * - Override this method in subclasses to add custom behavior when `dateAt` changes.
179
- * - By default, updates `dayType` based on the new `dateAt` value and synchronizes to workers.
180
- * - @param {Date} v - The new `dateAt` value
174
+ * - Returns an array dividing the key into siteId, shiftType, and date.
175
+ * - @param {Object|string} key - The combined key string or object
176
+ * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
177
+ * - @throws {Error} - If the key is invalid.
178
+ *
179
+ * @override create - Override create method to indicate not implemented
180
+ * - Creation of OperationBilling instances is not implemented, as billing records are typically
181
+ * generated through the OperationResult class.
181
182
  *****************************************************************************/
182
183
  import OperationResult from "./OperationResult.js";
183
184
 
@@ -1,7 +1,8 @@
1
1
  /*****************************************************************************
2
- * OperationResult Model ver 1.1.0
2
+ * OperationResult Model
3
+ * @version 1.2.0 - 2025-11-19 Add `agreement`, `hasAgreement`, `isValid` properties.
3
4
  * @author shisyamo4131
4
- * ---------------------------------------------------------------------------
5
+ *
5
6
  * - Extends Operation class to represent the result of an operation.
6
7
  * - Also incorporates Agreement class properties for pricing and billing information.
7
8
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
@@ -9,7 +10,35 @@
9
10
  * - Supports both daily and hourly billing with adjusted quantities.
10
11
  * - Automatically updates `billingDateAt` based on `dateAt` and `cutoffDate`.
11
12
  * - Introduces a lock mechanism (`isLocked`) to prevent edits when necessary.
12
- * ---------------------------------------------------------------------------
13
+ *
14
+ * @prop {string} siteId - Site document ID (trigger property)
15
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
16
+ * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
17
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
18
+ * - Used to determine `dayType`.
19
+ * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
20
+ * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
21
+ * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
22
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
23
+ * @prop {string} startTime - Start time (HH:MM format)
24
+ * @prop {boolean} isStartNextDay - Next day start flag
25
+ * - `true` if the actual work starts the day after the placement date `dateAt`
26
+ * @prop {string} endTime - End time (HH:MM format)
27
+ * @prop {number} breakMinutes - Break time (minutes)
28
+ * @prop {number} regulationWorkMinutes - Regulation work minutes (trigger property)
29
+ * - Indicates the maximum working time treated as regular working hours.
30
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
31
+ * @prop {number} requiredPersonnel - Required number of personnel
32
+ * @prop {boolean} qualificationRequired - Qualification required flag
33
+ * @prop {string} workDescription - Work description
34
+ * @prop {string} remarks - Remarks
35
+ * @prop {Array<OperationResultDetail>} employees - Assigned employees
36
+ * - Array of `OperationResultDetail` instances representing assigned employees
37
+ * @prop {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
38
+ * - Array of `OperationResultDetail` instances representing assigned outsourcers
39
+ * @prop {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers`
40
+ * - Getter: Returns concatenated array of employees and outsourcers
41
+ * - Setter: Splits array into employees and outsourcers based on `isEmployee` property
13
42
  * @prop {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
14
43
  * - If this OperationResult was created from a SiteOperationSchedule, this property holds that ID.
15
44
  * - If this property is set, the instance cannot be deleted.
@@ -26,37 +55,54 @@
26
55
  * - The date used for billing purposes.
27
56
  * @prop {boolean} isLocked - Lock flag
28
57
  * - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
29
- * ---------------------------------------------------------------------------
30
- * @computed {Object} statistics - Statistics of workers (read-only)
58
+ * @prop {Agreement|null} agreement - Associated Agreement object
59
+ *
60
+ * @readonly
61
+ * @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
62
+ * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
63
+ * @prop {Date} startAt - Start date and time (Date object) (read-only)
64
+ * - Returns a Date object with `startTime` set based on `dateAt`.
65
+ * - If `isStartNextDay` is true, add 1 day.
66
+ * @prop {Date} endAt - End date and time (Date object) (read-only)
67
+ * - Returns a Date object with `endTime` set based on `dateAt`.
68
+ * - If `isStartNextDay` is true, add 1 day.
69
+ * - If `isSpansNextDay` is true, add 1 day.
70
+ * @prop {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
71
+ * - `true` if `startTime` is later than `endTime`
72
+ * @prop {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
73
+ * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
74
+ * @prop {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
75
+ * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
76
+ * @prop {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
77
+ * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
78
+ * @prop {boolean} hasAgreement - Indicates if an Agreement is associated (read-only)
79
+ * @prop {boolean} isValid - Indicates if the OperationResult is valid (read-only)
80
+ * - Valid if either an Agreement is associated or adjusted quantities are not used.
81
+ * - If `hasAgreement` is true, always valid.
82
+ * @prop {Object} statistics - Statistics of workers (read-only)
31
83
  * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
32
84
  * - Structure: { base: {...}, qualified: {...}, total: {...} }
33
85
  * - Each category contains: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
34
86
  * - Each category also has an 'ojt' subcategory with the same structure.
35
- * @computed {Object} sales - Sales amounts (read-only)
87
+ * @prop {Object} sales - Sales amounts (read-only)
36
88
  * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
37
89
  * - Structure: { base: {...}, qualified: {...} }
38
90
  * - Each category contains: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
39
91
  * - Calculations respect `useAdjustedQuantity`, `billingUnitType`, and `includeBreakInBilling` settings.
40
- * @computed {number} salesAmount - Total sales amount (read-only)
92
+ * @prop {number} salesAmount - Total sales amount (read-only)
41
93
  * - Sum of sales amounts for base and qualified workers with rounding applied.
42
- * @computed {number} tax - Calculated tax amount (read-only)
94
+ * @prop {number} tax - Calculated tax amount (read-only)
43
95
  * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
44
- * @computed {number} billingAmount - Total billing amount including tax (read-only)
96
+ * @prop {number} billingAmount - Total billing amount including tax (read-only)
45
97
  * - Sum of `salesAmount` and `tax`.
46
- * @computed {string} billingMonth - Billing month in YYYY-MM format (read-only)
47
- * ---------------------------------------------------------------------------
48
- * @inherited - The following properties are inherited from Operation:
49
- * @prop {string} siteId - Site document ID (trigger property)
50
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
51
- * @prop {number} requiredPersonnel - Required number of personnel
52
- * @prop {boolean} qualificationRequired - Qualification required flag
53
- * @prop {string} workDescription - Work description
54
- * @prop {string} remarks - Remarks
55
- * @prop {Array<OperationResultDetail>} employees - Assigned employees
56
- * - Array of `OperationResultDetail` instances representing assigned employees
57
- * @prop {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
58
- * - Array of `OperationResultDetail` instances representing assigned outsourcers
59
- * ---------------------------------------------------------------------------
98
+ * @prop {string} billingMonth - Billing month in YYYY-MM format (read-only)
99
+ * @prop {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
100
+ * @prop {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
101
+ * @prop {number} employeesCount - Count of assigned employees (read-only)
102
+ * @prop {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
103
+ * @prop {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
104
+ * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
105
+ *
60
106
  * @inherited - The following properties are inherited from Agreement (via Operation):
61
107
  * @prop {number} unitPriceBase - Base unit price (JPY)
62
108
  * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
@@ -68,55 +114,7 @@
68
114
  * - The cutoff date for billing, using values defined in the CutoffDate utility class.
69
115
  * - Used to calculate `billingDateAt`.
70
116
  * - When `cutoffDate` or `dateAt` changes, `billingDateAt` is automatically updated.
71
- * ---------------------------------------------------------------------------
72
- * @inherited - The following properties are inherited from WorkingResult (via Operation):
73
- * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
74
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
75
- * - Used to determine `dayType`.
76
- * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
77
- * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
78
- * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
79
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
80
- * @prop {string} startTime - Start time (HH:MM format)
81
- * @prop {boolean} isStartNextDay - Next day start flag
82
- * - `true` if the actual work starts the day after the placement date `dateAt`
83
- * @prop {string} endTime - End time (HH:MM format)
84
- * @prop {number} breakMinutes - Break time (minutes)
85
- * @prop {number} regulationWorkMinutes - Regulation work minutes (trigger property)
86
- * - Indicates the maximum working time treated as regular working hours.
87
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
88
- * ---------------------------------------------------------------------------
89
- * @inherited - The following computed properties are inherited from Operation:
90
- * @computed {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
91
- * @computed {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
92
- * @computed {number} employeesCount - Count of assigned employees (read-only)
93
- * @computed {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
94
- * @computed {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
95
- * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
96
- * @computed {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers`
97
- * - Getter: Returns concatenated array of employees and outsourcers
98
- * - Setter: Splits array into employees and outsourcers based on `isEmployee` property
99
- * ---------------------------------------------------------------------------
100
- * @inherited - The following computed properties are inherited from WorkingResult (via Operation):
101
- * @computed {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
102
- * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
103
- * @computed {Date} startAt - Start date and time (Date object) (read-only)
104
- * - Returns a Date object with `startTime` set based on `dateAt`.
105
- * - If `isStartNextDay` is true, add 1 day.
106
- * @computed {Date} endAt - End date and time (Date object) (read-only)
107
- * - Returns a Date object with `endTime` set based on `dateAt`.
108
- * - If `isStartNextDay` is true, add 1 day.
109
- * - If `isSpansNextDay` is true, add 1 day.
110
- * @computed {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
111
- * - `true` if `startTime` is later than `endTime`
112
- * @computed {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
113
- * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
114
- * @computed {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
115
- * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
116
- * @computed {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
117
- * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
118
- * ---------------------------------------------------------------------------
119
- * @inherited - The following getter properties are inherited from Operation:
117
+ *
120
118
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
121
119
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
122
120
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -128,8 +126,6 @@
128
126
  * - Workers that exist in `_beforeData` but not in current data
129
127
  * @getter {Array<OperationResultDetail>} updatedWorkers - An array of workers that have been updated (read-only)
130
128
  * - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
131
- * ---------------------------------------------------------------------------
132
- * @inherited - The following getter properties are inherited from WorkingResult (via Operation):
133
129
  * @getter {number} startHour - Start hour (0-23) (read-only)
134
130
  * - Extracted from `startTime`.
135
131
  * @getter {number} startMinute - Start minute (0-59) (read-only)
@@ -138,54 +134,49 @@
138
134
  * - Extracted from `endTime`.
139
135
  * @getter {number} endMinute - End minute (0-59) (read-only)
140
136
  * - Extracted from `endTime`.
141
- * ---------------------------------------------------------------------------
142
- * @method {function} beforeDelete - Override method to prevent deletion with siteOperationScheduleId
137
+ *
138
+ * @method beforeDelete - Override method to prevent deletion with siteOperationScheduleId
143
139
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
144
140
  * - Throws an error if deletion is attempted on an instance created from SiteOperationSchedule.
145
- * @method {function} refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
141
+ * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
146
142
  * - Updates `billingDateAt` based on the current `dateAt` and `cutoffDate` values.
147
- * ---------------------------------------------------------------------------
148
- * @inherited - The following methods are inherited from Operation:
149
- * @method {function} addWorker - Adds a new worker (employee or outsourcer)
143
+ * @method addWorker - Adds a new worker (employee or outsourcer)
150
144
  * - @param {Object} options - Options for adding a worker
151
145
  * - @param {string} options.id - The worker ID (employeeId or outsourcerId)
152
146
  * - @param {boolean} [options.isEmployee=true] - Whether the worker is an employee
153
147
  * - @param {number} [index=0] - Insertion position. If -1, adds to the end
154
- * @method {function} moveWorker - Moves the position of a worker (employee or outsourcer)
148
+ * @method moveWorker - Moves the position of a worker (employee or outsourcer)
155
149
  * - @param {Object} options - Options for changing worker position
156
150
  * - @param {number} options.oldIndex - The original index
157
151
  * - @param {number} options.newIndex - The new index
158
152
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
159
- * @method {function} changeWorker - Changes the details of a worker
153
+ * @method changeWorker - Changes the details of a worker
160
154
  * - @param {Object} newWorker - New worker object
161
- * @method {function} removeWorker - Removes a worker (employee or outsourcer)
155
+ * @method removeWorker - Removes a worker (employee or outsourcer)
162
156
  * - @param {Object} options - Options for removing a worker
163
157
  * - @param {string} options.workerId - The ID of the employee or outsourcer
164
158
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
165
- * @method {function} setSiteIdCallback - Callback method called when `siteId` is set
159
+ * @method setSiteIdCallback - Callback method called when `siteId` is set
166
160
  * - Override this method in subclasses to add custom behavior when `siteId` changes.
167
161
  * - By default, does nothing.
168
162
  * - @param {string} v - The new `siteId` value
169
- * @method {function} setShiftTypeCallback - Callback method called when `shiftType` is set
163
+ * @method setShiftTypeCallback - Callback method called when `shiftType` is set
170
164
  * - Override this method in subclasses to add custom behavior when `shiftType` changes.
171
165
  * - By default, does nothing.
172
166
  * - @param {string} v - The new `shiftType` value
173
- * @method {function} setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
167
+ * @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
174
168
  * - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
175
169
  * - By default, does nothing.
176
170
  * - @param {number} v - The new `regulationWorkMinutes` value
171
+ *
177
172
  * @static
178
173
  * @method groupKeyDivider
179
- * Returns an array dividing the key into siteId, shiftType, and date.
180
- * @param {Object|string} key - The combined key string or object
181
- * @returns {Array<string>} - Array containing [siteId, shiftType, date]
182
- * @throws {Error} - If the key is invalid.
183
- * ---------------------------------------------------------------------------
184
- * @inherited - The following method is inherited from WorkingResult (via Operation):
185
- * @method {function} setDateAtCallback - Callback method called when `dateAt` is set
186
- * - Override this method in subclasses to add custom behavior when `dateAt` changes.
187
- * - By default, updates `dayType` based on the new `dateAt` value and synchronizes to workers.
188
- * - @param {Date} v - The new `dateAt` value
174
+ * - Returns an array dividing the key into siteId, shiftType, and date.
175
+ * - @param {Object|string} key - The combined key string or object
176
+ * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
177
+ * - @throws {Error} - If the key is invalid.
178
+ *
179
+ * @override setDateAtCallback - Updates `billingDateAt` based on the new `dateAt` value.
189
180
  *****************************************************************************/
190
181
  import Operation from "./Operation.js";
191
182
  import Agreement from "./Agreement.js";
@@ -230,6 +221,9 @@ const classProps = {
230
221
  label: "ロック",
231
222
  default: false,
232
223
  }),
224
+
225
+ /** add */
226
+ agreement: defField("object", { label: "取極め", customClass: Agreement }),
233
227
  };
234
228
 
235
229
  export default class OperationResult extends Operation {
@@ -451,6 +445,25 @@ export default class OperationResult extends Operation {
451
445
  },
452
446
  set(v) {},
453
447
  },
448
+
449
+ /** add */
450
+ hasAgreement: {
451
+ configurable: true,
452
+ enumerable: true,
453
+ get() {
454
+ return this.agreement != null;
455
+ },
456
+ set(v) {},
457
+ },
458
+ isValid: {
459
+ configurable: true,
460
+ enumerable: true,
461
+ get() {
462
+ if (this.hasAgreement) return true;
463
+ return !this.hasAgreement && !this.useAdjustedQuantity;
464
+ },
465
+ set(v) {},
466
+ },
454
467
  });
455
468
  }
456
469