@shisyamo4131/air-guard-v2-schemas 1.2.1 → 1.3.0

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.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/Agreement.js CHANGED
@@ -234,6 +234,34 @@ export default class Agreement extends WorkingResult {
234
234
  static classProps = classProps;
235
235
  static headers = headers;
236
236
 
237
+ /**
238
+ * Returns an object containing price-related properties.
239
+ * This accessor is useful for synchronizing price details when creating `OperationResult` instance
240
+ * from a `SiteOperationSchedule`.
241
+ * - Includes `regulationWorkMinutes`.
242
+ * @returns {Object} An object with price-related properties.
243
+ * @property {number} cutoffDate - Cutoff date
244
+ * @property {number} regulationWorkMinutes - Regulation work minutes
245
+ * @property {number} unitPriceBase - Base unit price
246
+ * @property {number} overtimeUnitPriceBase - Overtime base unit price
247
+ * @property {number} unitPriceQualified - Qualified unit price
248
+ * @property {number} overtimeUnitPriceQualified - Overtime qualified unit price
249
+ * @property {string} billingUnitType - Billing unit type
250
+ * @property {boolean} includeBreakInBilling - Whether to include break time in billing
251
+ */
252
+ get billingInfo() {
253
+ return {
254
+ cutoffDate: this.cutoffDate,
255
+ regulationWorkMinutes: this.regulationWorkMinutes,
256
+ unitPriceBase: this.unitPriceBase,
257
+ overtimeUnitPriceBase: this.overtimeUnitPriceBase,
258
+ unitPriceQualified: this.unitPriceQualified,
259
+ overtimeUnitPriceQualified: this.overtimeUnitPriceQualified,
260
+ billingUnitType: this.billingUnitType,
261
+ includeBreakInBilling: this.includeBreakInBilling,
262
+ };
263
+ }
264
+
237
265
  /**
238
266
  * Returns an object containing price-related properties.
239
267
  * This accessor is useful for synchronizing price details when creating `OperationResult` instance
@@ -249,6 +277,9 @@ export default class Agreement extends WorkingResult {
249
277
  * @property {boolean} includeBreakInBilling - Whether to include break time in billing
250
278
  */
251
279
  get prices() {
280
+ console.warn(
281
+ "`Agreement.prices` is deprecated. Use `Agreement.billingInfo` instead."
282
+ );
252
283
  return {
253
284
  regulationWorkMinutes: this.regulationWorkMinutes,
254
285
  unitPriceBase: this.unitPriceBase,
@@ -246,12 +246,7 @@ export default class OperationResult extends Operation {
246
246
  set(v) {
247
247
  _cutoffDate = v;
248
248
  // Update billingDateAt when cutoffDate changes
249
- if (this.dateAt) {
250
- this.billingDateAt = CutoffDate.calculateBillingDateAt(
251
- this.dateAt,
252
- this.cutoffDate
253
- );
254
- }
249
+ this.refreshBillingDateAt();
255
250
  },
256
251
  },
257
252
  statistics: {
@@ -429,10 +424,24 @@ export default class OperationResult extends Operation {
429
424
  });
430
425
  }
431
426
 
427
+ refreshBillingDateAt() {
428
+ if (!this.dateAt) {
429
+ this.billingDateAt = null;
430
+ return;
431
+ }
432
+ if (this.cutoffDate !== 0 && !this.cutoffDate) {
433
+ this.billingDateAt = null;
434
+ return;
435
+ }
436
+ this.billingDateAt = CutoffDate.calculateBillingDateAt(
437
+ this.dateAt,
438
+ this.cutoffDate
439
+ );
440
+ }
441
+
432
442
  setDateAtCallback(v) {
433
443
  super.setDateAtCallback(v);
434
- if (!this.cutoffDate) return;
435
- this.billingDateAt = CutoffDate.calculateBillingDateAt(v, this.cutoffDate);
444
+ this.refreshBillingDateAt();
436
445
  }
437
446
 
438
447
  /**