@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.7 → 2.4.2-dev.71

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.
Files changed (44) hide show
  1. package/index.js +9 -0
  2. package/package.json +45 -47
  3. package/src/Agreement.js +17 -24
  4. package/src/AgreementV2.js +185 -0
  5. package/src/ArrangementNotification.js +8 -8
  6. package/src/Billing.js +5 -34
  7. package/src/Company.js +162 -25
  8. package/src/Customer.js +39 -59
  9. package/src/Employee.js +595 -297
  10. package/src/Insurance.js +408 -0
  11. package/src/Operation.js +272 -280
  12. package/src/OperationBilling.js +126 -192
  13. package/src/OperationDetail.js +115 -85
  14. package/src/OperationResult.js +257 -254
  15. package/src/OperationResultDetail.js +65 -56
  16. package/src/Site.js +160 -141
  17. package/src/SiteOperationSchedule.js +187 -247
  18. package/src/SiteOperationScheduleDetail.js +75 -65
  19. package/src/SiteOrder.js +18 -29
  20. package/src/User.js +5 -1
  21. package/src/WorkTimeBase.js +205 -0
  22. package/src/WorkingResult.js +83 -255
  23. package/src/constants/day-type.js +20 -12
  24. package/src/constants/index.js +4 -0
  25. package/src/constants/insurance-status.js +15 -0
  26. package/src/constants/shift-type.js +5 -2
  27. package/src/errorDefinitions.js +173 -0
  28. package/src/parts/fieldDefinitions/array.js +8 -0
  29. package/src/parts/fieldDefinitions/check.js +20 -0
  30. package/src/parts/fieldDefinitions/code.js +8 -0
  31. package/src/parts/fieldDefinitions/constants.js +9 -0
  32. package/src/parts/fieldDefinitions/dateAt.js +58 -0
  33. package/src/parts/fieldDefinitions/dateTimeAt.js +8 -0
  34. package/src/parts/fieldDefinitions/defaultDefinition.js +118 -0
  35. package/src/parts/fieldDefinitions/multipleLine.js +12 -0
  36. package/src/parts/fieldDefinitions/number.js +69 -0
  37. package/src/parts/fieldDefinitions/object.js +38 -0
  38. package/src/parts/fieldDefinitions/oneLine.js +306 -0
  39. package/src/parts/fieldDefinitions/radio.js +8 -0
  40. package/src/parts/fieldDefinitions/select.js +240 -0
  41. package/src/parts/fieldDefinitions/time.js +8 -0
  42. package/src/parts/fieldDefinitions.js +46 -669
  43. package/src/utils/CutoffDate.js +11 -15
  44. package/src/utils/index.js +44 -8
@@ -16,6 +16,7 @@
16
16
  * @static {function} getDisplayText - Get display text for cutoff date value
17
17
  * @static {function} isValidCutoffDate - Validate cutoff date value
18
18
  *****************************************************************************/
19
+ import { formatJstDate } from "./index.js";
19
20
 
20
21
  export default class CutoffDate {
21
22
  /**
@@ -88,7 +89,7 @@ export default class CutoffDate {
88
89
  const currentCutoffDay = CutoffDate.calculateActualCutoffDay(
89
90
  year,
90
91
  month,
91
- cutoffDateValue
92
+ cutoffDateValue,
92
93
  );
93
94
 
94
95
  let periodStart, periodEnd, periodLabel;
@@ -102,14 +103,14 @@ export default class CutoffDate {
102
103
  const prevCutoffDay = CutoffDate.calculateActualCutoffDay(
103
104
  prevYear,
104
105
  normalizedPrevMonth,
105
- cutoffDateValue
106
+ cutoffDateValue,
106
107
  );
107
108
 
108
109
  // Create dates in UTC representing JST dates (subtract 9 hours)
109
110
  const startJst = Date.UTC(
110
111
  prevYear,
111
112
  normalizedPrevMonth,
112
- prevCutoffDay + 1
113
+ prevCutoffDay + 1,
113
114
  );
114
115
  const endJst = Date.UTC(year, month, currentCutoffDay);
115
116
 
@@ -125,7 +126,7 @@ export default class CutoffDate {
125
126
  const nextCutoffDay = CutoffDate.calculateActualCutoffDay(
126
127
  nextYear,
127
128
  normalizedNextMonth,
128
- cutoffDateValue
129
+ cutoffDateValue,
129
130
  );
130
131
 
131
132
  // Create dates in UTC representing JST dates (subtract 9 hours)
@@ -136,7 +137,7 @@ export default class CutoffDate {
136
137
  periodEnd = new Date(endJst - 9 * 60 * 60 * 1000);
137
138
  periodLabel = `${nextYear}-${String(normalizedNextMonth + 1).padStart(
138
139
  2,
139
- "0"
140
+ "0",
140
141
  )}`;
141
142
  }
142
143
 
@@ -157,7 +158,7 @@ export default class CutoffDate {
157
158
  */
158
159
  static getDisplayText(cutoffDateValue) {
159
160
  const option = CutoffDate.OPTIONS.find(
160
- (opt) => opt.value === cutoffDateValue
161
+ (opt) => opt.value === cutoffDateValue,
161
162
  );
162
163
  return option ? option.title : "";
163
164
  }
@@ -197,7 +198,7 @@ export default class CutoffDate {
197
198
  const currentCutoffDay = CutoffDate.calculateActualCutoffDay(
198
199
  year,
199
200
  month,
200
- cutoffDateValue
201
+ cutoffDateValue,
201
202
  );
202
203
 
203
204
  if (day <= currentCutoffDay) {
@@ -215,7 +216,7 @@ export default class CutoffDate {
215
216
  const nextCutoffDay = CutoffDate.calculateActualCutoffDay(
216
217
  nextYear,
217
218
  normalizedNextMonth,
218
- cutoffDateValue
219
+ cutoffDateValue,
219
220
  );
220
221
 
221
222
  const cutoffJst = Date.UTC(nextYear, normalizedNextMonth, nextCutoffDay);
@@ -236,13 +237,8 @@ export default class CutoffDate {
236
237
  static calculateBillingDateAtString(salesDate, cutoffDateValue) {
237
238
  const cutoffDate = CutoffDate.calculateBillingDateAt(
238
239
  salesDate,
239
- cutoffDateValue
240
+ cutoffDateValue,
240
241
  );
241
- // Convert UTC back to JST for string representation
242
- const jstDate = new Date(cutoffDate.getTime() + 9 * 60 * 60 * 1000);
243
- const year = jstDate.getUTCFullYear();
244
- const month = String(jstDate.getUTCMonth() + 1).padStart(2, "0");
245
- const day = String(jstDate.getUTCDate()).padStart(2, "0");
246
- return `${year}-${month}-${day}`;
242
+ return formatJstDate(cutoffDate);
247
243
  }
248
244
  }
@@ -15,14 +15,14 @@ export function getDateAt(date, time, dateOffset = 0) {
15
15
  // If date is not null/undefined and is not a string or Date, throw an error
16
16
  if (date != null && !(typeof date === "string" || date instanceof Date)) {
17
17
  throw new Error(
18
- `[getDateAt] Invalid date type. Expected string or Date, got ${typeof date}`
18
+ `[getDateAt] Invalid date type. Expected string or Date, got ${typeof date}`,
19
19
  );
20
20
  }
21
21
 
22
22
  // If time is not null and is not a string, throw an error
23
23
  if (time != null && typeof time !== "string") {
24
24
  throw new Error(
25
- `[getDateAt] Invalid time type. Expected string, got ${typeof time}`
25
+ `[getDateAt] Invalid time type. Expected string, got ${typeof time}`,
26
26
  );
27
27
  }
28
28
 
@@ -31,18 +31,54 @@ export function getDateAt(date, time, dateOffset = 0) {
31
31
  const [hour, minute] = time ? time.split(":").map(Number) : [0, 0];
32
32
  if (isNaN(hour) || isNaN(minute)) {
33
33
  throw new Error(
34
- `[getDateAt] Invalid time format. Expected HH:MM, got ${time}`
34
+ `[getDateAt] Invalid time format. Expected HH:MM, got ${time}`,
35
35
  );
36
36
  }
37
37
 
38
38
  // If date is not provided, use the current date
39
- const result = new Date(date || Date.now());
39
+ const baseDate = new Date(date || Date.now());
40
40
 
41
- // JSTはUTC+9なので、UTC時刻として設定してから9時間引く
42
- result.setUTCHours(hour - 9, minute, 0, 0);
43
- result.setUTCDate(result.getUTCDate() + dateOffset);
41
+ // 入力日時から JST の日付成分を取得してから、JST時刻を合成する。
42
+ // これにより、UTC日付境界を跨ぐケースでも期待通りの JST 日付を保てる。
43
+ const jstDate = new Date(baseDate.getTime() + 9 * 60 * 60 * 1000);
44
+ const year = jstDate.getUTCFullYear();
45
+ const month = jstDate.getUTCMonth();
46
+ const day = jstDate.getUTCDate();
44
47
 
45
- return result;
48
+ const utcMillis = Date.UTC(
49
+ year,
50
+ month,
51
+ day + dateOffset,
52
+ hour - 9,
53
+ minute,
54
+ 0,
55
+ 0,
56
+ );
57
+ return new Date(utcMillis);
58
+ }
59
+
60
+ /**
61
+ * DateオブジェクトをJST基準の文字列に変換
62
+ * UTCとして保存されているJST時刻を、JST日付の文字列表現に変換します。
63
+ * @param {Date} dateAt - UTCとして保存されたJST時刻
64
+ * @param {string} format - 'YYYY-MM-DD' | 'YYYY-MM'
65
+ * @returns {string|null} フォーマットされた日付文字列。dateAtがnull/undefinedの場合はnullを返す。
66
+ * @example
67
+ * // YYYY-MM-DD形式
68
+ * formatJstDate(new Date('2024-03-04T15:00:00Z')) // '2024-03-05'
69
+ *
70
+ * // YYYY-MM形式
71
+ * formatJstDate(new Date('2024-03-04T15:00:00Z'), 'YYYY-MM') // '2024-03'
72
+ */
73
+ export function formatJstDate(dateAt, format = "YYYY-MM-DD") {
74
+ if (!dateAt) return null;
75
+
76
+ const jstDate = new Date(dateAt.getTime() + 9 * 60 * 60 * 1000);
77
+ const year = jstDate.getUTCFullYear();
78
+ const month = String(jstDate.getUTCMonth() + 1).padStart(2, "0");
79
+ const day = String(jstDate.getUTCDate()).padStart(2, "0");
80
+
81
+ return format === "YYYY-MM" ? `${year}-${month}` : `${year}-${month}-${day}`;
46
82
  }
47
83
 
48
84
  export { ContextualError } from "./ContextualError.js";