@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.8 → 2.4.2-dev.80
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/index.js +12 -0
- package/package.json +45 -47
- package/src/Agreement.js +17 -24
- package/src/AgreementV2.js +185 -0
- package/src/ArrangementNotification.js +16 -8
- package/src/Billing.js +5 -34
- package/src/Company.js +162 -25
- package/src/Customer.js +39 -59
- package/src/Employee.js +591 -297
- package/src/FcmToken.js +73 -0
- package/src/Insurance.js +409 -0
- package/src/Notification.js +95 -0
- package/src/NotificationRecipient.js +68 -0
- package/src/Operation.js +272 -280
- package/src/OperationBilling.js +126 -192
- package/src/OperationDetail.js +115 -85
- package/src/OperationResult.js +257 -254
- package/src/OperationResultDetail.js +65 -56
- package/src/Site.js +160 -137
- package/src/SiteOperationSchedule.js +187 -247
- package/src/SiteOperationScheduleDetail.js +75 -65
- package/src/SiteOrder.js +18 -29
- package/src/User.js +44 -47
- package/src/WorkTimeBase.js +205 -0
- package/src/WorkingResult.js +83 -255
- package/src/constants/day-type.js +20 -12
- package/src/constants/index.js +4 -0
- package/src/constants/insurance-status.js +15 -0
- package/src/constants/shift-type.js +5 -2
- package/src/errorDefinitions.js +173 -0
- package/src/parts/fieldDefinitions/array.js +50 -0
- package/src/parts/fieldDefinitions/check.js +53 -0
- package/src/parts/fieldDefinitions/code.js +8 -0
- package/src/parts/fieldDefinitions/constants.js +9 -0
- package/src/parts/fieldDefinitions/dateAt.js +63 -0
- package/src/parts/fieldDefinitions/dateTimeAt.js +8 -0
- package/src/parts/fieldDefinitions/defaultDefinition.js +118 -0
- package/src/parts/fieldDefinitions/multipleLine.js +16 -0
- package/src/parts/fieldDefinitions/number.js +69 -0
- package/src/parts/fieldDefinitions/object.js +38 -0
- package/src/parts/fieldDefinitions/oneLine.js +409 -0
- package/src/parts/fieldDefinitions/radio.js +8 -0
- package/src/parts/fieldDefinitions/select.js +267 -0
- package/src/parts/fieldDefinitions/time.js +8 -0
- package/src/parts/fieldDefinitions.js +46 -669
- package/src/utils/CutoffDate.js +11 -15
- package/src/utils/index.js +44 -8
|
@@ -1,226 +1,126 @@
|
|
|
1
1
|
/*****************************************************************************
|
|
2
|
-
* SiteOperationSchedule
|
|
3
|
-
* @version 1.1.1
|
|
2
|
+
* @file ./src/SiteOperationSchedule.js
|
|
4
3
|
* @author shisyamo4131
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* -
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* -
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* -
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* -
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
44
|
-
* @property {
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @property {number} requiredPersonnel -
|
|
48
|
-
*
|
|
49
|
-
* @property {
|
|
50
|
-
*
|
|
51
|
-
* @property {
|
|
52
|
-
*
|
|
53
|
-
* @property {string}
|
|
54
|
-
*
|
|
55
|
-
* @property {
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @property {Array<
|
|
59
|
-
* -
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @property {
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* -
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
* -
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
* -
|
|
85
|
-
* -
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* - If `isStartNextDay` is true, add 1 day.
|
|
110
|
-
*
|
|
111
|
-
* @property {Date} endAt - End date and time (Date object) (read-only)
|
|
112
|
-
* - Returns a Date object with `endTime` set based on `dateAt`.
|
|
113
|
-
* - If `isStartNextDay` is true, add 1 day.
|
|
114
|
-
* - If `isSpansNextDay` is true, add 1 day.
|
|
115
|
-
*
|
|
116
|
-
* @property {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
|
|
117
|
-
* - `true` if `startTime` is later than `endTime`
|
|
118
|
-
*
|
|
119
|
-
* @property {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
|
|
120
|
-
* - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
|
|
121
|
-
*
|
|
122
|
-
* @property {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
|
|
123
|
-
* - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
|
|
124
|
-
*
|
|
125
|
-
* @property {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
|
|
126
|
-
* - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
|
|
127
|
-
*
|
|
128
|
-
* @inherited - The following getter properties are inherited from Operation:
|
|
129
|
-
* @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
|
|
130
|
-
*
|
|
131
|
-
* @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
|
|
132
|
-
* - Returns true if the employee IDs have changed compared to `_beforeData`
|
|
133
|
-
*
|
|
134
|
-
* @getter {boolean} isOutsourcersChanged - Indicates whether the outsourcers have changed (read-only)
|
|
135
|
-
* - Returns true if the outsourcer IDs have changed compared to `_beforeData`
|
|
136
|
-
*
|
|
137
|
-
* @getter {Array<SiteOperationScheduleDetail>} addedWorkers - An array of workers that have been added (read-only)
|
|
138
|
-
* - Workers that exist in current data but not in `_beforeData`
|
|
139
|
-
*
|
|
140
|
-
* @getter {Array<SiteOperationScheduleDetail>} removedWorkers - An array of workers that have been removed (read-only)
|
|
141
|
-
* - Workers that exist in `_beforeData` but not in current data
|
|
142
|
-
*
|
|
143
|
-
* @getter {Array<SiteOperationScheduleDetail>} updatedWorkers - An array of workers that have been updated (read-only)
|
|
144
|
-
* - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
|
|
145
|
-
*
|
|
146
|
-
* @inherited - The following getter properties are inherited from WorkingResult (via Operation):
|
|
147
|
-
* @getter {number} startHour - Start hour (0-23) (read-only)
|
|
148
|
-
* - Extracted from `startTime`.
|
|
149
|
-
*
|
|
150
|
-
* @getter {number} startMinute - Start minute (0-59) (read-only)
|
|
151
|
-
* - Extracted from `startTime`.
|
|
152
|
-
*
|
|
153
|
-
* @getter {number} endHour - End hour (0-23) (read-only)
|
|
154
|
-
* - Extracted from `endTime`.
|
|
155
|
-
*
|
|
156
|
-
* @getter {number} endMinute - End minute (0-59) (read-only)
|
|
157
|
-
* - Extracted from `endTime`.
|
|
158
|
-
*
|
|
159
|
-
* @getter {boolean} isKeyChanged - Flag indicating whether the key has changed compared to previous data (read-only)
|
|
160
|
-
* - Compares the current `key` with the `key` in `_beforeData`.
|
|
161
|
-
*
|
|
162
|
-
* @method duplicate - Duplicates the SiteOperationSchedule for specified dates
|
|
163
|
-
* - Creates new SiteOperationSchedule documents for each specified date,
|
|
164
|
-
* excluding the original date and avoiding duplicates.
|
|
165
|
-
* - Returns an array of newly created SiteOperationSchedule instances.
|
|
166
|
-
*
|
|
167
|
-
* @method notify - Creates arrangement notifications for workers who have not been notified
|
|
168
|
-
* - Creates ArrangementNotification documents for workers with `hasNotification` set to `false`.
|
|
169
|
-
* - Updates the `hasNotification` flag to `true` for all employees and outsourcers.
|
|
170
|
-
*
|
|
171
|
-
* @method syncToOperationResult - Creates an OperationResult document based on the current SiteOperationSchedule
|
|
172
|
-
* - The OperationResult document ID will be the same as the SiteOperationSchedule document ID.
|
|
173
|
-
* - Sets the `operationResultId` property of the SiteOperationSchedule to the created OperationResult document ID.
|
|
174
|
-
* - If an OperationResult already exists, it will be overwritten.
|
|
175
|
-
* - [UPDATE 2025-11-28] Removed the `agreement` parameter. The agreement is now fetched internally.
|
|
176
|
-
*
|
|
177
|
-
* @method toEvent - Converts the SiteOperationSchedule instance to a VCalendar event object
|
|
178
|
-
* - Returns an object with properties required for displaying events in Vuetify's VCalendar component.
|
|
179
|
-
* - Includes `name`, `start`, `end`, `color`, and a reference to the original `SiteOperationSchedule` instance.
|
|
4
|
+
* @description 現場稼働予定クラス
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @extends Operation
|
|
8
|
+
*
|
|
9
|
+
* @property {Date} dateAt - 日付 (変更されると `dayType` が自動的に更新されます)
|
|
10
|
+
* @property {string} shiftType - 勤務区分 (変更されると `employees` と `outsourcers` の `shiftType` が自動的に更新されます)
|
|
11
|
+
* @property {string} startTime - 開始時刻 (HH:MM 形式)
|
|
12
|
+
* @property {string} endTime - 終了時刻 (HH:MM 形式)
|
|
13
|
+
* @property {boolean} isStartNextDay - 翌日開始フラグ
|
|
14
|
+
* - `true` の場合、実際の勤務は `dateAt` の翌日であることを意味します。
|
|
15
|
+
* @property {number} breakMinutes - 休憩時間 (分)
|
|
16
|
+
* @property {string} date - `dateAt` に基づく YYYY-MM-DD 形式の日付文字列 (読み取り専用)
|
|
17
|
+
* - `dateAt` に基づいて YYYY-MM-DD 形式の文字列を返します。
|
|
18
|
+
* @property {Date} startAt - 開始日時 (Date オブジェクト) (読み取り専用)
|
|
19
|
+
* - `dateAt` に基づいて `startTime` を設定した Date オブジェクトを返します。
|
|
20
|
+
* - `isStartNextDay` が true の場合、1日加算します。
|
|
21
|
+
* @property {Date} endAt - 終了日時 (Date オブジェクト) (読み取り専用)
|
|
22
|
+
* - `startAt` を起点に、最初に現れる `endTime` の Date オブジェクトを返します。
|
|
23
|
+
* @property {boolean} isSpansNextDay - 翌日跨ぎフラグ (読み取り専用)
|
|
24
|
+
* - `true` の場合、`startAt` と `endAt` の日付が異なることを意味します。
|
|
25
|
+
* @property {number} regulationWorkMinutes - 規定労働時間 (分) (変更されると `employees` と `outsourcers` の `regulationWorkMinutes` が自動的に更新されます)
|
|
26
|
+
* - `startAt` から `endAt` までの時間から `breakMinutes` を差し引いた時間のうち、
|
|
27
|
+
* 規定内として扱う労働時間(分)です。
|
|
28
|
+
* - 実際の労働時間から残業時間を算出するための基準となる値です。
|
|
29
|
+
* - この値があることで、取極めに柔軟な設定を行うことが可能になる他、労働基準法の 1 日の所定労働時間上限が変更された際に
|
|
30
|
+
* 影響を最小限に抑えることができます。
|
|
31
|
+
* 例) 8:00 から 17:00 までの勤務で休憩が 60 分の場合
|
|
32
|
+
* - 規定労働時間を 8 時間 (480 分) とし、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
|
|
33
|
+
* 例) 8:00 から 16:00 までの勤務で休憩が 60 分の場合
|
|
34
|
+
* - 規定労働時間を 7 時間 (420 分) とすると、実際の勤務が 7 時間 (420 分) を超えた分が残業時間として扱われます。
|
|
35
|
+
* - 規定労働時間を 8 時間 (480 分) とすると、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
|
|
36
|
+
* 例) 7:00 から 翌日 7:00 までの勤務で休憩が 60 分の場合
|
|
37
|
+
* - 規定労働時間を 8 時間 (480 分) とすると、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
|
|
38
|
+
* この場合、最初の 8 時間までは基本単価が適用され、残りの 8 時間は残業単価が適用されるといった設定が可能になります。
|
|
39
|
+
* - 規定労働時間を 24 時間 (1440 分) とすると、実際の勤務が 24 時間 (1440 分) を超えた分が残業時間として扱われます。
|
|
40
|
+
* この場合、全ての勤務時間が基本単価で扱われるといった設定が可能になります。
|
|
41
|
+
* @property {string} dayType - 曜日区分
|
|
42
|
+
* @property {number} totalWorkMinutes - 総労働時間 (休憩時間を除く) (分) (読み取り専用)
|
|
43
|
+
* @property {number} regularTimeWorkMinutes - 所定労働時間 (分) (読み取り専用)
|
|
44
|
+
* @property {number} overtimeWorkMinutes - 残業時間 (分) (読み取り専用)
|
|
45
|
+
* @property {string} siteId - 現場ID (変更されると `employees` と `outsourcers` の `siteId` が自動的に更新されます)
|
|
46
|
+
* @property {number} requiredPersonnel - 必要人数
|
|
47
|
+
* @property {boolean} qualificationRequired - 資格要件フラグ
|
|
48
|
+
* @property {string} workDescription - 作業内容
|
|
49
|
+
* @property {string} remarks - 備考
|
|
50
|
+
* @property {Array<OperationDetail>} employees - 従業員の OperationDetail インスタンスの配列
|
|
51
|
+
* @property {Array<OperationDetail>} outsourcers - 外注の OperationDetail インスタンスの配列
|
|
52
|
+
* @property {Array<string>} employeeIds - 従業員の ID の配列 (読み取り専用)
|
|
53
|
+
* @property {Array<string>} outsourcerIds - 外注の ID の配列 (読み取り専用)
|
|
54
|
+
* @property {number} employeesCount - `employees` の要素数 (読み取り専用)
|
|
55
|
+
* @property {number} outsourcersCount - `outsourcers` の要素数 (読み取り専用)
|
|
56
|
+
* @property {boolean} isPersonnelShortage - 人員不足フラグ (読み取り専用)
|
|
57
|
+
* @property {Array<OperationDetail>} workers - 従業員と外注を合わせた配列
|
|
58
|
+
* - `employees` と `outsourcers` を結合した配列を返します。
|
|
59
|
+
* - Getter: `employees` と `outsourcers` を結合した配列を返します。
|
|
60
|
+
* - Setter: 配列を `isEmployee` プロパティに基づいて `employees` と `outsourcers` に分割します。
|
|
61
|
+
* @property {string} groupKey - `siteId`, `shiftType`, `date` を組み合わせたキー。(読み取り専用)
|
|
62
|
+
* @property {string} agreementKey - `date`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
63
|
+
* @property {string} orderKey - `siteId`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
64
|
+
*
|
|
65
|
+
* @property {string|null} operationResultId - 関連する OperationResult ドキュメントの ID
|
|
66
|
+
* - このスケジュールを元に OperationResult が作成されている場合、このプロパティにはその OperationResult ドキュメントの ID が入ります。
|
|
67
|
+
* - このプロパティが設定されている場合、スケジュールの更新や削除はできません。逆に、関連する OperationResult が削除された場合、このプロパティを null に設定することができます。
|
|
68
|
+
* @property {number} displayOrder - 同一日付・同一勤務区分のスケジュールの表示順を制御するためのプロパティ
|
|
69
|
+
*
|
|
70
|
+
* @method setDateAtCallback - `dateAt` が設定されたときに呼び出されるコールバック関数
|
|
71
|
+
* @method addWorker - `Workers` に新しい従業員または外注先を追加します。
|
|
72
|
+
* @method moveWorker - 従業員または外注先の位置を移動します。
|
|
73
|
+
* @method changeWorker - 従業員または外注先の詳細を変更します。
|
|
74
|
+
* @method removeWorker - 従業員または外注先を `workers` から削除します。
|
|
75
|
+
* @method setSiteIdCallback - `siteId` が変更された時に呼び出されるコールバック関数
|
|
76
|
+
* @method setShiftTypeCallback - `shiftType` が変更された時に呼び出されるコールバック関数
|
|
77
|
+
* @method setRegulationWorkMinutesCallback - `regulationWorkMinutes` が変更された時に呼び出されるコールバック関数
|
|
78
|
+
*
|
|
79
|
+
* @method duplicate - 指定された日付で SiteOperationSchedule を複製します。
|
|
80
|
+
* - 指定された日付ごとに新しい SiteOperationSchedule ドキュメントを作成します。
|
|
81
|
+
* 元の日付は除外し、重複を避けます。
|
|
82
|
+
* @method notify - 従業員に配置通知を作成します。
|
|
83
|
+
* - `hasNotification` が `false` の従業員に対して ArrangementNotification ドキュメントを作成します。
|
|
84
|
+
* - 全ての従業員と外注先の `hasNotification` フラグを `true` に更新します。
|
|
85
|
+
* - 既に通知が存在する場合は、新たに通知を作成しません。
|
|
86
|
+
* @method syncToOperationResult - 現在の SiteOperationSchedule を元に OperationResult ドキュメントを作成します。
|
|
87
|
+
* - OperationResult ドキュメントの ID は SiteOperationSchedule ドキュメントの ID と同じになります。
|
|
88
|
+
* - SiteOperationSchedule の `operationResultId` プロパティに作成された OperationResult ドキュメントの ID を設定します。
|
|
89
|
+
* - 既に OperationResult が存在する場合は、上書きされます。
|
|
90
|
+
* @method toEvent - SiteOperationSchedule インスタンスを VCalendar のイベントオブジェクトに変換します。
|
|
91
|
+
* - Vuetify の VCalendar コンポーネントでイベントを表示するために必要なプロパティを持つオブジェクトを返します。
|
|
92
|
+
* - `name`, `start`, `end`, `color`、および元の `SiteOperationSchedule` インスタンスへの参照を含みます。
|
|
93
|
+
*
|
|
94
|
+
* @getter {boolean} isInvalid - クラス特有のエラーが存在するかどうかを返すプロパティ
|
|
95
|
+
* @getter {Array<Object>} invalidReasons - エラーコード、メッセージ、多言語メッセージ、フィールド名を含む詳細情報の配列を返すプロパティ
|
|
96
|
+
* @getter {boolean} isGroupKeyChanged - `groupKey` プロパティが変更されたかどうかを返すプロパティ
|
|
97
|
+
* @getter {boolean} isAgreementKeyChanged - `agreementKey` プロパティが変更されたかどうかを返すプロパティ
|
|
98
|
+
* @getter {boolean} isEmployeesChanged - 従業員が変更されたかどうかを示すフラグ (読み取り専用)
|
|
99
|
+
* @getter {boolean} isOutsourcersChanged - 外注が変更されたかどうかを示すフラグ (読み取り専用)
|
|
100
|
+
* @getter {Array<OperationDetail>} addedWorkers - 追加された従業員の配列 (読み取り専用)
|
|
101
|
+
* @getter {Array<OperationDetail>} removedWorkers - 削除された従業員の配列 (読み取り専用)
|
|
102
|
+
* @getter {Array<OperationDetail>} updatedWorkers - 更新された従業員の配列 (読み取り専用)
|
|
103
|
+
*
|
|
104
|
+
* @getter {boolean} isEditable - スケジュールが編集可能かどうかを返すプロパティ
|
|
105
|
+
* - `operationResultId` が設定されている場合は `false` を返し、そうでない場合は `true` を返します。
|
|
106
|
+
* - これにより、関連する OperationResult が存在する場合にスケジュールの編集を制限することができます。
|
|
107
|
+
* @getter {boolean} isNotifiedAllWorkers - 全ての従業員に配置通知が行われているかどうかを返すプロパティ
|
|
180
108
|
*
|
|
181
109
|
* @override
|
|
182
110
|
* @method create - Creates a new SiteOperationSchedule with automatic display order assignment
|
|
183
|
-
*
|
|
184
111
|
* @method update - Updates the SiteOperationSchedule and manages related notifications
|
|
185
112
|
* - Clears all notifications if related data have been changed during updates.
|
|
186
113
|
* - Updates and deletes notifications for removed or updated employees if employee assignments have changed.
|
|
187
|
-
*
|
|
188
114
|
* @method delete - Deletes the SiteOperationSchedule and all related notifications
|
|
189
115
|
* - Deletes all notifications associated with the schedule before deleting the schedule itself.
|
|
190
|
-
*
|
|
191
|
-
* @method addWorker - Adds a new worker with automatic siteOperationScheduleId assignment
|
|
192
|
-
* - Overrides parent method to automatically set `siteOperationScheduleId`
|
|
193
|
-
*
|
|
194
|
-
* @inherited - The following methods are inherited from Operation:
|
|
195
|
-
* @method moveWorker - Moves the position of a worker (employee or outsourcer)
|
|
196
|
-
*
|
|
197
|
-
* @method changeWorker - Changes the details of a worker
|
|
198
|
-
*
|
|
199
|
-
* @method removeWorker - Removes a worker (employee or outsourcer)
|
|
200
|
-
*
|
|
201
|
-
* @method setSiteIdCallback - Callback method called when `siteId` is set
|
|
202
|
-
* - Override this method in subclasses to add custom behavior when `siteId` changes.
|
|
203
|
-
*
|
|
204
|
-
* @method setShiftTypeCallback - Callback method called when `shiftType` is set
|
|
205
|
-
* - Override this method in subclasses to add custom behavior when `shiftType` changes.
|
|
206
|
-
*
|
|
207
|
-
* @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
|
|
208
|
-
* - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
|
|
209
|
-
*
|
|
210
|
-
* @static
|
|
211
|
-
* @method groupKeyDivider Returns an array dividing the key into siteId, shiftType, and date.
|
|
212
|
-
*
|
|
213
|
-
* @inherited - The following method is inherited from WorkingResult (via Operation):
|
|
214
|
-
* @method setDateAtCallback - Callback method called when `dateAt` is set
|
|
215
|
-
* - Override this method in subclasses to add custom behavior when `dateAt` changes.
|
|
216
|
-
* - By default, updates `dayType` based on the new `dateAt` value and synchronizes to workers.
|
|
217
116
|
*****************************************************************************/
|
|
218
117
|
import Operation from "./Operation.js";
|
|
219
118
|
import { defField } from "./parts/fieldDefinitions.js";
|
|
220
|
-
import { ContextualError } from "./utils/index.js";
|
|
119
|
+
import { ContextualError, formatJstDate } from "./utils/index.js";
|
|
221
120
|
import ArrangementNotification from "./ArrangementNotification.js";
|
|
222
121
|
import SiteOperationScheduleDetail from "./SiteOperationScheduleDetail.js";
|
|
223
122
|
import OperationResult from "./OperationResult.js";
|
|
123
|
+
import Site from "./Site.js";
|
|
224
124
|
|
|
225
125
|
const classProps = {
|
|
226
126
|
...Operation.classProps,
|
|
@@ -338,7 +238,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
338
238
|
set(v) {
|
|
339
239
|
if (typeof v !== "number" || isNaN(v) || v < 0) {
|
|
340
240
|
throw new Error(
|
|
341
|
-
`breakMinutes must be a non-negative number. breakMinutes: ${v}
|
|
241
|
+
`breakMinutes must be a non-negative number. breakMinutes: ${v}`,
|
|
342
242
|
);
|
|
343
243
|
}
|
|
344
244
|
if (_breakMinutes === v) return;
|
|
@@ -353,7 +253,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
353
253
|
set(v) {
|
|
354
254
|
if (typeof v !== "boolean") {
|
|
355
255
|
throw new Error(
|
|
356
|
-
`isStartNextDay must be a boolean. isStartNextDay: ${v}
|
|
256
|
+
`isStartNextDay must be a boolean. isStartNextDay: ${v}`,
|
|
357
257
|
);
|
|
358
258
|
}
|
|
359
259
|
if (_isStartNextDay === v) return;
|
|
@@ -378,7 +278,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
378
278
|
* Returns whether all workers have been notified.
|
|
379
279
|
* @returns {boolean} - Whether all workers have been notified.
|
|
380
280
|
*/
|
|
381
|
-
get
|
|
281
|
+
get isNotifiedAllWorkers() {
|
|
382
282
|
return this.workers.every((worker) => worker.hasNotification);
|
|
383
283
|
}
|
|
384
284
|
|
|
@@ -396,7 +296,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
396
296
|
async beforeUpdate(args = {}) {
|
|
397
297
|
if (this._beforeData.operationResultId) {
|
|
398
298
|
throw new Error(
|
|
399
|
-
`Could not update this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}
|
|
299
|
+
`Could not update this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}`,
|
|
400
300
|
);
|
|
401
301
|
}
|
|
402
302
|
await super.beforeUpdate(args);
|
|
@@ -413,7 +313,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
413
313
|
async beforeDelete(args = {}) {
|
|
414
314
|
if (this._beforeData.operationResultId) {
|
|
415
315
|
throw new Error(
|
|
416
|
-
`Could not delete this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}
|
|
316
|
+
`Could not delete this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}`,
|
|
417
317
|
);
|
|
418
318
|
}
|
|
419
319
|
await super.beforeDelete(args);
|
|
@@ -587,7 +487,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
587
487
|
}
|
|
588
488
|
if (dates.some((d) => !(d instanceof Date) && typeof d !== "string")) {
|
|
589
489
|
throw new TypeError(
|
|
590
|
-
"日付の指定が無効です。Dateオブジェクトか文字列で指定してください。"
|
|
490
|
+
"日付の指定が無効です。Dateオブジェクトか文字列で指定してください。",
|
|
591
491
|
);
|
|
592
492
|
}
|
|
593
493
|
if (dates.length > 20) {
|
|
@@ -599,11 +499,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
599
499
|
const targetDates = dates
|
|
600
500
|
.map((date) => {
|
|
601
501
|
if (date instanceof Date) {
|
|
602
|
-
|
|
603
|
-
const year = jstDate.getUTCFullYear();
|
|
604
|
-
const month = String(jstDate.getUTCMonth() + 1).padStart(2, "0");
|
|
605
|
-
const day = String(jstDate.getUTCDate()).padStart(2, "0");
|
|
606
|
-
return `${year}-${month}-${day}`;
|
|
502
|
+
return formatJstDate(date);
|
|
607
503
|
}
|
|
608
504
|
return date;
|
|
609
505
|
})
|
|
@@ -631,7 +527,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
631
527
|
// トランザクションで一括作成
|
|
632
528
|
await this.constructor.runTransaction(async (transaction) => {
|
|
633
529
|
await Promise.all(
|
|
634
|
-
newSchedules.map((schedule) => schedule.create({ transaction }))
|
|
530
|
+
newSchedules.map((schedule) => schedule.create({ transaction })),
|
|
635
531
|
);
|
|
636
532
|
});
|
|
637
533
|
|
|
@@ -693,55 +589,84 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
693
589
|
className: "SiteOperationSchedule",
|
|
694
590
|
arguments: {},
|
|
695
591
|
state: this.toObject(),
|
|
696
|
-
}
|
|
592
|
+
},
|
|
697
593
|
);
|
|
698
594
|
}
|
|
699
595
|
}
|
|
700
596
|
|
|
701
|
-
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
* 既に存在する場合は上書きされます。
|
|
705
|
-
* - 現場稼働予定ドキュメントの `operationResultId` プロパティに
|
|
706
|
-
* 作成された稼働実績ドキュメントの ID が設定されます。(当該ドキュメント ID と同一)
|
|
597
|
+
/*****************************************************************************
|
|
598
|
+
* syncToOperationResult
|
|
599
|
+
* ---------------------------------------------------------
|
|
707
600
|
* @param {Object} notifications - 配置通知オブジェクトのマップ。
|
|
708
|
-
* -
|
|
709
|
-
* -
|
|
601
|
+
* - key: 配置通知の一意キー(`notificationKey` プロパティ)
|
|
602
|
+
* - value: 配置通知ドキュメントオブジェクト
|
|
710
603
|
* @returns {Promise<void>}
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
|
|
604
|
+
* ---------------------------------------------------------
|
|
605
|
+
* 現在の現場稼働予定 (SiteOperationSchedule) インスタンスをもとに稼働実績 (OperationResult) ドキュメントを作成します。
|
|
606
|
+
* - `OperationResult` の `docId` は `SiteOperationSchedule` の `docId` と同一になります。既に存在する場合は上書きされます。
|
|
607
|
+
* - このインスタンスの `operationResultId` プロパティは作成された`OperationResult` の `docId` が設定されます。
|
|
608
|
+
* - つまり、現場稼働予定ドキュメントと稼働実績ドキュメントは 1 対 1 の関係になり、現場稼働予定ドキュメントの `operationResultId` は
|
|
609
|
+
* 自身の `docId` と同じ値になります。
|
|
610
|
+
* - 稼働実績ドキュメントに適用されるべき取極め (Agreement) の取得は、`OperationResult` クラスに任せられます。
|
|
611
|
+
* - 引数として `notifications` を受け取ります。これは配置通知 (ArrangementNotification) ドキュメントのマップで、
|
|
612
|
+
* `notificationKey` をキー、配置通知ドキュメントオブジェクトを値とするオブジェクトです。
|
|
613
|
+
* `notifications` を受け取ると、従業員・外注先の稼働実績詳細データを生成する際に、配置通知ドキュメントの実際の開始時間、終了時間、休憩時間などが
|
|
614
|
+
* `employees` および `outsourcers` の `startTime`, `endTime`, `breakMinutes` などのプロパティに反映されます。
|
|
615
|
+
*****************************************************************************/
|
|
714
616
|
async syncToOperationResult(notifications = {}) {
|
|
617
|
+
// ドキュメントIDがない(現場稼働予定ドキュメントとして未作成)場合はエラー
|
|
715
618
|
if (!this.docId) {
|
|
716
619
|
throw new Error(
|
|
717
|
-
"不正な処理です。作成前の現場稼働予定から稼働実績を作成することはできません。"
|
|
620
|
+
"不正な処理です。作成前の現場稼働予定から稼働実績を作成することはできません。",
|
|
718
621
|
);
|
|
719
622
|
}
|
|
720
623
|
|
|
721
|
-
|
|
722
|
-
|
|
624
|
+
// 現場データの存在確認と登録状態の確認
|
|
625
|
+
// - 存在しない、または仮登録状態の場合はエラー
|
|
626
|
+
const siteInstance = new Site();
|
|
627
|
+
const siteIsExist = await siteInstance.fetch({ docId: this.siteId });
|
|
628
|
+
if (!siteIsExist) {
|
|
629
|
+
throw new Error(
|
|
630
|
+
`不正な処理です。現場ID: ${this.siteId} の現場データが存在しません。`,
|
|
631
|
+
);
|
|
723
632
|
}
|
|
633
|
+
if (siteInstance.isTemporary) {
|
|
634
|
+
throw new Error(
|
|
635
|
+
`不正な処理です。現場ID: ${this.siteId} の現場データは仮登録状態です。`,
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* 配置通知データをもとに、従業員・外注先の稼働実績詳細データを変換する関数
|
|
641
|
+
* - 該当する `notification` が存在する場合、`startTime`, `endTime`, `breakMinutes`, `isStartNextDay` が
|
|
642
|
+
* `notification` の `actualStartTime`, `actualEndTime`, `actualBreakMinutes`, `actualIsStartNextDay` に置き換えられます。
|
|
643
|
+
* @param {string} prop - 変換対象のプロパティ名("employees" または "outsourcers")
|
|
644
|
+
* @returns {Array<SiteOperationScheduleDetail>} 変換後の稼働実績詳細データの配列
|
|
645
|
+
*/
|
|
724
646
|
const converter = (prop) => {
|
|
725
647
|
return this[prop].map((w) => {
|
|
726
648
|
const notification = notifications[w.notificationKey];
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
649
|
+
const result = w.clone();
|
|
650
|
+
result.startTime = notification?.actualStartTime ?? w.startTime;
|
|
651
|
+
result.endTime = notification?.actualEndTime ?? w.endTime;
|
|
652
|
+
result.breakMinutes =
|
|
653
|
+
notification?.actualBreakMinutes ?? w.breakMinutes;
|
|
654
|
+
result.isStartNextDay =
|
|
655
|
+
notification?.actualIsStartNextDay ?? w.isStartNextDay;
|
|
656
|
+
return result;
|
|
735
657
|
});
|
|
736
658
|
};
|
|
659
|
+
|
|
660
|
+
// 従業員・外注先の稼働実績詳細データを生成
|
|
737
661
|
const employees = converter("employees");
|
|
738
662
|
const outsourcers = converter("outsourcers");
|
|
663
|
+
|
|
739
664
|
try {
|
|
740
665
|
// Create OperationResult instance based on the current SiteOperationSchedule
|
|
741
666
|
const operationResult = new OperationResult({
|
|
742
667
|
...this.toObject(),
|
|
743
|
-
employees,
|
|
744
|
-
outsourcers,
|
|
668
|
+
employees, // 配置通知の実際の勤務時間などを反映した従業員の稼働実績詳細データでマージ
|
|
669
|
+
outsourcers, // 配置通知の実際の勤務時間などを反映した外注先の稼働実績詳細データでマージ
|
|
745
670
|
siteOperationScheduleId: this.docId,
|
|
746
671
|
});
|
|
747
672
|
await this.constructor.runTransaction(async (transaction) => {
|
|
@@ -756,7 +681,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
756
681
|
throw new ContextualError(error.message, {
|
|
757
682
|
method: "syncToOperationResult()",
|
|
758
683
|
className: "SiteOperationSchedule",
|
|
759
|
-
arguments: {
|
|
684
|
+
arguments: { notifications },
|
|
760
685
|
state: this.toObject(),
|
|
761
686
|
});
|
|
762
687
|
}
|
|
@@ -795,8 +720,8 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
795
720
|
const color = !this.isEditable
|
|
796
721
|
? "grey"
|
|
797
722
|
: this.shiftType === "DAY"
|
|
798
|
-
|
|
799
|
-
|
|
723
|
+
? "orange"
|
|
724
|
+
: "indigo";
|
|
800
725
|
return {
|
|
801
726
|
name,
|
|
802
727
|
start: this.dateAt,
|
|
@@ -805,4 +730,19 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
805
730
|
item: this,
|
|
806
731
|
};
|
|
807
732
|
}
|
|
733
|
+
|
|
734
|
+
/***************************************************************************
|
|
735
|
+
* FOR DEPRECATED PROPERTIES
|
|
736
|
+
***************************************************************************/
|
|
737
|
+
/**
|
|
738
|
+
* @deprecated
|
|
739
|
+
* Returns whether all workers have been notified.
|
|
740
|
+
* @returns {boolean} - Whether all workers have been notified.
|
|
741
|
+
*/
|
|
742
|
+
get isNotificatedAllWorkers() {
|
|
743
|
+
console.warn(
|
|
744
|
+
"`isNotificatedAllWorkers` is deprecated. Use `isNotifiedAllWorkers` instead.",
|
|
745
|
+
);
|
|
746
|
+
return this.workers.every((worker) => worker.hasNotification);
|
|
747
|
+
}
|
|
808
748
|
}
|