@shisyamo4131/air-guard-v2-schemas 1.0.0
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 +15 -0
- package/package.json +44 -0
- package/src/Agreement.js +262 -0
- package/src/ArrangementNotification.js +505 -0
- package/src/Billing.js +159 -0
- package/src/Company.js +176 -0
- package/src/Customer.js +98 -0
- package/src/Employee.js +201 -0
- package/src/Operation.js +779 -0
- package/src/OperationBilling.js +193 -0
- package/src/OperationDetail.js +147 -0
- package/src/OperationResult.js +437 -0
- package/src/OperationResultDetail.js +72 -0
- package/src/Outsourcer.js +46 -0
- package/src/RoundSetting.js +123 -0
- package/src/Site.js +192 -0
- package/src/SiteOperationSchedule.js +503 -0
- package/src/SiteOperationScheduleDetail.js +99 -0
- package/src/SiteOrder.js +62 -0
- package/src/Tax.js +39 -0
- package/src/User.js +41 -0
- package/src/WorkingResult.js +297 -0
- package/src/apis/index.js +9 -0
- package/src/constants/arrangement-notification-status.js +68 -0
- package/src/constants/billing-unit-type.js +15 -0
- package/src/constants/contract-status.js +15 -0
- package/src/constants/day-type.js +44 -0
- package/src/constants/employment-status.js +15 -0
- package/src/constants/gender.js +11 -0
- package/src/constants/index.js +9 -0
- package/src/constants/prefectures.js +56 -0
- package/src/constants/shift-type.js +20 -0
- package/src/constants/site-status.js +15 -0
- package/src/parts/accessorDefinitions.js +109 -0
- package/src/parts/fieldDefinitions.js +642 -0
- package/src/utils/ContextualError.js +49 -0
- package/src/utils/CutoffDate.js +223 -0
- package/src/utils/index.js +48 -0
package/src/Company.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*****************************************************************************
|
|
2
|
+
* Company Model ver 1.0.0
|
|
3
|
+
* @author shisyamo4131
|
|
4
|
+
*****************************************************************************/
|
|
5
|
+
import FireModel from "@shisyamo4131/air-firebase-v2";
|
|
6
|
+
import { defField } from "./parts/fieldDefinitions.js";
|
|
7
|
+
import { defAccessor } from "./parts/accessorDefinitions.js";
|
|
8
|
+
import Agreement from "./Agreement.js";
|
|
9
|
+
import SiteOrder from "./SiteOrder.js";
|
|
10
|
+
import RoundSetting from "./RoundSetting.js";
|
|
11
|
+
|
|
12
|
+
const classProps = {
|
|
13
|
+
companyName: defField("name", { label: "会社名", required: true }),
|
|
14
|
+
companyNameKana: defField("nameKana", {
|
|
15
|
+
label: "会社名(カナ)",
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
/** 以下、管理者アカウント作成時に未入力状態で作成されるため required は未定義とする */
|
|
19
|
+
zipcode: defField("zipcode"),
|
|
20
|
+
prefCode: defField("prefCode"),
|
|
21
|
+
city: defField("city"),
|
|
22
|
+
address: defField("address"),
|
|
23
|
+
building: defField("building"),
|
|
24
|
+
location: defField("location", { hidden: true }),
|
|
25
|
+
tel: defField("tel"),
|
|
26
|
+
fax: defField("fax"),
|
|
27
|
+
agreements: defField("array", {
|
|
28
|
+
label: "既定の取極め",
|
|
29
|
+
customClass: Agreement,
|
|
30
|
+
}),
|
|
31
|
+
/**
|
|
32
|
+
* Field to manage the display order of site-shift type pairs for placement management.
|
|
33
|
+
* Format: { siteId, shiftType }
|
|
34
|
+
*/
|
|
35
|
+
siteOrder: defField("array", {
|
|
36
|
+
customClass: SiteOrder,
|
|
37
|
+
hidden: true,
|
|
38
|
+
}),
|
|
39
|
+
/**
|
|
40
|
+
* Interval in minutes used for VTimePicker's allowed-minutes.
|
|
41
|
+
*/
|
|
42
|
+
minuteInterval: defField("number", {
|
|
43
|
+
label: "時刻選択間隔(分)",
|
|
44
|
+
default: 15,
|
|
45
|
+
component: {
|
|
46
|
+
name: "air-number-input",
|
|
47
|
+
attrs: {
|
|
48
|
+
controlVariant: "split",
|
|
49
|
+
min: 1,
|
|
50
|
+
max: 30,
|
|
51
|
+
hint: "1〜30分の範囲で指定してください",
|
|
52
|
+
persistentHint: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
roundSetting: defField("select", {
|
|
57
|
+
label: "端数処理",
|
|
58
|
+
default: RoundSetting.ROUND,
|
|
59
|
+
component: {
|
|
60
|
+
name: "air-select",
|
|
61
|
+
attrs: {
|
|
62
|
+
items: RoundSetting.ITEMS,
|
|
63
|
+
hint: "売上金額や消費税の端数処理をどのように行うかを設定します。",
|
|
64
|
+
persistentHint: true,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default class Company extends FireModel {
|
|
71
|
+
static className = "会社";
|
|
72
|
+
static collectionPath = "Companies";
|
|
73
|
+
static useAutonumber = false;
|
|
74
|
+
static logicalDelete = false;
|
|
75
|
+
static classProps = classProps;
|
|
76
|
+
|
|
77
|
+
// Override `afterInitialize` to define computed properties.
|
|
78
|
+
afterInitialize() {
|
|
79
|
+
Object.defineProperties(this, {
|
|
80
|
+
fullAddress: defAccessor("fullAddress"),
|
|
81
|
+
prefecture: defAccessor("prefecture"),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/*************************************************************************
|
|
85
|
+
* CUSTOM METHODS FOR siteOrder ARRAY
|
|
86
|
+
* Note: These methods modify the siteOrder array directly.
|
|
87
|
+
* The Company instance itself is not updated by these methods.
|
|
88
|
+
* Use the provided public methods to interact with siteOrder.
|
|
89
|
+
*************************************************************************/
|
|
90
|
+
Object.defineProperties(this.siteOrder, {
|
|
91
|
+
/**
|
|
92
|
+
* Inserts a new SiteOrder into the `siteOrder` array.
|
|
93
|
+
* @param {Object} params - The parameters for the SiteOrder.
|
|
94
|
+
* @param {string} params.siteId - The ID of the site.
|
|
95
|
+
* @param {string} params.shiftType - The shift type associated with the site.
|
|
96
|
+
* @param {number} [index=-1] - The position to insert the new SiteOrder. Defaults to the end.
|
|
97
|
+
* @returns {SiteOrder} The newly created SiteOrder instance.
|
|
98
|
+
* @throws {Error} If a SiteOrder with the same key already exists.
|
|
99
|
+
*/
|
|
100
|
+
add: {
|
|
101
|
+
value: function ({ siteId, shiftType }, index = -1) {
|
|
102
|
+
const newOrder = new SiteOrder({ siteId, shiftType });
|
|
103
|
+
if (this.some((order) => order.key === newOrder.key)) {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`SiteOrder with key ${newOrder.key} already exists.`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
index === -1 ? this.push(newOrder) : this.splice(index, 0, newOrder);
|
|
109
|
+
return newOrder;
|
|
110
|
+
},
|
|
111
|
+
writable: false,
|
|
112
|
+
enumerable: false,
|
|
113
|
+
configurable: true,
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* Changes the order of a SiteOrder in the siteOrder array.
|
|
117
|
+
* Note: Company instance does not be updated by this method.
|
|
118
|
+
* @param {number} oldIndex - The current index of the SiteOrder.
|
|
119
|
+
* @param {number} newIndex - The new index to move the SiteOrder to.
|
|
120
|
+
* @returns {void}
|
|
121
|
+
* @throws {Error} If oldIndex or newIndex are out of bounds.
|
|
122
|
+
*/
|
|
123
|
+
change: {
|
|
124
|
+
value: function (oldIndex, newIndex) {
|
|
125
|
+
const length = this.length;
|
|
126
|
+
if (oldIndex < 0 || oldIndex >= length) {
|
|
127
|
+
throw new Error("Invalid oldIndex for site order change.");
|
|
128
|
+
}
|
|
129
|
+
if (newIndex < 0 || newIndex >= length) {
|
|
130
|
+
throw new Error("Invalid newIndex for site order change.");
|
|
131
|
+
}
|
|
132
|
+
const [movedOrder] = this.splice(oldIndex, 1);
|
|
133
|
+
this.splice(newIndex, 0, movedOrder);
|
|
134
|
+
},
|
|
135
|
+
writable: false,
|
|
136
|
+
enumerable: false,
|
|
137
|
+
configurable: true,
|
|
138
|
+
},
|
|
139
|
+
/**
|
|
140
|
+
* Removes a SiteOrder from the siteOrder array.
|
|
141
|
+
* Note: Company instance does not be updated by this method.
|
|
142
|
+
* @param {string|Object} arg - The key or {siteId, shiftType} of the SiteOrder to remove.
|
|
143
|
+
* @returns {void}
|
|
144
|
+
* @throws {Error} If the SiteOrder does not exist or if the argument is invalid.
|
|
145
|
+
*/
|
|
146
|
+
remove: {
|
|
147
|
+
value: function (arg) {
|
|
148
|
+
let key = "";
|
|
149
|
+
if (typeof arg === "string") {
|
|
150
|
+
key = arg;
|
|
151
|
+
} else if (typeof arg === "object" && arg.siteId && arg.shiftType) {
|
|
152
|
+
key = `${arg.siteId}-${arg.shiftType}`;
|
|
153
|
+
} else {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"Invalid argument for remove. Must be a string key or an object with siteId and shiftType."
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const index = this.findIndex((order) => order.key === key);
|
|
160
|
+
if (index === -1) {
|
|
161
|
+
throw new Error(`SiteOrder with key ${key} does not exist.`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.splice(index, 1);
|
|
165
|
+
},
|
|
166
|
+
writable: false,
|
|
167
|
+
enumerable: false,
|
|
168
|
+
configurable: true,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/***************************************************************************
|
|
174
|
+
* PUBLIC METHODS
|
|
175
|
+
***************************************************************************/
|
|
176
|
+
}
|
package/src/Customer.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*****************************************************************************
|
|
2
|
+
* Customer ver 1.0.0
|
|
3
|
+
* @author shisyamo4131
|
|
4
|
+
*
|
|
5
|
+
* @description Customer model.
|
|
6
|
+
* @hasMany Sites - related sites associated with the customer
|
|
7
|
+
*
|
|
8
|
+
* @prop {string} code - customer code
|
|
9
|
+
* @prop {string} name - customer name
|
|
10
|
+
* @prop {string} nameKana - customer name in kana
|
|
11
|
+
* @prop {string} zipcode - postal code
|
|
12
|
+
* @prop {string} prefCode - prefecture code
|
|
13
|
+
* @prop {string} city - city name
|
|
14
|
+
* @prop {string} address - address details
|
|
15
|
+
* @prop {string} building - building name
|
|
16
|
+
* @prop {object} location - geographical location
|
|
17
|
+
* @prop {string} tel - telephone number
|
|
18
|
+
* @prop {string} fax - fax number
|
|
19
|
+
* @prop {string} contractStatus - contract status
|
|
20
|
+
* @prop {string} remarks - additional remarks
|
|
21
|
+
*
|
|
22
|
+
* @readonly
|
|
23
|
+
* @prop {string} fullAddress - full address combining prefecture, city, and address (read-only)
|
|
24
|
+
* @prop {string} prefecture - prefecture name derived from `prefCode` (read-only)
|
|
25
|
+
*
|
|
26
|
+
* @static
|
|
27
|
+
* @prop {string} STATUS_ACTIVE - constant for active contract status
|
|
28
|
+
* @prop {string} STATUS_TERMINATED - constant for terminated contract status
|
|
29
|
+
*****************************************************************************/
|
|
30
|
+
import FireModel from "@shisyamo4131/air-firebase-v2";
|
|
31
|
+
import { defField } from "./parts/fieldDefinitions.js";
|
|
32
|
+
import { defAccessor } from "./parts/accessorDefinitions.js";
|
|
33
|
+
import { VALUES } from "./constants/contract-status.js";
|
|
34
|
+
|
|
35
|
+
const classProps = {
|
|
36
|
+
code: defField("code", { label: "取引先コード" }),
|
|
37
|
+
name: defField("name", { label: "取引先名", required: true }),
|
|
38
|
+
nameKana: defField("nameKana", { label: "取引先名(カナ)", required: true }),
|
|
39
|
+
zipcode: defField("zipcode", { required: true }),
|
|
40
|
+
prefCode: defField("prefCode", { required: true }),
|
|
41
|
+
city: defField("city", { required: true }),
|
|
42
|
+
address: defField("address", { required: true }),
|
|
43
|
+
building: defField("building"),
|
|
44
|
+
location: defField("location", { hidden: true }),
|
|
45
|
+
tel: defField("tel", { colsDefinition: { cols: 12, sm: 6 } }),
|
|
46
|
+
fax: defField("fax", { colsDefinition: { cols: 12, sm: 6 } }),
|
|
47
|
+
contractStatus: defField("contractStatus", { required: true }),
|
|
48
|
+
remarks: defField("multipleLine", { label: "備考" }),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default class Customer extends FireModel {
|
|
52
|
+
static className = "取引先";
|
|
53
|
+
static collectionPath = "Customers";
|
|
54
|
+
static useAutonumber = false;
|
|
55
|
+
static logicalDelete = true;
|
|
56
|
+
static classProps = classProps;
|
|
57
|
+
static tokenFields = ["name", "nameKana"];
|
|
58
|
+
static hasMany = [
|
|
59
|
+
{
|
|
60
|
+
collectionPath: "Sites",
|
|
61
|
+
field: "customerId",
|
|
62
|
+
condition: "==",
|
|
63
|
+
type: "collection",
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
static headers = [
|
|
68
|
+
{ key: "code", title: "取引先コード" },
|
|
69
|
+
{ key: "name", title: "取引先名" },
|
|
70
|
+
{ key: "fullAddress", title: "所在地" },
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
static STATUS_ACTIVE = VALUES.ACTIVE.value;
|
|
74
|
+
static STATUS_TERMINATED = VALUES.TERMINATED.value;
|
|
75
|
+
|
|
76
|
+
afterInitialize(item = {}) {
|
|
77
|
+
super.afterInitialize(item);
|
|
78
|
+
Object.defineProperties(this, {
|
|
79
|
+
fullAddress: defAccessor("fullAddress"),
|
|
80
|
+
prefecture: defAccessor("prefecture"),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/*****************************************************************************
|
|
86
|
+
* A minimal version of the Customer model with non-essential fields removed for
|
|
87
|
+
* lightweight data handling.
|
|
88
|
+
*****************************************************************************/
|
|
89
|
+
export class CustomerMinimal extends Customer {
|
|
90
|
+
afterInitialize() {
|
|
91
|
+
super.afterInitialize();
|
|
92
|
+
delete this.remarks;
|
|
93
|
+
delete this.tokenMap;
|
|
94
|
+
delete this.uid;
|
|
95
|
+
delete this.createdAt;
|
|
96
|
+
delete this.updatedAt;
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/Employee.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/Employee.js
|
|
3
|
+
* @author shisyamo4131
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import FireModel from "@shisyamo4131/air-firebase-v2";
|
|
7
|
+
import { defField } from "./parts/fieldDefinitions.js";
|
|
8
|
+
import { defAccessor } from "./parts/accessorDefinitions.js";
|
|
9
|
+
import { VALUES } from "./constants/employment-status.js";
|
|
10
|
+
|
|
11
|
+
const classProps = {
|
|
12
|
+
code: defField("code", { label: "従業員コード" }),
|
|
13
|
+
lastName: defField("lastName", { required: true }),
|
|
14
|
+
firstName: defField("firstName", { required: true }),
|
|
15
|
+
lastNameKana: defField("lastNameKana", { required: true }),
|
|
16
|
+
firstNameKana: defField("firstNameKana", { required: true }),
|
|
17
|
+
displayName: defField("displayName", { required: true }),
|
|
18
|
+
title: defField("oneLine", { label: "肩書", required: true }),
|
|
19
|
+
gender: defField("gender", { required: true }),
|
|
20
|
+
dateOfBirth: defField("dateAt", { label: "生年月日", required: true }),
|
|
21
|
+
zipcode: defField("zipcode", { required: true }),
|
|
22
|
+
prefCode: defField("prefCode", { required: true }),
|
|
23
|
+
city: defField("city", { required: true }),
|
|
24
|
+
address: defField("address", { required: true }),
|
|
25
|
+
building: defField("building"),
|
|
26
|
+
location: defField("location", { hidden: true }), // 非表示でOK
|
|
27
|
+
dateOfHire: defField("dateAt", { label: "入社日", required: true }),
|
|
28
|
+
employmentStatus: defField("employmentStatus", { required: true }),
|
|
29
|
+
dateOfTermination: defField("dateAt", {
|
|
30
|
+
label: "退職日",
|
|
31
|
+
component: {
|
|
32
|
+
attrs: {
|
|
33
|
+
required: (item) => item.employmentStatus === "terminated",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
isForeigner: defField("isForeigner"),
|
|
38
|
+
foreignName: defField("foreignName", {
|
|
39
|
+
component: {
|
|
40
|
+
attrs: {
|
|
41
|
+
required: (item) => item.isForeigner,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
nationality: defField("nationality", {
|
|
46
|
+
component: {
|
|
47
|
+
attrs: {
|
|
48
|
+
required: (item) => item.isForeigner,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
residenceStatus: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: null,
|
|
55
|
+
label: "在留資格",
|
|
56
|
+
required: undefined,
|
|
57
|
+
component: {
|
|
58
|
+
name: "air-text-field",
|
|
59
|
+
attrs: {
|
|
60
|
+
required: (item) => item.isForeigner,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
periodOfStay: defField("dateAt", {
|
|
65
|
+
label: "在留期間満了日",
|
|
66
|
+
component: {
|
|
67
|
+
attrs: {
|
|
68
|
+
required: (item) => item.isForeigner,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
remarks: defField("multipleLine", { label: "備考" }),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/*****************************************************************************
|
|
76
|
+
* Employee Model
|
|
77
|
+
* @props {string} code - Employee code.
|
|
78
|
+
* @props {string} lastName - Last name.
|
|
79
|
+
* @props {string} firstName - First name.
|
|
80
|
+
* @props {string} lastNameKana - Last name in Kana.
|
|
81
|
+
* @props {string} firstNameKana - First name in Kana.
|
|
82
|
+
* @props {string} displayName - Display name.
|
|
83
|
+
* @props {string} title - Job title.
|
|
84
|
+
* @props {string} gender - Gender.
|
|
85
|
+
* @props {Date} dateOfBirth - Date of birth.
|
|
86
|
+
* @props {string} zipcode - Postal code.
|
|
87
|
+
* @props {string} prefCode - Prefecture code.
|
|
88
|
+
* @props {string} city - City name.
|
|
89
|
+
* @props {string} address - Address details.
|
|
90
|
+
* @props {string} building - Building name.
|
|
91
|
+
* @props {object} location - Geographical location.
|
|
92
|
+
* @props {Date} dateOfHire - Date of hire.
|
|
93
|
+
* @props {string} employmentStatus - Employment status.
|
|
94
|
+
* @props {Date} dateOfTermination - Date of termination.
|
|
95
|
+
* @props {boolean} isForeigner - Is the employee a foreigner.
|
|
96
|
+
* @props {string} foreignName - Foreign name.
|
|
97
|
+
* @props {string} nationality - Nationality.
|
|
98
|
+
* @props {string} residenceStatus - Residence status.
|
|
99
|
+
* @props {Date} periodOfStay - Period of stay expiration date.
|
|
100
|
+
* @props {string} remarks - Additional remarks.
|
|
101
|
+
* @computed {string} fullName - Full name combining last and first names (read-only)
|
|
102
|
+
* @computed {string} fullAddress - Full address combining prefecture, city, and address (read-only)
|
|
103
|
+
* @computed {string} prefecture - Prefecture name derived from `prefCode` (read-only)
|
|
104
|
+
*****************************************************************************/
|
|
105
|
+
export default class Employee extends FireModel {
|
|
106
|
+
static className = "従業員";
|
|
107
|
+
static collectionPath = "Employees";
|
|
108
|
+
static useAutonumber = false;
|
|
109
|
+
static logicalDelete = true;
|
|
110
|
+
static classProps = classProps;
|
|
111
|
+
static tokenFields = [
|
|
112
|
+
"lastName",
|
|
113
|
+
"firstName",
|
|
114
|
+
"lastNameKana",
|
|
115
|
+
"firstNameKana",
|
|
116
|
+
"foreignName",
|
|
117
|
+
"displayName",
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
static headers = [
|
|
121
|
+
{ title: "code", key: "code" },
|
|
122
|
+
{ title: "名前", key: "fullName" },
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
static STATUS_ACTIVE = VALUES.ACTIVE.value;
|
|
126
|
+
static STATUS_TERMINATED = VALUES.TERMINATED.value;
|
|
127
|
+
|
|
128
|
+
afterInitialize(item = {}) {
|
|
129
|
+
super.afterInitialize(item);
|
|
130
|
+
Object.defineProperties(this, {
|
|
131
|
+
fullName: defAccessor("fullName"),
|
|
132
|
+
fullAddress: defAccessor("fullAddress"),
|
|
133
|
+
prefecture: defAccessor("prefecture"),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 外国籍の場合の必須フィールドを検証します。
|
|
139
|
+
* エラーがある場合は例外をスローします。
|
|
140
|
+
*/
|
|
141
|
+
_validateForeignerRequiredFields() {
|
|
142
|
+
if (this.isForeigner) {
|
|
143
|
+
if (!this.foreignName) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"[Employee.js] foreignName is required when isForeigner is true."
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (!this.nationality) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
"[Employee.js] nationality is required when isForeigner is true."
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (!this.residenceStatus) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"[Employee.js] residenceStatus is required when isForeigner is true."
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
if (!this.periodOfStay) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
"[Employee.js] periodOfStay is required when isForeigner is true."
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 退職済である場合の必須フィールドを検証します。
|
|
168
|
+
* エラーがある場合は例外をスローします。
|
|
169
|
+
*/
|
|
170
|
+
_validateTerminatedRequiredFields() {
|
|
171
|
+
if (this.employmentStatus === "terminated") {
|
|
172
|
+
if (!this.dateOfTermination) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
"[Employee.js] dateOfTermination is required when employmentStatus is 'terminated'."
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 新しい従業員ドキュメントが作成される前に実行されるフック。
|
|
182
|
+
* - 親クラスの `beforeCreate` を呼び出します。
|
|
183
|
+
* - 従業員が外国人の場合、外国人名と国籍が未入力であればエラーをスローします。
|
|
184
|
+
*/
|
|
185
|
+
async beforeCreate() {
|
|
186
|
+
await super.beforeCreate();
|
|
187
|
+
this._validateForeignerRequiredFields();
|
|
188
|
+
this._validateTerminatedRequiredFields();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 従業員ドキュメントが更新される前に実行されるフック。
|
|
193
|
+
* - 親クラスの `beforeUpdate` を呼び出します。
|
|
194
|
+
* - 従業員が外国人の場合、外国人名と国籍が未入力であればエラーをスローします。
|
|
195
|
+
*/
|
|
196
|
+
async beforeUpdate() {
|
|
197
|
+
await super.beforeUpdate();
|
|
198
|
+
this._validateForeignerRequiredFields();
|
|
199
|
+
this._validateTerminatedRequiredFields();
|
|
200
|
+
}
|
|
201
|
+
}
|