@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.0 → 2.4.2-dev.10
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 +1 -1
- package/src/Agreement.js +18 -17
- package/src/Company.js +16 -6
- package/src/Operation.js +63 -27
- package/src/OperationResult.js +57 -52
- package/src/Site.js +106 -47
- package/src/SiteOperationSchedule.js +56 -35
- package/src/WorkingResult.js +32 -18
- package/src/constants/day-of-week.js +20 -0
- package/src/constants/index.js +10 -0
- package/src/parts/fieldDefinitions.js +15 -0
package/package.json
CHANGED
package/src/Agreement.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* ---------------------------------------------------------------------------
|
|
5
5
|
* A class to manage agreement details based on WorkingResult.
|
|
6
6
|
* ---------------------------------------------------------------------------
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
7
|
+
* @property {number} unitPriceBase - Base unit price (JPY)
|
|
8
|
+
* @property {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
|
|
9
|
+
* @property {number} unitPriceQualified - Qualified unit price (JPY)
|
|
10
|
+
* @property {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
|
|
11
|
+
* @property {string} billingUnitType - Billing unit type
|
|
12
|
+
* @property {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
|
|
13
|
+
* @property {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
|
|
14
14
|
* - The cutoff date for billing, using values defined in the CutoffDate utility class.
|
|
15
15
|
* ---------------------------------------------------------------------------
|
|
16
16
|
* @getter {Object} prices - Object containing price-related properties (read-only)
|
|
@@ -20,21 +20,22 @@
|
|
|
20
20
|
* unitPriceQualified, overtimeUnitPriceQualified, billingUnitType, includeBreakInBilling
|
|
21
21
|
* ---------------------------------------------------------------------------
|
|
22
22
|
* @inherited - The following properties are inherited from WorkingResult:
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
23
|
+
* @property {Date} dateAt - Applicable start date (trigger property)
|
|
24
|
+
* @property {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
|
|
25
|
+
* @property {string} shiftType - Shift type (`DAY`, `NIGHT`)
|
|
26
|
+
* @property {string} startTime - Start time (HH:MM format)
|
|
27
|
+
* @property {boolean} isStartNextDay - Next day start flag
|
|
28
28
|
* - `true` if the actual work starts the day after the placement date `dateAt`
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
29
|
+
* @property {string} endTime - End time (HH:MM format)
|
|
30
|
+
* @property {number} breakMinutes - Break time (minutes)
|
|
31
|
+
* @property {number} regulationWorkMinutes - Regulation work minutes
|
|
32
32
|
* - The maximum working time defined by `unitPriceBase` (or `unitPriceQualified`).
|
|
33
33
|
* - Exceeding this time is considered overtime.
|
|
34
34
|
* ---------------------------------------------------------------------------
|
|
35
35
|
* @inherited - The following computed properties are inherited from WorkingResult:
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
*
|
|
37
|
+
* @property {string} key - {@link WorkingResult#key}
|
|
38
|
+
*
|
|
38
39
|
* @computed {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
|
|
39
40
|
* - Returns a string in the format YYYY-MM-DD based on `dateAt`.
|
|
40
41
|
* @computed {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
|
package/src/Company.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Company Model
|
|
3
3
|
* @version 1.0.0
|
|
4
4
|
* @author shisyamo4131
|
|
5
|
+
* @update 2026-01-06 - Add `firstDayOfWeek` property.
|
|
5
6
|
* @update 2025-12-29 - Add `isCompleteRequiredFields` computed property.
|
|
6
7
|
* @update 2025-12-02 - Add maintenance information properties.
|
|
7
8
|
* @update 2025-12-01 - Add Stripe integration fields (stripeCustomerId, subscription).
|
|
@@ -15,6 +16,7 @@ import Agreement from "./Agreement.js";
|
|
|
15
16
|
import SiteOrder from "./SiteOrder.js";
|
|
16
17
|
import RoundSetting from "./RoundSetting.js";
|
|
17
18
|
import { GeocodableMixin } from "./mixins/GeocodableMixin.js";
|
|
19
|
+
import { DAY_OF_WEEK_OPTIONS, DAY_OF_WEEK_VALUES } from "./constants/index.js";
|
|
18
20
|
|
|
19
21
|
const classProps = {
|
|
20
22
|
companyName: defField("name", { label: "会社名", required: true }),
|
|
@@ -42,12 +44,7 @@ const classProps = {
|
|
|
42
44
|
accountType: defField("select", {
|
|
43
45
|
label: "口座種別",
|
|
44
46
|
default: "普通",
|
|
45
|
-
component: {
|
|
46
|
-
name: "air-select",
|
|
47
|
-
attrs: {
|
|
48
|
-
items: ["普通", "当座"],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
47
|
+
component: { name: "air-select", attrs: { items: ["普通", "当座"] } },
|
|
51
48
|
}),
|
|
52
49
|
accountNumber: defField("oneLine", { label: "口座番号", length: 7 }),
|
|
53
50
|
accountHolder: defField("oneLine", { label: "口座名義", length: 50 }),
|
|
@@ -97,6 +94,19 @@ const classProps = {
|
|
|
97
94
|
},
|
|
98
95
|
}),
|
|
99
96
|
|
|
97
|
+
firstDayOfWeek: defField("select", {
|
|
98
|
+
label: "週の始まり",
|
|
99
|
+
default: DAY_OF_WEEK_VALUES[0].value,
|
|
100
|
+
component: {
|
|
101
|
+
name: "air-select",
|
|
102
|
+
attrs: {
|
|
103
|
+
items: DAY_OF_WEEK_OPTIONS,
|
|
104
|
+
hint: "勤怠管理などで週の始まりとする曜日を設定します。",
|
|
105
|
+
persistentHint: true,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
|
|
100
110
|
/** Stripe連携フィールド */
|
|
101
111
|
stripeCustomerId: defField("oneLine", {
|
|
102
112
|
label: "Stripe顧客ID",
|
package/src/Operation.js
CHANGED
|
@@ -11,51 +11,60 @@
|
|
|
11
11
|
* - `startTime`, `endTime`, and `breakMinutes` are NOT synchronized here.
|
|
12
12
|
* They should be synchronized at `SiteOperationSchedule` level instead.
|
|
13
13
|
* ---------------------------------------------------------------------------
|
|
14
|
-
* @
|
|
14
|
+
* @property {string} siteId
|
|
15
15
|
* - Site document ID (trigger property)
|
|
16
16
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
17
17
|
*
|
|
18
|
-
* @
|
|
18
|
+
* @property {number} requiredPersonnel
|
|
19
19
|
* - Required number of personnel
|
|
20
20
|
*
|
|
21
|
-
* @
|
|
21
|
+
* @property {boolean} qualificationRequired
|
|
22
22
|
* - Qualification required flag
|
|
23
23
|
*
|
|
24
|
-
* @
|
|
24
|
+
* @property {string} workDescription
|
|
25
25
|
* - Work description
|
|
26
26
|
*
|
|
27
|
-
* @
|
|
27
|
+
* @property {string} remarks
|
|
28
28
|
* - Remarks
|
|
29
29
|
*
|
|
30
|
-
* @
|
|
30
|
+
* @property {Array<OperationDetail>} employees
|
|
31
31
|
* - Assigned employees
|
|
32
32
|
* - Array of `OperationDetail` instances representing assigned employees
|
|
33
33
|
*
|
|
34
|
-
* @
|
|
34
|
+
* @property {Array<OperationDetail>} outsourcers
|
|
35
35
|
* - Assigned outsourcers
|
|
36
36
|
* - Array of `OperationDetail` instances representing assigned outsourcers
|
|
37
37
|
*
|
|
38
|
-
* @
|
|
38
|
+
* @property {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
|
|
39
39
|
* - Array of employee IDs from `employees` (read-only)
|
|
40
40
|
*
|
|
41
|
-
* @
|
|
41
|
+
* @property {Array<string>} outsourcerIds
|
|
42
42
|
* - Array of outsourcer IDs from `outsourcers` (read-only)
|
|
43
43
|
*
|
|
44
|
-
* @
|
|
44
|
+
* @property {number} employeesCount
|
|
45
45
|
* - Count of assigned employees (read-only)
|
|
46
46
|
*
|
|
47
|
-
* @
|
|
47
|
+
* @property {number} outsourcersCount
|
|
48
48
|
* - Count of assigned outsourcers (sum of amounts) (read-only)
|
|
49
49
|
*
|
|
50
|
-
* @
|
|
50
|
+
* @property {boolean} isPersonnelShortage
|
|
51
51
|
* - Indicates if there is a shortage of personnel (read-only)
|
|
52
52
|
* - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
|
|
53
53
|
*
|
|
54
|
-
* @
|
|
54
|
+
* @property {Array<OperationDetail>} workers
|
|
55
55
|
* - Combined array of `employees` and `outsourcers`
|
|
56
56
|
* - Getter: Returns concatenated array of employees and outsourcers
|
|
57
57
|
* - Setter: Splits array into employees and outsourcers based on `isEmployee` property
|
|
58
58
|
*
|
|
59
|
+
* @property {string} key - `siteId`, `date`, `dayType`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
60
|
+
* - `WorkingResult.key` をオーバーライドして `siteId` を含めるように定義されているが、未使用。
|
|
61
|
+
*
|
|
62
|
+
* @property {string} agreementKey - `siteId`, `date`, `dayType`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
63
|
+
* - 適用する取極めを特定するためのキーとして使用される。
|
|
64
|
+
*
|
|
65
|
+
* @property {string} orderKey - `siteId`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
66
|
+
* - `siteOrder` の `key` プロパティに対応するキー。稼働予測や配置管理で使用される。
|
|
67
|
+
*
|
|
59
68
|
* @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
|
|
60
69
|
* @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
|
|
61
70
|
* - Returns true if the employee IDs have changed compared to `_beforeData`
|
|
@@ -69,19 +78,18 @@
|
|
|
69
78
|
* - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
|
|
70
79
|
* ---------------------------------------------------------------------------
|
|
71
80
|
* @inherited - The following properties are inherited from WorkingResult:
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @prop {Date} dateAt - Date of operation (placement date) (trigger property)
|
|
81
|
+
*
|
|
82
|
+
* @property {Date} dateAt - Date of operation (placement date) (trigger property)
|
|
75
83
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
76
|
-
* @
|
|
77
|
-
* @
|
|
84
|
+
* @property {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
|
|
85
|
+
* @property {string} shiftType - `DAY` or `NIGHT` (trigger property)
|
|
78
86
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
79
|
-
* @
|
|
80
|
-
* @
|
|
87
|
+
* @property {string} startTime - Start time (HH:MM format)
|
|
88
|
+
* @property {boolean} isStartNextDay - Next day start flag
|
|
81
89
|
* - `true` if the actual work starts the day after the placement date `dateAt`
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
90
|
+
* @property {string} endTime - End time (HH:MM format)
|
|
91
|
+
* @property {number} breakMinutes - Break time (minutes)
|
|
92
|
+
* @property {number} regulationWorkMinutes - Regulation work minutes (trigger property)
|
|
85
93
|
* - Indicates the maximum working time treated as regular working hours.
|
|
86
94
|
* - A new value will be synchronized to all `employees` and `outsourcers`.
|
|
87
95
|
* ---------------------------------------------------------------------------
|
|
@@ -261,11 +269,13 @@ export default class Operation extends WorkingResult {
|
|
|
261
269
|
afterInitialize(item = {}) {
|
|
262
270
|
super.afterInitialize(item);
|
|
263
271
|
|
|
264
|
-
/**
|
|
265
|
-
* Override `key` computed property
|
|
266
|
-
* - `key`: Combines `siteId`, `date`, `dayType`, and `shiftType`.
|
|
267
|
-
*/
|
|
268
272
|
Object.defineProperties(this, {
|
|
273
|
+
/**
|
|
274
|
+
* `siteId`, `date`, `dayType`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
275
|
+
* - `WorkingResult.key` をオーバーライド。
|
|
276
|
+
* - 2026-01-07 現在使用していないプロパティ。
|
|
277
|
+
* - `dayType` は請求時の単価情報を取得するために必要な情報であるため含める必要がないと思われる。
|
|
278
|
+
*/
|
|
269
279
|
key: {
|
|
270
280
|
configurable: true,
|
|
271
281
|
enumberable: true,
|
|
@@ -274,6 +284,32 @@ export default class Operation extends WorkingResult {
|
|
|
274
284
|
},
|
|
275
285
|
set() {},
|
|
276
286
|
},
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* `siteId`, `date`, `dayType`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
290
|
+
* - 適用する取極めを特定するためのキーとして使用される。
|
|
291
|
+
*/
|
|
292
|
+
agreementKey: {
|
|
293
|
+
configurable: true,
|
|
294
|
+
enumberable: true,
|
|
295
|
+
get() {
|
|
296
|
+
return `${this.siteId}-${this.date}-${this.dayType}-${this.shiftType}`;
|
|
297
|
+
},
|
|
298
|
+
set() {},
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* `siteId`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
303
|
+
* - `siteOrder` の `key` プロパティに対応するキー。
|
|
304
|
+
*/
|
|
305
|
+
orderKey: {
|
|
306
|
+
configurable: true,
|
|
307
|
+
enumberable: true,
|
|
308
|
+
get() {
|
|
309
|
+
return `${this.siteId}-${this.shiftType}`;
|
|
310
|
+
},
|
|
311
|
+
set() {},
|
|
312
|
+
},
|
|
277
313
|
});
|
|
278
314
|
|
|
279
315
|
/***********************************************************
|
package/src/OperationResult.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/*****************************************************************************
|
|
2
2
|
* OperationResult Model
|
|
3
|
-
* @version 1.2.0 - 2025-11-19 Add `agreement`, `hasAgreement`, `isValid` properties.
|
|
4
3
|
* @author shisyamo4131
|
|
5
4
|
*
|
|
6
5
|
* - Extends Operation class to represent the result of an operation.
|
|
@@ -10,107 +9,110 @@
|
|
|
10
9
|
* - Automatically updates `billingDateAt` based on `dateAt` and `cutoffDate`.
|
|
11
10
|
* - Introduces a lock mechanism (`isLocked`) to prevent edits when necessary.
|
|
12
11
|
*
|
|
13
|
-
* @
|
|
14
|
-
* - A unique identifier for the working result, combining `siteId`, `date`, `dayType`, and `shiftType`.
|
|
12
|
+
* @property { string } key - {@link Operation#key}
|
|
15
13
|
*
|
|
16
|
-
* @
|
|
14
|
+
* @property {string} agreementKey - {@link Operation#agreementKey}
|
|
15
|
+
*
|
|
16
|
+
* @property {string} orderKey - {@link Operation#orderKey}
|
|
17
|
+
*
|
|
18
|
+
* @property {string} siteId - Site document ID (trigger property)
|
|
17
19
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
18
20
|
*
|
|
19
|
-
* @
|
|
21
|
+
* @property {Date} dateAt - Date of operation (placement date) (trigger property)
|
|
20
22
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
21
23
|
* - Used to determine `dayType`.
|
|
22
24
|
* - When `dateAt` changes, `billingDateAt` is also updated based on `agreement.cutoffDate`.
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
+
* @property {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
|
|
26
|
+
* @property {string} shiftType - `DAY` or `NIGHT` (trigger property)
|
|
25
27
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
28
|
+
* @property {string} startTime - Start time (HH:MM format)
|
|
29
|
+
* @property {boolean} isStartNextDay - Next day start flag
|
|
28
30
|
* - `true` if the actual work starts the day after the placement date `dateAt`
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
31
|
+
* @property {string} endTime - End time (HH:MM format)
|
|
32
|
+
* @property {number} breakMinutes - Break time (minutes)
|
|
33
|
+
* @property {number} regulationWorkMinutes - Regulation work minutes (trigger property)
|
|
32
34
|
* - Indicates the maximum working time treated as regular working hours.
|
|
33
35
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
36
|
-
* @
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
36
|
+
* @property {number} requiredPersonnel - Required number of personnel
|
|
37
|
+
* @property {boolean} qualificationRequired - Qualification required flag
|
|
38
|
+
* @property {string} workDescription - Work description
|
|
39
|
+
* @property {string} remarks - Remarks
|
|
40
|
+
* @property {Array<OperationResultDetail>} employees - Assigned employees
|
|
39
41
|
* - Array of `OperationResultDetail` instances representing assigned employees
|
|
40
|
-
* @
|
|
42
|
+
* @property {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
|
|
41
43
|
* - Array of `OperationResultDetail` instances representing assigned outsourcers
|
|
42
|
-
* @
|
|
44
|
+
* @property {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers`
|
|
43
45
|
* - Getter: Returns concatenated array of employees and outsourcers
|
|
44
46
|
* - Setter: Splits array into employees and outsourcers based on `isEmployee` property
|
|
45
|
-
* @
|
|
47
|
+
* @property {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
|
|
46
48
|
* - If this OperationResult was created from a SiteOperationSchedule, this property holds that ID.
|
|
47
|
-
* @
|
|
48
|
-
* @
|
|
49
|
+
* @property {boolean} useAdjustedQuantity - Flag to indicate if adjusted quantities are used for billing
|
|
50
|
+
* @property {number} adjustedQuantityBase - Adjusted quantity for base workers
|
|
49
51
|
* - Quantity used for billing base workers when `useAdjustedQuantity` is true.
|
|
50
|
-
* @
|
|
52
|
+
* @property {number} adjustedOvertimeBase - Adjusted overtime for base workers
|
|
51
53
|
* - Overtime used for billing base workers when `useAdjustedQuantity` is true.
|
|
52
|
-
* @
|
|
54
|
+
* @property {number} adjustedQuantityQualified - Adjusted quantity for qualified workers
|
|
53
55
|
* - Quantity used for billing qualified workers when `useAdjustedQuantity` is true.
|
|
54
|
-
* @
|
|
56
|
+
* @property {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
|
|
55
57
|
* - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
|
|
56
|
-
* @
|
|
58
|
+
* @property {Date} billingDateAt - Billing date
|
|
57
59
|
* - The date used for billing purposes.
|
|
58
|
-
* @
|
|
60
|
+
* @property {boolean} isLocked - Lock flag
|
|
59
61
|
* - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
|
|
60
|
-
* @
|
|
62
|
+
* @property {Agreement|null} agreement - Associated Agreement object
|
|
61
63
|
* - The Agreement instance associated with this OperationResult for pricing and billing information.
|
|
62
64
|
* - When set, it influences billing calculations such as unit prices and billing dates.
|
|
63
|
-
* @
|
|
65
|
+
* @property {boolean} allowEmptyAgreement - Flag to ignore missing Agreement
|
|
64
66
|
* - When set to true, allows the OperationResult to be valid even if no Agreement is associated.
|
|
65
67
|
* @readonly
|
|
66
|
-
* @
|
|
68
|
+
* @property {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
|
|
67
69
|
* - Returns a string in the format YYYY-MM-DD based on `dateAt`.
|
|
68
|
-
* @
|
|
70
|
+
* @property {Date} startAt - Start date and time (Date object) (read-only)
|
|
69
71
|
* - Returns a Date object with `startTime` set based on `dateAt`.
|
|
70
72
|
* - If `isStartNextDay` is true, add 1 day.
|
|
71
|
-
* @
|
|
73
|
+
* @property {Date} endAt - End date and time (Date object) (read-only)
|
|
72
74
|
* - Returns a Date object with `endTime` set based on `dateAt`.
|
|
73
75
|
* - If `isStartNextDay` is true, add 1 day.
|
|
74
76
|
* - If `isSpansNextDay` is true, add 1 day.
|
|
75
|
-
* @
|
|
77
|
+
* @property {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
|
|
76
78
|
* - `true` if `startTime` is later than `endTime`
|
|
77
|
-
* @
|
|
79
|
+
* @property {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
|
|
78
80
|
* - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
|
|
79
|
-
* @
|
|
81
|
+
* @property {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
|
|
80
82
|
* - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
|
|
81
|
-
* @
|
|
83
|
+
* @property {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
|
|
82
84
|
* - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
|
|
83
|
-
* @
|
|
85
|
+
* @property {boolean} hasAgreement - Indicates if an Agreement is associated (read-only)
|
|
84
86
|
* - `true` if `agreement` is set, otherwise `false`.
|
|
85
|
-
* @
|
|
87
|
+
* @property {string|false} isInvalid - Validation status (read-only)
|
|
86
88
|
* - Returns false if valid.
|
|
87
89
|
* - Returns reason code string if invalid:
|
|
88
90
|
* - `EMPTY_BILLING_DATE`: Billing date is missing.
|
|
89
91
|
* - `EMPTY_AGREEMENT`: Agreement is missing and `allowEmptyAgreement` is false.
|
|
90
|
-
* @
|
|
92
|
+
* @property {Object} statistics - Statistics of workers (read-only)
|
|
91
93
|
* - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
|
|
92
94
|
* - Structure: { base: {...}, qualified: {...}, total: {...} }
|
|
93
95
|
* - Each category contains: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
|
|
94
96
|
* - Each category also has an 'ojt' subcategory with the same structure.
|
|
95
|
-
* @
|
|
97
|
+
* @property {Object} sales - Sales amounts (read-only)
|
|
96
98
|
* - Contains sales calculations for base and qualified workers, including overtime breakdowns.
|
|
97
99
|
* - Structure: { base: {...}, qualified: {...} }
|
|
98
100
|
* - Each category contains: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
|
|
99
101
|
* - Calculations respect `useAdjustedQuantity`, `billingUnitType`, and `includeBreakInBilling` settings.
|
|
100
|
-
* @
|
|
102
|
+
* @property {number} salesAmount - Total sales amount (read-only)
|
|
101
103
|
* - Sum of sales amounts for base and qualified workers with rounding applied.
|
|
102
|
-
* @
|
|
104
|
+
* @property {number} tax - Calculated tax amount (read-only)
|
|
103
105
|
* - Calculated using the `Tax` utility based on `salesAmount` and `date`.
|
|
104
|
-
* @
|
|
106
|
+
* @property {number} billingAmount - Total billing amount including tax (read-only)
|
|
105
107
|
* - Sum of `salesAmount` and `tax`.
|
|
106
|
-
* @
|
|
108
|
+
* @property {string|null} billingDate - Billing date in YYYY-MM-DD format (read-only)
|
|
107
109
|
* - Returns a string in the format YYYY-MM-DD based on `billingDateAt`.
|
|
108
|
-
* @
|
|
109
|
-
* @
|
|
110
|
-
* @
|
|
111
|
-
* @
|
|
112
|
-
* @
|
|
113
|
-
* @
|
|
110
|
+
* @property {string} billingMonth - Billing month in YYYY-MM format (read-only)
|
|
111
|
+
* @property {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
|
|
112
|
+
* @property {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
|
|
113
|
+
* @property {number} employeesCount - Count of assigned employees (read-only)
|
|
114
|
+
* @property {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
|
|
115
|
+
* @property {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
|
|
114
116
|
* - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
|
|
115
117
|
*
|
|
116
118
|
* @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
|
|
@@ -543,7 +545,6 @@ export default class OperationResult extends Operation {
|
|
|
543
545
|
/**
|
|
544
546
|
* Synchronize customerId and apply (re-apply) agreement from siteId
|
|
545
547
|
* @param {Object} [args.transaction] - Firestore transaction.
|
|
546
|
-
* @param {Function} [args.callBack] - Callback function.
|
|
547
548
|
* @param {string} [args.prefix] - Path prefix.
|
|
548
549
|
* @returns {Promise<void>}
|
|
549
550
|
* @throws {Error} If the specified siteId does not exist
|
|
@@ -600,7 +601,11 @@ export default class OperationResult extends Operation {
|
|
|
600
601
|
}
|
|
601
602
|
|
|
602
603
|
// Sync customerId and apply agreement if key changed
|
|
603
|
-
|
|
604
|
+
/**
|
|
605
|
+
* 2026-01-08 `agreementKey` を実装したため、`key` の使用を避ける。
|
|
606
|
+
*/
|
|
607
|
+
// if (this.key === this._beforeData.key) return;
|
|
608
|
+
if (this.agreementKey === this._beforeData.agreementKey) return;
|
|
604
609
|
await this._syncCustomerIdAndApplyAgreement();
|
|
605
610
|
}
|
|
606
611
|
|
package/src/Site.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file src/Site.js
|
|
3
3
|
* @author shisyamo4131
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
13
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* NOTE: `customerId`, `customer` プロパティについて
|
|
6
|
+
* - 仮登録
|
|
7
|
+
* - 取引先未定での現場登録のシチュエーションを考慮して現場情報は仮登録を可能とする。
|
|
8
|
+
* - 仮登録状態の現場は `isTemporary` プロパティが `true` となる。
|
|
9
|
+
* - 但し、一度取引先を設定した後に未設定に戻すことはできない。
|
|
10
|
+
* - 取引先未設定の場合に、`Site` インスタンスから取引先名を参照する必要があるケースに備えて
|
|
11
|
+
* `customerName` プロパティを設ける。
|
|
12
|
+
* - 自身の従属先データを持たせる場合に `XxxxxMinimal` クラスを使用するが、アプリ側でオブジェクト選択を行う場合に
|
|
13
|
+
* `Xxxxx` クラスにするのか `XxxxxMinimal` クラスにするのかを判断できないため、docId を持たせて
|
|
14
|
+
* `beforeCreate` フックでオブジェクトを取得するようにする。
|
|
14
15
|
*/
|
|
15
16
|
import { default as FireModel } from "@shisyamo4131/air-firebase-v2";
|
|
16
17
|
import { defField } from "./parts/fieldDefinitions.js";
|
|
@@ -22,16 +23,24 @@ import { GeocodableMixin } from "./mixins/GeocodableMixin.js";
|
|
|
22
23
|
|
|
23
24
|
const classProps = {
|
|
24
25
|
customerId: defField("customerId", {
|
|
25
|
-
required: true,
|
|
26
26
|
component: {
|
|
27
27
|
attrs: {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/** `_beforeData.customerId` が存在する場合(本登録後の編集時を表す)には `customerId` を必須とする。 */
|
|
29
|
+
required: ({ item }) => {
|
|
30
|
+
return !!item._beforeData.customerId;
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
33
|
},
|
|
33
34
|
}),
|
|
34
35
|
customer: defField("customer", { hidden: true, customClass: Customer }),
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 取引先名
|
|
39
|
+
* - `customerId` が未設定の場合に必須(仮登録状態で取引先の名前だけ登録したい場合を想定)
|
|
40
|
+
*/
|
|
41
|
+
customerName: defField("customerName", {
|
|
42
|
+
required: ({ item }) => !item.customerId,
|
|
43
|
+
}),
|
|
35
44
|
code: defField("code", { label: "現場コード" }),
|
|
36
45
|
name: defField("name", {
|
|
37
46
|
label: "現場名",
|
|
@@ -55,24 +64,40 @@ const classProps = {
|
|
|
55
64
|
};
|
|
56
65
|
|
|
57
66
|
/*****************************************************************************
|
|
58
|
-
* @
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
67
|
+
* @property {string} customerId - 取引先ドキュメントID
|
|
68
|
+
*
|
|
69
|
+
* @property {object} customer - 取引先オブジェクト
|
|
70
|
+
* - `beforeCreate`, `beforeUpdate` で `customerId` に該当する `Customer` オブジェクトと自動的に同期されます。
|
|
71
|
+
* - `Customer` が更新された場合は Cloud Functions で同期される必要があります。
|
|
72
|
+
*
|
|
73
|
+
* @property {string} customerName - 取引先名
|
|
74
|
+
* - `customerId` が未設定の場合に必須(仮登録状態で取引先の名前だけ登録したい場合を想定)
|
|
75
|
+
*
|
|
76
|
+
* @property {string} code - 現場コード
|
|
77
|
+
*
|
|
78
|
+
* @property {string} name - 現場名
|
|
79
|
+
*
|
|
80
|
+
* @property {string} nameKana - 現場名カナ
|
|
81
|
+
*
|
|
82
|
+
* @property {string} zipcode - Postal code.
|
|
83
|
+
* @property {string} prefCode - Prefecture code.
|
|
84
|
+
*
|
|
85
|
+
* @property {string} prefecture - Prefecture name derived from `prefCode` (read-only)
|
|
86
|
+
*
|
|
87
|
+
* @property {string} city - City name.
|
|
88
|
+
* @property {string} address - Address details.
|
|
89
|
+
* @property {string} building - Building name.
|
|
90
|
+
*
|
|
91
|
+
* @property {string} fullAddress - Full address combining prefecture, city, and address (read-only)
|
|
92
|
+
*
|
|
93
|
+
* @property {object} location - Geographical location.
|
|
94
|
+
* @property {string} remarks - Additional remarks.
|
|
95
|
+
* @property {array} agreements - List of agreements (Agreement).
|
|
70
96
|
* - Enhanced with custom methods: `add()`, `change()`, `remove()`
|
|
71
|
-
* @props {string} status - Site status.
|
|
72
97
|
*
|
|
73
|
-
* @
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
98
|
+
* @property {string} status - Site status.
|
|
99
|
+
*
|
|
100
|
+
* @property {boolean} isTemporary - 仮登録状態かどうかを表すフラグ
|
|
76
101
|
*
|
|
77
102
|
* @function getAgreement
|
|
78
103
|
* Gets applicable agreement based on date, dayType, and shiftType.
|
|
@@ -127,31 +152,39 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
127
152
|
static STATUS_TERMINATED = VALUES.TERMINATED.value;
|
|
128
153
|
|
|
129
154
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @param {string} [args.docId] - Document ID to use (optional).
|
|
133
|
-
* @param {boolean} [args.useAutonumber=true] - Whether to use auto-numbering.
|
|
134
|
-
* @param {Object} [args.transaction] - Firestore transaction.
|
|
135
|
-
* @param {Function} [args.callBack] - Callback function.
|
|
136
|
-
* @param {string} [args.prefix] - Path prefix.
|
|
155
|
+
* `customerId` に該当する `Customer` インスタンスを取得して `customer` プロパティにセットします。
|
|
156
|
+
* - `customerId` が未設定の場合は何もしません。
|
|
137
157
|
* @returns {Promise<void>}
|
|
158
|
+
* @throws {Error} `Customer` が存在しない場合にスローされます。
|
|
138
159
|
*/
|
|
139
|
-
async
|
|
140
|
-
await super.beforeCreate(args);
|
|
160
|
+
async _setCustomer() {
|
|
141
161
|
if (!this.customerId) return;
|
|
142
162
|
const customerInstance = new Customer();
|
|
143
163
|
const isExist = await customerInstance.fetch({
|
|
144
|
-
...args,
|
|
145
164
|
docId: this.customerId,
|
|
146
165
|
});
|
|
147
166
|
if (!isExist) {
|
|
148
|
-
|
|
149
|
-
new Error("Invalid customerId: Customer does not exist.")
|
|
150
|
-
);
|
|
167
|
+
throw new Error("Customer does not exist.");
|
|
151
168
|
}
|
|
152
169
|
this.customer = customerInstance;
|
|
153
170
|
}
|
|
154
171
|
|
|
172
|
+
/**
|
|
173
|
+
* ドキュメント作成直前の処理です。
|
|
174
|
+
* - `customerId` に該当する `Customer` インスタンスを取得して `customer` プロパティにセットします。
|
|
175
|
+
* @param {Object} args - Creation options.
|
|
176
|
+
* @param {string} [args.docId] - Document ID to use (optional).
|
|
177
|
+
* @param {boolean} [args.useAutonumber=true] - Whether to use auto-numbering.
|
|
178
|
+
* @param {Object} [args.transaction] - Firestore transaction.
|
|
179
|
+
* @param {Function} [args.callBack] - Callback function.
|
|
180
|
+
* @param {string} [args.prefix] - Path prefix.
|
|
181
|
+
* @returns {Promise<void>}
|
|
182
|
+
*/
|
|
183
|
+
async beforeCreate(args = {}) {
|
|
184
|
+
await super.beforeCreate(args);
|
|
185
|
+
await this._setCustomer();
|
|
186
|
+
}
|
|
187
|
+
|
|
155
188
|
/**
|
|
156
189
|
* Override beforeUpdate to prevent changing customer reference.
|
|
157
190
|
* @param {Object} args - Creation options.
|
|
@@ -162,22 +195,48 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
162
195
|
*/
|
|
163
196
|
async beforeUpdate(args = {}) {
|
|
164
197
|
await super.beforeUpdate(args);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
);
|
|
198
|
+
|
|
199
|
+
// 一度設定した取引先を未設定に戻すことはできない。
|
|
200
|
+
if (this._beforeData.customerId && !this.customerId) {
|
|
201
|
+
throw new Error("Cannot unset customerId once it is set.");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 取引先が変更されていた場合は `customer` プロパティを更新する。
|
|
205
|
+
if (this.customerId !== this._beforeData.customerId) {
|
|
206
|
+
await this._setCustomer();
|
|
169
207
|
}
|
|
170
208
|
}
|
|
171
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Override `afterInitialize` to define custom accessors and methods.
|
|
212
|
+
* - Defines `fullAddress`, `prefecture`, and `isTemporary` accessors.
|
|
213
|
+
* - Enhances `agreements` array with `add`, `change`, and `remove` methods.
|
|
214
|
+
* @param {Object} item - Initial data item.
|
|
215
|
+
* @return {void}
|
|
216
|
+
*/
|
|
172
217
|
afterInitialize(item = {}) {
|
|
173
218
|
super.afterInitialize(item);
|
|
174
219
|
|
|
220
|
+
/** Define `fullAddress`, `prefecture`, and `isTemporary` accessors. */
|
|
175
221
|
Object.defineProperties(this, {
|
|
176
|
-
// customerId: defAccessor("customerId"),
|
|
177
222
|
fullAddress: defAccessor("fullAddress"),
|
|
178
223
|
prefecture: defAccessor("prefecture"),
|
|
224
|
+
isTemporary: {
|
|
225
|
+
configurable: true,
|
|
226
|
+
enumerable: true,
|
|
227
|
+
get() {
|
|
228
|
+
return !this.customerId;
|
|
229
|
+
},
|
|
230
|
+
set() {},
|
|
231
|
+
},
|
|
179
232
|
});
|
|
180
233
|
|
|
234
|
+
/**
|
|
235
|
+
* `Agreement` プロパティに対するカスタムメソッドを定義します。
|
|
236
|
+
* - add(agreement): `Agreement` インスタンスを追加します。
|
|
237
|
+
* - change(newAgreement): `key` プロパティを基に既存の `Agreement` を置き換えます。
|
|
238
|
+
* - remove(agreement): `key` プロパティを基に `Agreement` を削除します。
|
|
239
|
+
*/
|
|
181
240
|
const self = this;
|
|
182
241
|
Object.defineProperties(this.agreements, {
|
|
183
242
|
add: {
|
|
@@ -18,16 +18,19 @@
|
|
|
18
18
|
* `siteId`, `dateAt`, `shiftType`, and `regulationWorkMinutes` are synchronized
|
|
19
19
|
* in the parent `Operation` class.
|
|
20
20
|
*
|
|
21
|
-
* @
|
|
22
|
-
* - A unique identifier for the working result, combining `siteId`, `date`, `dayType`, and `shiftType`.
|
|
21
|
+
* @property { string } key - {@link Operation#key}
|
|
23
22
|
*
|
|
24
|
-
* @
|
|
23
|
+
* @property {string} agreementKey - {@link Operation#agreementKey}
|
|
24
|
+
*
|
|
25
|
+
* @property {string} orderKey - {@link Operation#orderKey}
|
|
26
|
+
*
|
|
27
|
+
* @property {string|null} operationResultId - Associated OperationResult document ID
|
|
25
28
|
* - If an OperationResult has been created based on this schedule, this property
|
|
26
29
|
* holds the ID of that OperationResult document.
|
|
27
30
|
* - If this property is set, the schedule cannot be updated or deleted.
|
|
28
31
|
* Conversely, if the associated OperationResult is deleted, this property can be set to null.
|
|
29
32
|
*
|
|
30
|
-
* @
|
|
33
|
+
* @property {number} displayOrder - Display order
|
|
31
34
|
* - Property to control the display order of schedules on the same date and shift type.
|
|
32
35
|
* - Automatically assigned during creation based on existing documents.
|
|
33
36
|
*
|
|
@@ -38,88 +41,88 @@
|
|
|
38
41
|
* - Returns `true` if all workers in the `workers` array have `hasNotification` set to `true`
|
|
39
42
|
*
|
|
40
43
|
* @inherited - The following properties are inherited from Operation:
|
|
41
|
-
* @
|
|
44
|
+
* @property {string} siteId - Site document ID (trigger property)
|
|
42
45
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
43
46
|
*
|
|
44
|
-
* @
|
|
47
|
+
* @property {number} requiredPersonnel - Required number of personnel
|
|
45
48
|
*
|
|
46
|
-
* @
|
|
49
|
+
* @property {boolean} qualificationRequired - Qualification required flag
|
|
47
50
|
*
|
|
48
|
-
* @
|
|
51
|
+
* @property {string} workDescription - Work description
|
|
49
52
|
*
|
|
50
|
-
* @
|
|
53
|
+
* @property {string} remarks - Remarks
|
|
51
54
|
*
|
|
52
|
-
* @
|
|
55
|
+
* @property {Array<SiteOperationScheduleDetail>} employees - Assigned employees
|
|
53
56
|
* - Array of `SiteOperationScheduleDetail` instances representing assigned employees
|
|
54
57
|
*
|
|
55
|
-
* @
|
|
58
|
+
* @property {Array<SiteOperationScheduleDetail>} outsourcers - Assigned outsourcers
|
|
56
59
|
* - Array of `SiteOperationScheduleDetail` instances representing assigned outsourcers
|
|
57
60
|
*
|
|
58
61
|
* @inherited - The following properties are inherited from WorkingResult (via Operation):
|
|
59
|
-
* @
|
|
62
|
+
* @property {Date} dateAt - Date of operation (placement date) (trigger property)
|
|
60
63
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
61
64
|
*
|
|
62
|
-
* @
|
|
65
|
+
* @property {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
|
|
63
66
|
*
|
|
64
|
-
* @
|
|
67
|
+
* @property {string} shiftType - `DAY` or `NIGHT` (trigger property)
|
|
65
68
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
66
69
|
*
|
|
67
|
-
* @
|
|
70
|
+
* @property {string} startTime - Start time (HH:MM format) (trigger property)
|
|
68
71
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
69
72
|
*
|
|
70
|
-
* @
|
|
73
|
+
* @property {boolean} isStartNextDay - Next day start flag (trigger property)
|
|
71
74
|
* - `true` if the actual work starts the day after the placement date `dateAt`
|
|
72
75
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
73
76
|
*
|
|
74
|
-
* @
|
|
77
|
+
* @property {string} endTime - End time (HH:MM format) (trigger property)
|
|
75
78
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
76
79
|
*
|
|
77
|
-
* @
|
|
80
|
+
* @property {number} breakMinutes - Break time (minutes) (trigger property)
|
|
78
81
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
79
82
|
*
|
|
80
|
-
* @
|
|
83
|
+
* @property {number} regulationWorkMinutes - Regulation work minutes (trigger property)
|
|
81
84
|
* - Indicates the maximum working time treated as regular working hours.
|
|
82
85
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
83
86
|
*
|
|
84
87
|
* @inherited - The following computed properties are inherited from Operation:
|
|
85
|
-
* @
|
|
88
|
+
* @property {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
|
|
86
89
|
*
|
|
87
|
-
* @
|
|
90
|
+
* @property {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
|
|
88
91
|
*
|
|
89
|
-
* @
|
|
92
|
+
* @property {number} employeesCount - Count of assigned employees (read-only)
|
|
90
93
|
*
|
|
91
|
-
* @
|
|
94
|
+
* @property {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
|
|
92
95
|
*
|
|
93
|
-
* @
|
|
96
|
+
* @property {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
|
|
94
97
|
* - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
|
|
95
98
|
*
|
|
96
|
-
* @
|
|
99
|
+
* @property {Array<SiteOperationScheduleDetail>} workers - Combined array of `employees` and `outsourcers`
|
|
97
100
|
* - Getter: Returns concatenated array of employees and outsourcers
|
|
98
101
|
* - Setter: Splits array into employees and outsourcers based on `isEmployee` property
|
|
99
102
|
*
|
|
100
103
|
* @inherited - The following computed properties are inherited from WorkingResult (via Operation):
|
|
101
|
-
* @
|
|
104
|
+
* @property {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
|
|
102
105
|
* - Returns a string in the format YYYY-MM-DD based on `dateAt`.
|
|
103
106
|
*
|
|
104
|
-
* @
|
|
107
|
+
* @property {Date} startAt - Start date and time (Date object) (read-only)
|
|
105
108
|
* - Returns a Date object with `startTime` set based on `dateAt`.
|
|
106
109
|
* - If `isStartNextDay` is true, add 1 day.
|
|
107
110
|
*
|
|
108
|
-
* @
|
|
111
|
+
* @property {Date} endAt - End date and time (Date object) (read-only)
|
|
109
112
|
* - Returns a Date object with `endTime` set based on `dateAt`.
|
|
110
113
|
* - If `isStartNextDay` is true, add 1 day.
|
|
111
114
|
* - If `isSpansNextDay` is true, add 1 day.
|
|
112
115
|
*
|
|
113
|
-
* @
|
|
116
|
+
* @property {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
|
|
114
117
|
* - `true` if `startTime` is later than `endTime`
|
|
115
118
|
*
|
|
116
|
-
* @
|
|
119
|
+
* @property {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
|
|
117
120
|
* - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
|
|
118
121
|
*
|
|
119
|
-
* @
|
|
122
|
+
* @property {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
|
|
120
123
|
* - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
|
|
121
124
|
*
|
|
122
|
-
* @
|
|
125
|
+
* @property {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
|
|
123
126
|
* - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
|
|
124
127
|
*
|
|
125
128
|
* @inherited - The following getter properties are inherited from Operation:
|
|
@@ -218,6 +221,7 @@ import { ContextualError } from "./utils/index.js";
|
|
|
218
221
|
import ArrangementNotification from "./ArrangementNotification.js";
|
|
219
222
|
import SiteOperationScheduleDetail from "./SiteOperationScheduleDetail.js";
|
|
220
223
|
import OperationResult from "./OperationResult.js";
|
|
224
|
+
import Site from "./Site.js";
|
|
221
225
|
|
|
222
226
|
const classProps = {
|
|
223
227
|
...Operation.classProps,
|
|
@@ -709,15 +713,29 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
709
713
|
* @update 2025-11-28 - Removed the `agreement` parameter.
|
|
710
714
|
*/
|
|
711
715
|
async syncToOperationResult(notifications = {}) {
|
|
716
|
+
// ドキュメントIDがない(現場稼働予定ドキュメントとして未作成)場合はエラー
|
|
712
717
|
if (!this.docId) {
|
|
713
718
|
throw new Error(
|
|
714
719
|
"不正な処理です。作成前の現場稼働予定から稼働実績を作成することはできません。"
|
|
715
720
|
);
|
|
716
721
|
}
|
|
717
722
|
|
|
718
|
-
|
|
719
|
-
|
|
723
|
+
// 現場データの存在確認と登録状態の確認
|
|
724
|
+
// - 存在しない、または仮登録状態の場合はエラー
|
|
725
|
+
const siteInstance = new Site();
|
|
726
|
+
const siteIsExist = await siteInstance.fetch({ docId: this.siteId });
|
|
727
|
+
if (!siteIsExist) {
|
|
728
|
+
throw new Error(
|
|
729
|
+
`不正な処理です。現場ID: ${this.siteId} の現場データが存在しません。`
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
if (siteInstance.isTemporary) {
|
|
733
|
+
throw new Error(
|
|
734
|
+
`不正な処理です。現場ID: ${this.siteId} の現場データは仮登録状態です。`
|
|
735
|
+
);
|
|
720
736
|
}
|
|
737
|
+
|
|
738
|
+
// 配置通知データをもとに、従業員・外注先の稼働実績詳細データを生成する関数
|
|
721
739
|
const converter = (prop) => {
|
|
722
740
|
return this[prop].map((w) => {
|
|
723
741
|
const notification = notifications[w.notificationKey];
|
|
@@ -731,8 +749,11 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
731
749
|
});
|
|
732
750
|
});
|
|
733
751
|
};
|
|
752
|
+
|
|
753
|
+
// 従業員・外注先の稼働実績詳細データを生成
|
|
734
754
|
const employees = converter("employees");
|
|
735
755
|
const outsourcers = converter("outsourcers");
|
|
756
|
+
|
|
736
757
|
try {
|
|
737
758
|
// Create OperationResult instance based on the current SiteOperationSchedule
|
|
738
759
|
const operationResult = new OperationResult({
|
|
@@ -753,7 +774,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
753
774
|
throw new ContextualError(error.message, {
|
|
754
775
|
method: "syncToOperationResult()",
|
|
755
776
|
className: "SiteOperationSchedule",
|
|
756
|
-
arguments: {
|
|
777
|
+
arguments: {},
|
|
757
778
|
state: this.toObject(),
|
|
758
779
|
});
|
|
759
780
|
}
|
package/src/WorkingResult.js
CHANGED
|
@@ -2,46 +2,60 @@
|
|
|
2
2
|
* WorkingResult ver 1.0.0
|
|
3
3
|
* @author shisyamo4131
|
|
4
4
|
* ---------------------------------------------------------------------------
|
|
5
|
+
* - `Agreement`, `Operation` クラスの継承元となるクラスです。
|
|
5
6
|
* A class representing the working result for a specific date and shift extending FireModel.
|
|
6
7
|
* - This class is intended to be inherited by other classes so, it cannot be instantiated directly.
|
|
7
8
|
* - `dateAt` is defined as a trigger property. When it is set, `dayType` is automatically updated.
|
|
8
9
|
* - Subclasses can override `setDateAtCallback` to add custom behavior when `dateAt` changes.
|
|
9
10
|
* ---------------------------------------------------------------------------
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
11
|
+
* @property {Date} dateAt - Applicable start date (trigger property)
|
|
12
|
+
*
|
|
13
|
+
* @property {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
|
|
14
|
+
*
|
|
15
|
+
* @property {string} shiftType - Shift type (`DAY`, `NIGHT`)
|
|
16
|
+
*
|
|
17
|
+
* @property {string} startTime - Start time (HH:MM format)
|
|
18
|
+
*
|
|
19
|
+
* @property {boolean} isStartNextDay - Next day start flag
|
|
15
20
|
* - `true` if the actual work starts the day after the placement date `dateAt`
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
18
|
-
*
|
|
21
|
+
*
|
|
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
|
|
19
27
|
* - The maximum working time defined by `unitPriceBase` (or `unitPriceQualified`).
|
|
20
28
|
* - Exceeding this time is considered overtime.
|
|
21
29
|
*
|
|
22
|
-
* @
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
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)
|
|
26
34
|
* - Returns a string in the format YYYY-MM-DD based on `dateAt`.
|
|
27
|
-
*
|
|
35
|
+
*
|
|
36
|
+
* @property {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
|
|
28
37
|
* - `true` if `startTime` is later than `endTime`
|
|
29
|
-
*
|
|
38
|
+
*
|
|
39
|
+
* @property {Date} startAt - Start date and time (Date object) (read-only)
|
|
30
40
|
* - Returns a Date object with `startTime` set based on `dateAt`.
|
|
31
41
|
* - If `isStartNextDay` is true, add 1 day.
|
|
32
|
-
*
|
|
42
|
+
*
|
|
43
|
+
* @property {Date} endAt - End date and time (Date object) (read-only)
|
|
33
44
|
* - Returns a Date object with `endTime` set based on `dateAt`.
|
|
34
45
|
* - If `isStartNextDay` is true, add 1 day.
|
|
35
46
|
* - If `isSpansNextDay` is true, add 1 day.
|
|
36
|
-
*
|
|
47
|
+
*
|
|
48
|
+
* @property {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
|
|
37
49
|
* - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
|
|
38
50
|
* - If the difference between `endAt` and `startAt` is negative, returns 0.
|
|
39
51
|
* - If `startAt` or `endAt` is not set, returns 0.
|
|
40
|
-
*
|
|
52
|
+
*
|
|
53
|
+
* @property {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
|
|
41
54
|
* - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
|
|
42
55
|
* - If actual working time is less than regulation time (e.g., early leave), it equals `totalWorkMinutes`.
|
|
43
56
|
* - If actual working time exceeds regulation time (overtime), it equals `regulationWorkMinutes`.
|
|
44
|
-
*
|
|
57
|
+
*
|
|
58
|
+
* @property {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
|
|
45
59
|
* - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
|
|
46
60
|
* - Overtime work is not negative; the minimum is 0.
|
|
47
61
|
* ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
export const VALUES = Object.freeze({
|
|
3
|
+
0: { value: 0, title: "日曜日" },
|
|
4
|
+
1: { value: 1, title: "月曜日" },
|
|
5
|
+
2: { value: 2, title: "火曜日" },
|
|
6
|
+
3: { value: 3, title: "水曜日" },
|
|
7
|
+
4: { value: 4, title: "木曜日" },
|
|
8
|
+
5: { value: 5, title: "金曜日" },
|
|
9
|
+
6: { value: 6, title: "土曜日" },
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const OPTIONS = [
|
|
13
|
+
{ title: VALUES[0].title, value: VALUES[0].value },
|
|
14
|
+
{ title: VALUES[1].title, value: VALUES[1].value },
|
|
15
|
+
{ title: VALUES[2].title, value: VALUES[2].value },
|
|
16
|
+
{ title: VALUES[3].title, value: VALUES[3].value },
|
|
17
|
+
{ title: VALUES[4].title, value: VALUES[4].value },
|
|
18
|
+
{ title: VALUES[5].title, value: VALUES[5].value },
|
|
19
|
+
{ title: VALUES[6].title, value: VALUES[6].value },
|
|
20
|
+
];
|
package/src/constants/index.js
CHANGED
|
@@ -18,6 +18,16 @@ export {
|
|
|
18
18
|
VALUES as CONTRACT_STATUS_VALUES,
|
|
19
19
|
OPTIONS as CONTRACT_STATUS_OPTIONS,
|
|
20
20
|
} from "./contract-status.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Day of Week Constants
|
|
24
|
+
* @see src/constants/day-of-week.js
|
|
25
|
+
*/
|
|
26
|
+
export {
|
|
27
|
+
VALUES as DAY_OF_WEEK_VALUES,
|
|
28
|
+
OPTIONS as DAY_OF_WEEK_OPTIONS,
|
|
29
|
+
} from "./day-of-week.js";
|
|
30
|
+
|
|
21
31
|
export {
|
|
22
32
|
VALUES as DAY_TYPE_VALUES,
|
|
23
33
|
OPTIONS as DAY_TYPE_OPTIONS,
|
|
@@ -287,6 +287,21 @@ export const fieldDefinitions = {
|
|
|
287
287
|
},
|
|
288
288
|
},
|
|
289
289
|
},
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* 取引先名
|
|
293
|
+
* - 2文字以上最大20文字
|
|
294
|
+
*/
|
|
295
|
+
customerName: {
|
|
296
|
+
...generalDefinitions.oneLine,
|
|
297
|
+
label: "取引先名",
|
|
298
|
+
length: 20,
|
|
299
|
+
component: {
|
|
300
|
+
name: generalDefinitions.oneLine.component.name,
|
|
301
|
+
attrs: { minLength: 2 },
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
|
|
290
305
|
displayName: {
|
|
291
306
|
...generalDefinitions.oneLine,
|
|
292
307
|
label: "表示名",
|