@shisyamo4131/air-guard-v2-schemas 1.2.0 → 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.0",
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.getBillingDateAt(
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.getBillingDateAt(v, this.cutoffDate);
444
+ this.refreshBillingDateAt();
436
445
  }
437
446
 
438
447
  /**
@@ -11,8 +11,8 @@
11
11
  * @static {Array} OPTIONS - Options for selection components
12
12
  * @static {function} calculateActualCutoffDay - Calculate actual cutoff day for given year/month
13
13
  * @static {function} calculateBillingPeriod - Calculate billing period for given date and cutoff
14
- * @static {function} calculateCutoffDate - Calculate cutoff date as Date object for given sales date
15
- * @static {function} calculateCutoffDateString - Calculate cutoff date as string (YYYY-MM-DD) for given sales date
14
+ * @static {function} calculateBillingDateAt - Calculate cutoff date as Date object for given sales date
15
+ * @static {function} calculateBillingDateAtString - Calculate cutoff date as string (YYYY-MM-DD) for given sales date
16
16
  * @static {function} getDisplayText - Get display text for cutoff date value
17
17
  * @static {function} isValidCutoffDate - Validate cutoff date value
18
18
  *****************************************************************************/
@@ -179,14 +179,14 @@ export default class CutoffDate {
179
179
  * @example
180
180
  * // For JST 2024-03-15 with 10th cutoff
181
181
  * // Input: UTC date representing JST 2024-03-15
182
- * const cutoffDate = CutoffDate.calculateCutoffDate(new Date('2024-03-14T15:00:00Z'), CutoffDate.VALUES.DAY_10);
182
+ * const cutoffDate = CutoffDate.calculateBillingDateAt(new Date('2024-03-14T15:00:00Z'), CutoffDate.VALUES.DAY_10);
183
183
  * // Returns: UTC date representing JST 2024-04-10
184
184
  *
185
185
  * // For JST 2024-03-05 with 10th cutoff
186
- * const cutoffDate = CutoffDate.calculateCutoffDate(new Date('2024-03-04T15:00:00Z'), CutoffDate.VALUES.DAY_10);
186
+ * const cutoffDate = CutoffDate.calculateBillingDateAt(new Date('2024-03-04T15:00:00Z'), CutoffDate.VALUES.DAY_10);
187
187
  * // Returns: UTC date representing JST 2024-03-10
188
188
  */
189
- static calculateCutoffDate(salesDate, cutoffDateValue) {
189
+ static calculateBillingDateAt(salesDate, cutoffDateValue) {
190
190
  // Convert UTC to JST by adding 9 hours to get the JST date
191
191
  const jstDate = new Date(salesDate.getTime() + 9 * 60 * 60 * 1000);
192
192
  const year = jstDate.getUTCFullYear();
@@ -230,11 +230,11 @@ export default class CutoffDate {
230
230
  * @returns {string} Cutoff date in YYYY-MM-DD format (JST)
231
231
  * @example
232
232
  * // For JST 2024-03-15 with 10th cutoff
233
- * const cutoffDateString = CutoffDate.calculateCutoffDateString(new Date('2024-03-14T15:00:00Z'), CutoffDate.VALUES.DAY_10);
233
+ * const cutoffDateString = CutoffDate.calculateBillingDateAtString(new Date('2024-03-14T15:00:00Z'), CutoffDate.VALUES.DAY_10);
234
234
  * // Returns "2024-04-10"
235
235
  */
236
- static calculateCutoffDateString(salesDate, cutoffDateValue) {
237
- const cutoffDate = CutoffDate.calculateCutoffDate(
236
+ static calculateBillingDateAtString(salesDate, cutoffDateValue) {
237
+ const cutoffDate = CutoffDate.calculateBillingDateAt(
238
238
  salesDate,
239
239
  cutoffDateValue
240
240
  );