@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
package/src/Employee.js
CHANGED
|
@@ -1,225 +1,559 @@
|
|
|
1
|
-
|
|
1
|
+
/*****************************************************************************
|
|
2
2
|
* @file src/Employee.js
|
|
3
|
-
|
|
4
|
-
* @version 1.0.0
|
|
5
|
-
*/
|
|
3
|
+
*****************************************************************************/
|
|
6
4
|
import FireModel from "@shisyamo4131/air-firebase-v2";
|
|
7
5
|
import { defField } from "./parts/fieldDefinitions.js";
|
|
8
6
|
import { defAccessor } from "./parts/accessorDefinitions.js";
|
|
9
7
|
import { VALUES as EMPLOYMENT_STATUS_VALUES } from "./constants/employment-status.js";
|
|
10
8
|
import { VALUES as BLOOD_TYPE_VALUES } from "./constants/blood-type.js";
|
|
9
|
+
import { VALUES as EMERGENCY_CONTACT_RELATION_VALUES } from "./constants/emergency-contact-relation.js";
|
|
11
10
|
import Certification from "./Certification.js";
|
|
12
11
|
import { GeocodableMixin } from "./mixins/GeocodableMixin.js";
|
|
12
|
+
import { VALIDATION_ERRORS } from "./errorDefinitions.js";
|
|
13
|
+
import Insurance from "./Insurance.js";
|
|
13
14
|
|
|
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
|
-
|
|
15
|
+
/*****************************************************************************
|
|
16
|
+
* @class Employee
|
|
17
|
+
* @extends GeocodableMixin(FireModel)
|
|
18
|
+
*
|
|
19
|
+
* @property {string} code - 従業員コード
|
|
20
|
+
* @property {string} lastName - 姓
|
|
21
|
+
* @property {string} firstName - 名
|
|
22
|
+
* @property {string} lastNameKana - 姓(カナ)
|
|
23
|
+
* @property {string} firstNameKana - 名(カナ)
|
|
24
|
+
* @property {string} displayName - 表示名
|
|
25
|
+
* @property {string} gender - 性別
|
|
26
|
+
* @property {Date} dateOfBirth - 生年月日
|
|
27
|
+
* @property {string} zipcode - 郵便番号
|
|
28
|
+
* @property {string} prefCode - 都道府県コード
|
|
29
|
+
* @property {string} city - 市区町村
|
|
30
|
+
* @property {string} address - 住所
|
|
31
|
+
* @property {string} building - 建物名
|
|
32
|
+
* @property {object} location - 地理的な位置情報
|
|
33
|
+
* @property {string} mobile - 携帯電話番号
|
|
34
|
+
* @property {string} email - メールアドレス
|
|
35
|
+
* @property {Date} dateOfHire - 入社日
|
|
36
|
+
* @property {string} employmentStatus - 雇用状況
|
|
37
|
+
* @property {string} title - 肩書
|
|
38
|
+
* @property {Date} dateOfTermination - 退職日
|
|
39
|
+
* @property {string} reasonOfTermination - 退職理由
|
|
40
|
+
* @property {boolean} isForeigner - 外国人かどうか
|
|
41
|
+
* @property {string} foreignName - 外国人氏名
|
|
42
|
+
* @property {string} nationality - 国籍
|
|
43
|
+
* @property {string} residenceStatus - 在留資格
|
|
44
|
+
* @property {boolean} hasPeriodOfStayLimit - 在留期間制限の有無
|
|
45
|
+
* @property {Date} periodOfStay - 在留期間満了日
|
|
46
|
+
* @property {boolean} hasWorkRestrictions - 就労制限の有無
|
|
47
|
+
* @property {boolean} hasSecurityGuardRegistration - 警備員資格登録の有無
|
|
48
|
+
* @property {Date} dateOfSecurityGuardRegistration - 警備員資格登録日
|
|
49
|
+
* @property {string} bloodType - 血液型
|
|
50
|
+
* @property {string} emergencyContactName - 緊急連絡先氏名
|
|
51
|
+
* @property {string} emergencyContactRelation - 緊急連絡先との関係
|
|
52
|
+
* @property {string} emergencyContactRelationDetail - 緊急連絡先との関係詳細
|
|
53
|
+
* @property {string} emergencyContactAddress - 緊急連絡先住所
|
|
54
|
+
* @property {string} emergencyContactPhone - 緊急連絡先電話番号
|
|
55
|
+
* @property {string} domicile - 本籍地
|
|
56
|
+
* @property {Array<Certification>} securityCertifications - 警備員資格情報の配列
|
|
57
|
+
* @property {Insurance} healthInsurance - 健康保険情報
|
|
58
|
+
* @property {Insurance} pensionInsurance - 厚生年金保険情報
|
|
59
|
+
* @property {Insurance} employmentInsurance - 雇用保険情報
|
|
60
|
+
* @property {string} remarks - 備考
|
|
61
|
+
*
|
|
62
|
+
* @property {string} fullName - 姓と名を結合したフルネーム(読み取り専用)
|
|
63
|
+
* @property {string} fullNameKana - 姓と名を結合したフルネーム(カナ、読み取り専用)
|
|
64
|
+
* @property {string} fullAddress - 都道府県、市区町村、住所を結合したフルアドレス(読み取り専用)
|
|
65
|
+
* @property {string} prefecture - `prefCode` から派生した都道府県名(読み取り専用)
|
|
66
|
+
*
|
|
67
|
+
* @getter
|
|
68
|
+
* @property {number} age - `dateOfBirth` から計算された年齢(読み取り専用)
|
|
69
|
+
* @property {number} yearsOfService - `dateOfHire` から計算された勤続年数(読み取り専用)
|
|
70
|
+
*
|
|
71
|
+
* @static
|
|
72
|
+
* @property {Object} EMPLOYMENT_STATUS - 雇用状況の定数オブジェクト
|
|
73
|
+
* @property {string} STATUS_ACTIVE - 在職中の雇用状況を表す定数
|
|
74
|
+
* @property {string} STATUS_TERMINATED - 退職済みの雇用状況を表す定数
|
|
75
|
+
*
|
|
76
|
+
* @function toTerminated - 現在の従業員インスタンスを退職済みに変更する関数
|
|
77
|
+
*****************************************************************************/
|
|
78
|
+
export default class Employee extends GeocodableMixin(FireModel) {
|
|
79
|
+
static className = "従業員";
|
|
80
|
+
static collectionPath = "Employees";
|
|
81
|
+
static useAutonumber = false;
|
|
82
|
+
static logicalDelete = true;
|
|
83
|
+
static classProps = {
|
|
84
|
+
code: defField("code", { label: "従業員コード" }),
|
|
85
|
+
lastName: defField("lastName", { required: true }),
|
|
86
|
+
firstName: defField("firstName", { required: true }),
|
|
87
|
+
lastNameKana: defField("lastNameKana", { required: true }),
|
|
88
|
+
firstNameKana: defField("firstNameKana", { required: true }),
|
|
89
|
+
displayName: defField("displayName", { required: true }),
|
|
90
|
+
gender: defField("gender", { required: true }),
|
|
91
|
+
dateOfBirth: defField("dateOfBirth", { required: true }),
|
|
92
|
+
zipcode: defField("zipcode", { required: true }),
|
|
93
|
+
prefCode: defField("prefCode", { required: true }),
|
|
94
|
+
city: defField("city", { required: true }),
|
|
95
|
+
address: defField("address", { required: true }),
|
|
96
|
+
building: defField("building"),
|
|
97
|
+
location: defField("location", { hidden: true }),
|
|
98
|
+
mobile: defField("mobile"),
|
|
99
|
+
email: defField("email", { required: false }),
|
|
100
|
+
dateOfHire: defField("dateOfHire", { required: true }),
|
|
101
|
+
employmentStatus: defField("employmentStatus", { required: true }),
|
|
102
|
+
title: defField("title"),
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 退職年月日
|
|
106
|
+
* - `employmentStatus` が `TERMINATED` の場合、必須フィールド。
|
|
107
|
+
* - `employmentStatus` が `ACTIVE` の場合、入力不可(disabled)。
|
|
108
|
+
* - バリデーションルール:
|
|
109
|
+
* - `employmentStatus` が `TERMINATED` の場合、必須。
|
|
110
|
+
* - `employmentStatus` が `TERMINATED` の場合、`dateOfHire` より前の日付は不可。
|
|
111
|
+
* - `employmentStatus` が `ACTIVE` の場合、常に null でなければならない。
|
|
112
|
+
* - フロントエンドのフォームでは、`employmentStatus` の値に応じて入力フィールドの表示/非表示や必須/任意を切り替えることが推奨される。
|
|
113
|
+
*/
|
|
114
|
+
dateOfTermination: defField("dateOfTermination", {
|
|
115
|
+
validator: (value, item) => {
|
|
116
|
+
if (
|
|
117
|
+
item.employmentStatus === EMPLOYMENT_STATUS_VALUES.TERMINATED.value
|
|
118
|
+
) {
|
|
119
|
+
if (!value) {
|
|
120
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
121
|
+
"INVALID_DATE_OF_TERMINATION",
|
|
122
|
+
"dateOfTermination is required when employmentStatus is 'terminated'.",
|
|
123
|
+
{ ja: "在職区分が '退職' の場合、退職年月日は必須です。" },
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (!(value instanceof Date)) {
|
|
127
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
128
|
+
"INVALID_DATE_OF_TERMINATION",
|
|
129
|
+
"dateOfTermination must be a Date object.",
|
|
130
|
+
{ ja: "退職年月日はDateオブジェクトである必要があります。" },
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (value < item.dateOfHire) {
|
|
134
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
135
|
+
"INVALID_DATE_OF_TERMINATION",
|
|
136
|
+
"dateOfTermination cannot be earlier than dateOfHire.",
|
|
137
|
+
{ ja: "退職年月日は入社日より前に設定できません。" },
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
},
|
|
143
|
+
component: {
|
|
144
|
+
attrs: {
|
|
145
|
+
required: ({ item }) =>
|
|
146
|
+
item.employmentStatus === EMPLOYMENT_STATUS_VALUES.TERMINATED.value,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
reasonOfTermination: defField("reasonOfTermination", {
|
|
151
|
+
validator: (value, item) => {
|
|
152
|
+
if (
|
|
153
|
+
item.employmentStatus === EMPLOYMENT_STATUS_VALUES.TERMINATED.value
|
|
154
|
+
) {
|
|
155
|
+
if (!value) {
|
|
156
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
157
|
+
"INVALID_REASON_OF_TERMINATION",
|
|
158
|
+
"reasonOfTermination is required when employmentStatus is 'terminated'.",
|
|
159
|
+
{ ja: "在職区分が '退職' の場合、退職理由は必須です。" },
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (typeof value !== "string") {
|
|
163
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
164
|
+
"INVALID_REASON_OF_TERMINATION",
|
|
165
|
+
"reasonOfTermination must be a string.",
|
|
166
|
+
{ ja: "退職理由は文字列である必要があります。" },
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
},
|
|
172
|
+
component: {
|
|
173
|
+
attrs: {
|
|
174
|
+
required: ({ item }) =>
|
|
175
|
+
item.employmentStatus === EMPLOYMENT_STATUS_VALUES.TERMINATED.value,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
|
|
180
|
+
// Foreign related fields
|
|
181
|
+
isForeigner: defField("isForeigner"),
|
|
182
|
+
foreignName: defField("foreignName", {
|
|
183
|
+
validator: (value, item) => {
|
|
184
|
+
if (item.isForeigner) {
|
|
185
|
+
if (!value) {
|
|
186
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
187
|
+
"FOREIGN_NAME_REQUIRED",
|
|
188
|
+
"foreignName is required when isForeigner is true.",
|
|
189
|
+
{ ja: "外国籍の場合、外国名は必須です。" },
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
if (typeof value !== "string") {
|
|
193
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
194
|
+
"FOREIGN_NAME_INVALID",
|
|
195
|
+
"foreignName must be a string.",
|
|
196
|
+
{ ja: "外国名は文字列である必要があります。" },
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
},
|
|
202
|
+
component: {
|
|
203
|
+
attrs: {
|
|
204
|
+
required: ({ item }) => item.isForeigner,
|
|
205
|
+
disabled: ({ item }) => !item.isForeigner,
|
|
206
|
+
},
|
|
41
207
|
},
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
208
|
+
}),
|
|
209
|
+
nationality: defField("nationality", {
|
|
210
|
+
validator: (value, item) => {
|
|
211
|
+
if (item.isForeigner) {
|
|
212
|
+
if (!value) {
|
|
213
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
214
|
+
"NATIONALITY_REQUIRED",
|
|
215
|
+
"nationality is required when isForeigner is true.",
|
|
216
|
+
{ ja: "外国籍の場合、国籍は必須です。" },
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
if (typeof value !== "string") {
|
|
220
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
221
|
+
"NATIONALITY_INVALID",
|
|
222
|
+
"nationality must be a string.",
|
|
223
|
+
{ ja: "国籍は文字列である必要があります。" },
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return true;
|
|
228
|
+
},
|
|
229
|
+
component: {
|
|
230
|
+
attrs: {
|
|
231
|
+
required: ({ item }) => item.isForeigner,
|
|
232
|
+
disabled: ({ item }) => !item.isForeigner,
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
residenceStatus: defField("residenceStatus", {
|
|
237
|
+
validator: (value, item) => {
|
|
238
|
+
if (item.isForeigner) {
|
|
239
|
+
if (!value) {
|
|
240
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
241
|
+
"RESIDENCE_STATUS_REQUIRED",
|
|
242
|
+
"residenceStatus is required when isForeigner is true.",
|
|
243
|
+
{ ja: "外国籍の場合、在留資格は必須です。" },
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
if (typeof value !== "string") {
|
|
247
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
248
|
+
"RESIDENCE_STATUS_INVALID",
|
|
249
|
+
"residenceStatus must be a string.",
|
|
250
|
+
{ ja: "在留資格は文字列である必要があります。" },
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return true;
|
|
255
|
+
},
|
|
256
|
+
component: {
|
|
257
|
+
attrs: {
|
|
258
|
+
required: ({ item }) => item.isForeigner,
|
|
259
|
+
disabled: ({ item }) => !item.isForeigner,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
}),
|
|
263
|
+
hasPeriodOfStayLimit: defField("hasPeriodOfStayLimit", {
|
|
264
|
+
component: {
|
|
265
|
+
attrs: {
|
|
266
|
+
disabled: ({ item }) => !item.isForeigner,
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
}),
|
|
270
|
+
periodOfStay: defField("periodOfStay", {
|
|
271
|
+
validator: (value, item) => {
|
|
272
|
+
if (item.isForeigner && item.hasPeriodOfStayLimit) {
|
|
273
|
+
if (!value) {
|
|
274
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
275
|
+
"PERIOD_OF_STAY_REQUIRED",
|
|
276
|
+
"periodOfStay is required when isForeigner is true and hasPeriodOfStayLimit is true.",
|
|
277
|
+
{
|
|
278
|
+
ja: "外国籍で在留期間制限がある場合、在留期間満了日は必須です。",
|
|
279
|
+
},
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
if (!(value instanceof Date)) {
|
|
283
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
284
|
+
"PERIOD_OF_STAY_INVALID",
|
|
285
|
+
"periodOfStay must be a Date.",
|
|
286
|
+
{ ja: "在留期間満了日は日付である必要があります。" },
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
51
291
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
component: {
|
|
59
|
-
attrs: {
|
|
60
|
-
required: ({ item }) => item.isForeigner,
|
|
61
|
-
disabled: ({ item }) => !item.isForeigner,
|
|
292
|
+
component: {
|
|
293
|
+
attrs: {
|
|
294
|
+
required: ({ item }) => item.isForeigner && item.hasPeriodOfStayLimit,
|
|
295
|
+
disabled: ({ item }) =>
|
|
296
|
+
!item.isForeigner || !item.hasPeriodOfStayLimit,
|
|
297
|
+
},
|
|
62
298
|
},
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
disabled: ({ item }) => !item.isForeigner,
|
|
299
|
+
}),
|
|
300
|
+
hasWorkRestrictions: defField("hasWorkRestrictions", {
|
|
301
|
+
component: {
|
|
302
|
+
attrs: {
|
|
303
|
+
disabled: ({ item }) => !item.isForeigner,
|
|
304
|
+
},
|
|
70
305
|
},
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
306
|
+
}),
|
|
307
|
+
// Security guard related fields
|
|
308
|
+
hasSecurityGuardRegistration: defField("check", { label: "警備員登録" }),
|
|
309
|
+
dateOfSecurityGuardRegistration: defField(
|
|
310
|
+
"dateOfSecurityGuardRegistration",
|
|
311
|
+
{
|
|
312
|
+
validator: (value, item) => {
|
|
313
|
+
if (item.hasSecurityGuardRegistration) {
|
|
314
|
+
if (!value) {
|
|
315
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
316
|
+
"SECURITY_GUARD_REGISTRATION_DATE_REQUIRED",
|
|
317
|
+
"dateOfSecurityGuardRegistration is required when hasSecurityGuardRegistration is true.",
|
|
318
|
+
{ ja: "警備員登録がある場合、警備員登録日は必須です。" },
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
if (!(value instanceof Date)) {
|
|
322
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
323
|
+
"SECURITY_GUARD_REGISTRATION_DATE_INVALID",
|
|
324
|
+
"dateOfSecurityGuardRegistration must be a Date.",
|
|
325
|
+
{ ja: "警備員登録日は日付である必要があります。" },
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return true;
|
|
330
|
+
},
|
|
331
|
+
component: {
|
|
332
|
+
attrs: {
|
|
333
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
334
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
),
|
|
339
|
+
bloodType: defField("bloodType", {
|
|
340
|
+
validator: (value, item) => {
|
|
341
|
+
if (item.hasSecurityGuardRegistration) {
|
|
342
|
+
if (!value) {
|
|
343
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
344
|
+
"BLOOD_TYPE_REQUIRED",
|
|
345
|
+
"bloodType is required when hasSecurityGuardRegistration is true.",
|
|
346
|
+
{ ja: "警備員登録がある場合、血液型は必須です。" },
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
if (
|
|
350
|
+
!Object.values(BLOOD_TYPE_VALUES).some((v) => v.value === value)
|
|
351
|
+
) {
|
|
352
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
353
|
+
"BLOOD_TYPE_INVALID",
|
|
354
|
+
"bloodType must be a valid value.",
|
|
355
|
+
{ ja: "血液型は有効な値である必要があります。" },
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return true;
|
|
360
|
+
},
|
|
361
|
+
component: {
|
|
362
|
+
attrs: {
|
|
363
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
364
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
}),
|
|
368
|
+
emergencyContactName: defField("emergencyContactName", {
|
|
369
|
+
validator: (value, item) => {
|
|
370
|
+
if (item.hasSecurityGuardRegistration) {
|
|
371
|
+
if (!value) {
|
|
372
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
373
|
+
"EMERGENCY_CONTACT_NAME_REQUIRED",
|
|
374
|
+
"emergencyContactName is required when hasSecurityGuardRegistration is true.",
|
|
375
|
+
{ ja: "警備員登録がある場合、緊急連絡先の名前は必須です。" },
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
if (typeof value !== "string") {
|
|
379
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
380
|
+
"EMERGENCY_CONTACT_NAME_INVALID",
|
|
381
|
+
"emergencyContactName must be a valid string.",
|
|
382
|
+
{ ja: "緊急連絡先の名前は有効な文字列である必要があります。" },
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
},
|
|
388
|
+
component: {
|
|
389
|
+
attrs: {
|
|
390
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
391
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
}),
|
|
395
|
+
emergencyContactRelation: defField("emergencyContactRelation", {
|
|
396
|
+
validator: (value, item) => {
|
|
397
|
+
if (item.hasSecurityGuardRegistration) {
|
|
398
|
+
if (!value) {
|
|
399
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
400
|
+
"EMERGENCY_CONTACT_RELATION_REQUIRED",
|
|
401
|
+
"emergencyContactRelation is required when hasSecurityGuardRegistration is true.",
|
|
402
|
+
{ ja: "警備員登録がある場合、緊急連絡先の関係は必須です。" },
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
if (
|
|
406
|
+
!Object.values(EMERGENCY_CONTACT_RELATION_VALUES).some(
|
|
407
|
+
(v) => v.value === value,
|
|
408
|
+
)
|
|
409
|
+
) {
|
|
410
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
411
|
+
"EMERGENCY_CONTACT_RELATION_INVALID",
|
|
412
|
+
"emergencyContactRelation must be a valid value.",
|
|
413
|
+
{ ja: "緊急連絡先の関係は有効な値である必要があります。" },
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return true;
|
|
78
418
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
required: ({ item }) => item.isForeigner,
|
|
85
|
-
disabled: ({ item }) => !item.isForeigner,
|
|
419
|
+
component: {
|
|
420
|
+
attrs: {
|
|
421
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
422
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
423
|
+
},
|
|
86
424
|
},
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
425
|
+
}),
|
|
426
|
+
emergencyContactRelationDetail: defField("emergencyContactRelationDetail", {
|
|
427
|
+
validator: (value, item) => {
|
|
428
|
+
if (item.hasSecurityGuardRegistration) {
|
|
429
|
+
if (!value) {
|
|
430
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
431
|
+
"EMERGENCY_CONTACT_RELATION_DETAIL_REQUIRED",
|
|
432
|
+
"emergencyContactRelationDetail is required when hasSecurityGuardRegistration is true.",
|
|
433
|
+
{ ja: "警備員登録がある場合、緊急連絡先の詳細は必須です。" },
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
if (typeof value !== "string") {
|
|
437
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
438
|
+
"EMERGENCY_CONTACT_RELATION_DETAIL_INVALID",
|
|
439
|
+
"emergencyContactRelationDetail must be a valid string.",
|
|
440
|
+
{ ja: "緊急連絡先の詳細は有効な文字列である必要があります。" },
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return true;
|
|
97
445
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
104
|
-
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
446
|
+
component: {
|
|
447
|
+
attrs: {
|
|
448
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
449
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
450
|
+
},
|
|
105
451
|
},
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
452
|
+
}),
|
|
453
|
+
emergencyContactAddress: defField("emergencyContactAddress", {
|
|
454
|
+
validator: (value, item) => {
|
|
455
|
+
if (item.hasSecurityGuardRegistration) {
|
|
456
|
+
if (!value) {
|
|
457
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
458
|
+
"EMERGENCY_CONTACT_ADDRESS_REQUIRED",
|
|
459
|
+
"emergencyContactAddress is required when hasSecurityGuardRegistration is true.",
|
|
460
|
+
{ ja: "警備員登録がある場合、緊急連絡先の住所は必須です。" },
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
if (typeof value !== "string") {
|
|
464
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
465
|
+
"EMERGENCY_CONTACT_ADDRESS_INVALID",
|
|
466
|
+
"emergencyContactAddress must be a valid string.",
|
|
467
|
+
{ ja: "緊急連絡先の住所は有効な文字列である必要があります。" },
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return true;
|
|
113
472
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
120
|
-
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
473
|
+
component: {
|
|
474
|
+
attrs: {
|
|
475
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
476
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
477
|
+
},
|
|
121
478
|
},
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
479
|
+
}),
|
|
480
|
+
emergencyContactPhone: defField("emergencyContactPhone", {
|
|
481
|
+
validator: (value, item) => {
|
|
482
|
+
if (item.hasSecurityGuardRegistration) {
|
|
483
|
+
if (!value) {
|
|
484
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
485
|
+
"EMERGENCY_CONTACT_PHONE_REQUIRED",
|
|
486
|
+
"emergencyContactPhone is required when hasSecurityGuardRegistration is true.",
|
|
487
|
+
{ ja: "警備員登録がある場合、緊急連絡先の電話番号は必須です。" },
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
if (typeof value !== "string") {
|
|
491
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
492
|
+
"EMERGENCY_CONTACT_PHONE_INVALID",
|
|
493
|
+
"emergencyContactPhone must be a valid string.",
|
|
494
|
+
{
|
|
495
|
+
ja: "緊急連絡先の電話番号は有効な文字列である必要があります。",
|
|
496
|
+
},
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return true;
|
|
129
501
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
136
|
-
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
502
|
+
component: {
|
|
503
|
+
attrs: {
|
|
504
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
505
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
506
|
+
},
|
|
137
507
|
},
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
508
|
+
}),
|
|
509
|
+
domicile: defField("domicile", {
|
|
510
|
+
validator: (value, item) => {
|
|
511
|
+
if (item.hasSecurityGuardRegistration) {
|
|
512
|
+
if (!value) {
|
|
513
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
514
|
+
"DOMICILE_REQUIRED",
|
|
515
|
+
"domicile is required when hasSecurityGuardRegistration is true.",
|
|
516
|
+
{ ja: "警備員登録がある場合、本籍地は必須です。" },
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
if (typeof value !== "string") {
|
|
520
|
+
return VALIDATION_ERRORS.CUSTOM_ERROR(
|
|
521
|
+
"DOMICILE_INVALID",
|
|
522
|
+
"domicile must be a valid string.",
|
|
523
|
+
{ ja: "本籍地は有効な文字列である必要があります。" },
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return true;
|
|
145
528
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
152
|
-
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
529
|
+
component: {
|
|
530
|
+
attrs: {
|
|
531
|
+
required: ({ item }) => item.hasSecurityGuardRegistration,
|
|
532
|
+
disabled: ({ item }) => !item.hasSecurityGuardRegistration,
|
|
533
|
+
},
|
|
153
534
|
},
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
535
|
+
}),
|
|
536
|
+
securityCertifications: defField("array", {
|
|
537
|
+
label: "保有資格",
|
|
538
|
+
customClass: Certification,
|
|
539
|
+
}),
|
|
540
|
+
|
|
541
|
+
// 加入保険
|
|
542
|
+
healthInsurance: defField("healthInsurance", {
|
|
543
|
+
default: () => new Insurance(),
|
|
544
|
+
customClass: Insurance,
|
|
545
|
+
}),
|
|
546
|
+
pensionInsurance: defField("pensionInsurance", {
|
|
547
|
+
default: () => new Insurance(),
|
|
548
|
+
customClass: Insurance,
|
|
549
|
+
}),
|
|
550
|
+
employmentInsurance: defField("employmentInsurance", {
|
|
551
|
+
default: () => new Insurance(),
|
|
552
|
+
customClass: Insurance,
|
|
553
|
+
}),
|
|
554
|
+
remarks: defField("remarks"),
|
|
555
|
+
};
|
|
162
556
|
|
|
163
|
-
/*****************************************************************************
|
|
164
|
-
* @prop {string} code - Employee code.
|
|
165
|
-
* @prop {string} lastName - Last name.
|
|
166
|
-
* @prop {string} firstName - First name.
|
|
167
|
-
* @prop {string} lastNameKana - Last name in Kana.
|
|
168
|
-
* @prop {string} firstNameKana - First name in Kana.
|
|
169
|
-
* @prop {string} displayName - Display name.
|
|
170
|
-
* @prop {string} gender - Gender.
|
|
171
|
-
* @prop {Date} dateOfBirth - Date of birth.
|
|
172
|
-
* @prop {string} zipcode - Postal code.
|
|
173
|
-
* @prop {string} prefCode - Prefecture code.
|
|
174
|
-
* @prop {string} city - City name.
|
|
175
|
-
* @prop {string} address - Address details.
|
|
176
|
-
* @prop {string} building - Building name.
|
|
177
|
-
* @prop {object} location - Geographical location.
|
|
178
|
-
* @prop {string} mobile - Mobile phone number.
|
|
179
|
-
* @prop {string} email - Email address.
|
|
180
|
-
* @prop {Date} dateOfHire - Date of hire.
|
|
181
|
-
* @prop {string} employmentStatus - Employment status.
|
|
182
|
-
* @prop {string} title - Job title.
|
|
183
|
-
* @prop {Date} dateOfTermination - Date of termination.
|
|
184
|
-
* @prop {string} reasonOfTermination - Reason for termination.
|
|
185
|
-
* @prop {boolean} isForeigner - Is the employee a foreigner.
|
|
186
|
-
* @prop {string} foreignName - Foreign name.
|
|
187
|
-
* @prop {string} nationality - Nationality.
|
|
188
|
-
* @prop {string} residenceStatus - Residence status.
|
|
189
|
-
* @prop {Date} periodOfStay - Period of stay expiration date.
|
|
190
|
-
* @prop {boolean} hasSecurityGuardRegistration - Has security guard registration.
|
|
191
|
-
* @prop {Date} dateOfSecurityGuardRegistration - Date of security guard registration.
|
|
192
|
-
* @prop {string} bloodType - Blood type.
|
|
193
|
-
* @prop {string} emergencyContactName - Emergency contact name.
|
|
194
|
-
* @prop {string} emergencyContactRelation - Emergency contact relation.
|
|
195
|
-
* @prop {string} emergencyContactRelationDetail - Emergency contact relation detail.
|
|
196
|
-
* @prop {string} emergencyContactAddress - Emergency contact address.
|
|
197
|
-
* @prop {string} emergencyContactPhone - Emergency contact phone number.
|
|
198
|
-
* @prop {string} domicile - Domicile.
|
|
199
|
-
* @prop {Array<Certification>} securityCertifications - Array of security certifications.
|
|
200
|
-
* @prop {string} remarks - Additional remarks.
|
|
201
|
-
*
|
|
202
|
-
* @prop {string} fullName - Full name combining last and first names (read-only)
|
|
203
|
-
* @prop {string} fullNameKana - Full name in Kana combining last and first names (read-only)
|
|
204
|
-
* @prop {string} fullAddress - Full address combining prefecture, city, and address (read-only)
|
|
205
|
-
* @prop {string} prefecture - Prefecture name derived from `prefCode` (read-only)
|
|
206
|
-
*
|
|
207
|
-
* @getter
|
|
208
|
-
* @prop {number} age - Age calculated from `dateOfBirth` (read-only)
|
|
209
|
-
* @prop {number} yearsOfService - Years of service calculated from `dateOfHire` (read-only)
|
|
210
|
-
*
|
|
211
|
-
* @static
|
|
212
|
-
* @prop {string} STATUS_ACTIVE - constant for active employment status
|
|
213
|
-
* @prop {string} STATUS_TERMINATED - constant for terminated employment status
|
|
214
|
-
*
|
|
215
|
-
* @function toTerminated - Change the current employee instance to terminated status.
|
|
216
|
-
*****************************************************************************/
|
|
217
|
-
export default class Employee extends GeocodableMixin(FireModel) {
|
|
218
|
-
static className = "従業員";
|
|
219
|
-
static collectionPath = "Employees";
|
|
220
|
-
static useAutonumber = false;
|
|
221
|
-
static logicalDelete = true;
|
|
222
|
-
static classProps = classProps;
|
|
223
557
|
static tokenFields = [
|
|
224
558
|
"code",
|
|
225
559
|
"lastName",
|
|
@@ -238,6 +572,9 @@ export default class Employee extends GeocodableMixin(FireModel) {
|
|
|
238
572
|
static STATUS_ACTIVE = EMPLOYMENT_STATUS_VALUES.ACTIVE.value;
|
|
239
573
|
static STATUS_TERMINATED = EMPLOYMENT_STATUS_VALUES.TERMINATED.value;
|
|
240
574
|
|
|
575
|
+
/** 2026-03-18 追加 */
|
|
576
|
+
static EMPLOYMENT_STATUS = EMPLOYMENT_STATUS_VALUES;
|
|
577
|
+
|
|
241
578
|
constructor(item = {}) {
|
|
242
579
|
super(item);
|
|
243
580
|
|
|
@@ -344,108 +681,61 @@ export default class Employee extends GeocodableMixin(FireModel) {
|
|
|
344
681
|
}
|
|
345
682
|
|
|
346
683
|
/**
|
|
347
|
-
*
|
|
348
|
-
* -
|
|
684
|
+
* 退職状態に関連するフィールドを初期化します。
|
|
685
|
+
* - `employmentStatus` が `TERMINATED` でない場合、以下のプロパティを初期化します。
|
|
686
|
+
* - `dateOfTermination`
|
|
687
|
+
* - `reasonOfTermination`
|
|
688
|
+
* @returns {void}
|
|
689
|
+
*/
|
|
690
|
+
_initTerminatedFields() {
|
|
691
|
+
if (this.employmentStatus !== EMPLOYMENT_STATUS_VALUES.TERMINATED.value) {
|
|
692
|
+
this.dateOfTermination = null;
|
|
693
|
+
this.reasonOfTermination = null;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* 外国籍に関連するフィールドを初期化します。
|
|
349
699
|
* - `isForeigner` が false の場合、以下のプロパティを初期化します。
|
|
350
700
|
* - `foreignName`
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
701
|
+
* - `nationality`
|
|
702
|
+
* - `residenceStatus`
|
|
703
|
+
* - `hasPeriodOfStayLimit`
|
|
704
|
+
* - `periodOfStay`
|
|
705
|
+
* - `hasWorkRestrictions`
|
|
706
|
+
* - `isForeigner` が true で `hasPeriodOfStayLimit` が false の場合、`periodOfStay` を初期化します。
|
|
354
707
|
* @returns {void}
|
|
355
|
-
* @throws {Error} 外国籍の場合に必須フィールドが未入力の場合。
|
|
356
708
|
*/
|
|
357
|
-
|
|
358
|
-
if (this.isForeigner) {
|
|
359
|
-
if (!this.foreignName) {
|
|
360
|
-
throw new Error(
|
|
361
|
-
"[Employee.js] foreignName is required when isForeigner is true."
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
if (!this.nationality) {
|
|
365
|
-
throw new Error(
|
|
366
|
-
"[Employee.js] nationality is required when isForeigner is true."
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
if (!this.residenceStatus) {
|
|
370
|
-
throw new Error(
|
|
371
|
-
"[Employee.js] residenceStatus is required when isForeigner is true."
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
if (!this.periodOfStay) {
|
|
375
|
-
throw new Error(
|
|
376
|
-
"[Employee.js] periodOfStay is required when isForeigner is true."
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
} else {
|
|
380
|
-
// 外国籍でない場合、関連フィールドを初期化
|
|
709
|
+
_initForeignerFields() {
|
|
710
|
+
if (!this.isForeigner) {
|
|
381
711
|
this.foreignName = null;
|
|
382
712
|
this.nationality = null;
|
|
383
713
|
this.residenceStatus = null;
|
|
714
|
+
this.hasPeriodOfStayLimit = false;
|
|
384
715
|
this.periodOfStay = null;
|
|
716
|
+
this.hasWorkRestrictions = false;
|
|
717
|
+
} else {
|
|
718
|
+
if (!this.hasPeriodOfStayLimit) {
|
|
719
|
+
this.periodOfStay = null;
|
|
720
|
+
}
|
|
385
721
|
}
|
|
386
722
|
}
|
|
387
723
|
|
|
388
724
|
/**
|
|
389
|
-
*
|
|
390
|
-
* -
|
|
391
|
-
*
|
|
392
|
-
* - `
|
|
393
|
-
* - `
|
|
394
|
-
*
|
|
725
|
+
* 警備員登録に関連するフィールドを初期化します。
|
|
726
|
+
* - `hasSecurityGuardRegistration` が false の場合、以下のプロパティを初期化します。
|
|
727
|
+
* - `dateOfSecurityGuardRegistration`
|
|
728
|
+
* - `bloodType`
|
|
729
|
+
* - `emergencyContactName`
|
|
730
|
+
* - `emergencyContactRelation`
|
|
731
|
+
* - `emergencyContactRelationDetail`
|
|
732
|
+
* - `emergencyContactAddress`
|
|
733
|
+
* - `emergencyContactPhone`
|
|
734
|
+
* - `domicile`
|
|
395
735
|
* @returns {void}
|
|
396
|
-
* @throws {Error} 退職済の場合に必須フィールドが未入力の場合。
|
|
397
736
|
*/
|
|
398
|
-
|
|
399
|
-
if (this.
|
|
400
|
-
if (!this.dateOfTermination) {
|
|
401
|
-
throw new Error(
|
|
402
|
-
"[Employee.js] dateOfTermination is required when employmentStatus is 'terminated'."
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
if (!this.reasonOfTermination) {
|
|
406
|
-
throw new Error(
|
|
407
|
-
"[Employee.js] reasonOfTermination is required when employmentStatus is 'terminated'."
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
} else {
|
|
411
|
-
this.dateOfTermination = null;
|
|
412
|
-
this.reasonOfTermination = null;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
_validateSecurityGuardFields() {
|
|
417
|
-
if (this.hasSecurityGuardRegistration) {
|
|
418
|
-
if (!this.dateOfSecurityGuardRegistration) {
|
|
419
|
-
throw new Error(
|
|
420
|
-
"[Employee.js] dateOfSecurityGuardRegistration is required when hasSecurityGuardRegistration is true."
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
if (!this.emergencyContactName) {
|
|
424
|
-
throw new Error(
|
|
425
|
-
"[Employee.js] emergencyContactName is required when hasSecurityGuardRegistration is true."
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
if (!this.emergencyContactRelationDetail) {
|
|
429
|
-
throw new Error(
|
|
430
|
-
"[Employee.js] emergencyContactRelationDetail is required when hasSecurityGuardRegistration is true."
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
if (!this.emergencyContactAddress) {
|
|
434
|
-
throw new Error(
|
|
435
|
-
"[Employee.js] emergencyContactAddress is required when hasSecurityGuardRegistration is true."
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
if (!this.emergencyContactPhone) {
|
|
439
|
-
throw new Error(
|
|
440
|
-
"[Employee.js] emergencyContactPhone is required when hasSecurityGuardRegistration is true."
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
if (!this.domicile) {
|
|
444
|
-
throw new Error(
|
|
445
|
-
"[Employee.js] domicile is required when hasSecurityGuardRegistration is true."
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
} else {
|
|
737
|
+
_initSecurityGuardFields() {
|
|
738
|
+
if (!this.hasSecurityGuardRegistration) {
|
|
449
739
|
this.dateOfSecurityGuardRegistration = null;
|
|
450
740
|
this.bloodType = BLOOD_TYPE_VALUES.A.value;
|
|
451
741
|
this.emergencyContactName = null;
|
|
@@ -470,9 +760,11 @@ export default class Employee extends GeocodableMixin(FireModel) {
|
|
|
470
760
|
*/
|
|
471
761
|
async beforeCreate(args = {}) {
|
|
472
762
|
await super.beforeCreate(args);
|
|
473
|
-
this._validateForeignerRequiredFields();
|
|
474
|
-
this.
|
|
475
|
-
this.
|
|
763
|
+
// this._validateForeignerRequiredFields();
|
|
764
|
+
this._initForeignerFields();
|
|
765
|
+
this._initTerminatedFields();
|
|
766
|
+
// this._validateSecurityGuardFields();
|
|
767
|
+
this._initSecurityGuardFields();
|
|
476
768
|
}
|
|
477
769
|
|
|
478
770
|
/**
|
|
@@ -497,13 +789,15 @@ export default class Employee extends GeocodableMixin(FireModel) {
|
|
|
497
789
|
this._beforeData.employmentStatus === Employee.STATUS_ACTIVE
|
|
498
790
|
) {
|
|
499
791
|
throw new Error(
|
|
500
|
-
"[Employee.js] Direct changes to employmentStatus to 'terminated' are not allowed. Use toTerminated() method instead."
|
|
792
|
+
"[Employee.js] Direct changes to employmentStatus to 'terminated' are not allowed. Use toTerminated() method instead.",
|
|
501
793
|
);
|
|
502
794
|
}
|
|
503
795
|
|
|
504
|
-
this._validateForeignerRequiredFields();
|
|
505
|
-
this.
|
|
506
|
-
this.
|
|
796
|
+
// this._validateForeignerRequiredFields();
|
|
797
|
+
this._initForeignerFields();
|
|
798
|
+
this._initTerminatedFields();
|
|
799
|
+
// this._validateSecurityGuardFields();
|
|
800
|
+
this._initSecurityGuardFields();
|
|
507
801
|
}
|
|
508
802
|
|
|
509
803
|
/**
|
|
@@ -520,23 +814,23 @@ export default class Employee extends GeocodableMixin(FireModel) {
|
|
|
520
814
|
async toTerminated(dateOfTermination, reasonOfTermination, options = {}) {
|
|
521
815
|
if (!this.docId) {
|
|
522
816
|
throw new Error(
|
|
523
|
-
"[Employee.js] docId is required to terminate an employee."
|
|
817
|
+
"[Employee.js] docId is required to terminate an employee.",
|
|
524
818
|
);
|
|
525
819
|
}
|
|
526
820
|
if (!dateOfTermination || !(dateOfTermination instanceof Date)) {
|
|
527
821
|
throw new Error(
|
|
528
|
-
"[Employee.js] A valid dateOfTermination is required to terminate an employee."
|
|
822
|
+
"[Employee.js] A valid dateOfTermination is required to terminate an employee.",
|
|
529
823
|
);
|
|
530
824
|
}
|
|
531
825
|
if (dateOfTermination < this.dateOfHire) {
|
|
532
826
|
throw new Error(
|
|
533
|
-
"[Employee.js] dateOfTermination cannot be earlier than dateOfHire."
|
|
827
|
+
"[Employee.js] dateOfTermination cannot be earlier than dateOfHire.",
|
|
534
828
|
);
|
|
535
829
|
}
|
|
536
830
|
|
|
537
831
|
if (!reasonOfTermination || typeof reasonOfTermination !== "string") {
|
|
538
832
|
throw new Error(
|
|
539
|
-
"[Employee.js] A valid reasonOfTermination is required to terminate an employee."
|
|
833
|
+
"[Employee.js] A valid reasonOfTermination is required to terminate an employee.",
|
|
540
834
|
);
|
|
541
835
|
}
|
|
542
836
|
|