@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.
Files changed (47) hide show
  1. package/index.js +12 -0
  2. package/package.json +45 -47
  3. package/src/Agreement.js +17 -24
  4. package/src/AgreementV2.js +185 -0
  5. package/src/ArrangementNotification.js +16 -8
  6. package/src/Billing.js +5 -34
  7. package/src/Company.js +162 -25
  8. package/src/Customer.js +39 -59
  9. package/src/Employee.js +591 -297
  10. package/src/FcmToken.js +73 -0
  11. package/src/Insurance.js +409 -0
  12. package/src/Notification.js +95 -0
  13. package/src/NotificationRecipient.js +68 -0
  14. package/src/Operation.js +272 -280
  15. package/src/OperationBilling.js +126 -192
  16. package/src/OperationDetail.js +115 -85
  17. package/src/OperationResult.js +257 -254
  18. package/src/OperationResultDetail.js +65 -56
  19. package/src/Site.js +160 -137
  20. package/src/SiteOperationSchedule.js +187 -247
  21. package/src/SiteOperationScheduleDetail.js +75 -65
  22. package/src/SiteOrder.js +18 -29
  23. package/src/User.js +44 -47
  24. package/src/WorkTimeBase.js +205 -0
  25. package/src/WorkingResult.js +83 -255
  26. package/src/constants/day-type.js +20 -12
  27. package/src/constants/index.js +4 -0
  28. package/src/constants/insurance-status.js +15 -0
  29. package/src/constants/shift-type.js +5 -2
  30. package/src/errorDefinitions.js +173 -0
  31. package/src/parts/fieldDefinitions/array.js +50 -0
  32. package/src/parts/fieldDefinitions/check.js +53 -0
  33. package/src/parts/fieldDefinitions/code.js +8 -0
  34. package/src/parts/fieldDefinitions/constants.js +9 -0
  35. package/src/parts/fieldDefinitions/dateAt.js +63 -0
  36. package/src/parts/fieldDefinitions/dateTimeAt.js +8 -0
  37. package/src/parts/fieldDefinitions/defaultDefinition.js +118 -0
  38. package/src/parts/fieldDefinitions/multipleLine.js +16 -0
  39. package/src/parts/fieldDefinitions/number.js +69 -0
  40. package/src/parts/fieldDefinitions/object.js +38 -0
  41. package/src/parts/fieldDefinitions/oneLine.js +409 -0
  42. package/src/parts/fieldDefinitions/radio.js +8 -0
  43. package/src/parts/fieldDefinitions/select.js +267 -0
  44. package/src/parts/fieldDefinitions/time.js +8 -0
  45. package/src/parts/fieldDefinitions.js +46 -669
  46. package/src/utils/CutoffDate.js +11 -15
  47. package/src/utils/index.js +44 -8
@@ -1,184 +1,133 @@
1
1
  /*****************************************************************************
2
- * OperationBilling Model
3
- * @version 1.0.0
2
+ * @file ./src/OperationBilling.js
4
3
  * @author shisyamo4131
4
+ * @description 稼働請求クラス
5
5
  *
6
- * - Extends OperationResult class to represent the billing of an operation.
7
- * - This class provides the same functionality as OperationResult but with a different semantic meaning
8
- * focused on billing operations rather than general operation results.
9
- * - All properties, computed values, and methods are inherited from OperationResult.
10
- * - The `className` is set to "稼働請求" (Operation Billing) to distinguish it from OperationResult.
11
- * - The `create` method is overridden to indicate that creation of OperationBilling instances
12
- * is not implemented, as billing records are typically generated through the OperationResult class.
6
+ * @class
7
+ * @extends OperationResult
13
8
  *
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 `agreement.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
42
- * @prop {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
43
- * - If this OperationResult was created from a SiteOperationSchedule, this property holds that ID.
44
- * @prop {boolean} useAdjustedQuantity - Flag to indicate if adjusted quantities are used for billing
45
- * @prop {number} adjustedQuantityBase - Adjusted quantity for base workers
46
- * - Quantity used for billing base workers when `useAdjustedQuantity` is true.
47
- * @prop {number} adjustedOvertimeBase - Adjusted overtime for base workers
48
- * - Overtime used for billing base workers when `useAdjustedQuantity` is true.
49
- * @prop {number} adjustedQuantityQualified - Adjusted quantity for qualified workers
50
- * - Quantity used for billing qualified workers when `useAdjustedQuantity` is true.
51
- * @prop {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
52
- * - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
53
- * @prop {Date} billingDateAt - Billing date
54
- * - The date used for billing purposes.
55
- * @prop {boolean} isLocked - Lock flag
56
- * - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
57
- * @prop {Agreement|null} agreement - Associated Agreement object
58
- * - The Agreement instance associated with this OperationResult for pricing and billing information.
59
- * - When set, it influences billing calculations such as unit prices and billing dates.
60
- * @prop {boolean} allowEmptyAgreement - Flag to ignore missing Agreement
61
- * - When set to true, allows the OperationResult to be valid even if no Agreement is associated.
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
+ * @property {string|null} siteOperationScheduleId - 現場稼働予定ID
65
+ * - このプロパティは、OperationResult が現場稼働予定に紐づいている場合に、その現場稼働予定の ID を保持します。
66
+ * @property {boolean} useAdjustedQuantity - 請求に調整済み数量を使用するかどうかのフラグ
67
+ * @property {number} adjustedQuantityBase - 基本従業員の調整済み数量
68
+ * - `useAdjustedQuantity` が true の場合、基本従業員の請求に使用される数量です。
69
+ * @property {number} adjustedOvertimeBase - 基本従業員の調整済み残業時間
70
+ * - `useAdjustedQuantity` が true の場合、基本従業員の請求に使用される残業時間です。
71
+ * @property {number} adjustedQuantityQualified - 資格者の調整済み数量
72
+ * - `useAdjustedQuantity` が true の場合、資格者の請求に使用される数量です。
73
+ * @property {number} adjustedOvertimeQualified - 資格者の調整済み残業時間
74
+ * - `useAdjustedQuantity` が true の場合、資格者の請求に使用される残業時間です。
75
+ * @property {Date} billingDateAt - 請求日
76
+ * - 請求に使用される日付です。
77
+ * @property {boolean} isLocked - ロックフラグ
78
+ * - true の場合、OperationResult は OperationBilling として編集する場合を除き、編集できません。
79
+ * @property {Agreement|null} agreement - 関連する取極めオブジェクト
80
+ * - この OperationResult に関連付けられた取極めインスタンスで、価格設定や請求情報に使用されます。
81
+ * - 設定されている場合、単価や請求日などの計算に影響を与えます。
82
+ * @property {boolean} allowEmptyAgreement - 取極めが存在しない場合を許可するフラグ
83
+ * - true に設定されている場合、取極めが関連付けられていなくても OperationResult は有効と見なされます。
84
+ * @property {boolean} hasAgreement - 取極めが関連付けられているかどうかを示すフラグ (読み取り専用)
85
+ * - `agreement` が設定されている場合は `true`、それ以外の場合は `false`。
86
+ * @property {Object} statistics - 従業員の統計情報 (読み取り専用)
87
+ * - 基本従業員と資格者のカウントおよび総労働時間を含む統計情報。
88
+ * - 構造: { base: {...}, qualified: {...}, total: {...} }
89
+ * - 各カテゴリには以下が含まれます: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
90
+ * - 各カテゴリには 'ojt' サブカテゴリも同様の構造で含まれます。
91
+ * @property {Object} sales - 売上金額 (読み取り専用)
92
+ * - 基本従業員と資格者の売上計算を含む。
93
+ * - 構造: { base: {...}, qualified: {...} }
94
+ * - 各カテゴリには以下が含まれます: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
95
+ * - 計算は `useAdjustedQuantity`, `billingUnitType`, `includeBreakInBilling` の設定を考慮します。
96
+ * @property {number} salesAmount - 売上合計金額 (読み取り専用)
97
+ * - 基本従業員と資格者の売上金額の合計を返します。
98
+ * @property {number} tax - 計算された税額 (読み取り専用)
99
+ * - `salesAmount` と `date` に基づいて `Tax` ユーティリティを使用して計算されます。
100
+ * @property {number} billingAmount - 税込の請求金額 (読み取り専用)
101
+ * - `salesAmount` と `tax` の合計を返します。
102
+ * @property {string|null} billingDate - 請求日 (YYYY-MM-DD 形式) (読み取り専用)
103
+ * - `billingDateAt` に基づいて YYYY-MM-DD 形式の文字列を返します。
104
+ * @property {string} billingMonth - 請求月 (YYYY-MM 形式) (読み取り専用)
105
+ * @property {string|false} isInvalid - バリデーションステータス (読み取り専用)
106
+ * - 有効な場合は false を返します。
107
+ * - 無効な場合は理由コードの文字列を返します:
108
+ * - `EMPTY_BILLING_DATE`: 請求日が存在しない場合。
109
+ * - `EMPTY_AGREEMENT`: 取極めが存在せず、`allowEmptyAgreement` が false の場合。
62
110
  *
63
- * @readonly
64
- * @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
65
- * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
66
- * @prop {Date} startAt - Start date and time (Date object) (read-only)
67
- * - Returns a Date object with `startTime` set based on `dateAt`.
68
- * - If `isStartNextDay` is true, add 1 day.
69
- * @prop {Date} endAt - End date and time (Date object) (read-only)
70
- * - Returns a Date object with `endTime` set based on `dateAt`.
71
- * - If `isStartNextDay` is true, add 1 day.
72
- * - If `isSpansNextDay` is true, add 1 day.
73
- * @prop {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
74
- * - `true` if `startTime` is later than `endTime`
75
- * @prop {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
76
- * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
77
- * @prop {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
78
- * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
79
- * @prop {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
80
- * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
81
- * @prop {boolean} hasAgreement - Indicates if an Agreement is associated (read-only)
82
- * - `true` if `agreement` is set, otherwise `false`.
83
- * @prop {string|false} isInvalid - Validation status (read-only)
84
- * - Returns false if valid.
85
- * - Returns reason code string if invalid:
86
- * - `EMPTY_BILLING_DATE`: Billing date is missing.
87
- * - `EMPTY_AGREEMENT`: Agreement is missing and `allowEmptyAgreement` is false.
88
- * @prop {Object} statistics - Statistics of workers (read-only)
89
- * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
90
- * - Structure: { base: {...}, qualified: {...}, total: {...} }
91
- * - Each category contains: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
92
- * - Each category also has an 'ojt' subcategory with the same structure.
93
- * @prop {Object} sales - Sales amounts (read-only)
94
- * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
95
- * - Structure: { base: {...}, qualified: {...} }
96
- * - Each category contains: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
97
- * - Calculations respect `useAdjustedQuantity`, `billingUnitType`, and `includeBreakInBilling` settings.
98
- * @prop {number} salesAmount - Total sales amount (read-only)
99
- * - Sum of sales amounts for base and qualified workers with rounding applied.
100
- * @prop {number} tax - Calculated tax amount (read-only)
101
- * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
102
- * @prop {number} billingAmount - Total billing amount including tax (read-only)
103
- * - Sum of `salesAmount` and `tax`.
104
- * @prop {string|null} billingDate - Billing date in YYYY-MM-DD format (read-only)
105
- * - Returns a string in the format YYYY-MM-DD based on `billingDateAt`.
106
- * @prop {string} billingMonth - Billing month in YYYY-MM format (read-only)
107
- * @prop {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
108
- * @prop {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
109
- * @prop {number} employeesCount - Count of assigned employees (read-only)
110
- * @prop {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
111
- * @prop {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
112
- * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
111
+ * @method setDateAtCallback - `dateAt` が設定されたときに呼び出されるコールバック関数
112
+ * @method addWorker - `Workers` に新しい従業員または外注先を追加します。
113
+ * @method moveWorker - 従業員または外注先の位置を移動します。
114
+ * @method changeWorker - 従業員または外注先の詳細を変更します。
115
+ * @method removeWorker - 従業員または外注先を `workers` から削除します。
116
+ * @method setSiteIdCallback - `siteId` が変更された時に呼び出されるコールバック関数
117
+ * @method setShiftTypeCallback - `shiftType` が変更された時に呼び出されるコールバック関数
118
+ * @method setRegulationWorkMinutesCallback - `regulationWorkMinutes` が変更された時に呼び出されるコールバック関数
119
+ * @method refreshBillingDateAt - 請求日を `dateAt` `cutoffDate` に基づいて更新します。
120
+ * - 現在の `dateAt` `cutoffDate` の値に基づいて `billingDateAt` を更新します。
113
121
  *
114
- * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
115
- * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
116
- * - Returns true if the employee IDs have changed compared to `_beforeData`
117
- * @getter {boolean} isOutsourcersChanged - Indicates whether the outsourcers have changed (read-only)
118
- * - Returns true if the outsourcer IDs have changed compared to `_beforeData`
119
- * @getter {Array<OperationResultDetail>} addedWorkers - An array of workers that have been added (read-only)
120
- * - Workers that exist in current data but not in `_beforeData`
121
- * @getter {Array<OperationResultDetail>} removedWorkers - An array of workers that have been removed (read-only)
122
- * - Workers that exist in `_beforeData` but not in current data
123
- * @getter {Array<OperationResultDetail>} updatedWorkers - An array of workers that have been updated (read-only)
124
- * - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
125
- * @getter {number} startHour - Start hour (0-23) (read-only)
126
- * - Extracted from `startTime`.
127
- * @getter {number} startMinute - Start minute (0-59) (read-only)
128
- * - Extracted from `startTime`.
129
- * @getter {number} endHour - End hour (0-23) (read-only)
130
- * - Extracted from `endTime`.
131
- * @getter {number} endMinute - End minute (0-59) (read-only)
132
- * - Extracted from `endTime`.
133
- *
134
- * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
135
- * - Updates `billingDateAt` based on the current `dateAt` and `cutoffDate` values.
136
- * @method addWorker - Adds a new worker (employee or outsourcer)
137
- * - @param {Object} options - Options for adding a worker
138
- * - @param {string} options.id - The worker ID (employeeId or outsourcerId)
139
- * - @param {boolean} [options.isEmployee=true] - Whether the worker is an employee
140
- * - @param {number} [index=0] - Insertion position. If -1, adds to the end
141
- * @method moveWorker - Moves the position of a worker (employee or outsourcer)
142
- * - @param {Object} options - Options for changing worker position
143
- * - @param {number} options.oldIndex - The original index
144
- * - @param {number} options.newIndex - The new index
145
- * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
146
- * @method changeWorker - Changes the details of a worker
147
- * - @param {Object} newWorker - New worker object
148
- * @method removeWorker - Removes a worker (employee or outsourcer)
149
- * - @param {Object} options - Options for removing a worker
150
- * - @param {string} options.workerId - The ID of the employee or outsourcer
151
- * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
152
- * @method setSiteIdCallback - Callback method called when `siteId` is set
153
- * - Override this method in subclasses to add custom behavior when `siteId` changes.
154
- * - By default, does nothing.
155
- * - @param {string} v - The new `siteId` value
156
- * @method setShiftTypeCallback - Callback method called when `shiftType` is set
157
- * - Override this method in subclasses to add custom behavior when `shiftType` changes.
158
- * - By default, does nothing.
159
- * - @param {string} v - The new `shiftType` value
160
- * @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
161
- * - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
162
- * - By default, does nothing.
163
- * - @param {number} v - The new `regulationWorkMinutes` value
164
- *
165
- * @static
166
- * @method groupKeyDivider
167
- * - Returns an array dividing the key into siteId, shiftType, and date.
168
- * - @param {Object|string} key - The combined key string or object
169
- * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
170
- * - @throws {Error} - If the key is invalid.
171
- * @method toggleLock - Toggle the lock status of an OperationResult document
172
- * - @param {string} docId - Document ID
173
- * - @param {boolean} value - Lock status value
174
- * - @returns {Promise<void>}
122
+ * @method toggleLock - OperationResult ドキュメントのロック状態を切り替える
123
+ * - 指定されたドキュメント ID OperationResult ドキュメントを取得し、その `isLocked` プロパティを指定された値に更新します。
124
+ * - ドキュメントが存在しない場合や、無効な引数が提供された場合はエラーをスローします。
175
125
  *
176
126
  * @override
177
- * @method create - Override create method to indicate not implemented
178
- * - Creation of OperationBilling instances is not implemented, as billing records are typically
179
- * generated through the OperationResult class.
180
- * @method update - Override update method to allow editing even when isLocked is true
181
- * @method delete - Override delete method to allow deletion even when isLocked is true
127
+ * @method create - このクラスのインスタンスは `create` メソッドを使用できません。
128
+ * - 稼働請求のレコードは通常、OperationResult クラスを通じて生成されるため、OperationBilling クラスのインスタンスの作成は実装されていません。
129
+ * @method delete - このクラスのインスタンスは `delete` メソッドを使用できません。
130
+ * - 稼働請求のレコードは通常、OperationResult クラスを通じて生成されるため、OperationBilling クラスのインスタンスの削除は実装されていません。
182
131
  *****************************************************************************/
183
132
  import OperationResult from "./OperationResult.js";
184
133
 
@@ -191,21 +140,6 @@ export default class OperationBilling extends OperationResult {
191
140
  { title: "売上金額", key: "salesAmount", value: "salesAmount" },
192
141
  ];
193
142
 
194
- /**
195
- * Override beforeUpdate to skip `isLocked` check and sync customerId and apply agreement if key changed
196
- * @param {Object} args - Creation options.
197
- * @param {Object} [args.transaction] - Firestore transaction.
198
- * @param {Function} [args.callBack] - Callback function.
199
- * @param {string} [args.prefix] - Path prefix.
200
- * @returns {Promise<void>}
201
- */
202
- async beforeUpdate(args = {}) {
203
- await super.beforeUpdate(args);
204
- // Sync customerId and apply agreement if key changed
205
- if (this.key === this._beforeData.key) return;
206
- await this._syncCustomerIdAndApplyAgreement(args);
207
- }
208
-
209
143
  /**
210
144
  * Override create method to disallow creation of OperationBilling instances
211
145
  * @returns
@@ -213,8 +147,8 @@ export default class OperationBilling extends OperationResult {
213
147
  async create() {
214
148
  return Promise.reject(
215
149
  new Error(
216
- "[OperationBilling.js] Creation of OperationBilling is not implemented."
217
- )
150
+ "[OperationBilling.js] Creation of OperationBilling is not implemented.",
151
+ ),
218
152
  );
219
153
  }
220
154
 
@@ -225,8 +159,8 @@ export default class OperationBilling extends OperationResult {
225
159
  async delete() {
226
160
  return Promise.reject(
227
161
  new Error(
228
- "[OperationBilling.js] Deletion of OperationBilling is not implemented."
229
- )
162
+ "[OperationBilling.js] Deletion of OperationBilling is not implemented.",
163
+ ),
230
164
  );
231
165
  }
232
166
 
@@ -1,99 +1,100 @@
1
1
  /*****************************************************************************
2
- * OperationDetail Model ver 1.0.0
2
+ * @file ./src/OperationDetail.js
3
3
  * @author shisyamo4131
4
- * ---------------------------------------------------------------------------
5
- * - Base class for SiteOperationScheduleDetail and OperationResultDetail.
6
- * - Extends WorkingResult class, inheriting all working time calculation functionality
7
- * - This class is intended to be inherited by other classes so, it cannot be instantiated directly.
8
- * - Employee or Outsourcer document ID is stored in the id property.
9
- * This is useful for specifying as a key for tables.
10
- * - `amount` property is always fixed at 1 (reserved for future extension).
11
- * - `startTime` and `endTime` are managed as strings in HH:MM format.
12
- * - `isEmployee` property distinguishes between Employee and Outsourcer.
13
- * - `employeeId` and `outsourcerId` properties can be used to get each ID (null if not applicable).
14
- * --------------------------------------------------------------------------
15
- * @props {string} id - Employee or Outsourcer document ID
16
- * @props {number} index - Identifier index for Outsourcer (always 0 for Employee)
17
- * @props {boolean} isEmployee - Employee flag (true: Employee, false: Outsourcer)
18
- * @props {number} amount - Number of placements (always fixed at 1)
19
- * @props {string} siteId - Site ID
20
- * @props {boolean} isQualified - Qualified flag
21
- * @props {boolean} isOjt - OJT flag
22
- * --------------------------------------------------------------------------
23
- * @computed {string} workerId - Worker ID (read-only)
24
- * - For Employee, it's the same as `id`, for Outsourcer, it's a concatenation of `id` and `index` with ':'
25
- * @computed {string|null} employeeId - Employee ID (null if not applicable) (read-only)
26
- * @computed {string|null} outsourcerId - Outsourcer ID (null if not applicable) (read-only)
27
- * --------------------------------------------------------------------------
28
- * @inherited - The following properties are inherited from WorkingResult:
29
- * @props {Date} dateAt - Placement date (trigger property)
30
- * @props {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
31
- * @props {string} shiftType - `DAY` or `NIGHT`
32
- * @props {string} startTime - Start time (HH:MM format)
33
- * @props {boolean} isStartNextDay - Next day start flag
34
- * @props {string} endTime - End time (HH:MM format)
35
- * @props {number} breakMinutes - Break time (minutes)
36
- * @props {number} regulationWorkMinutes - Regulation work minutes
37
- * --------------------------------------------------------------------------
38
- * @inherited - The following computed properties are inherited from WorkingResult:
39
- * @computed {string} key - Unique key combining `date`, `dayType`, and `shiftType` (read-only)
40
- * @computed {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
41
- * @computed {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
42
- * @computed {Date} startAt - Start date and time (Date object) (read-only)
43
- * @computed {Date} endAt - End date and time (Date object) (read-only)
44
- * @computed {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
45
- * @computed {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
46
- * @computed {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
47
- * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
48
- * - Overtime work is not negative; the minimum is 0.
49
- * --------------------------------------------------------------------------
50
- * @inherited - The following getter properties are inherited from WorkingResult:
51
- * @getter {number} startHour - Start hour (0-23) (read-only)
52
- * - Extracted from `startTime`.
53
- * @getter {number} startMinute - Start minute (0-59) (read-only)
54
- * - Extracted from `startTime`.
55
- * @getter {number} endHour - End hour (0-23) (read-only)
56
- * - Extracted from `endTime`.
57
- * @getter {number} endMinute - End minute (0-59) (read-only)
58
- * - Extracted from `endTime`.
59
- * ---------------------------------------------------------------------------
60
- * @inherited - The following method is inherited from WorkingResult:
61
- * @method {function} setDateAtCallback - Callback method called when `dateAt` is set
62
- * - Override this method in subclasses to add custom behavior when `dateAt` changes.
63
- * - By default, updates `dayType` based on the new `dateAt` value.
64
- * - @param {Date} v - The new `dateAt` value
4
+ * @description 稼働明細クラス
5
+ * - 稼働明細を表す抽象クラスです。インスタンス化はできません。
6
+ * - `OperationDetail` ドキュメント群を一意に識別するためには `workerId` を使用してください。
7
+ *
8
+ * @class
9
+ * @extends WorkingResult
10
+ * @abstract
11
+ * @see OperationResultDetail
12
+ * @see SiteOperationScheduleDetail
13
+ *
14
+ * @property {Date} dateAt - 日付 (変更されると `dayType` が自動的に更新されます)
15
+ * @property {string} shiftType - 勤務区分
16
+ * @property {string} startTime - 開始時刻 (HH:MM 形式)
17
+ * @property {string} endTime - 終了時刻 (HH:MM 形式)
18
+ * @property {boolean} isStartNextDay - 翌日開始フラグ
19
+ * - `true` の場合、実際の勤務は `dateAt` の翌日であることを意味します。
20
+ * @property {number} breakMinutes - 休憩時間 (分)
21
+ * @property {string} date - `dateAt` に基づく YYYY-MM-DD 形式の日付文字列 (読み取り専用)
22
+ * - `dateAt` に基づいて YYYY-MM-DD 形式の文字列を返します。
23
+ * @property {Date} startAt - 開始日時 (Date オブジェクト) (読み取り専用)
24
+ * - `dateAt` に基づいて `startTime` を設定した Date オブジェクトを返します。
25
+ * - `isStartNextDay` true の場合、1日加算します。
26
+ * @property {Date} endAt - 終了日時 (Date オブジェクト) (読み取り専用)
27
+ * - `startAt` を起点に、最初に現れる `endTime` の Date オブジェクトを返します。
28
+ * @property {boolean} isSpansNextDay - 翌日跨ぎフラグ (読み取り専用)
29
+ * - `true` の場合、`startAt` `endAt` の日付が異なることを意味します。
30
+ * @property {number} regulationWorkMinutes - 規定労働時間 ()
31
+ * - `startAt` から `endAt` までの時間から `breakMinutes` を差し引いた時間のうち、
32
+ * 規定内として扱う労働時間(分)です。
33
+ * - 実際の労働時間から残業時間を算出するための基準となる値です。
34
+ * - この値があることで、取極めに柔軟な設定を行うことが可能になる他、労働基準法の 1 日の所定労働時間上限が変更された際に
35
+ * 影響を最小限に抑えることができます。
36
+ * 例) 8:00 から 17:00 までの勤務で休憩が 60 分の場合
37
+ * - 規定労働時間を 8 時間 (480 分) とし、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
38
+ * 例) 8:00 から 16:00 までの勤務で休憩が 60 分の場合
39
+ * - 規定労働時間を 7 時間 (420 分) とすると、実際の勤務が 7 時間 (420 分) を超えた分が残業時間として扱われます。
40
+ * - 規定労働時間を 8 時間 (480 分) とすると、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
41
+ * 例) 7:00 から 翌日 7:00 までの勤務で休憩が 60 分の場合
42
+ * - 規定労働時間を 8 時間 (480 分) とすると、実際の勤務が 8 時間 (480 ) を超えた分が残業時間として扱われます。
43
+ * この場合、最初の 8 時間までは基本単価が適用され、残りの 8 時間は残業単価が適用されるといった設定が可能になります。
44
+ * - 規定労働時間を 24 時間 (1440 分) とすると、実際の勤務が 24 時間 (1440 ) を超えた分が残業時間として扱われます。
45
+ * この場合、全ての勤務時間が基本単価で扱われるといった設定が可能になります。
46
+ * @property {string} dayType - 曜日区分
47
+ * @property {number} totalWorkMinutes - 総労働時間 (休憩時間を除く) (分) (読み取り専用)
48
+ * @property {number} regularTimeWorkMinutes - 所定労働時間 (分) (読み取り専用)
49
+ * @property {number} overtimeWorkMinutes - 残業時間 (分) (読み取り専用)
50
+ * @property {string} id - 従業員ID または 外注先ID
51
+ * @property {number} index - 外注先の識別用インデックス (従業員の場合は常に0)
52
+ * @property {boolean} isEmployee - 従業員フラグ (true: 従業員, false: 外注先)
53
+ * @property {number} amount - 配置人数 (常に1で固定)
54
+ * @property {string} siteId - 現場ID
55
+ * @property {boolean} isQualified - 資格者フラグ
56
+ * @property {boolean} isOjt - OJTフラグ
57
+ * @property {string} workerId - 作業者ID (読み取り専用)
58
+ * - 従業員の場合は `id` と同じ、外注先の場合は `id` と `index` を `:` で結合した文字列を返します。
59
+ * @property {string|null} employeeId - 従業員ID (該当しない場合は null) (読み取り専用)
60
+ * @property {string|null} outsourcerId - 外注先ID (該当しない場合は null) (読み取り専用)
61
+ *
62
+ * @removed
63
+ * @deprecated
64
+ * @property {string} key - 使用不可
65
+ *
66
+ * @method setDateAtCallback - `dateAt` が設定されたときに呼び出されるコールバック関数
67
+ * @method getInvalidReasons - クラス特有のエラーの有無を返すメソッド
68
+ *
69
+ * @getter {boolean} isInvalid - クラス特有のエラーが存在するかどうかを返すプロパティ
70
+ * @getter {Array<string>} invalidReasons - クラス特有のエラーコードの配列を返すプロパティ
71
+ *
72
+ * @deprecated
73
+ * @getter {boolean} isKeyChanged - 使用不可
74
+ *
75
+ * @static SHIFT_TYPE - 勤務区分を定義する定数オブジェクト
76
+ * @static INVALID_REASON - クラス特有のエラーコードを定義する定数オブジェクト
77
+ * - `BREAK_MINUTES_NEGATIVE`: `breakMinutes` が負の値である場合のエラーコード
78
+ * - `REGULATION_WORK_MINUTES_NEGATIVE`: `regulationWorkMinutes` が負の値である場合のエラーコード
79
+ * @static DAY_TYPE - 曜日区分を定義する定数オブジェクト
65
80
  *****************************************************************************/
66
81
  import { defField } from "./parts/fieldDefinitions.js";
67
82
  import WorkingResult from "./WorkingResult.js";
68
83
 
69
84
  const classProps = {
85
+ ...WorkingResult.classProps, // Inherited from WorkingResult.js
70
86
  id: defField("oneLine", { default: "" }),
71
87
  index: defField("number", { default: 0 }),
72
88
  isEmployee: defField("check", { default: true, required: true }),
73
89
  amount: defField("number", { default: 1, required: true, hidden: true }),
74
90
  siteId: defField("oneLine", { required: true }),
75
- ...WorkingResult.classProps, // Inherited from WorkingResult.js
76
91
  isQualified: defField("check", { label: "資格者" }),
77
92
  isOjt: defField("check", { label: "OJT" }),
78
93
  };
79
94
 
80
- /**
81
- * Wrapper to define computed properties.
82
- * @param {*} obj
83
- * @param {*} properties
84
- */
85
- function defineComputedProperties(obj, properties) {
86
- const descriptors = {};
87
- for (const [key, descriptor] of Object.entries(properties)) {
88
- descriptors[key] = {
89
- configurable: true,
90
- enumerable: true,
91
- ...descriptor,
92
- };
93
- }
94
- Object.defineProperties(obj, descriptors);
95
- }
96
-
95
+ /*****************************************************************************
96
+ * OperationDetail
97
+ *****************************************************************************/
97
98
  export default class OperationDetail extends WorkingResult {
98
99
  static className = "稼働明細ベース";
99
100
  static collectionPath = "OperationDetails";
@@ -103,13 +104,13 @@ export default class OperationDetail extends WorkingResult {
103
104
 
104
105
  /**
105
106
  * Constructor
106
- * - Prevent direct instantiation of OperationDetail class.
107
- * @param {*} item
107
+ * - 抽象クラスのため、直接のインスタンス化を防止します。
108
+ * @param {Object} item - 初期化オブジェクト
108
109
  */
109
110
  constructor(item = {}) {
110
111
  if (new.target === OperationDetail) {
111
112
  throw new Error(
112
- `OperationDetail is an abstract class and cannot be instantiated directly.`
113
+ `OperationDetail is an abstract class and cannot be instantiated directly.`,
113
114
  );
114
115
  }
115
116
  super(item);
@@ -117,26 +118,32 @@ export default class OperationDetail extends WorkingResult {
117
118
 
118
119
  /**
119
120
  * afterInitialize
120
- * @param {*} item
121
+ * @param {Object} item - 初期化オブジェクト
121
122
  */
122
123
  afterInitialize(item = {}) {
123
124
  super.afterInitialize(item);
124
125
 
125
126
  /** Define computed properties */
126
- defineComputedProperties(this, {
127
+ Object.defineProperties(this, {
127
128
  workerId: {
129
+ configurable: true,
130
+ enumerable: true,
128
131
  get() {
129
132
  return this.isEmployee ? this.id : `${this.id}:${this.index}`;
130
133
  },
131
134
  set() {},
132
135
  },
133
136
  employeeId: {
137
+ configurable: true,
138
+ enumerable: true,
134
139
  get() {
135
140
  return this.isEmployee ? this.id : null;
136
141
  },
137
142
  set() {},
138
143
  },
139
144
  outsourcerId: {
145
+ configurable: true,
146
+ enumerable: true,
140
147
  get() {
141
148
  return !this.isEmployee ? this.id : null;
142
149
  },
@@ -144,4 +151,27 @@ export default class OperationDetail extends WorkingResult {
144
151
  },
145
152
  });
146
153
  }
154
+
155
+ /***************************************************************************
156
+ * FOR DEPRECATED PROPERTIES
157
+ ***************************************************************************/
158
+ get key() {
159
+ console.warn(
160
+ "OperationDetail: `key` property is deprecated and should not be used.",
161
+ );
162
+ return null;
163
+ }
164
+
165
+ set key(v) {
166
+ console.warn(
167
+ "OperationDetail: `key` property is deprecated and should not be used.",
168
+ );
169
+ }
170
+
171
+ get isKeyChanged() {
172
+ console.warn(
173
+ "OperationDetail: `isKeyChanged` property is deprecated and should not be used.",
174
+ );
175
+ return false;
176
+ }
147
177
  }