@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.22 → 1.3.1-dev.24

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.22",
3
+ "version": "1.3.1-dev.24",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/Billing.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @prop {number} subtotal - subtotal (excluding tax) (computed-readonly)
24
24
  * @prop {number} taxAmount - tax amount (computed-readonly)
25
25
  * @prop {number} totalAmount - total amount (including tax) (computed-readonly)
26
- * @prop {Array<Object>} itemsSummary - billing items summary for display (computed-readonly)
26
+ * @prop {Array<Object>} summary - summary for display (computed-readonly)
27
27
  *****************************************************************************/
28
28
 
29
29
  import FireModel from "@shisyamo4131/air-firebase-v2";
@@ -171,7 +171,7 @@ export default class Billing extends FireModel {
171
171
  });
172
172
 
173
173
  // 表示用の明細サマリーを生成
174
- Object.defineProperty(this, "itemsSummary", {
174
+ Object.defineProperty(this, "summary", {
175
175
  get() {
176
176
  return this.operationResults.map((item) => ({
177
177
  operationResultId: item.docId,
package/src/Customer.js CHANGED
@@ -29,6 +29,10 @@
29
29
  * @static
30
30
  * @prop {string} STATUS_ACTIVE - constant for active contract status
31
31
  * @prop {string} STATUS_TERMINATED - constant for terminated contract status
32
+ *
33
+ * @method getPaymentDueDateAt
34
+ * @param {Date} baseDate - base date in UTC (JST - 9 hours)
35
+ * @returns {Date} payment due date in UTC (JST - 9 hours)
32
36
  *****************************************************************************/
33
37
  import FireModel from "@shisyamo4131/air-firebase-v2";
34
38
  import { defField } from "./parts/fieldDefinitions.js";
@@ -99,6 +103,42 @@ export default class Customer extends FireModel {
99
103
  prefecture: defAccessor("prefecture"),
100
104
  });
101
105
  }
106
+
107
+ /**
108
+ * 支払期日を計算する
109
+ * @param {Date} baseDate - 基準日(JSTから9時間引いたUTC表現)
110
+ * @returns {Date} 支払期日(JSTから9時間引いたUTC表現)
111
+ */
112
+ getPaymentDueDateAt(baseDate) {
113
+ // UTC → JST に変換(+9時間)
114
+ const jstDate = new Date(baseDate.getTime() + 9 * 60 * 60 * 1000);
115
+
116
+ // UTCメソッドでJST相当の年月を取得
117
+ const year = jstDate.getUTCFullYear();
118
+ const month = jstDate.getUTCMonth();
119
+
120
+ // paymentMonth分加算した年月を計算
121
+ const targetMonth = month + this.paymentMonth;
122
+ const targetYear = year + Math.floor(targetMonth / 12);
123
+ const finalMonth = targetMonth % 12;
124
+
125
+ let dueDate;
126
+ if (this.paymentDate === CutoffDate.VALUES.END_OF_MONTH) {
127
+ // 月末の場合
128
+ dueDate = new Date(Date.UTC(targetYear, finalMonth + 1, 0));
129
+ } else {
130
+ // 指定日の場合
131
+ dueDate = new Date(Date.UTC(targetYear, finalMonth, this.paymentDate));
132
+
133
+ // 指定日が存在しない場合は月末にする
134
+ if (dueDate.getUTCMonth() !== finalMonth) {
135
+ dueDate = new Date(Date.UTC(targetYear, finalMonth + 1, 0));
136
+ }
137
+ }
138
+
139
+ // JST → UTC に変換(-9時間)
140
+ return new Date(dueDate.getTime() - 9 * 60 * 60 * 1000);
141
+ }
102
142
  }
103
143
 
104
144
  /*****************************************************************************