@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.60 → 2.4.2-dev.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shisyamo4131/air-guard-v2-schemas",
3
- "version": "2.4.2-dev.60",
3
+ "version": "2.4.2-dev.62",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/Employee.js CHANGED
@@ -542,6 +542,7 @@ export default class Employee extends GeocodableMixin(FireModel) {
542
542
 
543
543
  // 加入保険
544
544
  employmentInsurance: defField("employmentInsurance", {
545
+ default: () => new Insurance(),
545
546
  customClass: Insurance,
546
547
  }),
547
548
  remarks: defField("remarks"),
package/src/Insurance.js CHANGED
@@ -22,6 +22,25 @@ export const ERROR_MESSAGES = Object.freeze({
22
22
 
23
23
  /*****************************************************************************
24
24
  * @class Insurance
25
+ *
26
+ * @property {string} status - 保険の状態を表す文字列。`INSURANCE_STATUS` のいずれかの値を取ります。
27
+ * @property {string} previousStatus - 直前の保険の状態を表す文字列。`INSURANCE_STATUS` のいずれかの値を取ります。
28
+ * @property {Date|null} enrollmentDateAt - 加入日を表す日付オブジェクト。加入していない場合は null になります。
29
+ * @property {string|null} number - 被保険者番号(整理記号)を表す文字列。加入していない場合は null になります。
30
+ * @property {Date|null} lossDateAt - 喪失日を表す日付オブジェクト。加入していない場合は null になります。
31
+ * @property {string|null} lossReason - 喪失理由を表す文字列。加入していない場合は null になります。
32
+ * @property {boolean} isProcessing - 加入手続き中であるかどうかを表す真偽値。加入手続き中の場合は true、そうでない場合は false になります。
33
+ * @property {Array} history - 状態遷移の履歴を記録するための配列。各要素は状態遷移前の状態を表すオブジェクトです。
34
+ *
35
+ * @note
36
+ * - 各プロパティは `現在の状態` を表すもので、状態の遷移には対応するメソッドを利用します。
37
+ * - `lossDateAt`(喪失日)と `lossReason`(喪失理由)は、`現在の状態` という意味では不要なプロパティですが、
38
+ * 資格喪失処理の際に必要になる情報であるため、プロパティとして用意しています。
39
+ * - 状態を遷移させるために必要な情報をこのインスタンスに設定(入力)する場合、
40
+ * 必ず複製したインスタンスのプロパティを編集し、複製元インスタンスの
41
+ * 状態遷移用メソッドを呼び出す際に引数として渡す、という形で利用してください。
42
+ * - 各状態遷移メソッドでは、`lossDateAt`(喪失日)と `lossReason`(喪失理由)は必ず null に初期化されます。
43
+ *
25
44
  * @method exempt - 現在の状態を `EXEMPT (適用除外)` に更新します。
26
45
  * @method enroll - 現在の状態を `ENROLLED (加入)` に更新します。
27
46
  * @method enrolled - 加入手続き中の状態を加入完了の状態に更新します。
@@ -36,6 +55,8 @@ export default class Insurance extends BaseClass {
36
55
  previousStatus: defField("insuranceStatus", { default: "" }),
37
56
  enrollmentDateAt: defField("enrollmentDateAt"),
38
57
  number: defField("insuranceNumber"),
58
+ lossDateAt: defField("lossDateAt"),
59
+ lossReason: defField("lossReason"),
39
60
  isProcessing: defField("check", { default: false }),
40
61
  history: defField("array"), // 状態遷移の履歴を記録するための配列
41
62
  };
@@ -117,16 +138,16 @@ export default class Insurance extends BaseClass {
117
138
  * 履歴エントリを作成します。
118
139
  * @param {Object} options
119
140
  * @param {Date|null} options.lossDateAt 喪失日
120
- * @param {String|null} options.reason 喪失理由
141
+ * @param {String|null} options.lossReason 喪失理由
121
142
  * @returns {Object} 履歴エントリ
122
143
  */
123
- _createHistoryEntry({ lossDateAt = null, reason = null } = {}) {
144
+ _createHistoryEntry({ lossDateAt = null, lossReason = null } = {}) {
124
145
  return {
125
146
  status: this.status,
126
147
  previousStatus: this.previousStatus,
127
148
  enrollmentDateAt: this.enrollmentDateAt,
128
149
  lossDateAt,
129
- reason,
150
+ lossReason,
130
151
  number: this.number,
131
152
  };
132
153
  }
@@ -136,19 +157,19 @@ export default class Insurance extends BaseClass {
136
157
  * - `NOT_ENROLLED (未加入)` または `ENROLLED (加入)` の状態でなければ加入手続きは行えません。
137
158
  * - 現在加入中の場合、加入の履歴を記録します。ただし、加入手続き中 (isProcessing が true) である場合は、加入の実態がなかったこととし、履歴に記録しません。
138
159
  * - 手続き中である場合、状態が `ENROLLED` から `EXEMPT` に更新される実務上の取り扱いは「加入申請の取り下げ(訂正)」に該当するものとし、加入の実態がなかったこととします。
139
- * - 現在加入中の場合、`lossDateAt (喪失日)` と `reason (喪失理由)` の指定が必要です。
160
+ * - 現在加入中の場合、`lossDateAt (喪失日)` と `lossReason (喪失理由)` の指定が必要です。
140
161
  * - `EXEMPT` 状態への更新に伴い、加入日を null に更新します。
141
162
  * - `EXEMPT` 状態への更新に伴い、加入手続き中である場合があるため `isProcessing` を false に更新します。
142
163
  * - `EXEMPT` 状態への更新に伴い、被保険者番号(整理記号)を null に更新します。
143
164
  * @param {Object} options
144
165
  * @param {Date|null} options.lossDateAt 喪失日(現在加入中の場合に必要)
145
- * @param {String|null} options.reason 喪失理由(現在加入中の場合に必要)
166
+ * @param {String|null} options.lossReason 喪失理由(現在加入中の場合に必要)
146
167
  * @returns {void}
147
168
  * @throws {Error} `status` が `NOT_ENROLLED (未加入)` または `ENROLLED (加入)` でない場合にエラーをスローします。
148
169
  * @throws {Error} 現在加入中の場合に `lossDateAt` が日付オブジェクトでない場合にエラーをスローします。
149
- * @throws {Error} 現在加入中の場合に `reason` が指定されていない場合にエラーをスローします。
170
+ * @throws {Error} 現在加入中の場合に `lossReason` が指定されていない場合にエラーをスローします。
150
171
  */
151
- exempt({ lossDateAt, reason } = {}) {
172
+ exempt({ lossDateAt, lossReason } = {}) {
152
173
  // validation
153
174
  const transitionCheck = this._canTransitionTo(
154
175
  INSURANCE_STATUS.EXEMPT.value,
@@ -160,7 +181,7 @@ export default class Insurance extends BaseClass {
160
181
  }
161
182
 
162
183
  // 履歴に記録するための状態を作成
163
- const currentStatus = this._createHistoryEntry({ lossDateAt, reason });
184
+ const currentStatus = this._createHistoryEntry({ lossDateAt, lossReason });
164
185
 
165
186
  // 加入完了している場合の検証(手続き中の場合は不要)
166
187
  if (this.isEnrollmentComplete()) {
@@ -168,7 +189,7 @@ export default class Insurance extends BaseClass {
168
189
  if (!lossDateAt || !(lossDateAt instanceof Date)) {
169
190
  throw new Error(ERROR_MESSAGES.REQUIRED_DATE("喪失日"));
170
191
  }
171
- if (!reason) {
192
+ if (!lossReason) {
172
193
  throw new Error(ERROR_MESSAGES.REQUIRED_FIELD("喪失理由"));
173
194
  }
174
195
  }
@@ -185,6 +206,8 @@ export default class Insurance extends BaseClass {
185
206
  this.enrollmentDateAt = null;
186
207
  this.isProcessing = false; // 加入手続き中である場合があるため false に更新しておく
187
208
  this.number = null;
209
+ this.lossDateAt = null; // 念のため null に更新しておく
210
+ this.lossReason = null; // 念のため null に更新しておく
188
211
  }
189
212
 
190
213
  /**
@@ -227,6 +250,8 @@ export default class Insurance extends BaseClass {
227
250
  this.enrollmentDateAt = enrollmentDateAt;
228
251
  this.number = immediate ? number : null;
229
252
  this.isProcessing = immediate ? false : true;
253
+ this.lossDateAt = null; // 念のため null に更新しておく
254
+ this.lossReason = null; // 念のため null に更新しておく
230
255
  }
231
256
 
232
257
  /**
@@ -255,6 +280,8 @@ export default class Insurance extends BaseClass {
255
280
  // 状態を更新
256
281
  this.number = number;
257
282
  this.isProcessing = false;
283
+ this.lossDateAt = null; // 念のため null に更新しておく
284
+ this.lossReason = null; // 念のため null に更新しておく
258
285
  }
259
286
 
260
287
  /**
@@ -276,25 +303,27 @@ export default class Insurance extends BaseClass {
276
303
  this.enrollmentDateAt = null;
277
304
  this.number = null;
278
305
  this.isProcessing = false;
306
+ this.lossDateAt = null; // 念のため null に更新しておく
307
+ this.lossReason = null; // 念のため null に更新しておく
279
308
  }
280
309
 
281
310
  /**
282
311
  * 加入している保険の喪失処理を行います。
283
312
  * - `ENROLLED (加入)` の状態でなければ喪失処理は行えません。
284
- * - `lossDateAt`(喪失日)、`reason`(喪失理由)の指定が必要です。
313
+ * - `lossDateAt`(喪失日)、`lossReason`(喪失理由)の指定が必要です。
285
314
  * - `isRetire` が true の場合、状態を `EXEMPT (適用除外)` ではなく `NOT_ENROLLED (未加入)` に更新します。
286
315
  * - `isRetire` が false の場合、状態を `EXEMPT (適用除外)` に更新します。
287
316
  * - `history` プロパティに、更新前の状態を記録します。
288
317
  * @param {*} options
289
318
  * @param {*} options.lossDateAt 喪失日
290
- * @param {*} options.reason 喪失理由
319
+ * @param {*} options.lossReason 喪失理由
291
320
  * @param {*} options.isRetire 退職フラグ(true の場合、状態を `EXEMPT (適用除外)` ではなく `NOT_ENROLLED (未加入)` に更新します)
292
321
  * @returns {void}
293
322
  * @throws {Error} `status` が `ENROLLED (加入)` でない場合にエラーをスローします。
294
323
  * @throws {Error} 喪失日が日付オブジェクトでない場合にエラーをスローします。
295
324
  * @throws {Error} 喪失理由が指定されていない場合にエラーをスローします。
296
325
  */
297
- loss({ lossDateAt, reason } = {}, isRetire = false) {
326
+ loss({ lossDateAt, lossReason } = {}, isRetire = false) {
298
327
  // validation
299
328
  if (!this.isEnrolled()) {
300
329
  throw new Error(ERROR_MESSAGES.ENROLLED_ONLY("喪失手続き"));
@@ -302,12 +331,12 @@ export default class Insurance extends BaseClass {
302
331
  if (!lossDateAt || !(lossDateAt instanceof Date)) {
303
332
  throw new Error(ERROR_MESSAGES.REQUIRED_DATE("喪失日"));
304
333
  }
305
- if (!reason) {
334
+ if (!lossReason) {
306
335
  throw new Error(ERROR_MESSAGES.REQUIRED_FIELD("喪失理由"));
307
336
  }
308
337
 
309
338
  // 履歴に記録するための状態を作成
310
- const currentStatus = this._createHistoryEntry({ lossDateAt, reason });
339
+ const currentStatus = this._createHistoryEntry({ lossDateAt, lossReason });
311
340
 
312
341
  this.history.push(currentStatus);
313
342
 
@@ -317,6 +346,8 @@ export default class Insurance extends BaseClass {
317
346
  : INSURANCE_STATUS.EXEMPT.value;
318
347
  this.enrollmentDateAt = null;
319
348
  this.number = null;
349
+ this.lossDateAt = null; // 念のため null に更新しておく
350
+ this.lossReason = null; // 念のため null に更新しておく
320
351
  }
321
352
 
322
353
  /**
@@ -343,5 +374,7 @@ export default class Insurance extends BaseClass {
343
374
  this.enrollmentDateAt = latestStatus.enrollmentDateAt;
344
375
  this.number = latestStatus.number;
345
376
  this.isProcessing = false; // 念のため false に戻しておく
377
+ this.lossDateAt = null; // 念のため null に戻しておく
378
+ this.lossReason = null; // 念のため null に戻しておく
346
379
  }
347
380
  }
@@ -253,6 +253,11 @@ export const fieldDefinitions = {
253
253
  ...generalDefinitions.dateAt,
254
254
  label: "取得日",
255
255
  },
256
+ lossDateAt: {
257
+ ...generalDefinitions.dateAt,
258
+ label: "資格喪失日",
259
+ default: null,
260
+ },
256
261
  periodOfStay: {
257
262
  ...generalDefinitions.dateAt,
258
263
  label: "在留期間満了日",
@@ -522,6 +527,11 @@ export const fieldDefinitions = {
522
527
  },
523
528
  },
524
529
  },
530
+ lossReason: {
531
+ ...generalDefinitions.oneLine,
532
+ label: "喪失理由",
533
+ length: 40,
534
+ },
525
535
  mobile: {
526
536
  ...generalDefinitions.oneLine,
527
537
  label: "携帯電話",