@shisyamo4131/air-guard-v2-schemas 1.3.0 → 1.3.1-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shisyamo4131/air-guard-v2-schemas",
3
- "version": "1.3.0",
3
+ "version": "1.3.1-dev.3",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -33,7 +33,10 @@
33
33
  "access": "public"
34
34
  },
35
35
  "scripts": {
36
- "test": "echo \"Error: no test specified\" && exit 1"
36
+ "dev:publish": "npm version prerelease --preid=dev && npm publish --tag dev",
37
+ "release:patch": "npm version patch && npm publish",
38
+ "release:minor": "npm version minor && npm publish",
39
+ "release:major": "npm version major && npm publish"
37
40
  },
38
41
  "peerDependencies": {
39
42
  "@shisyamo4131/air-firebase-v2": "^1.0.0"
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
- * @props {number} unitPriceBase - Base unit price (JPY)
8
- * @props {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
9
- * @props {number} unitPriceQualified - Qualified unit price (JPY)
10
- * @props {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
11
- * @props {string} billingUnitType - Billing unit type
12
- * @props {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
13
- * @props {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
7
+ * @prop {number} unitPriceBase - Base unit price (JPY)
8
+ * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
9
+ * @prop {number} unitPriceQualified - Qualified unit price (JPY)
10
+ * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
11
+ * @prop {string} billingUnitType - Billing unit type
12
+ * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
13
+ * @prop {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,15 +20,15 @@
20
20
  * unitPriceQualified, overtimeUnitPriceQualified, billingUnitType, includeBreakInBilling
21
21
  * ---------------------------------------------------------------------------
22
22
  * @inherited - The following properties are inherited from WorkingResult:
23
- * @props {Date} dateAt - Applicable start date (trigger property)
24
- * @props {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
25
- * @props {string} shiftType - Shift type (`DAY`, `NIGHT`)
26
- * @props {string} startTime - Start time (HH:MM format)
27
- * @props {boolean} isStartNextDay - Next day start flag
23
+ * @prop {Date} dateAt - Applicable start date (trigger property)
24
+ * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
25
+ * @prop {string} shiftType - Shift type (`DAY`, `NIGHT`)
26
+ * @prop {string} startTime - Start time (HH:MM format)
27
+ * @prop {boolean} isStartNextDay - Next day start flag
28
28
  * - `true` if the actual work starts the day after the placement date `dateAt`
29
- * @props {string} endTime - End time (HH:MM format)
30
- * @props {number} breakMinutes - Break time (minutes)
31
- * @props {number} regulationWorkMinutes - Regulation work minutes
29
+ * @prop {string} endTime - End time (HH:MM format)
30
+ * @prop {number} breakMinutes - Break time (minutes)
31
+ * @prop {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
  * ---------------------------------------------------------------------------
package/src/Billing.js CHANGED
@@ -9,16 +9,18 @@
9
9
  * @prop {string} billingMonth - billing month (YYYY-MM format)
10
10
  * @prop {Date} billingDate - billing date
11
11
  * @prop {Date} paymentDueDate - payment due date
12
+ *
13
+ * @prop {Array} paymentRecords - payment records (not implemented yet)
14
+ *
12
15
  * @prop {string} status - status (DRAFT/CONFIRMED/PAID/CANCELLED)
13
- * @prop {Array<OperationResult>} items - operation result items (raw data)
16
+ * @prop {Array<OperationResult>} operationResults - operation result documents.
14
17
  * @prop {Object} adjustment - adjustment
15
18
  * @prop {string} remarks - remarks
16
- * @prop {Object} pdfInfo - PDF information
17
19
  *
18
- * @computed {number} subtotal - subtotal (excluding tax)
19
- * @computed {number} taxAmount - tax amount
20
- * @computed {number} totalAmount - total amount (including tax)
21
- * @computed {Array<Object>} itemsSummary - billing items summary for display
20
+ * @prop {number} subtotal - subtotal (excluding tax) (computed-readonly)
21
+ * @prop {number} taxAmount - tax amount (computed-readonly)
22
+ * @prop {number} totalAmount - total amount (including tax) (computed-readonly)
23
+ * @prop {Array<Object>} itemsSummary - billing items summary for display (computed-readonly)
22
24
  *****************************************************************************/
23
25
 
24
26
  import FireModel from "@shisyamo4131/air-firebase-v2";
@@ -36,29 +38,21 @@ const classProps = {
36
38
  customerId: defField("customerId", { required: true }),
37
39
  siteId: defField("siteId", { required: true }),
38
40
  billingMonth: defField("oneLine", { required: true }),
39
- billingDate: defField("date"),
40
- paymentDueDate: defField("date"),
41
- status: defField("oneLine", { default: STATUS.DRAFT }),
41
+ billingDateAt: defField("date"),
42
+ paymentDueDateAt: defField("date"),
42
43
 
43
- // OperationResult の生データを配列で保持
44
- items: defField("array", { customClass: OperationResult }),
44
+ // 入金管理用配列(現時点では未使用 将来の拡張用)
45
+ paymentRecords: defField("array", { default: [] }), // Not implemented yet
45
46
 
47
+ status: defField("oneLine", { default: STATUS.DRAFT }),
48
+ operationResults: defField("array", { customClass: OperationResult }),
46
49
  adjustment: defField("object", {
47
50
  default: {
48
51
  amount: 0,
49
52
  description: "",
50
53
  },
51
54
  }),
52
-
53
55
  remarks: defField("multipleLine"),
54
-
55
- pdfInfo: defField("object", {
56
- default: {
57
- url: null,
58
- generatedAt: null,
59
- version: 1,
60
- },
61
- }),
62
56
  };
63
57
 
64
58
  export default class Billing extends FireModel {
@@ -75,13 +69,14 @@ export default class Billing extends FireModel {
75
69
  // 小計(税抜)を計算
76
70
  Object.defineProperty(this, "subtotal", {
77
71
  get() {
78
- const itemsTotal = this.items.reduce((sum, item) => {
72
+ const itemsTotal = this.operationResults.reduce((sum, item) => {
79
73
  return sum + (item.salesAmount || 0);
80
74
  }, 0);
81
75
  return itemsTotal + (this.adjustment?.amount || 0);
82
76
  },
83
77
  set() {},
84
78
  enumerable: true,
79
+ configurable: true,
85
80
  });
86
81
 
87
82
  // 消費税額を計算
@@ -91,6 +86,7 @@ export default class Billing extends FireModel {
91
86
  },
92
87
  set() {},
93
88
  enumerable: true,
89
+ configurable: true,
94
90
  });
95
91
 
96
92
  // 合計金額(税込)を計算
@@ -100,12 +96,13 @@ export default class Billing extends FireModel {
100
96
  },
101
97
  set() {},
102
98
  enumerable: true,
99
+ configurable: true,
103
100
  });
104
101
 
105
102
  // 表示用の明細サマリーを生成
106
103
  Object.defineProperty(this, "itemsSummary", {
107
104
  get() {
108
- return this.items.map((item) => ({
105
+ return this.operationResults.map((item) => ({
109
106
  operationResultId: item.docId,
110
107
  workDate: item.dateAt,
111
108
  shiftType: item.shiftType,
@@ -134,6 +131,7 @@ export default class Billing extends FireModel {
134
131
  },
135
132
  set() {},
136
133
  enumerable: true,
134
+ configurable: true,
137
135
  });
138
136
  }
139
137
 
package/src/Customer.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /*****************************************************************************
2
- * Customer ver 1.0.0
2
+ * Customer ver 1.1.0
3
3
  * @author shisyamo4131
4
4
  *
5
5
  * @description Customer model.
6
+ *
6
7
  * @hasMany Sites - related sites associated with the customer
7
8
  *
8
9
  * @prop {string} code - customer code
@@ -17,6 +18,8 @@
17
18
  * @prop {string} tel - telephone number
18
19
  * @prop {string} fax - fax number
19
20
  * @prop {string} contractStatus - contract status
21
+ * @prop {number} paymentMonth - payment site in months
22
+ * @prop {string} paymentDate - payment site date
20
23
  * @prop {string} remarks - additional remarks
21
24
  *
22
25
  * @readonly
@@ -31,6 +34,7 @@ import FireModel from "@shisyamo4131/air-firebase-v2";
31
34
  import { defField } from "./parts/fieldDefinitions.js";
32
35
  import { defAccessor } from "./parts/accessorDefinitions.js";
33
36
  import { VALUES } from "./constants/contract-status.js";
37
+ import CutoffDate from "./utils/CutoffDate.js";
34
38
 
35
39
  const classProps = {
36
40
  code: defField("code", { label: "取引先コード" }),
@@ -45,6 +49,21 @@ const classProps = {
45
49
  tel: defField("tel", { colsDefinition: { cols: 12, sm: 6 } }),
46
50
  fax: defField("fax", { colsDefinition: { cols: 12, sm: 6 } }),
47
51
  contractStatus: defField("contractStatus", { required: true }),
52
+ paymentMonth: defField("number", {
53
+ default: 1,
54
+ label: "入金サイト(月数)",
55
+ required: true,
56
+ }),
57
+ paymentDate: defField("select", {
58
+ label: "入金サイト(日付)",
59
+ default: CutoffDate.VALUES.END_OF_MONTH,
60
+ required: true,
61
+ component: {
62
+ attrs: {
63
+ items: CutoffDate.OPTIONS,
64
+ },
65
+ },
66
+ }),
48
67
  remarks: defField("multipleLine", { label: "備考" }),
49
68
  };
50
69
 
@@ -1,7 +1,8 @@
1
1
  /*****************************************************************************
2
- * OperationBilling Model ver 1.0.0
2
+ * OperationBilling Model
3
+ * @version 1.0.0
3
4
  * @author shisyamo4131
4
- * ---------------------------------------------------------------------------
5
+ *
5
6
  * - Extends OperationResult class to represent the billing of an operation.
6
7
  * - This class provides the same functionality as OperationResult but with a different semantic meaning
7
8
  * focused on billing operations rather than general operation results.
@@ -9,104 +10,111 @@
9
10
  * - The `className` is set to "稼働請求" (Operation Billing) to distinguish it from OperationResult.
10
11
  * - The `create` method is overridden to indicate that creation of OperationBilling instances
11
12
  * is not implemented, as billing records are typically generated through the OperationResult class.
12
- * ---------------------------------------------------------------------------
13
- * @inherited - The following properties are inherited from OperationResult:
14
- * @props {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
15
- * - If this OperationBilling was created from a SiteOperationSchedule, this property holds that ID.
16
- * - If this property is set, the instance cannot be deleted.
17
- * @props {boolean} useAdjustedQuantity - Flag to indicate if adjusted quantities are used for billing
18
- * @props {number} adjustedQuantityBase - Adjusted quantity for base workers
19
- * - Quantity used for billing base workers when `useAdjustedQuantity` is true.
20
- * @props {number} adjustedOvertimeBase - Adjusted overtime for base workers
21
- * - Overtime used for billing base workers when `useAdjustedQuantity` is true.
22
- * @props {number} adjustedQuantityQualified - Adjusted quantity for qualified workers
23
- * - Quantity used for billing qualified workers when `useAdjustedQuantity` is true.
24
- * @props {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
25
- * - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
26
- * @props {Date} billingDateAt - Billing date
27
- * ---------------------------------------------------------------------------
28
- * @inherited - The following properties are inherited from Operation (via OperationResult):
29
- * @props {string} siteId - Site document ID (trigger property)
13
+ *
14
+ * @prop {string} siteId - Site document ID (trigger property)
30
15
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
31
- * @props {number} requiredPersonnel - Required number of personnel
32
- * @props {boolean} qualificationRequired - Qualification required flag
33
- * @props {string} workDescription - Work description
34
- * @props {string} remarks - Remarks
35
- * @props {Array<OperationResultDetail>} employees - Assigned employees
36
- * - Array of `OperationResultDetail` instances representing assigned employees
37
- * @props {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
38
- * - Array of `OperationResultDetail` instances representing assigned outsourcers
39
- * ---------------------------------------------------------------------------
40
- * @inherited - The following properties are inherited from Agreement (via OperationResult):
41
- * @props {number} unitPriceBase - Base unit price (JPY)
42
- * @props {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
43
- * @props {number} unitPriceQualified - Qualified unit price (JPY)
44
- * @props {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
45
- * @props {string} billingUnitType - Billing unit type
46
- * @props {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
47
- * @props {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
48
- * - The cutoff date for billing, using values defined in the CutoffDate utility class.
49
- * ---------------------------------------------------------------------------
50
- * @inherited - The following properties are inherited from WorkingResult (via OperationResult):
51
- * @props {Date} dateAt - Date of operation (placement date) (trigger property)
16
+ * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
52
17
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
53
- * @props {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
54
- * @props {string} shiftType - `DAY` or `NIGHT` (trigger property)
18
+ * - Used to determine `dayType`.
19
+ * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
20
+ * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
21
+ * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
55
22
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
56
- * @props {string} startTime - Start time (HH:MM format)
57
- * @props {boolean} isStartNextDay - Next day start flag
23
+ * @prop {string} startTime - Start time (HH:MM format)
24
+ * @prop {boolean} isStartNextDay - Next day start flag
58
25
  * - `true` if the actual work starts the day after the placement date `dateAt`
59
- * @props {string} endTime - End time (HH:MM format)
60
- * @props {number} breakMinutes - Break time (minutes)
61
- * @props {number} regulationWorkMinutes - Regulation work minutes (trigger property)
26
+ * @prop {string} endTime - End time (HH:MM format)
27
+ * @prop {number} breakMinutes - Break time (minutes)
28
+ * @prop {number} regulationWorkMinutes - Regulation work minutes (trigger property)
62
29
  * - Indicates the maximum working time treated as regular working hours.
63
30
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
64
- * ---------------------------------------------------------------------------
65
- * @inherited - The following computed properties are inherited from OperationResult:
66
- * @computed {Object} statistics - Statistics of workers (read-only)
67
- * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
68
- * - Structure: { base: {...}, qualified: {...}, total: {...} }
69
- * @computed {Object} sales - Sales amounts (read-only)
70
- * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
71
- * - Structure: { base: {...}, qualified: {...} }
72
- * @computed {number} salesAmount - Total sales amount (read-only)
73
- * - Sum of sales amounts for base and qualified workers with rounding applied.
74
- * @computed {number} tax - Calculated tax amount (read-only)
75
- * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
76
- * @computed {number} billingAmount - Total billing amount including tax (read-only)
77
- * - Sum of `salesAmount` and `tax`.
78
- * ---------------------------------------------------------------------------
79
- * @inherited - The following computed properties are inherited from Operation (via OperationResult):
80
- * @computed {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
81
- * @computed {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
82
- * @computed {number} employeesCount - Count of assigned employees (read-only)
83
- * @computed {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
84
- * @computed {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
85
- * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
86
- * @computed {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers` (read-only)
31
+ * @prop {number} requiredPersonnel - Required number of personnel
32
+ * @prop {boolean} qualificationRequired - Qualification required flag
33
+ * @prop {string} workDescription - Work description
34
+ * @prop {string} remarks - Remarks
35
+ * @prop {Array<OperationResultDetail>} employees - Assigned employees
36
+ * - Array of `OperationResultDetail` instances representing assigned employees
37
+ * @prop {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
38
+ * - Array of `OperationResultDetail` instances representing assigned outsourcers
39
+ * @prop {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers`
87
40
  * - Getter: Returns concatenated array of employees and outsourcers
88
41
  * - Setter: Splits array into employees and outsourcers based on `isEmployee` property
89
- * ---------------------------------------------------------------------------
90
- * @inherited - The following computed properties are inherited from WorkingResult (via OperationResult):
91
- * @computed {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
42
+ * @prop {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
43
+ * - If this OperationResult was created from a SiteOperationSchedule, this property holds that ID.
44
+ * - If this property is set, the instance cannot be deleted.
45
+ * @prop {boolean} useAdjustedQuantity - Flag to indicate if adjusted quantities are used for billing
46
+ * @prop {number} adjustedQuantityBase - Adjusted quantity for base workers
47
+ * - Quantity used for billing base workers when `useAdjustedQuantity` is true.
48
+ * @prop {number} adjustedOvertimeBase - Adjusted overtime for base workers
49
+ * - Overtime used for billing base workers when `useAdjustedQuantity` is true.
50
+ * @prop {number} adjustedQuantityQualified - Adjusted quantity for qualified workers
51
+ * - Quantity used for billing qualified workers when `useAdjustedQuantity` is true.
52
+ * @prop {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
53
+ * - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
54
+ * @prop {Date} billingDateAt - Billing date
55
+ * - The date used for billing purposes.
56
+ * @prop {boolean} isLocked - Lock flag
57
+ * - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
58
+ * @prop {Agreement|null} agreement - Associated Agreement object
59
+ *
60
+ * @readonly
61
+ * @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
92
62
  * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
93
- * @computed {Date} startAt - Start date and time (Date object) (read-only)
63
+ * @prop {Date} startAt - Start date and time (Date object) (read-only)
94
64
  * - Returns a Date object with `startTime` set based on `dateAt`.
95
65
  * - If `isStartNextDay` is true, add 1 day.
96
- * @computed {Date} endAt - End date and time (Date object) (read-only)
66
+ * @prop {Date} endAt - End date and time (Date object) (read-only)
97
67
  * - Returns a Date object with `endTime` set based on `dateAt`.
98
68
  * - If `isStartNextDay` is true, add 1 day.
99
69
  * - If `isSpansNextDay` is true, add 1 day.
100
- * @computed {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
70
+ * @prop {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
101
71
  * - `true` if `startTime` is later than `endTime`
102
- * @computed {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
72
+ * @prop {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
103
73
  * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
104
- * @computed {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
74
+ * @prop {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
105
75
  * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
106
- * @computed {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
76
+ * @prop {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
107
77
  * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
108
- * ---------------------------------------------------------------------------
109
- * @inherited - The following getter properties are inherited from Operation (via OperationResult):
78
+ * @prop {boolean} hasAgreement - Indicates if an Agreement is associated (read-only)
79
+ * @prop {boolean} isValid - Indicates if the OperationResult is valid (read-only)
80
+ * - Valid if either an Agreement is associated or adjusted quantities are not used.
81
+ * - If `hasAgreement` is true, always valid.
82
+ * @prop {Object} statistics - Statistics of workers (read-only)
83
+ * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
84
+ * - Structure: { base: {...}, qualified: {...}, total: {...} }
85
+ * - Each category contains: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
86
+ * - Each category also has an 'ojt' subcategory with the same structure.
87
+ * @prop {Object} sales - Sales amounts (read-only)
88
+ * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
89
+ * - Structure: { base: {...}, qualified: {...} }
90
+ * - Each category contains: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
91
+ * - Calculations respect `useAdjustedQuantity`, `billingUnitType`, and `includeBreakInBilling` settings.
92
+ * @prop {number} salesAmount - Total sales amount (read-only)
93
+ * - Sum of sales amounts for base and qualified workers with rounding applied.
94
+ * @prop {number} tax - Calculated tax amount (read-only)
95
+ * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
96
+ * @prop {number} billingAmount - Total billing amount including tax (read-only)
97
+ * - Sum of `salesAmount` and `tax`.
98
+ * @prop {string} billingMonth - Billing month in YYYY-MM format (read-only)
99
+ * @prop {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
100
+ * @prop {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
101
+ * @prop {number} employeesCount - Count of assigned employees (read-only)
102
+ * @prop {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
103
+ * @prop {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
104
+ * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
105
+ *
106
+ * @inherited - The following properties are inherited from Agreement (via Operation):
107
+ * @prop {number} unitPriceBase - Base unit price (JPY)
108
+ * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
109
+ * @prop {number} unitPriceQualified - Qualified unit price (JPY)
110
+ * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
111
+ * @prop {string} billingUnitType - Billing unit type
112
+ * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
113
+ * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
114
+ * - The cutoff date for billing, using values defined in the CutoffDate utility class.
115
+ * - Used to calculate `billingDateAt`.
116
+ * - When `cutoffDate` or `dateAt` changes, `billingDateAt` is automatically updated.
117
+ *
110
118
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
111
119
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
112
120
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -118,8 +126,6 @@
118
126
  * - Workers that exist in `_beforeData` but not in current data
119
127
  * @getter {Array<OperationResultDetail>} updatedWorkers - An array of workers that have been updated (read-only)
120
128
  * - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
121
- * ---------------------------------------------------------------------------
122
- * @inherited - The following getter properties are inherited from WorkingResult (via OperationResult):
123
129
  * @getter {number} startHour - Start hour (0-23) (read-only)
124
130
  * - Extracted from `startTime`.
125
131
  * @getter {number} startMinute - Start minute (0-59) (read-only)
@@ -128,53 +134,51 @@
128
134
  * - Extracted from `endTime`.
129
135
  * @getter {number} endMinute - End minute (0-59) (read-only)
130
136
  * - Extracted from `endTime`.
131
- * ---------------------------------------------------------------------------
132
- * @inherited - The following methods are inherited from OperationResult:
133
- * @method {function} beforeDelete - Override method to prevent deletion with siteOperationScheduleId
137
+ *
138
+ * @method beforeDelete - Override method to prevent deletion with siteOperationScheduleId
134
139
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
135
140
  * - Throws an error if deletion is attempted on an instance created from SiteOperationSchedule.
136
- * ---------------------------------------------------------------------------
137
- * @inherited - The following methods are inherited from Operation (via OperationResult):
138
- * @method {function} addWorker - Adds a new worker (employee or outsourcer)
141
+ * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
142
+ * - Updates `billingDateAt` based on the current `dateAt` and `cutoffDate` values.
143
+ * @method addWorker - Adds a new worker (employee or outsourcer)
139
144
  * - @param {Object} options - Options for adding a worker
140
145
  * - @param {string} options.id - The worker ID (employeeId or outsourcerId)
141
146
  * - @param {boolean} [options.isEmployee=true] - Whether the worker is an employee
142
147
  * - @param {number} [index=0] - Insertion position. If -1, adds to the end
143
- * @method {function} moveWorker - Moves the position of a worker (employee or outsourcer)
148
+ * @method moveWorker - Moves the position of a worker (employee or outsourcer)
144
149
  * - @param {Object} options - Options for changing worker position
145
150
  * - @param {number} options.oldIndex - The original index
146
151
  * - @param {number} options.newIndex - The new index
147
152
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
148
- * @method {function} changeWorker - Changes the details of a worker
153
+ * @method changeWorker - Changes the details of a worker
149
154
  * - @param {Object} newWorker - New worker object
150
- * @method {function} removeWorker - Removes a worker (employee or outsourcer)
155
+ * @method removeWorker - Removes a worker (employee or outsourcer)
151
156
  * - @param {Object} options - Options for removing a worker
152
157
  * - @param {string} options.workerId - The ID of the employee or outsourcer
153
158
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
154
- * @method {function} setSiteIdCallback - Callback method called when `siteId` is set
159
+ * @method setSiteIdCallback - Callback method called when `siteId` is set
155
160
  * - Override this method in subclasses to add custom behavior when `siteId` changes.
156
161
  * - By default, does nothing.
157
162
  * - @param {string} v - The new `siteId` value
158
- * @method {function} setShiftTypeCallback - Callback method called when `shiftType` is set
163
+ * @method setShiftTypeCallback - Callback method called when `shiftType` is set
159
164
  * - Override this method in subclasses to add custom behavior when `shiftType` changes.
160
165
  * - By default, does nothing.
161
166
  * - @param {string} v - The new `shiftType` value
162
- * @method {function} setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
167
+ * @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
163
168
  * - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
164
169
  * - By default, does nothing.
165
170
  * - @param {number} v - The new `regulationWorkMinutes` value
171
+ *
166
172
  * @static
167
173
  * @method groupKeyDivider
168
- * Returns an array dividing the key into siteId, shiftType, and date.
169
- * @param {Object|string} key - The combined key string or object
170
- * @returns {Array<string>} - Array containing [siteId, shiftType, date]
171
- * @throws {Error} - If the key is invalid.
172
- * ---------------------------------------------------------------------------
173
- * @inherited - The following method is inherited from WorkingResult (via OperationResult):
174
- * @method {function} setDateAtCallback - Callback method called when `dateAt` is set
175
- * - Override this method in subclasses to add custom behavior when `dateAt` changes.
176
- * - By default, updates `dayType` based on the new `dateAt` value and synchronizes to workers.
177
- * - @param {Date} v - The new `dateAt` value
174
+ * - Returns an array dividing the key into siteId, shiftType, and date.
175
+ * - @param {Object|string} key - The combined key string or object
176
+ * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
177
+ * - @throws {Error} - If the key is invalid.
178
+ *
179
+ * @override create - Override create method to indicate not implemented
180
+ * - Creation of OperationBilling instances is not implemented, as billing records are typically
181
+ * generated through the OperationResult class.
178
182
  *****************************************************************************/
179
183
  import OperationResult from "./OperationResult.js";
180
184
 
@@ -1,13 +1,44 @@
1
1
  /*****************************************************************************
2
- * OperationResult Model ver 1.0.0
2
+ * OperationResult Model
3
+ * @version 1.2.0 - 2025-11-19 Add `agreement`, `hasAgreement`, `isValid` properties.
3
4
  * @author shisyamo4131
4
- * ---------------------------------------------------------------------------
5
+ *
5
6
  * - Extends Operation class to represent the result of an operation.
6
7
  * - Also incorporates Agreement class properties for pricing and billing information.
7
8
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
8
9
  * - Provides comprehensive billing calculations including statistics, sales amounts, and tax.
9
10
  * - Supports both daily and hourly billing with adjusted quantities.
10
- * ---------------------------------------------------------------------------
11
+ * - Automatically updates `billingDateAt` based on `dateAt` and `cutoffDate`.
12
+ * - Introduces a lock mechanism (`isLocked`) to prevent edits when necessary.
13
+ *
14
+ * @prop {string} siteId - Site document ID (trigger property)
15
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
16
+ * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
17
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
18
+ * - Used to determine `dayType`.
19
+ * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
20
+ * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
21
+ * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
22
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
23
+ * @prop {string} startTime - Start time (HH:MM format)
24
+ * @prop {boolean} isStartNextDay - Next day start flag
25
+ * - `true` if the actual work starts the day after the placement date `dateAt`
26
+ * @prop {string} endTime - End time (HH:MM format)
27
+ * @prop {number} breakMinutes - Break time (minutes)
28
+ * @prop {number} regulationWorkMinutes - Regulation work minutes (trigger property)
29
+ * - Indicates the maximum working time treated as regular working hours.
30
+ * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
31
+ * @prop {number} requiredPersonnel - Required number of personnel
32
+ * @prop {boolean} qualificationRequired - Qualification required flag
33
+ * @prop {string} workDescription - Work description
34
+ * @prop {string} remarks - Remarks
35
+ * @prop {Array<OperationResultDetail>} employees - Assigned employees
36
+ * - Array of `OperationResultDetail` instances representing assigned employees
37
+ * @prop {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
38
+ * - Array of `OperationResultDetail` instances representing assigned outsourcers
39
+ * @prop {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers`
40
+ * - Getter: Returns concatenated array of employees and outsourcers
41
+ * - Setter: Splits array into employees and outsourcers based on `isEmployee` property
11
42
  * @prop {string|null} siteOperationScheduleId - Associated SiteOperationSchedule document ID
12
43
  * - If this OperationResult was created from a SiteOperationSchedule, this property holds that ID.
13
44
  * - If this property is set, the instance cannot be deleted.
@@ -21,36 +52,57 @@
21
52
  * @prop {number} adjustedOvertimeQualified - Adjusted overtime for qualified workers
22
53
  * - Overtime used for billing qualified workers when `useAdjustedQuantity` is true.
23
54
  * @prop {Date} billingDateAt - Billing date
24
- * ---------------------------------------------------------------------------
25
- * @computed {Object} statistics - Statistics of workers (read-only)
55
+ * - The date used for billing purposes.
56
+ * @prop {boolean} isLocked - Lock flag
57
+ * - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
58
+ * @prop {Agreement|null} agreement - Associated Agreement object
59
+ *
60
+ * @readonly
61
+ * @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
62
+ * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
63
+ * @prop {Date} startAt - Start date and time (Date object) (read-only)
64
+ * - Returns a Date object with `startTime` set based on `dateAt`.
65
+ * - If `isStartNextDay` is true, add 1 day.
66
+ * @prop {Date} endAt - End date and time (Date object) (read-only)
67
+ * - Returns a Date object with `endTime` set based on `dateAt`.
68
+ * - If `isStartNextDay` is true, add 1 day.
69
+ * - If `isSpansNextDay` is true, add 1 day.
70
+ * @prop {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
71
+ * - `true` if `startTime` is later than `endTime`
72
+ * @prop {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
73
+ * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
74
+ * @prop {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
75
+ * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
76
+ * @prop {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
77
+ * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
78
+ * @prop {boolean} hasAgreement - Indicates if an Agreement is associated (read-only)
79
+ * @prop {boolean} isValid - Indicates if the OperationResult is valid (read-only)
80
+ * - Valid if either an Agreement is associated or adjusted quantities are not used.
81
+ * - If `hasAgreement` is true, always valid.
82
+ * @prop {Object} statistics - Statistics of workers (read-only)
26
83
  * - Contains counts and total work minutes for base and qualified workers, including OJT breakdowns.
27
84
  * - Structure: { base: {...}, qualified: {...}, total: {...} }
28
85
  * - Each category contains: quantity, regularTimeWorkMinutes, overtimeWorkMinutes, totalWorkMinutes, breakMinutes
29
86
  * - Each category also has an 'ojt' subcategory with the same structure.
30
- * @computed {Object} sales - Sales amounts (read-only)
87
+ * @prop {Object} sales - Sales amounts (read-only)
31
88
  * - Contains sales calculations for base and qualified workers, including overtime breakdowns.
32
89
  * - Structure: { base: {...}, qualified: {...} }
33
90
  * - Each category contains: unitPrice, quantity, regularAmount, overtimeUnitPrice, overtimeMinutes, overtimeAmount, total
34
91
  * - Calculations respect `useAdjustedQuantity`, `billingUnitType`, and `includeBreakInBilling` settings.
35
- * @computed {number} salesAmount - Total sales amount (read-only)
92
+ * @prop {number} salesAmount - Total sales amount (read-only)
36
93
  * - Sum of sales amounts for base and qualified workers with rounding applied.
37
- * @computed {number} tax - Calculated tax amount (read-only)
94
+ * @prop {number} tax - Calculated tax amount (read-only)
38
95
  * - Calculated using the `Tax` utility based on `salesAmount` and `date`.
39
- * @computed {number} billingAmount - Total billing amount including tax (read-only)
96
+ * @prop {number} billingAmount - Total billing amount including tax (read-only)
40
97
  * - Sum of `salesAmount` and `tax`.
41
- * ---------------------------------------------------------------------------
42
- * @inherited - The following properties are inherited from Operation:
43
- * @prop {string} siteId - Site document ID (trigger property)
44
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
45
- * @prop {number} requiredPersonnel - Required number of personnel
46
- * @prop {boolean} qualificationRequired - Qualification required flag
47
- * @prop {string} workDescription - Work description
48
- * @prop {string} remarks - Remarks
49
- * @prop {Array<OperationResultDetail>} employees - Assigned employees
50
- * - Array of `OperationResultDetail` instances representing assigned employees
51
- * @prop {Array<OperationResultDetail>} outsourcers - Assigned outsourcers
52
- * - Array of `OperationResultDetail` instances representing assigned outsourcers
53
- * ---------------------------------------------------------------------------
98
+ * @prop {string} billingMonth - Billing month in YYYY-MM format (read-only)
99
+ * @prop {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
100
+ * @prop {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
101
+ * @prop {number} employeesCount - Count of assigned employees (read-only)
102
+ * @prop {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
103
+ * @prop {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
104
+ * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
105
+ *
54
106
  * @inherited - The following properties are inherited from Agreement (via Operation):
55
107
  * @prop {number} unitPriceBase - Base unit price (JPY)
56
108
  * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
@@ -60,53 +112,9 @@
60
112
  * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
61
113
  * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
62
114
  * - The cutoff date for billing, using values defined in the CutoffDate utility class.
63
- * ---------------------------------------------------------------------------
64
- * @inherited - The following properties are inherited from WorkingResult (via Operation):
65
- * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
66
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
67
- * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
68
- * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
69
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
70
- * @prop {string} startTime - Start time (HH:MM format)
71
- * @prop {boolean} isStartNextDay - Next day start flag
72
- * - `true` if the actual work starts the day after the placement date `dateAt`
73
- * @prop {string} endTime - End time (HH:MM format)
74
- * @prop {number} breakMinutes - Break time (minutes)
75
- * @prop {number} regulationWorkMinutes - Regulation work minutes (trigger property)
76
- * - Indicates the maximum working time treated as regular working hours.
77
- * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
78
- * ---------------------------------------------------------------------------
79
- * @inherited - The following computed properties are inherited from Operation:
80
- * @computed {Array<string>} employeeIds - Array of employee IDs from `employees` (read-only)
81
- * @computed {Array<string>} outsourcerIds - Array of outsourcer IDs from `outsourcers` (read-only)
82
- * @computed {number} employeesCount - Count of assigned employees (read-only)
83
- * @computed {number} outsourcersCount - Count of assigned outsourcers (sum of amounts) (read-only)
84
- * @computed {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
85
- * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
86
- * @computed {Array<OperationResultDetail>} workers - Combined array of `employees` and `outsourcers`
87
- * - Getter: Returns concatenated array of employees and outsourcers
88
- * - Setter: Splits array into employees and outsourcers based on `isEmployee` property
89
- * ---------------------------------------------------------------------------
90
- * @inherited - The following computed properties are inherited from WorkingResult (via Operation):
91
- * @computed {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
92
- * - Returns a string in the format YYYY-MM-DD based on `dateAt`.
93
- * @computed {Date} startAt - Start date and time (Date object) (read-only)
94
- * - Returns a Date object with `startTime` set based on `dateAt`.
95
- * - If `isStartNextDay` is true, add 1 day.
96
- * @computed {Date} endAt - End date and time (Date object) (read-only)
97
- * - Returns a Date object with `endTime` set based on `dateAt`.
98
- * - If `isStartNextDay` is true, add 1 day.
99
- * - If `isSpansNextDay` is true, add 1 day.
100
- * @computed {boolean} isSpansNextDay - Flag indicating whether the date spans from start date to end date (read-only)
101
- * - `true` if `startTime` is later than `endTime`
102
- * @computed {number} totalWorkMinutes - Total working time in minutes (excluding break time) (read-only)
103
- * - Calculated as the difference between `endAt` and `startAt` minus `breakMinutes`
104
- * @computed {number} regularTimeWorkMinutes - Regular working time in minutes (read-only)
105
- * - The portion of `totalWorkMinutes` that is considered within the contract's `regulationWorkMinutes`.
106
- * @computed {number} overtimeWorkMinutes - Overtime work in minutes (read-only)
107
- * - Calculated as `totalWorkMinutes` minus `regulationWorkMinutes`
108
- * ---------------------------------------------------------------------------
109
- * @inherited - The following getter properties are inherited from Operation:
115
+ * - Used to calculate `billingDateAt`.
116
+ * - When `cutoffDate` or `dateAt` changes, `billingDateAt` is automatically updated.
117
+ *
110
118
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
111
119
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
112
120
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -118,8 +126,6 @@
118
126
  * - Workers that exist in `_beforeData` but not in current data
119
127
  * @getter {Array<OperationResultDetail>} updatedWorkers - An array of workers that have been updated (read-only)
120
128
  * - Workers whose `startTime`, `isStartNextDay`, `endTime`, `breakMinutes`, `isQualified`, or `isOjt` have changed
121
- * ---------------------------------------------------------------------------
122
- * @inherited - The following getter properties are inherited from WorkingResult (via Operation):
123
129
  * @getter {number} startHour - Start hour (0-23) (read-only)
124
130
  * - Extracted from `startTime`.
125
131
  * @getter {number} startMinute - Start minute (0-59) (read-only)
@@ -128,52 +134,49 @@
128
134
  * - Extracted from `endTime`.
129
135
  * @getter {number} endMinute - End minute (0-59) (read-only)
130
136
  * - Extracted from `endTime`.
131
- * ---------------------------------------------------------------------------
132
- * @method {function} beforeDelete - Override method to prevent deletion with siteOperationScheduleId
137
+ *
138
+ * @method beforeDelete - Override method to prevent deletion with siteOperationScheduleId
133
139
  * - Prevents deletion if the instance has `siteOperationScheduleId`.
134
140
  * - Throws an error if deletion is attempted on an instance created from SiteOperationSchedule.
135
- * ---------------------------------------------------------------------------
136
- * @inherited - The following methods are inherited from Operation:
137
- * @method {function} addWorker - Adds a new worker (employee or outsourcer)
141
+ * @method refreshBillingDateAt - Refresh billingDateAt based on dateAt and cutoffDate
142
+ * - Updates `billingDateAt` based on the current `dateAt` and `cutoffDate` values.
143
+ * @method addWorker - Adds a new worker (employee or outsourcer)
138
144
  * - @param {Object} options - Options for adding a worker
139
145
  * - @param {string} options.id - The worker ID (employeeId or outsourcerId)
140
146
  * - @param {boolean} [options.isEmployee=true] - Whether the worker is an employee
141
147
  * - @param {number} [index=0] - Insertion position. If -1, adds to the end
142
- * @method {function} moveWorker - Moves the position of a worker (employee or outsourcer)
148
+ * @method moveWorker - Moves the position of a worker (employee or outsourcer)
143
149
  * - @param {Object} options - Options for changing worker position
144
150
  * - @param {number} options.oldIndex - The original index
145
151
  * - @param {number} options.newIndex - The new index
146
152
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
147
- * @method {function} changeWorker - Changes the details of a worker
153
+ * @method changeWorker - Changes the details of a worker
148
154
  * - @param {Object} newWorker - New worker object
149
- * @method {function} removeWorker - Removes a worker (employee or outsourcer)
155
+ * @method removeWorker - Removes a worker (employee or outsourcer)
150
156
  * - @param {Object} options - Options for removing a worker
151
157
  * - @param {string} options.workerId - The ID of the employee or outsourcer
152
158
  * - @param {boolean} [options.isEmployee=true] - True for employee, false for outsourcer
153
- * @method {function} setSiteIdCallback - Callback method called when `siteId` is set
159
+ * @method setSiteIdCallback - Callback method called when `siteId` is set
154
160
  * - Override this method in subclasses to add custom behavior when `siteId` changes.
155
161
  * - By default, does nothing.
156
162
  * - @param {string} v - The new `siteId` value
157
- * @method {function} setShiftTypeCallback - Callback method called when `shiftType` is set
163
+ * @method setShiftTypeCallback - Callback method called when `shiftType` is set
158
164
  * - Override this method in subclasses to add custom behavior when `shiftType` changes.
159
165
  * - By default, does nothing.
160
166
  * - @param {string} v - The new `shiftType` value
161
- * @method {function} setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
167
+ * @method setRegulationWorkMinutesCallback - Callback method called when `regulationWorkMinutes` is set
162
168
  * - Override this method in subclasses to add custom behavior when `regulationWorkMinutes` changes.
163
169
  * - By default, does nothing.
164
170
  * - @param {number} v - The new `regulationWorkMinutes` value
171
+ *
165
172
  * @static
166
173
  * @method groupKeyDivider
167
- * Returns an array dividing the key into siteId, shiftType, and date.
168
- * @param {Object|string} key - The combined key string or object
169
- * @returns {Array<string>} - Array containing [siteId, shiftType, date]
170
- * @throws {Error} - If the key is invalid.
171
- * ---------------------------------------------------------------------------
172
- * @inherited - The following method is inherited from WorkingResult (via Operation):
173
- * @method {function} setDateAtCallback - Callback method called when `dateAt` is set
174
- * - Override this method in subclasses to add custom behavior when `dateAt` changes.
175
- * - By default, updates `dayType` based on the new `dateAt` value and synchronizes to workers.
176
- * - @param {Date} v - The new `dateAt` value
174
+ * - Returns an array dividing the key into siteId, shiftType, and date.
175
+ * - @param {Object|string} key - The combined key string or object
176
+ * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
177
+ * - @throws {Error} - If the key is invalid.
178
+ *
179
+ * @override setDateAtCallback - Updates `billingDateAt` based on the new `dateAt` value.
177
180
  *****************************************************************************/
178
181
  import Operation from "./Operation.js";
179
182
  import Agreement from "./Agreement.js";
@@ -214,6 +217,13 @@ const classProps = {
214
217
  outsourcers: defField("array", {
215
218
  customClass: OperationResultDetail,
216
219
  }),
220
+ isLocked: defField("check", {
221
+ label: "ロック",
222
+ default: false,
223
+ }),
224
+
225
+ /** add */
226
+ agreement: defField("object", { label: "取極め", customClass: Agreement }),
217
227
  };
218
228
 
219
229
  export default class OperationResult extends Operation {
@@ -421,9 +431,46 @@ export default class OperationResult extends Operation {
421
431
  },
422
432
  set(v) {},
423
433
  },
434
+ billingMonth: {
435
+ configurable: true,
436
+ enumerable: true,
437
+ get() {
438
+ if (!this.billingDateAt) return null;
439
+ const jstDate = new Date(
440
+ this.billingDateAt.getTime() + 9 * 60 * 60 * 1000
441
+ ); /* JST補正 */
442
+ const year = jstDate.getUTCFullYear();
443
+ const month = jstDate.getUTCMonth() + 1;
444
+ return `${year}-${String(month).padStart(2, "0")}`;
445
+ },
446
+ set(v) {},
447
+ },
448
+
449
+ /** add */
450
+ hasAgreement: {
451
+ configurable: true,
452
+ enumerable: true,
453
+ get() {
454
+ return this.agreement != null;
455
+ },
456
+ set(v) {},
457
+ },
458
+ isValid: {
459
+ configurable: true,
460
+ enumerable: true,
461
+ get() {
462
+ if (this.hasAgreement) return true;
463
+ return !this.hasAgreement && !this.useAdjustedQuantity;
464
+ },
465
+ set(v) {},
466
+ },
424
467
  });
425
468
  }
426
469
 
470
+ /**
471
+ * Refresh billingDateAt based on dateAt and cutoffDate
472
+ * @returns {void}
473
+ */
427
474
  refreshBillingDateAt() {
428
475
  if (!this.dateAt) {
429
476
  this.billingDateAt = null;
@@ -439,6 +486,10 @@ export default class OperationResult extends Operation {
439
486
  );
440
487
  }
441
488
 
489
+ /**
490
+ * Override `setDateAtCallback` to refresh billingDateAt
491
+ * @param {Date} v
492
+ */
442
493
  setDateAtCallback(v) {
443
494
  super.setDateAtCallback(v);
444
495
  this.refreshBillingDateAt();
@@ -456,4 +507,32 @@ export default class OperationResult extends Operation {
456
507
  );
457
508
  }
458
509
  }
510
+
511
+ /**
512
+ * Override update method to prevent editing if isLocked is true
513
+ * @param {*} options
514
+ * @returns {Promise<void>}
515
+ */
516
+ async update(options = {}) {
517
+ if (this.isLocked) {
518
+ throw new Error(
519
+ "[OperationResult] This OperationResult is locked and cannot be edited."
520
+ );
521
+ }
522
+ return super.update(options);
523
+ }
524
+
525
+ /**
526
+ * Override delete method to prevent deletion if isLocked is true
527
+ * @param {*} options
528
+ * @returns {Promise<void>}
529
+ */
530
+ async delete(options = {}) {
531
+ if (this.isLocked) {
532
+ throw new Error(
533
+ "[OperationResult] This OperationResult is locked and cannot be deleted."
534
+ );
535
+ }
536
+ return super.delete(options);
537
+ }
459
538
  }