@mulmoclaude/accounting-plugin 1.0.0 → 1.0.1

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 (54) hide show
  1. package/dist/server/accountNormalize.d.ts +1 -1
  2. package/dist/server/accountNormalize.d.ts.map +1 -1
  3. package/dist/server/context.d.ts +3 -10
  4. package/dist/server/context.d.ts.map +1 -1
  5. package/dist/server/defaultAccounts.d.ts +1 -1
  6. package/dist/server/defaultAccounts.d.ts.map +1 -1
  7. package/dist/server/http.d.ts.map +1 -1
  8. package/dist/server/index.d.ts +1 -1
  9. package/dist/server/index.d.ts.map +1 -1
  10. package/dist/server/io.d.ts +2 -1
  11. package/dist/server/io.d.ts.map +1 -1
  12. package/dist/server/journal.d.ts +1 -1
  13. package/dist/server/journal.d.ts.map +1 -1
  14. package/dist/server/openingBalances.d.ts +1 -1
  15. package/dist/server/openingBalances.d.ts.map +1 -1
  16. package/dist/server/report.d.ts +6 -64
  17. package/dist/server/report.d.ts.map +1 -1
  18. package/dist/server/service.d.ts +1 -1
  19. package/dist/server/service.d.ts.map +1 -1
  20. package/dist/server/snapshotCache.d.ts +2 -1
  21. package/dist/server/snapshotCache.d.ts.map +1 -1
  22. package/dist/server/timeSeries.d.ts +1 -1
  23. package/dist/server/timeSeries.d.ts.map +1 -1
  24. package/dist/server/types.d.ts +1 -123
  25. package/dist/server/types.d.ts.map +1 -1
  26. package/dist/server.cjs +22 -73
  27. package/dist/server.cjs.map +1 -1
  28. package/dist/server.js +14 -65
  29. package/dist/server.js.map +1 -1
  30. package/dist/shared/errors.d.ts +1 -1
  31. package/dist/shared/errors.d.ts.map +1 -1
  32. package/dist/shared/index.d.ts +1 -0
  33. package/dist/shared/index.d.ts.map +1 -1
  34. package/dist/shared/types.d.ts +188 -0
  35. package/dist/shared/types.d.ts.map +1 -0
  36. package/dist/shared-CcU3_qAa.cjs +749 -0
  37. package/dist/shared-CcU3_qAa.cjs.map +1 -0
  38. package/dist/shared-MOpJ1kUa.js +516 -0
  39. package/dist/shared-MOpJ1kUa.js.map +1 -0
  40. package/dist/shared.cjs +40 -519
  41. package/dist/shared.js +2 -483
  42. package/dist/vue/api.d.ts +2 -121
  43. package/dist/vue/api.d.ts.map +1 -1
  44. package/dist/vue/lang/index.d.ts +204 -215
  45. package/dist/vue/lang/index.d.ts.map +1 -1
  46. package/dist/vue.cjs +1651 -1678
  47. package/dist/vue.cjs.map +1 -1
  48. package/dist/vue.js +1652 -1679
  49. package/dist/vue.js.map +1 -1
  50. package/package.json +11 -6
  51. package/dist/server/atomic.d.ts +0 -15
  52. package/dist/server/atomic.d.ts.map +0 -1
  53. package/dist/shared.cjs.map +0 -1
  54. package/dist/shared.js.map +0 -1
@@ -0,0 +1,749 @@
1
+ //#region src/shared/actions.ts
2
+ var ACCOUNTING_ACTIONS = {
3
+ openBook: "openBook",
4
+ getBooks: "getBooks",
5
+ createBook: "createBook",
6
+ updateBook: "updateBook",
7
+ deleteBook: "deleteBook",
8
+ getAccounts: "getAccounts",
9
+ upsertAccount: "upsertAccount",
10
+ addEntries: "addEntries",
11
+ voidEntry: "voidEntry",
12
+ getJournalEntries: "getJournalEntries",
13
+ getOpeningBalances: "getOpeningBalances",
14
+ setOpeningBalances: "setOpeningBalances",
15
+ getReport: "getReport",
16
+ getTimeSeries: "getTimeSeries",
17
+ rebuildSnapshots: "rebuildSnapshots"
18
+ };
19
+ //#endregion
20
+ //#region src/shared/api.ts
21
+ var ACCOUNTING_API = { dispatch: {
22
+ path: "/api/accounting",
23
+ method: "POST"
24
+ } };
25
+ //#endregion
26
+ //#region src/shared/types.ts
27
+ var ACCOUNT_TYPES = [
28
+ "asset",
29
+ "liability",
30
+ "equity",
31
+ "income",
32
+ "expense"
33
+ ];
34
+ /** B/S accounts (assets / liabilities / equity). Used by opening
35
+ * balance validation: opening entries reference balance-sheet
36
+ * accounts only. */
37
+ var BALANCE_SHEET_ACCOUNT_TYPES = [
38
+ "asset",
39
+ "liability",
40
+ "equity"
41
+ ];
42
+ //#endregion
43
+ //#region src/shared/channels.ts
44
+ /** Channel factory for per-book event streams. Subscribers:
45
+ * `useAccountingChannel(bookId)`. Publisher: the package's server
46
+ * surface `eventPublisher`. */
47
+ function bookChannel(bookId) {
48
+ return `accounting:${bookId}`;
49
+ }
50
+ /** Book-list-level channel — a book was created / deleted. Subscribers
51
+ * refetch the BookSwitcher dropdown. Mirrors the host META's
52
+ * `staticChannels.accountingBooks` literal (kept in sync by value;
53
+ * the host META stays the codegen-discoverable source for the
54
+ * aggregator merge). */
55
+ var ACCOUNTING_BOOKS_CHANNEL = "accounting:books";
56
+ /** Event kinds that ride `bookChannel(bookId)`. Single source of
57
+ * truth for both publishers (server/accounting) and subscribers
58
+ * (the View) — anyone branching on event kind imports from here
59
+ * and the type system catches drift on either side.
60
+ *
61
+ * - `journal` — addEntry / voidEntry hit the books at `period`.
62
+ * Refetch the journal list and (if the View is
63
+ * showing balances at or after `period`) the
64
+ * relevant report.
65
+ * - `opening` — setOpeningBalances. Affects every period from
66
+ * the opening date forward; refetch everything.
67
+ * - `accounts` — chart-of-accounts mutation that may affect
68
+ * aggregation (account type changed). Refetch
69
+ * accounts and the active report.
70
+ * - `snapshotsRebuilding` / `snapshotsReady` — purely informational;
71
+ * the View can show a "calculating" spinner
72
+ * during rebuild, but the lazy-rebuild safety
73
+ * net means a refetch always returns the right
74
+ * answer regardless. */
75
+ var BOOK_EVENT_KINDS = {
76
+ journal: "journal",
77
+ opening: "opening",
78
+ accounts: "accounts",
79
+ snapshotsRebuilding: "snapshots-rebuilding",
80
+ snapshotsReady: "snapshots-ready"
81
+ };
82
+ //#endregion
83
+ //#region ../../common/dist/index.js
84
+ /** Narrow `unknown` to a plain object (not null, not array). */
85
+ function isRecord(value) {
86
+ return typeof value === "object" && value !== null && !Array.isArray(value);
87
+ }
88
+ /** Check that a record has a specific key with a string value. */
89
+ function hasStringProp(value, key) {
90
+ return isRecord(value) && typeof value[key] === "string";
91
+ }
92
+ /** Normalise an unknown thrown value into a human-readable string. Isomorphic
93
+ * (host, bridges, plugins, Vue) — this is the single home for the helper that
94
+ * #2217 could only consolidate for server code, since `@mulmoclaude/core/utils`
95
+ * is server-only.
96
+ *
97
+ * A non-Error object with a non-empty string `details` (gRPC convention) or
98
+ * `message` field surfaces that field — `details` wins — instead of the
99
+ * `[object Object]` a bare `String(err)` would print; an empty-string field
100
+ * falls through. `fallback` covers the error-boundary idiom where a thrown
101
+ * non-Error should read as a descriptive message rather than `String(err)`
102
+ * noise; omit it in logging contexts where `String(err)` is fine. */
103
+ function errorMessage(err, fallback) {
104
+ if (err instanceof Error) return err.message;
105
+ if (hasStringProp(err, "details") && err.details) return err.details;
106
+ if (hasStringProp(err, "message") && err.message) return err.message;
107
+ if (fallback !== void 0) return fallback;
108
+ return String(err);
109
+ }
110
+ //#endregion
111
+ //#region src/shared/paths.ts
112
+ var ACCOUNTING_DIRS = {
113
+ /** `data/accounting/config.json` + the books tree below. */
114
+ accounting: "data/accounting",
115
+ /** `data/accounting/books/<bookId>/{accounts.json, journal/, snapshots/}`. */
116
+ accountingBooks: "data/accounting/books"
117
+ };
118
+ //#endregion
119
+ //#region src/shared/fiscalYear.ts
120
+ var FISCAL_YEAR_END_MONTHS = [
121
+ 1,
122
+ 2,
123
+ 3,
124
+ 4,
125
+ 5,
126
+ 6,
127
+ 7,
128
+ 8,
129
+ 9,
130
+ 10,
131
+ 11,
132
+ 12
133
+ ];
134
+ var DEFAULT_FISCAL_YEAR_END = 12;
135
+ /** Legacy calendar-quarter tokens → closing month, for books written
136
+ * before the field became a month number. */
137
+ var LEGACY_QUARTER_MONTHS = {
138
+ Q1: 3,
139
+ Q2: 6,
140
+ Q3: 9,
141
+ Q4: 12
142
+ };
143
+ function isFiscalYearEnd(value) {
144
+ return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 12;
145
+ }
146
+ /** Normalise any stored / inbound value to a concrete closing month.
147
+ * Absent or unrecognised → the default (December); a legacy "Q1".."Q4"
148
+ * token → its closing month; a valid 1-12 number → itself. Kept
149
+ * tolerant (unknown input) so a legacy book read from disk — or shared
150
+ * with an older MulmoTerminal — never breaks the UI or a report. */
151
+ function resolveFiscalYearEnd(value) {
152
+ if (isFiscalYearEnd(value)) return value;
153
+ if (typeof value === "string" && Object.hasOwn(LEGACY_QUARTER_MONTHS, value)) return LEGACY_QUARTER_MONTHS[value];
154
+ return 12;
155
+ }
156
+ /** Last calendar month (1-12) of the fiscal year. The stored token IS
157
+ * the closing month now, so this reads as `resolveFiscalYearEnd` under
158
+ * a name that states intent at the call sites (and still absorbs a
159
+ * stray legacy token defensively). */
160
+ function fiscalYearEndMonth(end) {
161
+ return resolveFiscalYearEnd(end);
162
+ }
163
+ /** Localised label for a fiscal-year-end month, showing that month's
164
+ * last day — e.g. 8 → "August 31" / "8月31日" / "31 de agosto". Uses a
165
+ * fixed non-leap reference year, so February reads as the 28th; this
166
+ * is display only — the engine still computes the real last day
167
+ * (Feb 29 in a leap year) at runtime. */
168
+ function fiscalYearEndMonthLabel(month, locale) {
169
+ const lastDay = new Date(Date.UTC(2001, month, 0));
170
+ try {
171
+ return new Intl.DateTimeFormat(locale, {
172
+ month: "long",
173
+ day: "numeric",
174
+ timeZone: "UTC"
175
+ }).format(lastDay);
176
+ } catch {
177
+ return String(month);
178
+ }
179
+ }
180
+ function pad2$1(num) {
181
+ return String(num).padStart(2, "0");
182
+ }
183
+ function lastDayOfMonth(year, monthZeroBased) {
184
+ return new Date(year, monthZeroBased + 1, 0).getDate();
185
+ }
186
+ function ymd(year, monthOneBased, day) {
187
+ return `${year}-${pad2$1(monthOneBased)}-${pad2$1(day)}`;
188
+ }
189
+ /** Fiscal quarter index (0..3) of the given local date under `end`,
190
+ * where 0 is the first quarter of the fiscal year (right after the
191
+ * prior year's close) and 3 is the closing quarter. */
192
+ function fiscalQuarterIndex(end, today) {
193
+ const closingMonth = fiscalYearEndMonth(end);
194
+ const offset = (today.getMonth() + 1 - closingMonth - 1 + 12) % 12;
195
+ return Math.floor(offset / 3);
196
+ }
197
+ /** Calendar (year, monthOneBased) of the *first* month of the fiscal
198
+ * quarter at index `index` in the fiscal year that *contains*
199
+ * `today`. Returned both as the first day of that month and as the
200
+ * count of months covered (always 3 — exposed as a constant). */
201
+ function fiscalQuarterStart(end, today, index) {
202
+ const closingMonth = fiscalYearEndMonth(end);
203
+ const todayMonth = today.getMonth() + 1;
204
+ const todayYear = today.getFullYear();
205
+ const startMonth = closingMonth % 12 + 1;
206
+ const fyStartYear = todayMonth >= startMonth ? todayYear : todayYear - 1;
207
+ const flatMonth = startMonth + index * 3;
208
+ return {
209
+ year: fyStartYear + Math.floor((flatMonth - 1) / 12),
210
+ month: (flatMonth - 1) % 12 + 1
211
+ };
212
+ }
213
+ function quarterRangeAt(end, today, index) {
214
+ const start = fiscalQuarterStart(end, today, index);
215
+ const lastMonthFlat = start.month - 1 + 2;
216
+ const lastMonthYear = start.year + Math.floor(lastMonthFlat / 12);
217
+ const lastMonth = lastMonthFlat % 12 + 1;
218
+ const lastDay = lastDayOfMonth(lastMonthYear, lastMonth - 1);
219
+ return {
220
+ from: ymd(start.year, start.month, 1),
221
+ to: ymd(lastMonthYear, lastMonth, lastDay)
222
+ };
223
+ }
224
+ function currentQuarterRange(end, today = /* @__PURE__ */ new Date()) {
225
+ return quarterRangeAt(end, today, fiscalQuarterIndex(end, today));
226
+ }
227
+ function previousQuarterRange(end, today = /* @__PURE__ */ new Date()) {
228
+ const idx = fiscalQuarterIndex(end, today);
229
+ if (idx > 0) return quarterRangeAt(end, today, idx - 1);
230
+ return quarterRangeAt(end, new Date(today.getFullYear(), today.getMonth() - 3, 1), 3);
231
+ }
232
+ /** Current fiscal year — Q0 start through Q3 close. */
233
+ function currentFiscalYearRange(end, today = /* @__PURE__ */ new Date()) {
234
+ const first = quarterRangeAt(end, today, 0);
235
+ const last = quarterRangeAt(end, today, 3);
236
+ return {
237
+ from: first.from,
238
+ to: last.to
239
+ };
240
+ }
241
+ function previousFiscalYearRange(end, today = /* @__PURE__ */ new Date()) {
242
+ return currentFiscalYearRange(end, new Date(today.getFullYear() - 1, today.getMonth(), today.getDate()));
243
+ }
244
+ //#endregion
245
+ //#region src/shared/countries.ts
246
+ /** ISO 3166-1 alpha-2 country codes shown in the book country
247
+ * dropdown. Curated to cover every jurisdiction the Accounting role
248
+ * has explicit tax-registration advice for, plus the major economies
249
+ * represented in `SUPPORTED_CURRENCY_CODES`. */
250
+ var SUPPORTED_COUNTRY_CODES = [
251
+ "US",
252
+ "JP",
253
+ "GB",
254
+ "CA",
255
+ "AU",
256
+ "NZ",
257
+ "DE",
258
+ "FR",
259
+ "IT",
260
+ "ES",
261
+ "NL",
262
+ "BE",
263
+ "AT",
264
+ "IE",
265
+ "PT",
266
+ "FI",
267
+ "SE",
268
+ "DK",
269
+ "PL",
270
+ "CH",
271
+ "NO",
272
+ "CN",
273
+ "KR",
274
+ "TW",
275
+ "HK",
276
+ "SG",
277
+ "IN",
278
+ "BR",
279
+ "MX"
280
+ ];
281
+ /** EU member states as of 2026. Used by the role-prompt advice path
282
+ * to recommend a VAT identification number when the book country is
283
+ * in the EU. */
284
+ var EU_COUNTRY_CODES = /* @__PURE__ */ new Set([
285
+ "AT",
286
+ "BE",
287
+ "BG",
288
+ "CY",
289
+ "CZ",
290
+ "DE",
291
+ "DK",
292
+ "EE",
293
+ "ES",
294
+ "FI",
295
+ "FR",
296
+ "GR",
297
+ "HR",
298
+ "HU",
299
+ "IE",
300
+ "IT",
301
+ "LT",
302
+ "LU",
303
+ "LV",
304
+ "MT",
305
+ "NL",
306
+ "PL",
307
+ "PT",
308
+ "RO",
309
+ "SE",
310
+ "SI",
311
+ "SK"
312
+ ]);
313
+ /** Localized human name for a country code. Falls back to the code
314
+ * itself if the runtime can't resolve the name. */
315
+ function localizedCountryName(code, locale) {
316
+ try {
317
+ return new Intl.DisplayNames([locale], { type: "region" }).of(code) ?? code;
318
+ } catch {
319
+ return code;
320
+ }
321
+ }
322
+ /** Runtime guard for `BookSummary.country`. The type is the union
323
+ * `SupportedCountryCode`, but every entry point that takes user /
324
+ * LLM input arrives as raw `string` (form submit, JSON-RPC body),
325
+ * so the service layer narrows here before persisting. */
326
+ function isSupportedCountryCode(value) {
327
+ return typeof value === "string" && SUPPORTED_COUNTRY_CODES.includes(value);
328
+ }
329
+ /** Country-gated UI features. Each key is a feature name; the value
330
+ * is the set of country codes for which the feature is enabled.
331
+ * Components ask `countryHasFeature("...", country)` instead of
332
+ * hard-coding country lists at the call site.
333
+ *
334
+ * Add a new country-specific feature by adding a new key here and
335
+ * reading it via `countryHasFeature`. An unknown / undefined
336
+ * country never has any feature — components fall back to neutral
337
+ * default UI rather than guessing.
338
+ *
339
+ * Mirrors the "Country-aware tax behaviour" prose in the
340
+ * Accounting role prompt (`src/config/roles.ts`). The two MUST
341
+ * stay in sync — drift means the LLM and the form give the user
342
+ * contradictory advice. The prompt is the source of truth for
343
+ * agent behaviour; this table is structured-data sibling for the
344
+ * form. */
345
+ var COUNTRY_FEATURES = {
346
+ /** Show an amber "missing tax ID" warning + helper text on a
347
+ * postable 14xx (input-tax) line whose taxRegistrationId is
348
+ * blank. Limited to jurisdictions where the role prompt
349
+ * explicitly requires the counterparty registration number
350
+ * (JP T-number, EU VAT ID, GB VAT, GSTIN, ABN, NZ GST, CA BN).
351
+ * The "other countries" bucket and US (no federal sales-tax
352
+ * registration) intentionally stay quiet. 24xx output-tax
353
+ * lines don't trigger the warning — see `isTaxAccountCode`. */
354
+ warnMissingTaxRegistrationId: /* @__PURE__ */ new Set([
355
+ "JP",
356
+ "GB",
357
+ "DE",
358
+ "FR",
359
+ "IT",
360
+ "ES",
361
+ "NL",
362
+ "BE",
363
+ "AT",
364
+ "IE",
365
+ "PT",
366
+ "FI",
367
+ "SE",
368
+ "DK",
369
+ "PL",
370
+ "IN",
371
+ "AU",
372
+ "NZ",
373
+ "CA"
374
+ ]) };
375
+ /** Resolve a country-gated feature flag. Returns `false` when the
376
+ * country is undefined / unsupported — components default to the
377
+ * neutral path (no warning, no extra UI) rather than guessing. */
378
+ function countryHasFeature(feature, country) {
379
+ if (!country) return false;
380
+ return COUNTRY_FEATURES[feature].has(country);
381
+ }
382
+ //#endregion
383
+ //#region src/shared/currencies.ts
384
+ /** ISO 4217 codes shown in the New Book dropdown. Curated for
385
+ * recognisability — Intl.DisplayNames provides the localised
386
+ * human name at render time, so this stays a flat list of codes. */
387
+ var SUPPORTED_CURRENCY_CODES = [
388
+ "USD",
389
+ "EUR",
390
+ "JPY",
391
+ "GBP",
392
+ "CNY",
393
+ "KRW",
394
+ "TWD",
395
+ "HKD",
396
+ "SGD",
397
+ "AUD",
398
+ "CAD",
399
+ "CHF",
400
+ "INR",
401
+ "BRL",
402
+ "MXN"
403
+ ];
404
+ var DEFAULT_FALLBACK_DIGITS = 2;
405
+ /** Localised human name for a currency code. Falls back to the
406
+ * code itself if the runtime can't resolve the name. */
407
+ function localizedCurrencyName(code, locale) {
408
+ try {
409
+ return new Intl.DisplayNames([locale], { type: "currency" }).of(code) ?? code;
410
+ } catch {
411
+ return code;
412
+ }
413
+ }
414
+ /** Number of fraction digits ISO 4217 specifies for a currency.
415
+ * JPY = 0, USD = 2, KWD = 3. Used both for amount formatting and
416
+ * for the HTML input step on debit/credit fields. */
417
+ function fractionDigitsFor(currency) {
418
+ try {
419
+ return new Intl.NumberFormat("en", {
420
+ style: "currency",
421
+ currency
422
+ }).resolvedOptions().maximumFractionDigits ?? DEFAULT_FALLBACK_DIGITS;
423
+ } catch {
424
+ return DEFAULT_FALLBACK_DIGITS;
425
+ }
426
+ }
427
+ /** "1" for JPY, "0.01" for USD, "0.001" for KWD. Used as the HTML
428
+ * input step on debit/credit fields so a JPY book doesn't let the
429
+ * user type cents that would just round-trip back through the
430
+ * decimal validator. */
431
+ function inputStepFor(currency) {
432
+ const digits = fractionDigitsFor(currency);
433
+ if (digits === 0) return "1";
434
+ return (1 / 10 ** digits).toFixed(digits);
435
+ }
436
+ /** Locale-aware currency formatter — returns "¥1,130" / "$1,130.00"
437
+ * etc. Falls back to fixed-point formatting if the runtime can't
438
+ * resolve the currency code; the fallback still respects the
439
+ * currency's natural fraction-digit count so JPY shows whole
440
+ * numbers even on the slow path. */
441
+ function formatAmount(value, currency, locale) {
442
+ try {
443
+ return new Intl.NumberFormat(locale, {
444
+ style: "currency",
445
+ currency
446
+ }).format(value);
447
+ } catch {
448
+ return value.toFixed(fractionDigitsFor(currency));
449
+ }
450
+ }
451
+ /** Currency-agnostic amount formatter — "1,130.00" — for places that
452
+ * don't carry the currency code on the data path (compact preview
453
+ * envelopes etc.). Use `formatAmount(value, currency)` whenever the
454
+ * currency IS available — the currency-aware path picks the right
455
+ * fraction-digit count automatically (JPY = 0, USD = 2).
456
+ *
457
+ * `locale` mirrors `formatAmount`'s signature: pass an explicit BCP-47
458
+ * locale (`"en-US"`, `"ja-JP"`, …) when the caller knows the desired
459
+ * grouping / digit-shape; omit to fall back to the runtime default. */
460
+ function formatAmountNumeric(value, decimals = 2, locale) {
461
+ return value.toLocaleString(locale, {
462
+ minimumFractionDigits: decimals,
463
+ maximumFractionDigits: decimals
464
+ });
465
+ }
466
+ //#endregion
467
+ //#region src/shared/dates.ts
468
+ function pad2(num) {
469
+ return String(num).padStart(2, "0");
470
+ }
471
+ /** Today as `YYYY-MM-DD` in the user's local timezone. */
472
+ function localDateString(now = /* @__PURE__ */ new Date()) {
473
+ return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}`;
474
+ }
475
+ /** Current month as `YYYY-MM` in the user's local timezone. */
476
+ function localMonthString(now = /* @__PURE__ */ new Date()) {
477
+ return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}`;
478
+ }
479
+ /** First day of the current calendar year as `YYYY-MM-DD`. */
480
+ function localStartOfYearString(now = /* @__PURE__ */ new Date()) {
481
+ return `${now.getFullYear()}-01-01`;
482
+ }
483
+ /** Previous calendar month as `YYYY-MM` in the user's local timezone. */
484
+ function previousMonthString(now = /* @__PURE__ */ new Date()) {
485
+ const target = new Date(now.getFullYear(), now.getMonth() - 1, 1);
486
+ return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;
487
+ }
488
+ /** Last month of the previous calendar quarter as `YYYY-MM`. Calendar
489
+ * quarters: Q1=Jan–Mar, Q2=Apr–Jun, Q3=Jul–Sep, Q4=Oct–Dec. When the
490
+ * current month is in Q1, this rolls back to December of last year. */
491
+ function lastMonthOfPreviousQuarterString(now = /* @__PURE__ */ new Date()) {
492
+ const firstMonthOfCurrentQuarter = Math.floor(now.getMonth() / 3) * 3;
493
+ const target = new Date(now.getFullYear(), firstMonthOfCurrentQuarter - 1, 1);
494
+ return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;
495
+ }
496
+ /** December of the previous calendar year as `YYYY-MM`. */
497
+ function decemberOfPreviousYearString(now = /* @__PURE__ */ new Date()) {
498
+ return `${now.getFullYear() - 1}-12`;
499
+ }
500
+ //#endregion
501
+ //#region src/shared/timeSeriesEnums.ts
502
+ var TIME_SERIES_METRICS = [
503
+ "revenue",
504
+ "expense",
505
+ "netIncome",
506
+ "accountBalance"
507
+ ];
508
+ var TIME_SERIES_GRANULARITIES = [
509
+ "month",
510
+ "quarter",
511
+ "year"
512
+ ];
513
+ //#endregion
514
+ Object.defineProperty(exports, "ACCOUNTING_ACTIONS", {
515
+ enumerable: true,
516
+ get: function() {
517
+ return ACCOUNTING_ACTIONS;
518
+ }
519
+ });
520
+ Object.defineProperty(exports, "ACCOUNTING_API", {
521
+ enumerable: true,
522
+ get: function() {
523
+ return ACCOUNTING_API;
524
+ }
525
+ });
526
+ Object.defineProperty(exports, "ACCOUNTING_BOOKS_CHANNEL", {
527
+ enumerable: true,
528
+ get: function() {
529
+ return ACCOUNTING_BOOKS_CHANNEL;
530
+ }
531
+ });
532
+ Object.defineProperty(exports, "ACCOUNTING_DIRS", {
533
+ enumerable: true,
534
+ get: function() {
535
+ return ACCOUNTING_DIRS;
536
+ }
537
+ });
538
+ Object.defineProperty(exports, "ACCOUNT_TYPES", {
539
+ enumerable: true,
540
+ get: function() {
541
+ return ACCOUNT_TYPES;
542
+ }
543
+ });
544
+ Object.defineProperty(exports, "BALANCE_SHEET_ACCOUNT_TYPES", {
545
+ enumerable: true,
546
+ get: function() {
547
+ return BALANCE_SHEET_ACCOUNT_TYPES;
548
+ }
549
+ });
550
+ Object.defineProperty(exports, "BOOK_EVENT_KINDS", {
551
+ enumerable: true,
552
+ get: function() {
553
+ return BOOK_EVENT_KINDS;
554
+ }
555
+ });
556
+ Object.defineProperty(exports, "COUNTRY_FEATURES", {
557
+ enumerable: true,
558
+ get: function() {
559
+ return COUNTRY_FEATURES;
560
+ }
561
+ });
562
+ Object.defineProperty(exports, "DEFAULT_FISCAL_YEAR_END", {
563
+ enumerable: true,
564
+ get: function() {
565
+ return DEFAULT_FISCAL_YEAR_END;
566
+ }
567
+ });
568
+ Object.defineProperty(exports, "EU_COUNTRY_CODES", {
569
+ enumerable: true,
570
+ get: function() {
571
+ return EU_COUNTRY_CODES;
572
+ }
573
+ });
574
+ Object.defineProperty(exports, "FISCAL_YEAR_END_MONTHS", {
575
+ enumerable: true,
576
+ get: function() {
577
+ return FISCAL_YEAR_END_MONTHS;
578
+ }
579
+ });
580
+ Object.defineProperty(exports, "SUPPORTED_COUNTRY_CODES", {
581
+ enumerable: true,
582
+ get: function() {
583
+ return SUPPORTED_COUNTRY_CODES;
584
+ }
585
+ });
586
+ Object.defineProperty(exports, "SUPPORTED_CURRENCY_CODES", {
587
+ enumerable: true,
588
+ get: function() {
589
+ return SUPPORTED_CURRENCY_CODES;
590
+ }
591
+ });
592
+ Object.defineProperty(exports, "TIME_SERIES_GRANULARITIES", {
593
+ enumerable: true,
594
+ get: function() {
595
+ return TIME_SERIES_GRANULARITIES;
596
+ }
597
+ });
598
+ Object.defineProperty(exports, "TIME_SERIES_METRICS", {
599
+ enumerable: true,
600
+ get: function() {
601
+ return TIME_SERIES_METRICS;
602
+ }
603
+ });
604
+ Object.defineProperty(exports, "bookChannel", {
605
+ enumerable: true,
606
+ get: function() {
607
+ return bookChannel;
608
+ }
609
+ });
610
+ Object.defineProperty(exports, "countryHasFeature", {
611
+ enumerable: true,
612
+ get: function() {
613
+ return countryHasFeature;
614
+ }
615
+ });
616
+ Object.defineProperty(exports, "currentFiscalYearRange", {
617
+ enumerable: true,
618
+ get: function() {
619
+ return currentFiscalYearRange;
620
+ }
621
+ });
622
+ Object.defineProperty(exports, "currentQuarterRange", {
623
+ enumerable: true,
624
+ get: function() {
625
+ return currentQuarterRange;
626
+ }
627
+ });
628
+ Object.defineProperty(exports, "decemberOfPreviousYearString", {
629
+ enumerable: true,
630
+ get: function() {
631
+ return decemberOfPreviousYearString;
632
+ }
633
+ });
634
+ Object.defineProperty(exports, "errorMessage", {
635
+ enumerable: true,
636
+ get: function() {
637
+ return errorMessage;
638
+ }
639
+ });
640
+ Object.defineProperty(exports, "fiscalYearEndMonth", {
641
+ enumerable: true,
642
+ get: function() {
643
+ return fiscalYearEndMonth;
644
+ }
645
+ });
646
+ Object.defineProperty(exports, "fiscalYearEndMonthLabel", {
647
+ enumerable: true,
648
+ get: function() {
649
+ return fiscalYearEndMonthLabel;
650
+ }
651
+ });
652
+ Object.defineProperty(exports, "formatAmount", {
653
+ enumerable: true,
654
+ get: function() {
655
+ return formatAmount;
656
+ }
657
+ });
658
+ Object.defineProperty(exports, "formatAmountNumeric", {
659
+ enumerable: true,
660
+ get: function() {
661
+ return formatAmountNumeric;
662
+ }
663
+ });
664
+ Object.defineProperty(exports, "fractionDigitsFor", {
665
+ enumerable: true,
666
+ get: function() {
667
+ return fractionDigitsFor;
668
+ }
669
+ });
670
+ Object.defineProperty(exports, "inputStepFor", {
671
+ enumerable: true,
672
+ get: function() {
673
+ return inputStepFor;
674
+ }
675
+ });
676
+ Object.defineProperty(exports, "isFiscalYearEnd", {
677
+ enumerable: true,
678
+ get: function() {
679
+ return isFiscalYearEnd;
680
+ }
681
+ });
682
+ Object.defineProperty(exports, "isSupportedCountryCode", {
683
+ enumerable: true,
684
+ get: function() {
685
+ return isSupportedCountryCode;
686
+ }
687
+ });
688
+ Object.defineProperty(exports, "lastMonthOfPreviousQuarterString", {
689
+ enumerable: true,
690
+ get: function() {
691
+ return lastMonthOfPreviousQuarterString;
692
+ }
693
+ });
694
+ Object.defineProperty(exports, "localDateString", {
695
+ enumerable: true,
696
+ get: function() {
697
+ return localDateString;
698
+ }
699
+ });
700
+ Object.defineProperty(exports, "localMonthString", {
701
+ enumerable: true,
702
+ get: function() {
703
+ return localMonthString;
704
+ }
705
+ });
706
+ Object.defineProperty(exports, "localStartOfYearString", {
707
+ enumerable: true,
708
+ get: function() {
709
+ return localStartOfYearString;
710
+ }
711
+ });
712
+ Object.defineProperty(exports, "localizedCountryName", {
713
+ enumerable: true,
714
+ get: function() {
715
+ return localizedCountryName;
716
+ }
717
+ });
718
+ Object.defineProperty(exports, "localizedCurrencyName", {
719
+ enumerable: true,
720
+ get: function() {
721
+ return localizedCurrencyName;
722
+ }
723
+ });
724
+ Object.defineProperty(exports, "previousFiscalYearRange", {
725
+ enumerable: true,
726
+ get: function() {
727
+ return previousFiscalYearRange;
728
+ }
729
+ });
730
+ Object.defineProperty(exports, "previousMonthString", {
731
+ enumerable: true,
732
+ get: function() {
733
+ return previousMonthString;
734
+ }
735
+ });
736
+ Object.defineProperty(exports, "previousQuarterRange", {
737
+ enumerable: true,
738
+ get: function() {
739
+ return previousQuarterRange;
740
+ }
741
+ });
742
+ Object.defineProperty(exports, "resolveFiscalYearEnd", {
743
+ enumerable: true,
744
+ get: function() {
745
+ return resolveFiscalYearEnd;
746
+ }
747
+ });
748
+
749
+ //# sourceMappingURL=shared-CcU3_qAa.cjs.map