@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.0 → 1.3.1-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 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.4",
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 `agreement.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,81 @@
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
+ *
113
106
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
114
107
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
115
108
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -121,8 +114,6 @@
121
114
  * - Workers that exist in `_beforeData` but not in current data
122
115
  * @getter {Array<OperationResultDetail>} updatedWorkers - An array of workers that have been updated (read-only)
123
116
  * - 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
117
  * @getter {number} startHour - Start hour (0-23) (read-only)
127
118
  * - Extracted from `startTime`.
128
119
  * @getter {number} startMinute - Start minute (0-59) (read-only)
@@ -131,53 +122,51 @@
131
122
  * - Extracted from `endTime`.
132
123
  * @getter {number} endMinute - End minute (0-59) (read-only)
133
124
  * - Extracted from `endTime`.
134
- * ---------------------------------------------------------------------------
135
- * @inherited - The following methods are inherited from OperationResult:
136
- * @method {function} beforeDelete - Override method to prevent deletion with siteOperationScheduleId
125
+ *
126
+ * @method beforeDelete - Override method to prevent deletion with siteOperationScheduleId
137
127
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
138
128
  * - 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)
129
+ * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
130
+ * - Updates `billingDateAt` based on the current `dateAt` and `cutoffDate` values.
131
+ * @method addWorker - Adds a new worker (employee or outsourcer)
142
132
  * - @param {Object} options - Options for adding a worker
143
133
  * - @param {string} options.id - The worker ID (employeeId or outsourcerId)
144
134
  * - @param {boolean} [options.isEmployee=true] - Whether the worker is an employee
145
135
  * - @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)
136
+ * @method moveWorker - Moves the position of a worker (employee or outsourcer)
147
137
  * - @param {Object} options - Options for changing worker position
148
138
  * - @param {number} options.oldIndex - The original index
149
139
  * - @param {number} options.newIndex - The new index
150
140
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
151
- * @method {function} changeWorker - Changes the details of a worker
141
+ * @method changeWorker - Changes the details of a worker
152
142
  * - @param {Object} newWorker - New worker object
153
- * @method {function} removeWorker - Removes a worker (employee or outsourcer)
143
+ * @method removeWorker - Removes a worker (employee or outsourcer)
154
144
  * - @param {Object} options - Options for removing a worker
155
145
  * - @param {string} options.workerId - The ID of the employee or outsourcer
156
146
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
157
- * @method {function} setSiteIdCallback - Callback method called when `siteId` is set
147
+ * @method setSiteIdCallback - Callback method called when `siteId` is set
158
148
  * - Override this method in subclasses to add custom behavior when `siteId` changes.
159
149
  * - By default, does nothing.
160
150
  * - @param {string} v - The new `siteId` value
161
- * @method {function} setShiftTypeCallback - Callback method called when `shiftType` is set
151
+ * @method setShiftTypeCallback - Callback method called when `shiftType` is set
162
152
  * - Override this method in subclasses to add custom behavior when `shiftType` changes.
163
153
  * - By default, does nothing.
164
154
  * - @param {string} v - The new `shiftType` value
165
- * @method {function} setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
155
+ * @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
166
156
  * - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
167
157
  * - By default, does nothing.
168
158
  * - @param {number} v - The new `regulationWorkMinutes` value
159
+ *
169
160
  * @static
170
161
  * @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
162
+ * - Returns an array dividing the key into siteId, shiftType, and date.
163
+ * - @param {Object|string} key - The combined key string or object
164
+ * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
165
+ * - @throws {Error} - If the key is invalid.
166
+ *
167
+ * @override create - Override create method to indicate not implemented
168
+ * - Creation of OperationBilling instances is not implemented, as billing records are typically
169
+ * generated through the OperationResult class.
181
170
  *****************************************************************************/
182
171
  import OperationResult from "./OperationResult.js";
183
172
 
@@ -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,71 +10,13 @@
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
- * @prop {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
14
- * - If this OperationResult was created from a SiteOperationSchedule, this property holds that ID.
15
- * - If this property is set, the instance cannot be deleted.
16
- * @prop {boolean} useAdjustedQuantity - Flag to indicate if adjusted quantities are used for billing
17
- * @prop {number} adjustedQuantityBase - Adjusted quantity for base workers
18
- * - Quantity used for billing base workers when `useAdjustedQuantity` is true.
19
- * @prop {number} adjustedOvertimeBase - Adjusted overtime for base workers
20
- * - Overtime used for billing base workers when `useAdjustedQuantity` is true.
21
- * @prop {number} adjustedQuantityQualified - Adjusted quantity for qualified workers
22
- * - Quantity used for billing qualified workers when `useAdjustedQuantity` is true.
23
- * @prop {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
24
- * - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
25
- * @prop {Date} billingDateAt - Billing date
26
- * - The date used for billing purposes.
27
- * @prop {boolean} isLocked - Lock flag
28
- * - 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)
31
- * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
32
- * - Structure: { base: {...}, qualified: {...}, total: {...} }
33
- * - Each category contains: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
34
- * - Each category also has an 'ojt' subcategory with the same structure.
35
- * @computed {Object} sales - Sales amounts (read-only)
36
- * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
37
- * - Structure: { base: {...}, qualified: {...} }
38
- * - Each category contains: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
39
- * - Calculations respect `useAdjustedQuantity`, `billingUnitType`, and `includeBreakInBilling` settings.
40
- * @computed {number} salesAmount - Total sales amount (read-only)
41
- * - Sum of sales amounts for base and qualified workers with rounding applied.
42
- * @computed {number} tax - Calculated tax amount (read-only)
43
- * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
44
- * @computed {number} billingAmount - Total billing amount including tax (read-only)
45
- * - 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:
13
+ *
49
14
  * @prop {string} siteId - Site document ID (trigger property)
50
15
  * - 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
- * ---------------------------------------------------------------------------
60
- * @inherited - The following properties are inherited from Agreement (via Operation):
61
- * @prop {number} unitPriceBase - Base unit price (JPY)
62
- * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
63
- * @prop {number} unitPriceQualified - Qualified unit price (JPY)
64
- * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
65
- * @prop {string} billingUnitType - Billing unit type
66
- * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
67
- * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
68
- * - The cutoff date for billing, using values defined in the CutoffDate utility class.
69
- * - Used to calculate `billingDateAt`.
70
- * - When `cutoffDate` or `dateAt` changes, `billingDateAt` is automatically updated.
71
- * ---------------------------------------------------------------------------
72
- * @inherited - The following properties are inherited from WorkingResult (via Operation):
73
16
  * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
74
17
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
75
18
  * - Used to determine `dayType`.
76
- * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
19
+ * - When `dateAt` changes, `billingDateAt` is also updated based on `agreement.cutoffDate`.
77
20
  * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
78
21
  * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
79
22
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
@@ -85,38 +28,81 @@
85
28
  * @prop {number} regulationWorkMinutes - Regulation work minutes (trigger property)
86
29
  * - Indicates the maximum working time treated as regular working hours.
87
30
  * - 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`
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`
97
40
  * - Getter: Returns concatenated array of employees and outsourcers
98
41
  * - 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)
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)
102
62
  * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
103
- * @computed {Date} startAt - Start date and time (Date object) (read-only)
63
+ * @prop {Date} startAt - Start date and time (Date object) (read-only)
104
64
  * - Returns a Date object with `startTime` set based on `dateAt`.
105
65
  * - If `isStartNextDay` is true, add 1 day.
106
- * @computed {Date} endAt - End date and time (Date object) (read-only)
66
+ * @prop {Date} endAt - End date and time (Date object) (read-only)
107
67
  * - Returns a Date object with `endTime` set based on `dateAt`.
108
68
  * - If `isStartNextDay` is true, add 1 day.
109
69
  * - 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)
70
+ * @prop {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
111
71
  * - `true` if `startTime` is later than `endTime`
112
- * @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)
113
73
  * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
114
- * @computed {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
74
+ * @prop {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
115
75
  * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
116
- * @computed {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
76
+ * @prop {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
117
77
  * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
118
- * ---------------------------------------------------------------------------
119
- * @inherited - The following getter properties are inherited from Operation:
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
+ *
120
106
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
121
107
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
122
108
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -128,8 +114,6 @@
128
114
  * - Workers that exist in `_beforeData` but not in current data
129
115
  * @getter {Array<OperationResultDetail>} updatedWorkers - An array of workers that have been updated (read-only)
130
116
  * - 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
117
  * @getter {number} startHour - Start hour (0-23) (read-only)
134
118
  * - Extracted from `startTime`.
135
119
  * @getter {number} startMinute - Start minute (0-59) (read-only)
@@ -138,54 +122,49 @@
138
122
  * - Extracted from `endTime`.
139
123
  * @getter {number} endMinute - End minute (0-59) (read-only)
140
124
  * - Extracted from `endTime`.
141
- * ---------------------------------------------------------------------------
142
- * @method {function} beforeDelete - Override method to prevent deletion with siteOperationScheduleId
125
+ *
126
+ * @method beforeDelete - Override method to prevent deletion with siteOperationScheduleId
143
127
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
144
128
  * - Throws an error if deletion is attempted on an instance created from SiteOperationSchedule.
145
- * @method {function} refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
129
+ * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
146
130
  * - 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)
131
+ * @method addWorker - Adds a new worker (employee or outsourcer)
150
132
  * - @param {Object} options - Options for adding a worker
151
133
  * - @param {string} options.id - The worker ID (employeeId or outsourcerId)
152
134
  * - @param {boolean} [options.isEmployee=true] - Whether the worker is an employee
153
135
  * - @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)
136
+ * @method moveWorker - Moves the position of a worker (employee or outsourcer)
155
137
  * - @param {Object} options - Options for changing worker position
156
138
  * - @param {number} options.oldIndex - The original index
157
139
  * - @param {number} options.newIndex - The new index
158
140
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
159
- * @method {function} changeWorker - Changes the details of a worker
141
+ * @method changeWorker - Changes the details of a worker
160
142
  * - @param {Object} newWorker - New worker object
161
- * @method {function} removeWorker - Removes a worker (employee or outsourcer)
143
+ * @method removeWorker - Removes a worker (employee or outsourcer)
162
144
  * - @param {Object} options - Options for removing a worker
163
145
  * - @param {string} options.workerId - The ID of the employee or outsourcer
164
146
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
165
- * @method {function} setSiteIdCallback - Callback method called when `siteId` is set
147
+ * @method setSiteIdCallback - Callback method called when `siteId` is set
166
148
  * - Override this method in subclasses to add custom behavior when `siteId` changes.
167
149
  * - By default, does nothing.
168
150
  * - @param {string} v - The new `siteId` value
169
- * @method {function} setShiftTypeCallback - Callback method called when `shiftType` is set
151
+ * @method setShiftTypeCallback - Callback method called when `shiftType` is set
170
152
  * - Override this method in subclasses to add custom behavior when `shiftType` changes.
171
153
  * - By default, does nothing.
172
154
  * - @param {string} v - The new `shiftType` value
173
- * @method {function} setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
155
+ * @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
174
156
  * - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
175
157
  * - By default, does nothing.
176
158
  * - @param {number} v - The new `regulationWorkMinutes` value
159
+ *
177
160
  * @static
178
161
  * @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
162
+ * - Returns an array dividing the key into siteId, shiftType, and date.
163
+ * - @param {Object|string} key - The combined key string or object
164
+ * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
165
+ * - @throws {Error} - If the key is invalid.
166
+ *
167
+ * @override setDateAtCallback - Updates `billingDateAt` based on the new `dateAt` value.
189
168
  *****************************************************************************/
190
169
  import Operation from "./Operation.js";
191
170
  import Agreement from "./Agreement.js";
@@ -199,7 +178,6 @@ import CutoffDate from "./utils/CutoffDate.js";
199
178
 
200
179
  const classProps = {
201
180
  ...Operation.classProps,
202
- ...Agreement.classProps,
203
181
  siteOperationScheduleId: defField("oneLine", { hidden: true }),
204
182
  useAdjustedQuantity: defField("check", {
205
183
  label: "調整数量を使用",
@@ -230,6 +208,9 @@ const classProps = {
230
208
  label: "ロック",
231
209
  default: false,
232
210
  }),
211
+
212
+ /** add */
213
+ agreement: defField("object", { label: "取極め", customClass: Agreement }),
233
214
  };
234
215
 
235
216
  export default class OperationResult extends Operation {
@@ -251,20 +232,7 @@ export default class OperationResult extends Operation {
251
232
  super.afterInitialize();
252
233
 
253
234
  /** Computed properties */
254
- let _cutoffDate = this.cutoffDate;
255
235
  Object.defineProperties(this, {
256
- cutoffDate: {
257
- configurable: true,
258
- enumerable: true,
259
- get() {
260
- return _cutoffDate;
261
- },
262
- set(v) {
263
- _cutoffDate = v;
264
- // Update billingDateAt when cutoffDate changes
265
- this.refreshBillingDateAt();
266
- },
267
- },
268
236
  statistics: {
269
237
  configurable: true,
270
238
  enumerable: true,
@@ -340,14 +308,19 @@ export default class OperationResult extends Operation {
340
308
  return createInitialValues();
341
309
  }
342
310
 
311
+ // agreementがfalsyの場合は初期値を返す
312
+ if (!this.agreement) {
313
+ return createInitialValues();
314
+ }
315
+
343
316
  const unitPrice = isQualified
344
- ? this.unitPriceQualified || 0
345
- : this.unitPriceBase || 0;
317
+ ? this.agreement.unitPriceQualified || 0
318
+ : this.agreement.unitPriceBase || 0;
346
319
  const overtimeUnitPrice = isQualified
347
- ? this.overtimeUnitPriceQualified || 0
348
- : this.overtimeUnitPriceBase || 0;
320
+ ? this.agreement.overtimeUnitPriceQualified || 0
321
+ : this.agreement.overtimeUnitPriceBase || 0;
349
322
  const isPerHour =
350
- this.billingUnitType === BILLING_UNIT_TYPE_PER_HOUR;
323
+ this.agreement.billingUnitType === BILLING_UNIT_TYPE_PER_HOUR;
351
324
 
352
325
  const result = createInitialValues();
353
326
 
@@ -364,28 +337,24 @@ export default class OperationResult extends Operation {
364
337
  ? this.adjustedOvertimeQualified || 0
365
338
  : this.adjustedOvertimeBase || 0;
366
339
  } else {
367
- // result.quantity = isPerHour
368
- // ? (categoryStats.totalWorkMinutes || 0) / 60
369
- // : categoryStats.quantity || 0;
370
- // result.overtimeMinutes = categoryStats.overtimeWorkMinutes || 0;
371
340
  if (isPerHour) {
372
341
  // 時間単位請求の場合
373
342
  let totalMinutes = categoryStats.totalWorkMinutes || 0;
374
343
 
375
344
  // 休憩時間を請求に含める場合は休憩時間を追加
376
- if (this.includeBreakInBilling) {
345
+ if (this.agreement.includeBreakInBilling) {
377
346
  totalMinutes += categoryStats.breakMinutes || 0;
378
347
  }
379
348
 
380
349
  result.quantity = totalMinutes / 60;
381
350
  } else {
382
- // 日単位請求の場合(休憩時間は関係なし)
351
+ // 日単位請求の場合(休憩時間は関係なし)
383
352
  result.quantity = categoryStats.quantity || 0;
384
353
  }
385
354
  result.overtimeMinutes = categoryStats.overtimeWorkMinutes || 0;
386
355
  }
387
356
 
388
- // 金額計算(RoundSettingを適用)
357
+ // 金額計算(RoundSettingを適用)
389
358
  result.regularAmount = RoundSetting.apply(
390
359
  result.quantity * unitPrice
391
360
  );
@@ -451,6 +420,25 @@ export default class OperationResult extends Operation {
451
420
  },
452
421
  set(v) {},
453
422
  },
423
+
424
+ /** add */
425
+ hasAgreement: {
426
+ configurable: true,
427
+ enumerable: true,
428
+ get() {
429
+ return this.agreement != null;
430
+ },
431
+ set(v) {},
432
+ },
433
+ isValid: {
434
+ configurable: true,
435
+ enumerable: true,
436
+ get() {
437
+ if (this.hasAgreement) return true;
438
+ return !this.hasAgreement && !this.useAdjustedQuantity;
439
+ },
440
+ set(v) {},
441
+ },
454
442
  });
455
443
  }
456
444
 
@@ -463,13 +451,17 @@ export default class OperationResult extends Operation {
463
451
  this.billingDateAt = null;
464
452
  return;
465
453
  }
466
- if (this.cutoffDate !== 0 && !this.cutoffDate) {
454
+ if (!this.agreement) {
455
+ this.billingDateAt = null;
456
+ return;
457
+ }
458
+ if (this.agreement.cutoffDate !== 0 && !this.agreement.cutoffDate) {
467
459
  this.billingDateAt = null;
468
460
  return;
469
461
  }
470
462
  this.billingDateAt = CutoffDate.calculateBillingDateAt(
471
463
  this.dateAt,
472
- this.cutoffDate
464
+ this.agreement.cutoffDate
473
465
  );
474
466
  }
475
467