@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.4 → 2.4.2-dev.5
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/Operation.js +18 -3
- package/src/OperationResult.js +7 -3
- package/src/Site.js +108 -53
- package/src/SiteOperationSchedule.js +2 -0
- package/src/WorkingResult.js +1 -1
package/package.json
CHANGED
package/src/Operation.js
CHANGED
|
@@ -57,11 +57,13 @@
|
|
|
57
57
|
* - Setter: Splits array into employees and outsourcers based on `isEmployee` property
|
|
58
58
|
*
|
|
59
59
|
* @property {string} key - `siteId`, `date`, `dayType`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
60
|
-
* -
|
|
61
|
-
*
|
|
60
|
+
* - `WorkingResult.key` をオーバーライドして `siteId` を含めるように定義されているが、未使用。
|
|
61
|
+
*
|
|
62
|
+
* @property {string} agreementKey - `siteId`, `date`, `dayType`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
63
|
+
* - 適用する取極めを特定するためのキーとして使用される。
|
|
62
64
|
*
|
|
63
65
|
* @property {string} orderKey - `siteId`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
64
|
-
* - `siteOrder` の `key`
|
|
66
|
+
* - `siteOrder` の `key` プロパティに対応するキー。稼働予測や配置管理で使用される。
|
|
65
67
|
*
|
|
66
68
|
* @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
|
|
67
69
|
* @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
|
|
@@ -283,6 +285,19 @@ export default class Operation extends WorkingResult {
|
|
|
283
285
|
set() {},
|
|
284
286
|
},
|
|
285
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
|
+
|
|
286
301
|
/**
|
|
287
302
|
* `siteId`, `shiftType` を組み合わせたキー。(読み取り専用)
|
|
288
303
|
* - `siteOrder` の `key` プロパティに対応するキー。
|
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.
|
|
@@ -12,6 +11,8 @@
|
|
|
12
11
|
*
|
|
13
12
|
* @property { string } key - {@link Operation#key}
|
|
14
13
|
*
|
|
14
|
+
* @property {string} agreementKey - {@link Operation#agreementKey}
|
|
15
|
+
*
|
|
15
16
|
* @property {string} orderKey - {@link Operation#orderKey}
|
|
16
17
|
*
|
|
17
18
|
* @property {string} siteId - Site document ID (trigger property)
|
|
@@ -544,7 +545,6 @@ export default class OperationResult extends Operation {
|
|
|
544
545
|
/**
|
|
545
546
|
* Synchronize customerId and apply (re-apply) agreement from siteId
|
|
546
547
|
* @param {Object} [args.transaction] - Firestore transaction.
|
|
547
|
-
* @param {Function} [args.callBack] - Callback function.
|
|
548
548
|
* @param {string} [args.prefix] - Path prefix.
|
|
549
549
|
* @returns {Promise<void>}
|
|
550
550
|
* @throws {Error} If the specified siteId does not exist
|
|
@@ -601,7 +601,11 @@ export default class OperationResult extends Operation {
|
|
|
601
601
|
}
|
|
602
602
|
|
|
603
603
|
// Sync customerId and apply agreement if key changed
|
|
604
|
-
|
|
604
|
+
/**
|
|
605
|
+
* 2026-01-08 `agreementKey` を実装したため、`key` の使用を避ける。
|
|
606
|
+
*/
|
|
607
|
+
// if (this.key === this._beforeData.key) return;
|
|
608
|
+
if (this.agreementKey === this._beforeData.agreementKey) return;
|
|
605
609
|
await this._syncCustomerIdAndApplyAgreement();
|
|
606
610
|
}
|
|
607
611
|
|
package/src/Site.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file src/Site.js
|
|
3
3
|
* @author shisyamo4131
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @update 2025-11-20 version 0.2.0-bata
|
|
6
|
-
* - Prevent changing customer reference on update.
|
|
7
|
-
* - Move `customer` property to the top of classProps for better visibility.
|
|
8
4
|
*
|
|
9
|
-
* NOTE: `customer` プロパティについて
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
13
|
-
*
|
|
5
|
+
* NOTE: `customerId`, `customer` プロパティについて
|
|
6
|
+
* - 仮登録
|
|
7
|
+
* - 取引先未定での現場登録のシチュエーションを考慮して現場情報は仮登録を可能とする。
|
|
8
|
+
* - 仮登録状態の現場は `isTemporary` プロパティが `true` となる。
|
|
9
|
+
* - 但し、一度取引先を設定した後に未設定に戻すことはできない。
|
|
10
|
+
* - 自身の従属先データを持たせる場合に `XxxxxMinimal` クラスを使用するが、アプリ側でオブジェクト選択を行う場合に
|
|
11
|
+
* `Xxxxx` クラスにするのか `XxxxxMinimal` クラスにするのかを判断できないため、docId を持たせて
|
|
12
|
+
* `beforeCreate` フックでオブジェクトを取得するようにする。
|
|
14
13
|
*/
|
|
15
14
|
import { default as FireModel } from "@shisyamo4131/air-firebase-v2";
|
|
16
15
|
import { defField } from "./parts/fieldDefinitions.js";
|
|
@@ -21,16 +20,17 @@ import { VALUES } from "./constants/site-status.js";
|
|
|
21
20
|
import { GeocodableMixin } from "./mixins/GeocodableMixin.js";
|
|
22
21
|
|
|
23
22
|
const classProps = {
|
|
24
|
-
customerId: defField("customerId", {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}),
|
|
23
|
+
// customerId: defField("customerId", {
|
|
24
|
+
// required: true,
|
|
25
|
+
// component: {
|
|
26
|
+
// attrs: {
|
|
27
|
+
// disabled: ({ editMode }) => {
|
|
28
|
+
// return editMode !== "CREATE";
|
|
29
|
+
// },
|
|
30
|
+
// },
|
|
31
|
+
// },
|
|
32
|
+
// }),
|
|
33
|
+
customerId: defField("customerId"),
|
|
34
34
|
customer: defField("customer", { hidden: true, customClass: Customer }),
|
|
35
35
|
code: defField("code", { label: "現場コード" }),
|
|
36
36
|
name: defField("name", {
|
|
@@ -55,24 +55,34 @@ const classProps = {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/*****************************************************************************
|
|
58
|
-
* @
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
65
|
-
* @
|
|
66
|
-
* @
|
|
67
|
-
* @
|
|
68
|
-
* @
|
|
69
|
-
*
|
|
58
|
+
* @property {string} customerId - 取引先ドキュメントID
|
|
59
|
+
*
|
|
60
|
+
* @property {object} customer - 取引先オブジェクト
|
|
61
|
+
* - `beforeCreate`, `beforeUpdate` で `customerId` に該当する `Customer` オブジェクトと自動的に同期されます。
|
|
62
|
+
* - `Customer` が更新された場合は Cloud Functions で同期される必要があります。
|
|
63
|
+
*
|
|
64
|
+
* @property {string} code - Site code.
|
|
65
|
+
* @property {string} name - Site name.
|
|
66
|
+
* @property {string} nameKana - Site name in Kana.
|
|
67
|
+
* @property {string} zipcode - Postal code.
|
|
68
|
+
* @property {string} prefCode - Prefecture code.
|
|
69
|
+
*
|
|
70
|
+
* @property {string} prefecture - Prefecture name derived from `prefCode` (read-only)
|
|
71
|
+
*
|
|
72
|
+
* @property {string} city - City name.
|
|
73
|
+
* @property {string} address - Address details.
|
|
74
|
+
* @property {string} building - Building name.
|
|
75
|
+
*
|
|
76
|
+
* @property {string} fullAddress - Full address combining prefecture, city, and address (read-only)
|
|
77
|
+
*
|
|
78
|
+
* @property {object} location - Geographical location.
|
|
79
|
+
* @property {string} remarks - Additional remarks.
|
|
80
|
+
* @property {array} agreements - List of agreements (Agreement).
|
|
70
81
|
* - Enhanced with custom methods: `add()`, `change()`, `remove()`
|
|
71
|
-
* @props {string} status - Site status.
|
|
72
82
|
*
|
|
73
|
-
* @
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
83
|
+
* @property {string} status - Site status.
|
|
84
|
+
*
|
|
85
|
+
* @property {boolean} isTemporary - 仮登録状態かどうかを表すフラグ
|
|
76
86
|
*
|
|
77
87
|
* @function getAgreement
|
|
78
88
|
* Gets applicable agreement based on date, dayType, and shiftType.
|
|
@@ -127,31 +137,51 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
127
137
|
static STATUS_TERMINATED = VALUES.TERMINATED.value;
|
|
128
138
|
|
|
129
139
|
/**
|
|
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.
|
|
140
|
+
* `customerId` に該当する `Customer` インスタンスを取得して `customer` プロパティにセットします。
|
|
141
|
+
* - `customerId` が未設定の場合は何もしません。
|
|
137
142
|
* @returns {Promise<void>}
|
|
143
|
+
* @throws {Error} `Customer` が存在しない場合にスローされます。
|
|
138
144
|
*/
|
|
139
|
-
async
|
|
140
|
-
await super.beforeCreate(args);
|
|
145
|
+
async _setCustomer() {
|
|
141
146
|
if (!this.customerId) return;
|
|
142
147
|
const customerInstance = new Customer();
|
|
143
148
|
const isExist = await customerInstance.fetch({
|
|
144
|
-
...args,
|
|
145
149
|
docId: this.customerId,
|
|
146
150
|
});
|
|
147
151
|
if (!isExist) {
|
|
148
|
-
|
|
149
|
-
new Error("Invalid customerId: Customer does not exist.")
|
|
150
|
-
);
|
|
152
|
+
throw new Error("Customer does not exist.");
|
|
151
153
|
}
|
|
152
154
|
this.customer = customerInstance;
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
/**
|
|
158
|
+
* ドキュメント作成直前の処理です。
|
|
159
|
+
* - `customerId` に該当する `Customer` インスタンスを取得して `customer` プロパティにセットします。
|
|
160
|
+
* @param {Object} args - Creation options.
|
|
161
|
+
* @param {string} [args.docId] - Document ID to use (optional).
|
|
162
|
+
* @param {boolean} [args.useAutonumber=true] - Whether to use auto-numbering.
|
|
163
|
+
* @param {Object} [args.transaction] - Firestore transaction.
|
|
164
|
+
* @param {Function} [args.callBack] - Callback function.
|
|
165
|
+
* @param {string} [args.prefix] - Path prefix.
|
|
166
|
+
* @returns {Promise<void>}
|
|
167
|
+
*/
|
|
168
|
+
async beforeCreate(args = {}) {
|
|
169
|
+
await super.beforeCreate(args);
|
|
170
|
+
// if (!this.customerId) return;
|
|
171
|
+
// const customerInstance = new Customer();
|
|
172
|
+
// const isExist = await customerInstance.fetch({
|
|
173
|
+
// ...args,
|
|
174
|
+
// docId: this.customerId,
|
|
175
|
+
// });
|
|
176
|
+
// if (!isExist) {
|
|
177
|
+
// return Promise.reject(
|
|
178
|
+
// new Error("Invalid customerId: Customer does not exist.")
|
|
179
|
+
// );
|
|
180
|
+
// }
|
|
181
|
+
// this.customer = customerInstance;
|
|
182
|
+
await this._setCustomer();
|
|
183
|
+
}
|
|
184
|
+
|
|
155
185
|
/**
|
|
156
186
|
* Override beforeUpdate to prevent changing customer reference.
|
|
157
187
|
* @param {Object} args - Creation options.
|
|
@@ -162,10 +192,21 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
162
192
|
*/
|
|
163
193
|
async beforeUpdate(args = {}) {
|
|
164
194
|
await super.beforeUpdate(args);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
195
|
+
|
|
196
|
+
// if (this.customer.docId !== this._beforeData.customer.docId) {
|
|
197
|
+
// return Promise.reject(
|
|
198
|
+
// new Error("Not allowed to change customer reference.")
|
|
199
|
+
// );
|
|
200
|
+
// }
|
|
201
|
+
|
|
202
|
+
// 取引先を未設定に戻すことはできない。
|
|
203
|
+
if (this._beforeData.customerId && !this.customerId) {
|
|
204
|
+
throw new Error("Cannot unset customerId once it is set.");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 取引先が変更されていた場合は `customer` プロパティを更新する。
|
|
208
|
+
if (this.customerId !== this._beforeData.customerId) {
|
|
209
|
+
await this._setCustomer();
|
|
169
210
|
}
|
|
170
211
|
}
|
|
171
212
|
|
|
@@ -173,12 +214,26 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
173
214
|
super.afterInitialize(item);
|
|
174
215
|
|
|
175
216
|
Object.defineProperties(this, {
|
|
176
|
-
// customerId: defAccessor("customerId"),
|
|
177
217
|
fullAddress: defAccessor("fullAddress"),
|
|
178
218
|
prefecture: defAccessor("prefecture"),
|
|
219
|
+
isTemporary: {
|
|
220
|
+
configurable: true,
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get() {
|
|
223
|
+
return !!this.customerId;
|
|
224
|
+
},
|
|
225
|
+
set() {},
|
|
226
|
+
},
|
|
179
227
|
});
|
|
180
228
|
|
|
181
229
|
const self = this;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* `Agreement` プロパティに対するカスタムメソッドを定義します。
|
|
233
|
+
* - add(agreement): `Agreement` インスタンスを追加します。
|
|
234
|
+
* - change(newAgreement): `key` プロパティを基に既存の `Agreement` を置き換えます。
|
|
235
|
+
* - remove(agreement): `key` プロパティを基に `Agreement` を削除します。
|
|
236
|
+
*/
|
|
182
237
|
Object.defineProperties(this.agreements, {
|
|
183
238
|
add: {
|
|
184
239
|
value: function (agreement) {
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @property { string } key - {@link Operation#key}
|
|
22
22
|
*
|
|
23
|
+
* @property {string} agreementKey - {@link Operation#agreementKey}
|
|
24
|
+
*
|
|
23
25
|
* @property {string} orderKey - {@link Operation#orderKey}
|
|
24
26
|
*
|
|
25
27
|
* @property {string|null} operationResultId - Associated OperationResult document ID
|
package/src/WorkingResult.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* - The maximum working time defined by `unitPriceBase` (or `unitPriceQualified`).
|
|
28
28
|
* - Exceeding this time is considered overtime.
|
|
29
29
|
*
|
|
30
|
-
* @property {string} key - `date`, `dayType`, `
|
|
30
|
+
* @property {string} key - `date`, `dayType`, `shiftType` を組み合わせたユニークキー。(読み取り専用)
|
|
31
31
|
* - 継承先である `Agreement` でデータを一意に識別するためのキーとして使用されます。
|
|
32
32
|
*
|
|
33
33
|
* @property {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
|