@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.6 → 1.3.1-dev.8

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.6",
3
+ "version": "1.3.1-dev.8",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -205,12 +205,14 @@ const classProps = {
205
205
  customClass: OperationResultDetail,
206
206
  }),
207
207
  isLocked: defField("check", {
208
- label: "ロック",
208
+ label: "実績確定",
209
209
  default: false,
210
210
  }),
211
-
212
- /** add */
213
211
  agreement: defField("object", { label: "取極め", customClass: Agreement }),
212
+ ignoreEmptyAgreement: defField("check", {
213
+ label: "取極めなしを無視",
214
+ default: false,
215
+ }),
214
216
  };
215
217
 
216
218
  export default class OperationResult extends Operation {
@@ -232,6 +234,7 @@ export default class OperationResult extends Operation {
232
234
  super.afterInitialize();
233
235
 
234
236
  /** Computed properties */
237
+ let _agreement = this.agreement;
235
238
  Object.defineProperties(this, {
236
239
  statistics: {
237
240
  configurable: true,
@@ -417,7 +420,17 @@ export default class OperationResult extends Operation {
417
420
  set(v) {},
418
421
  },
419
422
 
420
- /** add */
423
+ agreement: {
424
+ configurable: true,
425
+ enumerable: true,
426
+ get() {
427
+ return _agreement;
428
+ },
429
+ set(v) {
430
+ _agreement = v;
431
+ this.refreshBillingDateAt();
432
+ },
433
+ },
421
434
  hasAgreement: {
422
435
  configurable: true,
423
436
  enumerable: true,
@@ -431,7 +444,7 @@ export default class OperationResult extends Operation {
431
444
  enumerable: true,
432
445
  get() {
433
446
  if (this.hasAgreement) return true;
434
- return this.useAdjustedQuantity;
447
+ return this.ignoreEmptyAgreement;
435
448
  },
436
449
  set(v) {},
437
450
  },
@@ -471,20 +484,22 @@ export default class OperationResult extends Operation {
471
484
  }
472
485
 
473
486
  /**
474
- * Override `beforeDelete`.
475
- * - Prevents deletion if the instance has `siteOperationScheduleId`.
487
+ * Override create method to validate billingDateAt when ignoreEmptyAgreement is true
488
+ * @param {*} options
489
+ * @returns {Promise<DocumentReference>}
476
490
  */
477
- async beforeDelete() {
478
- await super.beforeDelete();
479
- if (this.siteOperationScheduleId) {
491
+ async create(options = {}) {
492
+ if (this.ignoreEmptyAgreement && !this.billingDateAt) {
480
493
  throw new Error(
481
- "この稼働実績は現場稼働予定から作成されているため、削除できません。"
494
+ "[OperationResult] Billing date is required when 'ignoreEmptyAgreement' is true."
482
495
  );
483
496
  }
497
+ return await super.create(options);
484
498
  }
485
499
 
486
500
  /**
487
501
  * Override update method to prevent editing if isLocked is true
502
+ * - Also validate billingDateAt when ignoreEmptyAgreement is true
488
503
  * @param {*} options
489
504
  * @returns {Promise<void>}
490
505
  */
@@ -494,7 +509,12 @@ export default class OperationResult extends Operation {
494
509
  "[OperationResult] This OperationResult is locked and cannot be edited."
495
510
  );
496
511
  }
497
- return super.update(options);
512
+ if (this.ignoreEmptyAgreement && !this.billingDateAt) {
513
+ throw new Error(
514
+ "[OperationResult] Billing date is required when 'ignoreEmptyAgreement' is true."
515
+ );
516
+ }
517
+ return await super.update(options);
498
518
  }
499
519
 
500
520
  /**
@@ -508,6 +528,6 @@ export default class OperationResult extends Operation {
508
528
  "[OperationResult] This OperationResult is locked and cannot be deleted."
509
529
  );
510
530
  }
511
- return super.delete(options);
531
+ return await super.delete(options);
512
532
  }
513
533
  }