@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.7 → 1.3.1-dev.9
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/OperationBilling.js +4 -0
- package/src/OperationResult.js +40 -6
package/package.json
CHANGED
package/src/OperationBilling.js
CHANGED
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
* @prop {boolean} isLocked - Lock flag
|
|
57
57
|
* - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
|
|
58
58
|
* @prop {Agreement|null} agreement - Associated Agreement object
|
|
59
|
+
* - The Agreement instance associated with this OperationResult for pricing and billing information.
|
|
60
|
+
* - When set, it influences billing calculations such as unit prices and billing dates.
|
|
61
|
+
* @prop {boolean} allowEmptyAgreement - Flag to ignore missing Agreement
|
|
62
|
+
* - When set to true, allows the OperationResult to be valid even if no Agreement is associated.
|
|
59
63
|
*
|
|
60
64
|
* @readonly
|
|
61
65
|
* @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
|
package/src/OperationResult.js
CHANGED
|
@@ -56,7 +56,10 @@
|
|
|
56
56
|
* @prop {boolean} isLocked - Lock flag
|
|
57
57
|
* - When set to true, the OperationResult is locked from edits exept for editing as OperationBilling.
|
|
58
58
|
* @prop {Agreement|null} agreement - Associated Agreement object
|
|
59
|
-
*
|
|
59
|
+
* - The Agreement instance associated with this OperationResult for pricing and billing information.
|
|
60
|
+
* - When set, it influences billing calculations such as unit prices and billing dates.
|
|
61
|
+
* @prop {boolean} allowEmptyAgreement - Flag to ignore missing Agreement
|
|
62
|
+
* - When set to true, allows the OperationResult to be valid even if no Agreement is associated.
|
|
60
63
|
* @readonly
|
|
61
64
|
* @prop {string} date - Date string in YYYY-MM-DD format based on `dateAt` (read-only)
|
|
62
65
|
* - Returns a string in the format YYYY-MM-DD based on `dateAt`.
|
|
@@ -209,7 +212,7 @@ const classProps = {
|
|
|
209
212
|
default: false,
|
|
210
213
|
}),
|
|
211
214
|
agreement: defField("object", { label: "取極め", customClass: Agreement }),
|
|
212
|
-
|
|
215
|
+
allowEmptyAgreement: defField("check", {
|
|
213
216
|
label: "取極めなしを無視",
|
|
214
217
|
default: false,
|
|
215
218
|
}),
|
|
@@ -234,6 +237,7 @@ export default class OperationResult extends Operation {
|
|
|
234
237
|
super.afterInitialize();
|
|
235
238
|
|
|
236
239
|
/** Computed properties */
|
|
240
|
+
let _agreement = this.agreement;
|
|
237
241
|
Object.defineProperties(this, {
|
|
238
242
|
statistics: {
|
|
239
243
|
configurable: true,
|
|
@@ -419,7 +423,17 @@ export default class OperationResult extends Operation {
|
|
|
419
423
|
set(v) {},
|
|
420
424
|
},
|
|
421
425
|
|
|
422
|
-
|
|
426
|
+
agreement: {
|
|
427
|
+
configurable: true,
|
|
428
|
+
enumerable: true,
|
|
429
|
+
get() {
|
|
430
|
+
return _agreement;
|
|
431
|
+
},
|
|
432
|
+
set(v) {
|
|
433
|
+
_agreement = v;
|
|
434
|
+
this.refreshBillingDateAt();
|
|
435
|
+
},
|
|
436
|
+
},
|
|
423
437
|
hasAgreement: {
|
|
424
438
|
configurable: true,
|
|
425
439
|
enumerable: true,
|
|
@@ -433,7 +447,7 @@ export default class OperationResult extends Operation {
|
|
|
433
447
|
enumerable: true,
|
|
434
448
|
get() {
|
|
435
449
|
if (this.hasAgreement) return true;
|
|
436
|
-
return this.
|
|
450
|
+
return this.allowEmptyAgreement;
|
|
437
451
|
},
|
|
438
452
|
set(v) {},
|
|
439
453
|
},
|
|
@@ -472,8 +486,23 @@ export default class OperationResult extends Operation {
|
|
|
472
486
|
this.refreshBillingDateAt();
|
|
473
487
|
}
|
|
474
488
|
|
|
489
|
+
/**
|
|
490
|
+
* Override create method to validate billingDateAt when allowEmptyAgreement is true
|
|
491
|
+
* @param {*} options
|
|
492
|
+
* @returns {Promise<DocumentReference>}
|
|
493
|
+
*/
|
|
494
|
+
async create(options = {}) {
|
|
495
|
+
if (this.allowEmptyAgreement && !this.billingDateAt) {
|
|
496
|
+
throw new Error(
|
|
497
|
+
"[OperationResult] Billing date is required when 'allowEmptyAgreement' is true."
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
return await super.create(options);
|
|
501
|
+
}
|
|
502
|
+
|
|
475
503
|
/**
|
|
476
504
|
* Override update method to prevent editing if isLocked is true
|
|
505
|
+
* - Also validate billingDateAt when allowEmptyAgreement is true
|
|
477
506
|
* @param {*} options
|
|
478
507
|
* @returns {Promise<void>}
|
|
479
508
|
*/
|
|
@@ -483,7 +512,12 @@ export default class OperationResult extends Operation {
|
|
|
483
512
|
"[OperationResult] This OperationResult is locked and cannot be edited."
|
|
484
513
|
);
|
|
485
514
|
}
|
|
486
|
-
|
|
515
|
+
if (this.allowEmptyAgreement && !this.billingDateAt) {
|
|
516
|
+
throw new Error(
|
|
517
|
+
"[OperationResult] Billing date is required when 'allowEmptyAgreement' is true."
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
return await super.update(options);
|
|
487
521
|
}
|
|
488
522
|
|
|
489
523
|
/**
|
|
@@ -497,6 +531,6 @@ export default class OperationResult extends Operation {
|
|
|
497
531
|
"[OperationResult] This OperationResult is locked and cannot be deleted."
|
|
498
532
|
);
|
|
499
533
|
}
|
|
500
|
-
return super.delete(options);
|
|
534
|
+
return await super.delete(options);
|
|
501
535
|
}
|
|
502
536
|
}
|