@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,142 +1,92 @@
1
1
  /*****************************************************************************
2
- * WorkingResult ver 1.0.0
2
+ * @file ./src/WorkingResult.js
3
3
  * @author shisyamo4131
4
- * ---------------------------------------------------------------------------
5
- * - `Agreement`, `Operation` クラスの継承元となるクラスです。
6
- * A class representing the working result for a specific date and shift extending FireModel.
7
- * - This class is intended to be inherited by other classes so, it cannot be instantiated directly.
8
- * - `dateAt` is defined as a trigger property. When it is set, `dayType` is automatically updated.
9
- * - Subclasses can override `setDateAtCallback` to add custom behavior when `dateAt` changes.
10
- * ---------------------------------------------------------------------------
11
- * @property {Date} dateAt - Applicable start date (trigger property)
4
+ * @description 勤務実績クラス
5
+ * - 勤務実績を表す抽象クラスです。インスタンス化はできません。
12
6
  *
13
- * @property {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
7
+ * @class
8
+ * @extends WorkTimeBase
9
+ * @abstract
10
+ * @see Operation
11
+ * @see OperationDetail
14
12
  *
15
- * @property {string} shiftType - Shift type (`DAY`, `NIGHT`)
13
+ * @property {Date} dateAt - 日付 (変更されると `dayType` が自動的に更新されます)
14
+ * @property {string} shiftType - 勤務区分
15
+ * @property {string} startTime - 開始時刻 (HH:MM 形式)
16
+ * @property {string} endTime - 終了時刻 (HH:MM 形式)
17
+ * @property {boolean} isStartNextDay - 翌日開始フラグ
18
+ * - `true` の場合、実際の勤務は `dateAt` の翌日であることを意味します。
19
+ * @property {number} breakMinutes - 休憩時間 (分)
20
+ * @property {string} date - `dateAt` に基づく YYYY-MM-DD 形式の日付文字列 (読み取り専用)
21
+ * - `dateAt` に基づいて YYYY-MM-DD 形式の文字列を返します。
22
+ * @property {Date} startAt - 開始日時 (Date オブジェクト) (読み取り専用)
23
+ * - `dateAt` に基づいて `startTime` を設定した Date オブジェクトを返します。
24
+ * - `isStartNextDay` が true の場合、1日加算します。
25
+ * @property {Date} endAt - 終了日時 (Date オブジェクト) (読み取り専用)
26
+ * - `startAt` を起点に、最初に現れる `endTime` の Date オブジェクトを返します。
27
+ * @property {boolean} isSpansNextDay - 翌日跨ぎフラグ (読み取り専用)
28
+ * - `true` の場合、`startAt` と `endAt` の日付が異なることを意味します。
29
+ * @property {number} regulationWorkMinutes - 規定労働時間 (分)
30
+ * - `startAt` から `endAt` までの時間から `breakMinutes` を差し引いた時間のうち、
31
+ * 規定内として扱う労働時間(分)です。
32
+ * - 実際の労働時間から残業時間を算出するための基準となる値です。
33
+ * - この値があることで、取極めに柔軟な設定を行うことが可能になる他、労働基準法の 1 日の所定労働時間上限が変更された際に
34
+ * 影響を最小限に抑えることができます。
35
+ * 例) 8:00 から 17:00 までの勤務で休憩が 60 分の場合
36
+ * - 規定労働時間を 8 時間 (480 分) とし、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
37
+ * 例) 8:00 から 16:00 までの勤務で休憩が 60 分の場合
38
+ * - 規定労働時間を 7 時間 (420 分) とすると、実際の勤務が 7 時間 (420 分) を超えた分が残業時間として扱われます。
39
+ * - 規定労働時間を 8 時間 (480 分) とすると、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
40
+ * 例) 7:00 から 翌日 7:00 までの勤務で休憩が 60 分の場合
41
+ * - 規定労働時間を 8 時間 (480 分) とすると、実際の勤務が 8 時間 (480 分) を超えた分が残業時間として扱われます。
42
+ * この場合、最初の 8 時間までは基本単価が適用され、残りの 8 時間は残業単価が適用されるといった設定が可能になります。
43
+ * - 規定労働時間を 24 時間 (1440 分) とすると、実際の勤務が 24 時間 (1440 分) を超えた分が残業時間として扱われます。
44
+ * この場合、全ての勤務時間が基本単価で扱われるといった設定が可能になります。
45
+ * @property {string} dayType - 曜日区分
46
+ * @property {number} totalWorkMinutes - 総労働時間 (休憩時間を除く) (分) (読み取り専用)
47
+ * @property {number} regularTimeWorkMinutes - 所定労働時間 (分) (読み取り専用)
48
+ * @property {number} overtimeWorkMinutes - 残業時間 (分) (読み取り専用)
16
49
  *
17
- * @property {string} startTime - Start time (HH:MM format)
50
+ * @method setDateAtCallback - `dateAt` が設定されたときに呼び出されるコールバック関数
18
51
  *
19
- * @property {boolean} isStartNextDay - Next day start flag
20
- * - `true` if the actual work starts the day after the placement date `dateAt`
52
+ * @getter {boolean} isInvalid - クラス特有のエラーが存在するかどうかを返すプロパティ
53
+ * @getter {Array<Object>} invalidReasons - エラーコード、メッセージ、多言語メッセージ、フィールド名を含む詳細情報の配列を返すプロパティ
21
54
  *
22
- * @property {string} endTime - End time (HH:MM format)
23
- *
24
- * @property {number} breakMinutes - Break time (minutes)
25
- *
26
- * @property {number} regulationWorkMinutes - Regulation work minutes
27
- * - The maximum working time defined by `unitPriceBase` (or `unitPriceQualified`).
28
- * - Exceeding this time is considered overtime.
29
- *
30
- * @property {string} key - `date`, `dayType`, `shiftType` を組み合わせたユニークキー。(読み取り専用)
31
- * - 継承先である `Agreement` でデータを一意に識別するためのキーとして使用されます。
32
- *
33
- * @property {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
34
- * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
35
- *
36
- * @property {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
37
- * - `true` if `startTime` is later than `endTime`
38
- *
39
- * @property {Date} startAt - Start date and time (Date object) (read-only)
40
- * - Returns a Date object with `startTime` set based on `dateAt`.
41
- * - If `isStartNextDay` is true, add 1 day.
42
- *
43
- * @property {Date} endAt - End date and time (Date object) (read-only)
44
- * - Returns a Date object with `endTime` set based on `dateAt`.
45
- * - If `isStartNextDay` is true, add 1 day.
46
- * - If `isSpansNextDay` is true, add 1 day.
47
- *
48
- * @property {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
49
- * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
50
- * - If the difference between `endAt` and `startAt` is negative, returns 0.
51
- * - If `startAt` or `endAt` is not set, returns 0.
52
- *
53
- * @property {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
54
- * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
55
- * - If actual working time is less than regulation time (e.g., early leave), it equals `totalWorkMinutes`.
56
- * - If actual working time exceeds regulation time (overtime), it equals `regulationWorkMinutes`.
57
- *
58
- * @property {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
59
- * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
60
- * - Overtime work is not negative; the minimum is 0.
61
- * ---------------------------------------------------------------------------
62
- * @getter {number} startHour - Start hour (0-23) (read-only)
63
- * - Extracted from `startTime`.
64
- * @getter {number} startMinute - Start minute (0-59) (read-only)
65
- * - Extracted from `startTime`.
66
- * @getter {number} endHour - End hour (0-23) (read-only)
67
- * - Extracted from `endTime`.
68
- * @getter {number} endMinute - End minute (0-59) (read-only)
69
- * - Extracted from `endTime`.
70
- * @getter {boolean} isKeyChanged - Flag indicating whether the key has changed compared to previous data (read-only)
71
- * - Compares the current `key` with the `key` in `_beforeData`.
72
- * ---------------------------------------------------------------------------
73
- * @method {function} setDateAtCallback - Callback method called when `dateAt` is set
74
- * - Override this method in subclasses to add custom behavior when `dateAt` changes.
75
- * - By default, updates `dayType` based on the new `dateAt` value.
76
- * - @param {Date} v - The new `dateAt` value
55
+ * @static SHIFT_TYPE - 勤務区分を定義する定数オブジェクト
56
+ * @static INVALID_REASON - クラス特有のエラーコードを定義する定数オブジェクト
57
+ * - `BREAK_MINUTES_NEGATIVE`: `breakMinutes` が負の値である場合のエラーコード
58
+ * - `REGULATION_WORK_MINUTES_NEGATIVE`: `regulationWorkMinutes` が負の値である場合のエラーコード
59
+ * @static DAY_TYPE - 曜日区分を定義する定数オブジェクト
77
60
  *****************************************************************************/
78
- import FireModel from "@shisyamo4131/air-firebase-v2";
79
61
  import { defField } from "./parts/fieldDefinitions.js";
80
- import { getDateAt } from "./utils/index.js";
81
62
  import { getDayType } from "./constants/day-type.js";
82
63
  import { VALUES as DAY_TYPE } from "./constants/day-type.js";
83
- import { VALUES as SHIFT_TYPE } from "./constants/shift-type.js";
64
+ import WorkTimeBase from "./WorkTimeBase.js";
84
65
 
85
66
  const classProps = {
86
- dateAt: defField("dateAt", { required: true }),
67
+ ...WorkTimeBase.classProps,
87
68
  dayType: defField("dayType", { required: true }),
88
- shiftType: defField("shiftType", { required: true }),
89
- startTime: defField("time", {
90
- label: "開始時刻",
91
- required: true,
92
- default: "08:00",
93
- }),
94
- isStartNextDay: defField("check", { label: "翌日開始" }),
95
- endTime: defField("time", {
96
- label: "終了時刻",
97
- required: true,
98
- default: "17:00",
99
- }),
100
- breakMinutes: defField("breakMinutes", { required: true }),
101
- regulationWorkMinutes: defField("regulationWorkMinutes", { required: true }),
102
69
  };
103
70
 
104
- /**
105
- * Wrapper to define computed properties.
106
- * @param {*} obj
107
- * @param {*} properties
108
- */
109
- function defineComputedProperties(obj, properties) {
110
- const descriptors = {};
111
- for (const [key, descriptor] of Object.entries(properties)) {
112
- descriptors[key] = {
113
- configurable: true,
114
- enumerable: true,
115
- ...descriptor,
116
- };
117
- }
118
- Object.defineProperties(obj, descriptors);
119
- }
120
-
121
- export default class WorkingResult extends FireModel {
71
+ /*****************************************************************************
72
+ * WorkingResult
73
+ *****************************************************************************/
74
+ export default class WorkingResult extends WorkTimeBase {
122
75
  static className = "WorkingResult";
123
76
  static collectionPath = "WorkingResults";
124
- static useAutonumber = false;
125
- static logicalDelete = false;
126
77
  static classProps = classProps;
127
78
 
128
79
  static DAY_TYPE = DAY_TYPE;
129
- static SHIFT_TYPE = SHIFT_TYPE;
130
80
 
131
81
  /**
132
82
  * Constructor
133
- * - Prevent direct instantiation of WorkingResult class.
134
- * @param {*} item
83
+ * - 抽象クラスのため、直接のインスタンス化を防止します。
84
+ * @param {Object} item - 初期化オブジェクト
135
85
  */
136
86
  constructor(item = {}) {
137
87
  if (new.target === WorkingResult) {
138
88
  throw new Error(
139
- "WorkingResult is an abstract class and cannot be instantiated directly."
89
+ "WorkingResult is an abstract class and cannot be instantiated directly.",
140
90
  );
141
91
  }
142
92
  super(item);
@@ -144,104 +94,18 @@ export default class WorkingResult extends FireModel {
144
94
 
145
95
  /**
146
96
  * afterInitialize
147
- * @param {*} item
97
+ * @param {Object} item - 初期化オブジェクト
148
98
  */
149
99
  afterInitialize(item = {}) {
150
100
  super.afterInitialize(item);
151
101
 
152
- /** Define triggers */
153
- let _dateAt = this.dateAt;
154
- defineComputedProperties(this, {
155
- /**
156
- * dateAt - Convert `dateAt` property to use getter/setter
157
- * - When `dateAt` is set, call `setDateAtCallback` to update dependent properties.
158
- */
159
- dateAt: {
160
- get() {
161
- return _dateAt;
162
- },
163
- set(v) {
164
- if (_dateAt && v.getTime() === _dateAt.getTime()) {
165
- return;
166
- }
167
- const newDate = new Date(v);
168
- newDate.setHours(0, 0, 0, 0); // 時刻部分をクリア
169
- _dateAt = newDate;
170
- this.setDateAtCallback(newDate);
171
- },
172
- },
173
- });
174
-
175
- /** Define computed properties */
176
- defineComputedProperties(this, {
177
- /**
178
- * key - Unique key combining date, dayType, and shiftType
179
- * - A unique identifier for the working result, combining `date`, `dayType`, and `shiftType`.
180
- */
181
- key: {
182
- get: () => {
183
- return `${this.date}-${this.dayType}-${this.shiftType}`;
184
- },
185
- set: () => {},
186
- },
187
- /**
188
- * date - Date string in YYYY-MM-DD format based on `dateAt`
189
- * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
190
- * - If `dateAt` is not set, returns an empty string.
191
- */
192
- date: {
193
- get: () => {
194
- if (!this.dateAt) return "";
195
- // UTC時刻に9時間(JST)を加算してJST日付を取得
196
- const jstDate = new Date(this.dateAt.getTime() + 9 * 60 * 60 * 1000);
197
- const year = jstDate.getUTCFullYear();
198
- const month = String(jstDate.getUTCMonth() + 1).padStart(2, "0");
199
- const day = String(jstDate.getUTCDate()).padStart(2, "0");
200
- return `${year}-${month}-${day}`;
201
- },
202
- set: (v) => {},
203
- },
102
+ Object.defineProperties(this, {
204
103
  /**
205
- * isSpansNextDay - Flag indicating whether the date spans from start date to end date
206
- * - `true` if `startTime` is later than `endTime`
207
- */
208
- isSpansNextDay: {
209
- get: () => this.startTime > this.endTime,
210
- set: (v) => {},
211
- },
212
- /**
213
- * startAt - Start date and time (Date object)
214
- * - Returns a Date object with `startTime` set based on `dateAt`.
215
- * - If `isStartNextDay` is true, add 1 day.
216
- */
217
- startAt: {
218
- get() {
219
- const dateOffset = this.isStartNextDay ? 1 : 0;
220
- return getDateAt(this.dateAt, this.startTime, dateOffset);
221
- },
222
- set(v) {},
223
- },
224
- /**
225
- * endAt - End date and time (Date object)
226
- * - Returns a Date object with `endTime` set based on `dateAt`.
227
- * - If `isStartNextDay` is true, add 1 day.
228
- * - If `isSpansNextDay` is true, add 1 day.
229
- */
230
- endAt: {
231
- get() {
232
- const dateOffset =
233
- (this.isSpansNextDay ? 1 : 0) + (this.isStartNextDay ? 1 : 0);
234
- return getDateAt(this.dateAt, this.endTime, dateOffset);
235
- },
236
- set(v) {},
237
- },
238
- /**
239
- * totalWorkMinutes - Total working time in minutes (excluding break time)
240
- * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
241
- * - If the difference between `endAt` and `startAt` is negative, returns 0.
242
- * - If `startAt` or `endAt` is not set, returns 0.
104
+ * `startAt`, `endAt`, `breakMinutes` から総労働時間を計算して返します。
243
105
  */
244
106
  totalWorkMinutes: {
107
+ configurable: true,
108
+ enumerable: true,
245
109
  get: () => {
246
110
  const start = this.startAt;
247
111
  const end = this.endAt;
@@ -251,24 +115,29 @@ export default class WorkingResult extends FireModel {
251
115
  },
252
116
  set: (v) => {},
253
117
  },
118
+
254
119
  /**
255
- * regularTimeWorkMinutes - Regular working time in minutes
256
- * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
257
- * - If actual working time is less than regulation time (e.g., early leave), it equals `totalWorkMinutes`.
258
- * - If actual working time exceeds regulation time (overtime), it equals `regulationWorkMinutes`.
120
+ * 所定労働時間を返します。
121
+ * - `totalWorkMinutes` のうち `regulationWorkMinutes` の範囲である部分を返します。
122
+ * - 実際の労働時間が所定労働時間未満の場合(早退など)は `totalWorkMinutes` と同じ値になります。
123
+ * - 実際の労働時間が所定労働時間を超える場合(残業など)は `regulationWorkMinutes` と同じ値になります。
259
124
  */
260
125
  regularTimeWorkMinutes: {
126
+ configurable: true,
127
+ enumerable: true,
261
128
  get: () => {
262
129
  return Math.min(this.totalWorkMinutes, this.regulationWorkMinutes);
263
130
  },
264
131
  set: (v) => {},
265
132
  },
266
133
  /**
267
- * overtimeWorkMinutes - Overtime working time in minutes
268
- * - The value obtained by subtracting `regulationWorkMinutes` from `totalWorkMinutes`.
269
- * - Overtime working time is capped at 0 to prevent negative values.
134
+ * 残業時間を返します。
135
+ * - `totalWorkMinutes` から `regulationWorkMinutes` を引いた値を返します。
136
+ * - 残業時間は負の値にならないように、最小値は 0 になります。
270
137
  */
271
138
  overtimeWorkMinutes: {
139
+ configurable: true,
140
+ enumerable: true,
272
141
  get: () => {
273
142
  const diff = this.totalWorkMinutes - this.regulationWorkMinutes;
274
143
  return Math.max(0, diff);
@@ -279,54 +148,13 @@ export default class WorkingResult extends FireModel {
279
148
  }
280
149
 
281
150
  /**
282
- * A function called when `dateAt` is set.
283
- * - Override this method in subclasses to add custom behavior when `dateAt` changes.
284
- * @param {*} v
151
+ * `WorkTimeBase` クラスの `setDateAtCallback` をオーバライドします。
152
+ * - `dayType` を更新します。
153
+ * @param {Date} v - 新しい `dateAt` 値
154
+ * @returns {void}
285
155
  */
286
156
  setDateAtCallback(v) {
157
+ super.setDateAtCallback(v);
287
158
  this.dayType = getDayType(v);
288
159
  }
289
-
290
- /**
291
- * Returns the start hour extracted from `startTime`.
292
- * - Returns 0 if `startTime` is not set.
293
- */
294
- get startHour() {
295
- return this.startTime ? Number(this.startTime.split(":")[0]) : 0;
296
- }
297
-
298
- /**
299
- * Returns the start minute extracted from `startTime`.
300
- * - Returns 0 if `startTime` is not set.
301
- */
302
- get startMinute() {
303
- return this.startTime ? Number(this.startTime.split(":")[1]) : 0;
304
- }
305
-
306
- /**
307
- * Returns the end hour extracted from `endTime`.
308
- * - Returns 0 if `endTime` is not set.
309
- */
310
- get endHour() {
311
- return this.endTime ? Number(this.endTime.split(":")[0]) : 0;
312
- }
313
-
314
- /**
315
- * Returns the end minute extracted from `endTime`.
316
- * - Returns 0 if `endTime` is not set.
317
- */
318
- get endMinute() {
319
- return this.endTime ? Number(this.endTime.split(":")[1]) : 0;
320
- }
321
-
322
- /**
323
- * Returns whether the key has changed compared to the previous data.
324
- * - Compares the current `key` with the `key` in `_beforeData`.
325
- * - Returns `true` if they are different, otherwise `false`.
326
- */
327
- get isKeyChanged() {
328
- const current = this.key;
329
- const before = this._beforeData?.key;
330
- return current !== before;
331
- }
332
160
  }
@@ -1,11 +1,19 @@
1
- // prettier-ignore
1
+ /*****************************************************************************
2
+ * @file ./constants/day-type.js
3
+ * @description 曜日区分定義
4
+ * @author shisyamo4131
5
+ *
6
+ * @export {Object} VALUES - 曜日区分の定数オブジェクト
7
+ * @export {Array} OPTIONS - 曜日区分の選択肢配列
8
+ * @export {Function} getDayType - 日付から曜日区分を取得する関数
9
+ *****************************************************************************/
2
10
  import holiday_jp from "@holiday-jp/holiday_jp";
3
11
 
4
12
  export const VALUES = Object.freeze({
5
- WEEKDAY: { value: "WEEKDAY", title: "平日" },
6
- SATURDAY: { value: "SATURDAY", title: "土曜" },
7
- SUNDAY: { value: "SUNDAY", title: "日曜" },
8
- HOLIDAY: { value: "HOLIDAY", title: "祝日" },
13
+ WEEKDAY: { value: "WEEKDAY", title: "平日", order: 0 },
14
+ SATURDAY: { value: "SATURDAY", title: "土曜", order: 1 },
15
+ SUNDAY: { value: "SUNDAY", title: "日曜", order: 2 },
16
+ HOLIDAY: { value: "HOLIDAY", title: "祝日", order: 3 },
9
17
  });
10
18
 
11
19
  export const OPTIONS = [
@@ -16,14 +24,14 @@ export const OPTIONS = [
16
24
  ];
17
25
 
18
26
  /**
19
- * Returns the corresponding day type based on the given date's day of the week.
20
- * If the date is a holiday, it returns "HOLIDAY".
21
- * If the date is a Sunday, it returns "SUNDAY".
22
- * If the date is a Saturday, it returns "SATURDAY".
23
- * Otherwise, it returns "WEEKDAY".
27
+ * 引数で与えられた日付の曜日に基づいて、対応する曜日区分を返します。
28
+ * - 日付が祝日であれば、「HOLIDAY」を返します。
29
+ * - 日付が日曜日であれば、「SUNDAY」を返します。
30
+ * - 日付が土曜日であれば、「SATURDAY」を返します。
31
+ * - それ以外の場合は、「WEEKDAY」を返します。
24
32
  * @param {Date} date
25
- * @returns {string} - The day type corresponding to the date.
26
- * @throws {TypeError} if date is not a Date object
33
+ * @returns {string} - 引数の日付に対応する曜日区分
34
+ * @throws {TypeError} - 引数がDateオブジェクトでない場合
27
35
  */
28
36
  export const getDayType = (date) => {
29
37
  if (!(date instanceof Date)) {
@@ -45,6 +45,10 @@ export {
45
45
  VALUES as GENDER_VALUES,
46
46
  OPTIONS as GENDER_OPTIONS,
47
47
  } from "./gender.js";
48
+ export {
49
+ VALUES as INSURANCE_STATUS_VALUES,
50
+ OPTIONS as INSURANCE_STATUS_OPTIONS,
51
+ } from "./insurance-status.js";
48
52
  export {
49
53
  VALUES as PAYMENT_MONTH_VALUES,
50
54
  OPTIONS as PAYMENT_MONTH_OPTIONS,
@@ -0,0 +1,15 @@
1
+ /*****************************************************************************
2
+ * @file ./src/constants/insurance-status.js
3
+ * @description 保険状態定義
4
+ *****************************************************************************/
5
+ export const VALUES = Object.freeze({
6
+ NOT_ENROLLED: { value: "NOT_ENROLLED", title: "未加入" },
7
+ ENROLLED: { value: "ENROLLED", title: "加入" },
8
+ EXEMPT: { value: "EXEMPT", title: "適用除外" },
9
+ });
10
+
11
+ export const OPTIONS = [
12
+ { title: VALUES.NOT_ENROLLED.title, value: VALUES.NOT_ENROLLED.value },
13
+ { title: VALUES.ENROLLED.title, value: VALUES.ENROLLED.value },
14
+ { title: VALUES.EXEMPT.title, value: VALUES.EXEMPT.value },
15
+ ];
@@ -1,7 +1,10 @@
1
+ /*****************************************************************************
2
+ * 勤務区分定数定義
3
+ *****************************************************************************/
1
4
  // prettier-ignore
2
5
  export const VALUES = Object.freeze({
3
- DAY: { value: "DAY", title: "日勤", color: "deep-orange" },
4
- NIGHT: { value: "NIGHT", title: "夜勤", color: "indigo" },
6
+ DAY: { value: "DAY", title: "日勤", color: "deep-orange", order: 0 },
7
+ NIGHT: { value: "NIGHT", title: "夜勤", color: "indigo", order: 1 },
5
8
  });
6
9
 
7
10
  export const OPTIONS = [
@@ -0,0 +1,173 @@
1
+ /**
2
+ * バリデーションエラー定義
3
+ * - validator がオブジェクト形式でエラーを返す際に使用します。
4
+ * - 各エラーは関数として定義され、動的なパラメータを受け取ります。
5
+ *
6
+ * 返却値の形式:
7
+ * {
8
+ * code: 'ERROR_CODE', // エラーコード
9
+ * message: 'English message', // 英語メッセージ(デフォルト言語)
10
+ * messages: { // その他の言語のメッセージ
11
+ * ja: '日本語メッセージ'
12
+ * }
13
+ * }
14
+ *
15
+ * 使用例:
16
+ * ```javascript
17
+ * import { VALIDATION_ERRORS } from './errorDefinitions.js';
18
+ *
19
+ * validator: (v) => {
20
+ * const minValue = 0;
21
+ * if (v < minValue) {
22
+ * return VALIDATION_ERRORS.MIN_VALUE_ERROR(minValue);
23
+ * }
24
+ * return true;
25
+ * }
26
+ * ```
27
+ */
28
+
29
+ export const VALIDATION_ERRORS = {
30
+ /**
31
+ * 最小値エラー
32
+ * @param {number} minValue - 最小値
33
+ * @returns {Object} エラーオブジェクト
34
+ */
35
+ MIN_VALUE_ERROR: (minValue) => ({
36
+ code: "MIN_VALUE_ERROR",
37
+ message: `Please enter a value of ${minValue} or more.`,
38
+ messages: {
39
+ ja: `${minValue}以上の値を入力してください。`,
40
+ },
41
+ }),
42
+
43
+ /**
44
+ * 最大値エラー
45
+ * @param {number} maxValue - 最大値
46
+ * @returns {Object} エラーオブジェクト
47
+ */
48
+ MAX_VALUE_ERROR: (maxValue) => ({
49
+ code: "MAX_VALUE_ERROR",
50
+ message: `Please enter a value of ${maxValue} or less.`,
51
+ messages: {
52
+ ja: `${maxValue}以下の値を入力してください。`,
53
+ },
54
+ }),
55
+
56
+ /**
57
+ * 範囲エラー
58
+ * @param {number} minValue - 最小値
59
+ * @param {number} maxValue - 最大値
60
+ * @returns {Object} エラーオブジェクト
61
+ */
62
+ RANGE_ERROR: (minValue, maxValue) => ({
63
+ code: "RANGE_ERROR",
64
+ message: `Please enter a value between ${minValue} and ${maxValue}.`,
65
+ messages: {
66
+ ja: `${minValue}以上${maxValue}以下の値を入力してください。`,
67
+ },
68
+ }),
69
+
70
+ /**
71
+ * 最小文字数エラー
72
+ * @param {number} minLength - 最小文字数
73
+ * @returns {Object} エラーオブジェクト
74
+ */
75
+ MIN_LENGTH_ERROR: (minLength) => ({
76
+ code: "MIN_LENGTH_ERROR",
77
+ message: `Please enter at least ${minLength} characters.`,
78
+ messages: {
79
+ ja: `${minLength}文字以上で入力してください。`,
80
+ },
81
+ }),
82
+
83
+ /**
84
+ * 最大文字数エラー
85
+ * @param {number} maxLength - 最大文字数
86
+ * @returns {Object} エラーオブジェクト
87
+ */
88
+ MAX_LENGTH_ERROR: (maxLength) => ({
89
+ code: "MAX_LENGTH_ERROR",
90
+ message: `Please enter ${maxLength} characters or less.`,
91
+ messages: {
92
+ ja: `${maxLength}文字以内で入力してください。`,
93
+ },
94
+ }),
95
+
96
+ /**
97
+ * パターン不一致エラー
98
+ * @param {string} pattern - パターン名(例: 'email', 'phone')
99
+ * @returns {Object} エラーオブジェクト
100
+ */
101
+ PATTERN_ERROR: (pattern) => ({
102
+ code: "PATTERN_ERROR",
103
+ message: `Please enter a valid ${pattern} format.`,
104
+ messages: {
105
+ ja: `正しい${pattern}の形式で入力してください。`,
106
+ },
107
+ }),
108
+
109
+ /**
110
+ * 必須エラー(カスタムメッセージ用)
111
+ * @param {string} fieldName - フィールド名
112
+ * @returns {Object} エラーオブジェクト
113
+ */
114
+ REQUIRED_FIELD_ERROR: (fieldName) => ({
115
+ code: "REQUIRED_FIELD_ERROR",
116
+ message: `${fieldName} is required.`,
117
+ messages: {
118
+ ja: `${fieldName}は必須です。`,
119
+ },
120
+ }),
121
+
122
+ /**
123
+ * 日付範囲エラー
124
+ * @param {string} startDate - 開始日
125
+ * @param {string} endDate - 終了日
126
+ * @returns {Object} エラーオブジェクト
127
+ */
128
+ DATE_RANGE_ERROR: (startDate, endDate) => ({
129
+ code: "DATE_RANGE_ERROR",
130
+ message: `Please select a date between ${startDate} and ${endDate}.`,
131
+ messages: {
132
+ ja: `${startDate}から${endDate}の間の日付を選択してください。`,
133
+ },
134
+ }),
135
+
136
+ /**
137
+ * 日付順序エラー
138
+ * @returns {Object} エラーオブジェクト
139
+ */
140
+ DATE_ORDER_ERROR: () => ({
141
+ code: "DATE_ORDER_ERROR",
142
+ message: "Start date must be before end date.",
143
+ messages: {
144
+ ja: "開始日は終了日より前である必要があります。",
145
+ },
146
+ }),
147
+
148
+ /**
149
+ * 重複エラー
150
+ * @param {string} fieldName - フィールド名
151
+ * @returns {Object} エラーオブジェクト
152
+ */
153
+ DUPLICATE_ERROR: (fieldName) => ({
154
+ code: "DUPLICATE_ERROR",
155
+ message: `${fieldName} is already registered.`,
156
+ messages: {
157
+ ja: `${fieldName}は既に登録されています。`,
158
+ },
159
+ }),
160
+
161
+ /**
162
+ * カスタムエラー(汎用)
163
+ * @param {string} code - エラーコード
164
+ * @param {string} message - 英語メッセージ
165
+ * @param {Object} messages - 多言語メッセージオブジェクト(例: { ja: '日本語メッセージ' })
166
+ * @returns {Object} エラーオブジェクト
167
+ */
168
+ CUSTOM_ERROR: (code, message, messages) => ({
169
+ code,
170
+ message,
171
+ messages,
172
+ }),
173
+ };