@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.3 → 1.3.1-dev.4

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.3",
3
+ "version": "1.3.1-dev.4",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -16,7 +16,7 @@
16
16
  * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
17
17
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
18
18
  * - Used to determine `dayType`.
19
- * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
19
+ * - When `dateAt` changes, `billingDateAt` is also updated based on `agreement.cutoffDate`.
20
20
  * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
21
21
  * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
22
22
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
@@ -103,18 +103,6 @@
103
103
  * @prop {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
104
104
  * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
105
105
  *
106
- * @inherited - The following properties are inherited from Agreement (via Operation):
107
- * @prop {number} unitPriceBase - Base unit price (JPY)
108
- * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
109
- * @prop {number} unitPriceQualified - Qualified unit price (JPY)
110
- * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
111
- * @prop {string} billingUnitType - Billing unit type
112
- * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
113
- * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
114
- * - The cutoff date for billing, using values defined in the CutoffDate utility class.
115
- * - Used to calculate `billingDateAt`.
116
- * - When `cutoffDate` or `dateAt` changes, `billingDateAt` is automatically updated.
117
- *
118
106
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
119
107
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
120
108
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -16,7 +16,7 @@
16
16
  * @prop {Date} dateAt - Date of operation (placement date) (trigger property)
17
17
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
18
18
  * - Used to determine `dayType`.
19
- * - When `dateAt` changes, `billingDateAt` is also updated based on `cutoffDate`.
19
+ * - When `dateAt` changes, `billingDateAt` is also updated based on `agreement.cutoffDate`.
20
20
  * @prop {string} dayType - Day type (e.g., `WEEKDAY`, `WEEKEND`, `HOLIDAY`)
21
21
  * @prop {string} shiftType - `DAY` or `NIGHT` (trigger property)
22
22
  * - Automatically synchronizes to all `employees` and `outsourcers` when changed.
@@ -103,18 +103,6 @@
103
103
  * @prop {boolean} isPersonnelShortage - Indicates if there is a shortage of personnel (read-only)
104
104
  * - `true` if the sum of `employeesCount` and `outsourcersCount` is less than `requiredPersonnel`
105
105
  *
106
- * @inherited - The following properties are inherited from Agreement (via Operation):
107
- * @prop {number} unitPriceBase - Base unit price (JPY)
108
- * @prop {number} overtimeUnitPriceBase - Overtime unit price (JPY/hour)
109
- * @prop {number} unitPriceQualified - Qualified unit price (JPY)
110
- * @prop {number} overtimeUnitPriceQualified - Qualified overtime unit price (JPY/hour)
111
- * @prop {string} billingUnitType - Billing unit type
112
- * @prop {boolean} includeBreakInBilling - Whether to include break time in billing if `billingUnitType` is `PER_HOUR`.
113
- * @prop {number} cutoffDate - Cutoff date value from CutoffDate.VALUES
114
- * - The cutoff date for billing, using values defined in the CutoffDate utility class.
115
- * - Used to calculate `billingDateAt`.
116
- * - When `cutoffDate` or `dateAt` changes, `billingDateAt` is automatically updated.
117
- *
118
106
  * @getter {string} groupKey - Combines `siteId`, `shiftType`, and `date` to indicate operation grouping (read-only)
119
107
  * @getter {boolean} isEmployeesChanged - Indicates whether the employees have changed (read-only)
120
108
  * - Returns true if the employee IDs have changed compared to `_beforeData`
@@ -190,7 +178,6 @@ import CutoffDate from "./utils/CutoffDate.js";
190
178
 
191
179
  const classProps = {
192
180
  ...Operation.classProps,
193
- ...Agreement.classProps,
194
181
  siteOperationScheduleId: defField("oneLine", { hidden: true }),
195
182
  useAdjustedQuantity: defField("check", {
196
183
  label: "調整数量を使用",
@@ -245,20 +232,7 @@ export default class OperationResult extends Operation {
245
232
  super.afterInitialize();
246
233
 
247
234
  /** Computed properties */
248
- let _cutoffDate = this.cutoffDate;
249
235
  Object.defineProperties(this, {
250
- cutoffDate: {
251
- configurable: true,
252
- enumerable: true,
253
- get() {
254
- return _cutoffDate;
255
- },
256
- set(v) {
257
- _cutoffDate = v;
258
- // Update billingDateAt when cutoffDate changes
259
- this.refreshBillingDateAt();
260
- },
261
- },
262
236
  statistics: {
263
237
  configurable: true,
264
238
  enumerable: true,
@@ -334,14 +308,19 @@ export default class OperationResult extends Operation {
334
308
  return createInitialValues();
335
309
  }
336
310
 
311
+ // agreementがfalsyの場合は初期値を返す
312
+ if (!this.agreement) {
313
+ return createInitialValues();
314
+ }
315
+
337
316
  const unitPrice = isQualified
338
- ? this.unitPriceQualified || 0
339
- : this.unitPriceBase || 0;
317
+ ? this.agreement.unitPriceQualified || 0
318
+ : this.agreement.unitPriceBase || 0;
340
319
  const overtimeUnitPrice = isQualified
341
- ? this.overtimeUnitPriceQualified || 0
342
- : this.overtimeUnitPriceBase || 0;
320
+ ? this.agreement.overtimeUnitPriceQualified || 0
321
+ : this.agreement.overtimeUnitPriceBase || 0;
343
322
  const isPerHour =
344
- this.billingUnitType === BILLING_UNIT_TYPE_PER_HOUR;
323
+ this.agreement.billingUnitType === BILLING_UNIT_TYPE_PER_HOUR;
345
324
 
346
325
  const result = createInitialValues();
347
326
 
@@ -358,28 +337,24 @@ export default class OperationResult extends Operation {
358
337
  ? this.adjustedOvertimeQualified || 0
359
338
  : this.adjustedOvertimeBase || 0;
360
339
  } else {
361
- // result.quantity = isPerHour
362
- // ? (categoryStats.totalWorkMinutes || 0) / 60
363
- // : categoryStats.quantity || 0;
364
- // result.overtimeMinutes = categoryStats.overtimeWorkMinutes || 0;
365
340
  if (isPerHour) {
366
341
  // 時間単位請求の場合
367
342
  let totalMinutes = categoryStats.totalWorkMinutes || 0;
368
343
 
369
344
  // 休憩時間を請求に含める場合は休憩時間を追加
370
- if (this.includeBreakInBilling) {
345
+ if (this.agreement.includeBreakInBilling) {
371
346
  totalMinutes += categoryStats.breakMinutes || 0;
372
347
  }
373
348
 
374
349
  result.quantity = totalMinutes / 60;
375
350
  } else {
376
- // 日単位請求の場合(休憩時間は関係なし)
351
+ // 日単位請求の場合(休憩時間は関係なし)
377
352
  result.quantity = categoryStats.quantity || 0;
378
353
  }
379
354
  result.overtimeMinutes = categoryStats.overtimeWorkMinutes || 0;
380
355
  }
381
356
 
382
- // 金額計算(RoundSettingを適用)
357
+ // 金額計算(RoundSettingを適用)
383
358
  result.regularAmount = RoundSetting.apply(
384
359
  result.quantity * unitPrice
385
360
  );
@@ -476,13 +451,17 @@ export default class OperationResult extends Operation {
476
451
  this.billingDateAt = null;
477
452
  return;
478
453
  }
479
- if (this.cutoffDate !== 0 && !this.cutoffDate) {
454
+ if (!this.agreement) {
455
+ this.billingDateAt = null;
456
+ return;
457
+ }
458
+ if (this.agreement.cutoffDate !== 0 && !this.agreement.cutoffDate) {
480
459
  this.billingDateAt = null;
481
460
  return;
482
461
  }
483
462
  this.billingDateAt = CutoffDate.calculateBillingDateAt(
484
463
  this.dateAt,
485
- this.cutoffDate
464
+ this.agreement.cutoffDate
486
465
  );
487
466
  }
488
467