@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.17 → 1.3.1-dev.19

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.1-dev.17",
3
+ "version": "1.3.1-dev.19",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/Billing.js CHANGED
@@ -38,8 +38,8 @@ const classProps = {
38
38
  customerId: defField("customerId", { required: true }),
39
39
  siteId: defField("siteId", { required: true }),
40
40
  billingMonth: defField("oneLine", { required: true }),
41
- billingDateAt: defField("date"),
42
- paymentDueDateAt: defField("date"),
41
+ billingDateAt: defField("dateAt"),
42
+ paymentDueDateAt: defField("dateAt"),
43
43
 
44
44
  // 入金管理用配列(現時点では未使用 将来の拡張用)
45
45
  paymentRecords: defField("array", { default: [] }), // Not implemented yet
package/src/Site.js CHANGED
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * @file src/Site.js
3
3
  * @author shisyamo4131
4
- * @version 1.0.0
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.
5
8
  */
6
9
  import { default as FireModel } from "@shisyamo4131/air-firebase-v2";
7
10
  import { defField } from "./parts/fieldDefinitions.js";
@@ -12,6 +15,16 @@ import Agreement from "./Agreement.js";
12
15
  import { VALUES } from "./constants/site-status.js";
13
16
 
14
17
  const classProps = {
18
+ customer: defField("customer", {
19
+ required: true,
20
+ customClass: CustomerMinimal,
21
+ component: {
22
+ attrs: {
23
+ api: () => fetchDocsApi(CustomerMinimal),
24
+ noFilter: true,
25
+ },
26
+ },
27
+ }),
15
28
  code: defField("code", { label: "現場コード" }),
16
29
  name: defField("name", {
17
30
  label: "現場名",
@@ -29,16 +42,6 @@ const classProps = {
29
42
  address: defField("address", { required: true }),
30
43
  building: defField("building"),
31
44
  location: defField("location"),
32
- customer: defField("customer", {
33
- required: true,
34
- customClass: CustomerMinimal,
35
- component: {
36
- attrs: {
37
- api: () => fetchDocsApi(CustomerMinimal),
38
- noFilter: true,
39
- },
40
- },
41
- }),
42
45
  remarks: defField("multipleLine", { label: "備考" }),
43
46
  agreements: defField("array", { label: "取極め", customClass: Agreement }),
44
47
  status: defField("siteStatus", { required: true }),
@@ -115,6 +118,19 @@ export default class Site extends FireModel {
115
118
  static STATUS_ACTIVE = VALUES.ACTIVE.value;
116
119
  static STATUS_TERMINATED = VALUES.TERMINATED.value;
117
120
 
121
+ /**
122
+ * Override beforeUpdate to prevent changing customer reference.
123
+ * @returns {Promise<void>}
124
+ */
125
+ async beforeUpdate() {
126
+ await super.beforeUpdate();
127
+ if (this.customer.docId !== this._beforeData.customer.docId) {
128
+ return Promise.reject(
129
+ new Error("Not allowed to change customer reference.")
130
+ );
131
+ }
132
+ }
133
+
118
134
  afterInitialize(item = {}) {
119
135
  super.afterInitialize(item);
120
136
 
@@ -210,6 +210,18 @@ export const fieldDefinitions = {
210
210
  label: "市区町村",
211
211
  length: 10,
212
212
  },
213
+ customerId: {
214
+ ...generalDefinitions.oneLine,
215
+ label: "取引先",
216
+ component: {
217
+ name: "air-autocomplete-api",
218
+ attrs: {
219
+ itemValue: "docId",
220
+ itemTitle: "name",
221
+ noFilter: true,
222
+ },
223
+ },
224
+ },
213
225
  displayName: {
214
226
  ...generalDefinitions.oneLine,
215
227
  label: "表示名",