@mulmoclaude/accounting-plugin 0.2.0 → 0.3.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.
- package/dist/server/io.d.ts.map +1 -1
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/service.d.ts +2 -2
- package/dist/server/service.d.ts.map +1 -1
- package/dist/server/types.d.ts +7 -6
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server.cjs +59 -21
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +60 -22
- package/dist/server.js.map +1 -1
- package/dist/shared/fiscalYear.d.ts +19 -8
- package/dist/shared/fiscalYear.d.ts.map +1 -1
- package/dist/shared.cjs +55 -17
- package/dist/shared.cjs.map +1 -1
- package/dist/shared.js +54 -17
- package/dist/shared.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/vue/api.d.ts +10 -10
- package/dist/vue/api.d.ts.map +1 -1
- package/dist/vue/components/BookSettings.vue.d.ts.map +1 -1
- package/dist/vue/components/NewBookForm.vue.d.ts.map +1 -1
- package/dist/vue/lang/de.d.ts.map +1 -1
- package/dist/vue/lang/en.d.ts +0 -4
- package/dist/vue/lang/en.d.ts.map +1 -1
- package/dist/vue/lang/es.d.ts.map +1 -1
- package/dist/vue/lang/fr.d.ts.map +1 -1
- package/dist/vue/lang/index.d.ts +0 -4
- package/dist/vue/lang/index.d.ts.map +1 -1
- package/dist/vue/lang/ja.d.ts.map +1 -1
- package/dist/vue/lang/ko.d.ts.map +1 -1
- package/dist/vue/lang/ptBR.d.ts.map +1 -1
- package/dist/vue/lang/zh.d.ts.map +1 -1
- package/dist/vue.cjs +16 -48
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.js +17 -49
- package/dist/vue.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export type FiscalYearEnd = (typeof
|
|
1
|
+
export declare const FISCAL_YEAR_END_MONTHS: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
2
|
+
export type FiscalYearEnd = (typeof FISCAL_YEAR_END_MONTHS)[number];
|
|
3
3
|
export declare const DEFAULT_FISCAL_YEAR_END: FiscalYearEnd;
|
|
4
4
|
export declare function isFiscalYearEnd(value: unknown): value is FiscalYearEnd;
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare function
|
|
5
|
+
/** Normalise any stored / inbound value to a concrete closing month.
|
|
6
|
+
* Absent or unrecognised → the default (December); a legacy "Q1".."Q4"
|
|
7
|
+
* token → its closing month; a valid 1-12 number → itself. Kept
|
|
8
|
+
* tolerant (unknown input) so a legacy book read from disk — or shared
|
|
9
|
+
* with an older MulmoTerminal — never breaks the UI or a report. */
|
|
10
|
+
export declare function resolveFiscalYearEnd(value: unknown): FiscalYearEnd;
|
|
11
|
+
/** Last calendar month (1-12) of the fiscal year. The stored token IS
|
|
12
|
+
* the closing month now, so this reads as `resolveFiscalYearEnd` under
|
|
13
|
+
* a name that states intent at the call sites (and still absorbs a
|
|
14
|
+
* stray legacy token defensively). */
|
|
15
|
+
export declare function fiscalYearEndMonth(end: FiscalYearEnd): number;
|
|
16
|
+
/** Localised label for a fiscal-year-end month, showing that month's
|
|
17
|
+
* last day — e.g. 8 → "August 31" / "8月31日" / "31 de agosto". Uses a
|
|
18
|
+
* fixed non-leap reference year, so February reads as the 28th; this
|
|
19
|
+
* is display only — the engine still computes the real last day
|
|
20
|
+
* (Feb 29 in a leap year) at runtime. */
|
|
21
|
+
export declare function fiscalYearEndMonthLabel(month: FiscalYearEnd, locale: string): string;
|
|
11
22
|
export interface DateRange {
|
|
12
23
|
/** Inclusive lower bound (YYYY-MM-DD). Empty string = unbounded. */
|
|
13
24
|
from: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fiscalYear.d.ts","sourceRoot":"","sources":["../../src/shared/fiscalYear.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fiscalYear.d.ts","sourceRoot":"","sources":["../../src/shared/fiscalYear.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,sBAAsB,kDAAmD,CAAC;AACvF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,eAAO,MAAM,uBAAuB,EAAE,aAAkB,CAAC;AAMzD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;qEAIqE;AACrE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAIlE;AAED;;;uCAGuC;AACvC,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAE7D;AAED;;;;0CAI0C;AAC1C,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUpF;AAED,MAAM,WAAW,SAAS;IACxB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;CACZ;AA8DD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,GAAE,IAAiB,GAAG,SAAS,CAE3F;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,GAAE,IAAiB,GAAG,SAAS,CAQ5F;AAED,uDAAuD;AACvD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,GAAE,IAAiB,GAAG,SAAS,CAI9F;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,GAAE,IAAiB,GAAG,SAAS,CAI/F"}
|
package/dist/shared.cjs
CHANGED
|
@@ -85,28 +85,65 @@ var ACCOUNTING_DIRS = {
|
|
|
85
85
|
};
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region src/shared/fiscalYear.ts
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
var FISCAL_YEAR_END_MONTHS = [
|
|
89
|
+
1,
|
|
90
|
+
2,
|
|
91
|
+
3,
|
|
92
|
+
4,
|
|
93
|
+
5,
|
|
94
|
+
6,
|
|
95
|
+
7,
|
|
96
|
+
8,
|
|
97
|
+
9,
|
|
98
|
+
10,
|
|
99
|
+
11,
|
|
100
|
+
12
|
|
93
101
|
];
|
|
94
|
-
var DEFAULT_FISCAL_YEAR_END =
|
|
102
|
+
var DEFAULT_FISCAL_YEAR_END = 12;
|
|
103
|
+
/** Legacy calendar-quarter tokens → closing month, for books written
|
|
104
|
+
* before the field became a month number. */
|
|
105
|
+
var LEGACY_QUARTER_MONTHS = {
|
|
106
|
+
Q1: 3,
|
|
107
|
+
Q2: 6,
|
|
108
|
+
Q3: 9,
|
|
109
|
+
Q4: 12
|
|
110
|
+
};
|
|
95
111
|
function isFiscalYearEnd(value) {
|
|
96
|
-
return typeof value === "
|
|
112
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 12;
|
|
97
113
|
}
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
114
|
+
/** Normalise any stored / inbound value to a concrete closing month.
|
|
115
|
+
* Absent or unrecognised → the default (December); a legacy "Q1".."Q4"
|
|
116
|
+
* token → its closing month; a valid 1-12 number → itself. Kept
|
|
117
|
+
* tolerant (unknown input) so a legacy book read from disk — or shared
|
|
118
|
+
* with an older MulmoTerminal — never breaks the UI or a report. */
|
|
101
119
|
function resolveFiscalYearEnd(value) {
|
|
102
|
-
|
|
120
|
+
if (isFiscalYearEnd(value)) return value;
|
|
121
|
+
if (typeof value === "string" && Object.hasOwn(LEGACY_QUARTER_MONTHS, value)) return LEGACY_QUARTER_MONTHS[value];
|
|
122
|
+
return 12;
|
|
103
123
|
}
|
|
104
|
-
/** Last calendar month (1-12) of the fiscal year
|
|
124
|
+
/** Last calendar month (1-12) of the fiscal year. The stored token IS
|
|
125
|
+
* the closing month now, so this reads as `resolveFiscalYearEnd` under
|
|
126
|
+
* a name that states intent at the call sites (and still absorbs a
|
|
127
|
+
* stray legacy token defensively). */
|
|
105
128
|
function fiscalYearEndMonth(end) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
129
|
+
return resolveFiscalYearEnd(end);
|
|
130
|
+
}
|
|
131
|
+
/** Localised label for a fiscal-year-end month, showing that month's
|
|
132
|
+
* last day — e.g. 8 → "August 31" / "8月31日" / "31 de agosto". Uses a
|
|
133
|
+
* fixed non-leap reference year, so February reads as the 28th; this
|
|
134
|
+
* is display only — the engine still computes the real last day
|
|
135
|
+
* (Feb 29 in a leap year) at runtime. */
|
|
136
|
+
function fiscalYearEndMonthLabel(month, locale) {
|
|
137
|
+
const lastDay = new Date(Date.UTC(2001, month, 0));
|
|
138
|
+
try {
|
|
139
|
+
return new Intl.DateTimeFormat(locale, {
|
|
140
|
+
month: "long",
|
|
141
|
+
day: "numeric",
|
|
142
|
+
timeZone: "UTC"
|
|
143
|
+
}).format(lastDay);
|
|
144
|
+
} catch {
|
|
145
|
+
return String(month);
|
|
146
|
+
}
|
|
110
147
|
}
|
|
111
148
|
function pad2$1(num) {
|
|
112
149
|
return String(num).padStart(2, "0");
|
|
@@ -450,7 +487,7 @@ exports.BOOK_EVENT_KINDS = BOOK_EVENT_KINDS;
|
|
|
450
487
|
exports.COUNTRY_FEATURES = COUNTRY_FEATURES;
|
|
451
488
|
exports.DEFAULT_FISCAL_YEAR_END = DEFAULT_FISCAL_YEAR_END;
|
|
452
489
|
exports.EU_COUNTRY_CODES = EU_COUNTRY_CODES;
|
|
453
|
-
exports.
|
|
490
|
+
exports.FISCAL_YEAR_END_MONTHS = FISCAL_YEAR_END_MONTHS;
|
|
454
491
|
exports.SUPPORTED_COUNTRY_CODES = SUPPORTED_COUNTRY_CODES;
|
|
455
492
|
exports.SUPPORTED_CURRENCY_CODES = SUPPORTED_CURRENCY_CODES;
|
|
456
493
|
exports.TIME_SERIES_GRANULARITIES = TIME_SERIES_GRANULARITIES;
|
|
@@ -462,6 +499,7 @@ exports.currentQuarterRange = currentQuarterRange;
|
|
|
462
499
|
exports.decemberOfPreviousYearString = decemberOfPreviousYearString;
|
|
463
500
|
exports.errorMessage = errorMessage;
|
|
464
501
|
exports.fiscalYearEndMonth = fiscalYearEndMonth;
|
|
502
|
+
exports.fiscalYearEndMonthLabel = fiscalYearEndMonthLabel;
|
|
465
503
|
exports.formatAmount = formatAmount;
|
|
466
504
|
exports.formatAmountNumeric = formatAmountNumeric;
|
|
467
505
|
exports.fractionDigitsFor = fractionDigitsFor;
|
package/dist/shared.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.cjs","names":[],"sources":["../src/shared/actions.ts","../src/shared/api.ts","../src/shared/channels.ts","../src/shared/errors.ts","../src/shared/paths.ts","../src/shared/fiscalYear.ts","../src/shared/countries.ts","../src/shared/currencies.ts","../src/shared/dates.ts","../src/shared/timeSeriesEnums.ts"],"sourcesContent":["// Single source of truth for the manageAccounting LLM-facing action\n// names. Used by:\n// - definition.ts (the JSON-schema action enum exposed to the LLM)\n// - api.ts (the View's REST helpers — `call(action, args)`)\n// - server/api/routes/accounting.ts (handler-table keys, PREVIEW\n// and MESSAGE_BUILDERS membership)\n// - e2e/fixtures/accounting.ts (mock dispatcher's handler-table)\n//\n// Stays in its own module so server-side callers can import the\n// const without pulling in apiPost / Vue plumbing from `api.ts`.\n//\n// CLAUDE.md \"no magic literals — use existing `as const` objects\"\n// applies here: never reference an action by raw string at any of\n// the call sites above.\n\nexport const ACCOUNTING_ACTIONS = {\n openBook: \"openBook\",\n getBooks: \"getBooks\",\n createBook: \"createBook\",\n updateBook: \"updateBook\",\n deleteBook: \"deleteBook\",\n getAccounts: \"getAccounts\",\n upsertAccount: \"upsertAccount\",\n addEntries: \"addEntries\",\n voidEntry: \"voidEntry\",\n getJournalEntries: \"getJournalEntries\",\n getOpeningBalances: \"getOpeningBalances\",\n setOpeningBalances: \"setOpeningBalances\",\n getReport: \"getReport\",\n getTimeSeries: \"getTimeSeries\",\n rebuildSnapshots: \"rebuildSnapshots\",\n} as const;\n\nexport type AccountingAction = (typeof ACCOUNTING_ACTIONS)[keyof typeof ACCOUNTING_ACTIONS];\n","// Single source of truth for the accounting REST contract — the one\n// dispatch route the plugin owns. Consumed by BOTH the Vue api client\n// (./vue/api.ts) and the server router (./server/router.ts) so the path\n// can't drift between them. Mirrors the host META's\n// `{ apiNamespace: \"accounting\", dispatch: { method: \"POST\", path: \"\" } }`\n// resolved to a full URL.\n//\n// (CLAUDE.md: API routes go through `as const` objects, never hardcoded\n// strings at the call site.)\n\nexport const ACCOUNTING_API = {\n dispatch: {\n path: \"/api/accounting\",\n method: \"POST\",\n },\n} as const;\n","// Per-book event-stream contract for the accounting plugin — the\n// reusable channel-name factory + event-kind enum + payload shape.\n// Single source of truth for both publishers (the package's server\n// surface, `eventPublisher`) and subscribers (the Vue View's\n// `useAccountingChannel`), so anyone branching on event kind imports\n// from here and the type system catches drift on either side.\n//\n// Lives in the package's `./shared` (browser-safe) rather than the\n// host META because the backend needs it too — keeping it host-side\n// would force an uphill import. The host-wiring META (toolName /\n// apiNamespace / workspaceDirs / staticChannels) stays in the host's\n// `src/plugins/accounting/meta.ts` so the plugin-barrel codegen\n// discovers it.\n//\n// Browser-safe: no Vue imports, no server-only imports.\n\n/** Channel factory for per-book event streams. Subscribers:\n * `useAccountingChannel(bookId)`. Publisher: the package's server\n * surface `eventPublisher`. */\nexport function bookChannel(bookId: string): string {\n return `accounting:${bookId}`;\n}\n\n/** Book-list-level channel — a book was created / deleted. Subscribers\n * refetch the BookSwitcher dropdown. Mirrors the host META's\n * `staticChannels.accountingBooks` literal (kept in sync by value;\n * the host META stays the codegen-discoverable source for the\n * aggregator merge). */\nexport const ACCOUNTING_BOOKS_CHANNEL = \"accounting:books\";\n\n/** Event kinds that ride `bookChannel(bookId)`. Single source of\n * truth for both publishers (server/accounting) and subscribers\n * (the View) — anyone branching on event kind imports from here\n * and the type system catches drift on either side.\n *\n * - `journal` — addEntry / voidEntry hit the books at `period`.\n * Refetch the journal list and (if the View is\n * showing balances at or after `period`) the\n * relevant report.\n * - `opening` — setOpeningBalances. Affects every period from\n * the opening date forward; refetch everything.\n * - `accounts` — chart-of-accounts mutation that may affect\n * aggregation (account type changed). Refetch\n * accounts and the active report.\n * - `snapshotsRebuilding` / `snapshotsReady` — purely informational;\n * the View can show a \"calculating\" spinner\n * during rebuild, but the lazy-rebuild safety\n * net means a refetch always returns the right\n * answer regardless. */\nexport const BOOK_EVENT_KINDS = {\n journal: \"journal\",\n opening: \"opening\",\n accounts: \"accounts\",\n snapshotsRebuilding: \"snapshots-rebuilding\",\n snapshotsReady: \"snapshots-ready\",\n} as const;\n\nexport type BookEventKind = (typeof BOOK_EVENT_KINDS)[keyof typeof BOOK_EVENT_KINDS];\n\n/** Payload published on `bookChannel(bookId)`. */\nexport interface BookChannelPayload {\n kind: BookEventKind;\n /** YYYY-MM. Present for `journal` (entry month) and the snapshot\n * events (the earliest invalidated month). Absent for `opening`\n * (which invalidates everything) and `accounts`. */\n period?: string;\n}\n","// Normalise an unknown thrown value into a human-readable string.\n// Isomorphic (used by both the Vue surface and the server surface) so\n// it lives in ./shared. Mirrors the host's `src/utils/errors.ts`\n// `errorMessage` — kept in the package so neither surface reaches\n// uphill into the host for it.\n\nexport function errorMessage(err: unknown, fallback?: string): string {\n if (err instanceof Error) return err.message;\n if (err !== null && typeof err === \"object\") {\n const obj = err as { details?: unknown; message?: unknown };\n if (typeof obj.details === \"string\" && obj.details) return obj.details;\n if (typeof obj.message === \"string\" && obj.message) return obj.message;\n }\n if (fallback !== undefined) return fallback;\n return String(err);\n}\n","// Workspace-relative directories this plugin owns. Single source of\n// truth, consumed by BOTH the server io layer (./server/io.ts) and the\n// host META (src/plugins/accounting/meta.ts → the WORKSPACE_DIRS\n// aggregator), so the on-disk layout can't drift between the backend\n// and the rest of the app.\n//\n// Browser-safe: no node:* imports.\n\nexport const ACCOUNTING_DIRS = {\n /** `data/accounting/config.json` + the books tree below. */\n accounting: \"data/accounting\",\n /** `data/accounting/books/<bookId>/{accounts.json, journal/, snapshots/}`. */\n accountingBooks: \"data/accounting/books\",\n} as const;\n","// Fiscal-year arithmetic for the accounting plugin.\n//\n// Each book stores a `fiscalYearEnd` token (Q1..Q4) that says which\n// calendar-quarter end is the book's fiscal year end:\n//\n// Q1 → fiscal year ends March 31 (FY runs Apr 1 → Mar 31)\n// Q2 → fiscal year ends June 30 (FY runs Jul 1 → Jun 30)\n// Q3 → fiscal year ends September 30 (FY runs Oct 1 → Sep 30)\n// Q4 → fiscal year ends December 31 (FY runs Jan 1 → Dec 31; default)\n//\n// \"Current quarter\" / \"current year\" everywhere in the UI refer to\n// the *fiscal* quarter / *fiscal* year that contains today, under the\n// active book's `fiscalYearEnd`. For Q4 books fiscal quarters and\n// fiscal years coincide with calendar quarters / calendar years; for\n// the other three a shift applies.\n//\n// All helpers return `YYYY-MM-DD` strings in the user's local\n// timezone — same convention as `dates.ts`.\n\nexport const FISCAL_YEAR_ENDS = [\"Q1\", \"Q2\", \"Q3\", \"Q4\"] as const;\nexport type FiscalYearEnd = (typeof FISCAL_YEAR_ENDS)[number];\n\nexport const DEFAULT_FISCAL_YEAR_END: FiscalYearEnd = \"Q4\";\n\nexport function isFiscalYearEnd(value: unknown): value is FiscalYearEnd {\n return typeof value === \"string\" && (FISCAL_YEAR_ENDS as readonly string[]).includes(value);\n}\n\n/** Books written before the field existed are treated as Q4 in code\n * but never auto-rewritten on disk. The settings UI persists through\n * the field the next time the user saves anything on the book. */\nexport function resolveFiscalYearEnd(value: FiscalYearEnd | undefined): FiscalYearEnd {\n return value ?? DEFAULT_FISCAL_YEAR_END;\n}\n\n/** Last calendar month (1-12) of the fiscal year for the given Q. */\nexport function fiscalYearEndMonth(end: FiscalYearEnd): 3 | 6 | 9 | 12 {\n if (end === \"Q1\") return 3;\n if (end === \"Q2\") return 6;\n if (end === \"Q3\") return 9;\n return 12;\n}\n\nexport interface DateRange {\n /** Inclusive lower bound (YYYY-MM-DD). Empty string = unbounded. */\n from: string;\n /** Inclusive upper bound (YYYY-MM-DD). Empty string = unbounded. */\n to: string;\n}\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\nfunction lastDayOfMonth(year: number, monthZeroBased: number): number {\n // Day 0 of next month = last day of this month, all in local time.\n return new Date(year, monthZeroBased + 1, 0).getDate();\n}\n\nfunction ymd(year: number, monthOneBased: number, day: number): string {\n return `${year}-${pad2(monthOneBased)}-${pad2(day)}`;\n}\n\n/** Fiscal quarter index (0..3) of the given local date under `end`,\n * where 0 is the first quarter of the fiscal year (right after the\n * prior year's close) and 3 is the closing quarter. */\nfunction fiscalQuarterIndex(end: FiscalYearEnd, today: Date): number {\n const closingMonth = fiscalYearEndMonth(end); // 1-based\n const month = today.getMonth() + 1; // 1-based local month\n // Months past the close of the prior fiscal year, mod 12.\n const offset = (month - closingMonth - 1 + 12) % 12;\n return Math.floor(offset / 3);\n}\n\n/** Calendar (year, monthOneBased) of the *first* month of the fiscal\n * quarter at index `index` in the fiscal year that *contains*\n * `today`. Returned both as the first day of that month and as the\n * count of months covered (always 3 — exposed as a constant). */\nfunction fiscalQuarterStart(end: FiscalYearEnd, today: Date, index: number): { year: number; month: number } {\n const closingMonth = fiscalYearEndMonth(end);\n const todayMonth = today.getMonth() + 1;\n const todayYear = today.getFullYear();\n // Month after the close of the prior fiscal year — fiscal-year start month.\n const startMonth = (closingMonth % 12) + 1;\n // The fiscal year that contains `today` started in the calendar\n // year ≤ today's year. Specifically: if today's calendar month is\n // ≥ startMonth (or startMonth is 1, which is the Q4 case), the FY\n // started this calendar year; otherwise it started last year.\n const fyStartYear = todayMonth >= startMonth ? todayYear : todayYear - 1;\n // Month of the requested fiscal quarter's first month, expressed\n // as a 1-based offset from January of fyStartYear.\n const flatMonth = startMonth + index * 3; // 1-based, may exceed 12\n const year = fyStartYear + Math.floor((flatMonth - 1) / 12);\n const month = ((flatMonth - 1) % 12) + 1;\n return { year, month };\n}\n\nfunction quarterRangeAt(end: FiscalYearEnd, today: Date, index: number): DateRange {\n const start = fiscalQuarterStart(end, today, index);\n // Quarter spans 3 calendar months starting at `start`.\n const lastMonthFlat = start.month - 1 + 2; // 0-based offset of the third month\n const lastMonthYear = start.year + Math.floor(lastMonthFlat / 12);\n const lastMonth = (lastMonthFlat % 12) + 1; // 1-based\n const lastDay = lastDayOfMonth(lastMonthYear, lastMonth - 1);\n return {\n from: ymd(start.year, start.month, 1),\n to: ymd(lastMonthYear, lastMonth, lastDay),\n };\n}\n\nexport function currentQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n return quarterRangeAt(end, today, fiscalQuarterIndex(end, today));\n}\n\nexport function previousQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const idx = fiscalQuarterIndex(end, today);\n if (idx > 0) return quarterRangeAt(end, today, idx - 1);\n // Wrap to Q4 of the prior fiscal year. Step `today` back 3 months\n // — that lands inside the prior fiscal year regardless of `end`,\n // and Q4 (closing) is index 3 within whichever FY contains it.\n const stepped = new Date(today.getFullYear(), today.getMonth() - 3, 1);\n return quarterRangeAt(end, stepped, 3);\n}\n\n/** Current fiscal year — Q0 start through Q3 close. */\nexport function currentFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const first = quarterRangeAt(end, today, 0);\n const last = quarterRangeAt(end, today, 3);\n return { from: first.from, to: last.to };\n}\n\nexport function previousFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n // Step a year back so `quarterRangeAt` resolves the prior FY.\n const stepped = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());\n return currentFiscalYearRange(end, stepped);\n}\n","// Country utilities for the accounting plugin.\n//\n// The book's country (ISO 3166-1 alpha-2) identifies the tax\n// jurisdiction the book is kept under. The Accounting role uses it\n// to give country-aware advice — Japanese T-number under\n// インボイス制度, EU VAT ID, UK VAT, GSTIN, ABN, etc.\n//\n// Curated against the supported currency list and the tax-regime\n// guidance in `src/config/roles.ts` (Accounting role prompt).\n// Intl.DisplayNames provides the localized human name at render\n// time, so this stays a flat list of codes.\n\n/** ISO 3166-1 alpha-2 country codes shown in the book country\n * dropdown. Curated to cover every jurisdiction the Accounting role\n * has explicit tax-registration advice for, plus the major economies\n * represented in `SUPPORTED_CURRENCY_CODES`. */\nexport const SUPPORTED_COUNTRY_CODES = [\n \"US\",\n \"JP\",\n \"GB\",\n \"CA\",\n \"AU\",\n \"NZ\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"CH\",\n \"NO\",\n \"CN\",\n \"KR\",\n \"TW\",\n \"HK\",\n \"SG\",\n \"IN\",\n \"BR\",\n \"MX\",\n] as const;\n\nexport type SupportedCountryCode = (typeof SUPPORTED_COUNTRY_CODES)[number];\n\n/** EU member states as of 2026. Used by the role-prompt advice path\n * to recommend a VAT identification number when the book country is\n * in the EU. */\nexport const EU_COUNTRY_CODES: ReadonlySet<string> = new Set([\n \"AT\",\n \"BE\",\n \"BG\",\n \"CY\",\n \"CZ\",\n \"DE\",\n \"DK\",\n \"EE\",\n \"ES\",\n \"FI\",\n \"FR\",\n \"GR\",\n \"HR\",\n \"HU\",\n \"IE\",\n \"IT\",\n \"LT\",\n \"LU\",\n \"LV\",\n \"MT\",\n \"NL\",\n \"PL\",\n \"PT\",\n \"RO\",\n \"SE\",\n \"SI\",\n \"SK\",\n]);\n\n/** Localized human name for a country code. Falls back to the code\n * itself if the runtime can't resolve the name. */\nexport function localizedCountryName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"region\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Runtime guard for `BookSummary.country`. The type is the union\n * `SupportedCountryCode`, but every entry point that takes user /\n * LLM input arrives as raw `string` (form submit, JSON-RPC body),\n * so the service layer narrows here before persisting. */\nexport function isSupportedCountryCode(value: unknown): value is SupportedCountryCode {\n return typeof value === \"string\" && (SUPPORTED_COUNTRY_CODES as readonly string[]).includes(value);\n}\n\n/** Country-gated UI features. Each key is a feature name; the value\n * is the set of country codes for which the feature is enabled.\n * Components ask `countryHasFeature(\"...\", country)` instead of\n * hard-coding country lists at the call site.\n *\n * Add a new country-specific feature by adding a new key here and\n * reading it via `countryHasFeature`. An unknown / undefined\n * country never has any feature — components fall back to neutral\n * default UI rather than guessing.\n *\n * Mirrors the \"Country-aware tax behaviour\" prose in the\n * Accounting role prompt (`src/config/roles.ts`). The two MUST\n * stay in sync — drift means the LLM and the form give the user\n * contradictory advice. The prompt is the source of truth for\n * agent behaviour; this table is structured-data sibling for the\n * form. */\nexport const COUNTRY_FEATURES = {\n /** Show an amber \"missing tax ID\" warning + helper text on a\n * postable 14xx (input-tax) line whose taxRegistrationId is\n * blank. Limited to jurisdictions where the role prompt\n * explicitly requires the counterparty registration number\n * (JP T-number, EU VAT ID, GB VAT, GSTIN, ABN, NZ GST, CA BN).\n * The \"other countries\" bucket and US (no federal sales-tax\n * registration) intentionally stay quiet. 24xx output-tax\n * lines don't trigger the warning — see `isTaxAccountCode`. */\n warnMissingTaxRegistrationId: new Set<SupportedCountryCode>([\n \"JP\",\n \"GB\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"IN\",\n \"AU\",\n \"NZ\",\n \"CA\",\n ]),\n} as const;\n\nexport type CountryFeature = keyof typeof COUNTRY_FEATURES;\n\n/** Resolve a country-gated feature flag. Returns `false` when the\n * country is undefined / unsupported — components default to the\n * neutral path (no warning, no extra UI) rather than guessing. */\nexport function countryHasFeature(feature: CountryFeature, country: SupportedCountryCode | undefined): boolean {\n if (!country) return false;\n return COUNTRY_FEATURES[feature].has(country);\n}\n","// Currency utilities for the accounting plugin.\n//\n// We expose a curated list of ISO 4217 codes for the New Book\n// dropdown — covering the major reserve currencies plus the most\n// requested Asian / regional ones — plus per-currency formatting\n// helpers built on Intl.NumberFormat.\n//\n// The book's currency is per-book metadata (BookSummary.currency)\n// and only matters once the user has opened the book; cross-book\n// aggregation isn't supported.\n\n/** ISO 4217 codes shown in the New Book dropdown. Curated for\n * recognisability — Intl.DisplayNames provides the localised\n * human name at render time, so this stays a flat list of codes. */\nexport const SUPPORTED_CURRENCY_CODES = [\"USD\", \"EUR\", \"JPY\", \"GBP\", \"CNY\", \"KRW\", \"TWD\", \"HKD\", \"SGD\", \"AUD\", \"CAD\", \"CHF\", \"INR\", \"BRL\", \"MXN\"] as const;\n\nexport type SupportedCurrencyCode = (typeof SUPPORTED_CURRENCY_CODES)[number];\n\nconst DEFAULT_FALLBACK_DIGITS = 2;\n\n/** Localised human name for a currency code. Falls back to the\n * code itself if the runtime can't resolve the name. */\nexport function localizedCurrencyName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"currency\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Number of fraction digits ISO 4217 specifies for a currency.\n * JPY = 0, USD = 2, KWD = 3. Used both for amount formatting and\n * for the HTML input step on debit/credit fields. */\nexport function fractionDigitsFor(currency: string): number {\n try {\n const opts = new Intl.NumberFormat(\"en\", { style: \"currency\", currency }).resolvedOptions();\n return opts.maximumFractionDigits ?? DEFAULT_FALLBACK_DIGITS;\n } catch {\n return DEFAULT_FALLBACK_DIGITS;\n }\n}\n\n/** \"1\" for JPY, \"0.01\" for USD, \"0.001\" for KWD. Used as the HTML\n * input step on debit/credit fields so a JPY book doesn't let the\n * user type cents that would just round-trip back through the\n * decimal validator. */\nexport function inputStepFor(currency: string): string {\n const digits = fractionDigitsFor(currency);\n if (digits === 0) return \"1\";\n return (1 / 10 ** digits).toFixed(digits);\n}\n\n/** Locale-aware currency formatter — returns \"¥1,130\" / \"$1,130.00\"\n * etc. Falls back to fixed-point formatting if the runtime can't\n * resolve the currency code; the fallback still respects the\n * currency's natural fraction-digit count so JPY shows whole\n * numbers even on the slow path. */\nexport function formatAmount(value: number, currency: string, locale?: string): string {\n try {\n return new Intl.NumberFormat(locale, { style: \"currency\", currency }).format(value);\n } catch {\n return value.toFixed(fractionDigitsFor(currency));\n }\n}\n\n/** Currency-agnostic amount formatter — \"1,130.00\" — for places that\n * don't carry the currency code on the data path (compact preview\n * envelopes etc.). Use `formatAmount(value, currency)` whenever the\n * currency IS available — the currency-aware path picks the right\n * fraction-digit count automatically (JPY = 0, USD = 2).\n *\n * `locale` mirrors `formatAmount`'s signature: pass an explicit BCP-47\n * locale (`\"en-US\"`, `\"ja-JP\"`, …) when the caller knows the desired\n * grouping / digit-shape; omit to fall back to the runtime default. */\nexport function formatAmountNumeric(value: number, decimals = 2, locale?: string): string {\n return value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n}\n","// Local-calendar date helpers for the accounting forms.\n//\n// Why not `new Date().toISOString().slice(0, 10)`? `toISOString` is\n// UTC. In a negative-offset zone (US Pacific, Eastern, …) the UTC\n// date crosses to \"tomorrow\" several hours before midnight local,\n// so a naively prefilled date input would post entries into the\n// wrong accounting day. Same mistake near month boundaries flips\n// the default Balance Sheet period to the next month.\n//\n// All four helpers below are pure local-calendar formatters built\n// from `getFullYear` / `getMonth` / `getDate`, which the JS engine\n// resolves in the user's local timezone.\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\n/** Today as `YYYY-MM-DD` in the user's local timezone. */\nexport function localDateString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}`;\n}\n\n/** Current month as `YYYY-MM` in the user's local timezone. */\nexport function localMonthString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}`;\n}\n\n/** First day of the current calendar year as `YYYY-MM-DD`. */\nexport function localStartOfYearString(now: Date = new Date()): string {\n return `${now.getFullYear()}-01-01`;\n}\n\n/** Previous calendar month as `YYYY-MM` in the user's local timezone. */\nexport function previousMonthString(now: Date = new Date()): string {\n const target = new Date(now.getFullYear(), now.getMonth() - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** Last month of the previous calendar quarter as `YYYY-MM`. Calendar\n * quarters: Q1=Jan–Mar, Q2=Apr–Jun, Q3=Jul–Sep, Q4=Oct–Dec. When the\n * current month is in Q1, this rolls back to December of last year. */\nexport function lastMonthOfPreviousQuarterString(now: Date = new Date()): string {\n const firstMonthOfCurrentQuarter = Math.floor(now.getMonth() / 3) * 3;\n const target = new Date(now.getFullYear(), firstMonthOfCurrentQuarter - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** December of the previous calendar year as `YYYY-MM`. */\nexport function decemberOfPreviousYearString(now: Date = new Date()): string {\n return `${now.getFullYear() - 1}-12`;\n}\n","// Single source of truth for the `getTimeSeries` action's enum\n// surfaces — kept outside the server module so the frontend tool\n// definition (`definition.ts`) and the server validator\n// (`server/accounting/timeSeries.ts`) can both import without\n// crossing the src ↔ server boundary in the wrong direction.\n//\n// Adding a new metric / granularity: extend the array here, then\n// extend the corresponding switch / aggregation in\n// `server/accounting/timeSeries.ts`. The LLM tool schema picks up\n// the new value automatically via `definition.ts`'s `enum` field.\n\nexport const TIME_SERIES_METRICS = [\"revenue\", \"expense\", \"netIncome\", \"accountBalance\"] as const;\nexport type TimeSeriesMetric = (typeof TIME_SERIES_METRICS)[number];\n\nexport const TIME_SERIES_GRANULARITIES = [\"month\", \"quarter\", \"year\"] as const;\nexport type TimeSeriesGranularity = (typeof TIME_SERIES_GRANULARITIES)[number];\n"],"mappings":";;AAeA,IAAa,qBAAqB;CAChC,UAAU;CACV,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,YA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;AAGvF,IAAa,4BAA4B;CAAC;CAAS;CAAW;AAAM"}
|
|
1
|
+
{"version":3,"file":"shared.cjs","names":[],"sources":["../src/shared/actions.ts","../src/shared/api.ts","../src/shared/channels.ts","../src/shared/errors.ts","../src/shared/paths.ts","../src/shared/fiscalYear.ts","../src/shared/countries.ts","../src/shared/currencies.ts","../src/shared/dates.ts","../src/shared/timeSeriesEnums.ts"],"sourcesContent":["// Single source of truth for the manageAccounting LLM-facing action\n// names. Used by:\n// - definition.ts (the JSON-schema action enum exposed to the LLM)\n// - api.ts (the View's REST helpers — `call(action, args)`)\n// - server/api/routes/accounting.ts (handler-table keys, PREVIEW\n// and MESSAGE_BUILDERS membership)\n// - e2e/fixtures/accounting.ts (mock dispatcher's handler-table)\n//\n// Stays in its own module so server-side callers can import the\n// const without pulling in apiPost / Vue plumbing from `api.ts`.\n//\n// CLAUDE.md \"no magic literals — use existing `as const` objects\"\n// applies here: never reference an action by raw string at any of\n// the call sites above.\n\nexport const ACCOUNTING_ACTIONS = {\n openBook: \"openBook\",\n getBooks: \"getBooks\",\n createBook: \"createBook\",\n updateBook: \"updateBook\",\n deleteBook: \"deleteBook\",\n getAccounts: \"getAccounts\",\n upsertAccount: \"upsertAccount\",\n addEntries: \"addEntries\",\n voidEntry: \"voidEntry\",\n getJournalEntries: \"getJournalEntries\",\n getOpeningBalances: \"getOpeningBalances\",\n setOpeningBalances: \"setOpeningBalances\",\n getReport: \"getReport\",\n getTimeSeries: \"getTimeSeries\",\n rebuildSnapshots: \"rebuildSnapshots\",\n} as const;\n\nexport type AccountingAction = (typeof ACCOUNTING_ACTIONS)[keyof typeof ACCOUNTING_ACTIONS];\n","// Single source of truth for the accounting REST contract — the one\n// dispatch route the plugin owns. Consumed by BOTH the Vue api client\n// (./vue/api.ts) and the server router (./server/router.ts) so the path\n// can't drift between them. Mirrors the host META's\n// `{ apiNamespace: \"accounting\", dispatch: { method: \"POST\", path: \"\" } }`\n// resolved to a full URL.\n//\n// (CLAUDE.md: API routes go through `as const` objects, never hardcoded\n// strings at the call site.)\n\nexport const ACCOUNTING_API = {\n dispatch: {\n path: \"/api/accounting\",\n method: \"POST\",\n },\n} as const;\n","// Per-book event-stream contract for the accounting plugin — the\n// reusable channel-name factory + event-kind enum + payload shape.\n// Single source of truth for both publishers (the package's server\n// surface, `eventPublisher`) and subscribers (the Vue View's\n// `useAccountingChannel`), so anyone branching on event kind imports\n// from here and the type system catches drift on either side.\n//\n// Lives in the package's `./shared` (browser-safe) rather than the\n// host META because the backend needs it too — keeping it host-side\n// would force an uphill import. The host-wiring META (toolName /\n// apiNamespace / workspaceDirs / staticChannels) stays in the host's\n// `src/plugins/accounting/meta.ts` so the plugin-barrel codegen\n// discovers it.\n//\n// Browser-safe: no Vue imports, no server-only imports.\n\n/** Channel factory for per-book event streams. Subscribers:\n * `useAccountingChannel(bookId)`. Publisher: the package's server\n * surface `eventPublisher`. */\nexport function bookChannel(bookId: string): string {\n return `accounting:${bookId}`;\n}\n\n/** Book-list-level channel — a book was created / deleted. Subscribers\n * refetch the BookSwitcher dropdown. Mirrors the host META's\n * `staticChannels.accountingBooks` literal (kept in sync by value;\n * the host META stays the codegen-discoverable source for the\n * aggregator merge). */\nexport const ACCOUNTING_BOOKS_CHANNEL = \"accounting:books\";\n\n/** Event kinds that ride `bookChannel(bookId)`. Single source of\n * truth for both publishers (server/accounting) and subscribers\n * (the View) — anyone branching on event kind imports from here\n * and the type system catches drift on either side.\n *\n * - `journal` — addEntry / voidEntry hit the books at `period`.\n * Refetch the journal list and (if the View is\n * showing balances at or after `period`) the\n * relevant report.\n * - `opening` — setOpeningBalances. Affects every period from\n * the opening date forward; refetch everything.\n * - `accounts` — chart-of-accounts mutation that may affect\n * aggregation (account type changed). Refetch\n * accounts and the active report.\n * - `snapshotsRebuilding` / `snapshotsReady` — purely informational;\n * the View can show a \"calculating\" spinner\n * during rebuild, but the lazy-rebuild safety\n * net means a refetch always returns the right\n * answer regardless. */\nexport const BOOK_EVENT_KINDS = {\n journal: \"journal\",\n opening: \"opening\",\n accounts: \"accounts\",\n snapshotsRebuilding: \"snapshots-rebuilding\",\n snapshotsReady: \"snapshots-ready\",\n} as const;\n\nexport type BookEventKind = (typeof BOOK_EVENT_KINDS)[keyof typeof BOOK_EVENT_KINDS];\n\n/** Payload published on `bookChannel(bookId)`. */\nexport interface BookChannelPayload {\n kind: BookEventKind;\n /** YYYY-MM. Present for `journal` (entry month) and the snapshot\n * events (the earliest invalidated month). Absent for `opening`\n * (which invalidates everything) and `accounts`. */\n period?: string;\n}\n","// Normalise an unknown thrown value into a human-readable string.\n// Isomorphic (used by both the Vue surface and the server surface) so\n// it lives in ./shared. Mirrors the host's `src/utils/errors.ts`\n// `errorMessage` — kept in the package so neither surface reaches\n// uphill into the host for it.\n\nexport function errorMessage(err: unknown, fallback?: string): string {\n if (err instanceof Error) return err.message;\n if (err !== null && typeof err === \"object\") {\n const obj = err as { details?: unknown; message?: unknown };\n if (typeof obj.details === \"string\" && obj.details) return obj.details;\n if (typeof obj.message === \"string\" && obj.message) return obj.message;\n }\n if (fallback !== undefined) return fallback;\n return String(err);\n}\n","// Workspace-relative directories this plugin owns. Single source of\n// truth, consumed by BOTH the server io layer (./server/io.ts) and the\n// host META (src/plugins/accounting/meta.ts → the WORKSPACE_DIRS\n// aggregator), so the on-disk layout can't drift between the backend\n// and the rest of the app.\n//\n// Browser-safe: no node:* imports.\n\nexport const ACCOUNTING_DIRS = {\n /** `data/accounting/config.json` + the books tree below. */\n accounting: \"data/accounting\",\n /** `data/accounting/books/<bookId>/{accounts.json, journal/, snapshots/}`. */\n accountingBooks: \"data/accounting/books\",\n} as const;\n","// Fiscal-year arithmetic for the accounting plugin.\n//\n// Each book stores a `fiscalYearEnd` = the calendar month (1-12) on\n// whose LAST DAY the book's fiscal year closes:\n//\n// 3 → fiscal year ends March 31 (FY runs Apr 1 → Mar 31)\n// 6 → fiscal year ends June 30 (FY runs Jul 1 → Jun 30)\n// 8 → fiscal year ends August 31 (FY runs Sep 1 → Aug 31)\n// 12 → fiscal year ends December 31 (FY runs Jan 1 → Dec 31; default)\n//\n// Any month is allowed — a corporation whose statutory closing date\n// is August 31 stores 8. The quarter / year arithmetic below is fully\n// parametric on the closing month, so a non-calendar-quarter close\n// (e.g. 8) just shifts the fiscal quarters accordingly.\n//\n// \"Current quarter\" / \"current year\" everywhere in the UI refer to\n// the *fiscal* quarter / *fiscal* year that contains today, under the\n// active book's `fiscalYearEnd`. For a December (12) book fiscal\n// quarters and fiscal years coincide with calendar quarters / calendar\n// years; for any other close a shift applies.\n//\n// Legacy books (written when the field was a calendar-quarter token\n// \"Q1\"..\"Q4\") are absorbed by `resolveFiscalYearEnd`, which maps the\n// old tokens to their closing month (Q1→3, Q2→6, Q3→9, Q4→12). The\n// on-disk value is only rewritten the next time the user saves the\n// book — same no-auto-migrate policy the field has always had.\n//\n// All helpers return `YYYY-MM-DD` strings in the user's local\n// timezone — same convention as `dates.ts`.\n\nexport const FISCAL_YEAR_END_MONTHS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] as const;\nexport type FiscalYearEnd = (typeof FISCAL_YEAR_END_MONTHS)[number];\n\nexport const DEFAULT_FISCAL_YEAR_END: FiscalYearEnd = 12;\n\n/** Legacy calendar-quarter tokens → closing month, for books written\n * before the field became a month number. */\nconst LEGACY_QUARTER_MONTHS: Record<string, FiscalYearEnd> = { Q1: 3, Q2: 6, Q3: 9, Q4: 12 };\n\nexport function isFiscalYearEnd(value: unknown): value is FiscalYearEnd {\n return typeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= 12;\n}\n\n/** Normalise any stored / inbound value to a concrete closing month.\n * Absent or unrecognised → the default (December); a legacy \"Q1\"..\"Q4\"\n * token → its closing month; a valid 1-12 number → itself. Kept\n * tolerant (unknown input) so a legacy book read from disk — or shared\n * with an older MulmoTerminal — never breaks the UI or a report. */\nexport function resolveFiscalYearEnd(value: unknown): FiscalYearEnd {\n if (isFiscalYearEnd(value)) return value;\n if (typeof value === \"string\" && Object.hasOwn(LEGACY_QUARTER_MONTHS, value)) return LEGACY_QUARTER_MONTHS[value];\n return DEFAULT_FISCAL_YEAR_END;\n}\n\n/** Last calendar month (1-12) of the fiscal year. The stored token IS\n * the closing month now, so this reads as `resolveFiscalYearEnd` under\n * a name that states intent at the call sites (and still absorbs a\n * stray legacy token defensively). */\nexport function fiscalYearEndMonth(end: FiscalYearEnd): number {\n return resolveFiscalYearEnd(end);\n}\n\n/** Localised label for a fiscal-year-end month, showing that month's\n * last day — e.g. 8 → \"August 31\" / \"8月31日\" / \"31 de agosto\". Uses a\n * fixed non-leap reference year, so February reads as the 28th; this\n * is display only — the engine still computes the real last day\n * (Feb 29 in a leap year) at runtime. */\nexport function fiscalYearEndMonthLabel(month: FiscalYearEnd, locale: string): string {\n // UTC day 0 of the *next* month = last day of `month`, in a fixed\n // non-leap reference year (2001) so the label is stable and\n // timezone-independent.\n const lastDay = new Date(Date.UTC(2001, month, 0));\n try {\n return new Intl.DateTimeFormat(locale, { month: \"long\", day: \"numeric\", timeZone: \"UTC\" }).format(lastDay);\n } catch {\n return String(month);\n }\n}\n\nexport interface DateRange {\n /** Inclusive lower bound (YYYY-MM-DD). Empty string = unbounded. */\n from: string;\n /** Inclusive upper bound (YYYY-MM-DD). Empty string = unbounded. */\n to: string;\n}\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\nfunction lastDayOfMonth(year: number, monthZeroBased: number): number {\n // Day 0 of next month = last day of this month, all in local time.\n return new Date(year, monthZeroBased + 1, 0).getDate();\n}\n\nfunction ymd(year: number, monthOneBased: number, day: number): string {\n return `${year}-${pad2(monthOneBased)}-${pad2(day)}`;\n}\n\n/** Fiscal quarter index (0..3) of the given local date under `end`,\n * where 0 is the first quarter of the fiscal year (right after the\n * prior year's close) and 3 is the closing quarter. */\nfunction fiscalQuarterIndex(end: FiscalYearEnd, today: Date): number {\n const closingMonth = fiscalYearEndMonth(end); // 1-based\n const month = today.getMonth() + 1; // 1-based local month\n // Months past the close of the prior fiscal year, mod 12.\n const offset = (month - closingMonth - 1 + 12) % 12;\n return Math.floor(offset / 3);\n}\n\n/** Calendar (year, monthOneBased) of the *first* month of the fiscal\n * quarter at index `index` in the fiscal year that *contains*\n * `today`. Returned both as the first day of that month and as the\n * count of months covered (always 3 — exposed as a constant). */\nfunction fiscalQuarterStart(end: FiscalYearEnd, today: Date, index: number): { year: number; month: number } {\n const closingMonth = fiscalYearEndMonth(end);\n const todayMonth = today.getMonth() + 1;\n const todayYear = today.getFullYear();\n // Month after the close of the prior fiscal year — fiscal-year start month.\n const startMonth = (closingMonth % 12) + 1;\n // The fiscal year that contains `today` started in the calendar\n // year ≤ today's year. Specifically: if today's calendar month is\n // ≥ startMonth (or startMonth is 1, which is the Q4 case), the FY\n // started this calendar year; otherwise it started last year.\n const fyStartYear = todayMonth >= startMonth ? todayYear : todayYear - 1;\n // Month of the requested fiscal quarter's first month, expressed\n // as a 1-based offset from January of fyStartYear.\n const flatMonth = startMonth + index * 3; // 1-based, may exceed 12\n const year = fyStartYear + Math.floor((flatMonth - 1) / 12);\n const month = ((flatMonth - 1) % 12) + 1;\n return { year, month };\n}\n\nfunction quarterRangeAt(end: FiscalYearEnd, today: Date, index: number): DateRange {\n const start = fiscalQuarterStart(end, today, index);\n // Quarter spans 3 calendar months starting at `start`.\n const lastMonthFlat = start.month - 1 + 2; // 0-based offset of the third month\n const lastMonthYear = start.year + Math.floor(lastMonthFlat / 12);\n const lastMonth = (lastMonthFlat % 12) + 1; // 1-based\n const lastDay = lastDayOfMonth(lastMonthYear, lastMonth - 1);\n return {\n from: ymd(start.year, start.month, 1),\n to: ymd(lastMonthYear, lastMonth, lastDay),\n };\n}\n\nexport function currentQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n return quarterRangeAt(end, today, fiscalQuarterIndex(end, today));\n}\n\nexport function previousQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const idx = fiscalQuarterIndex(end, today);\n if (idx > 0) return quarterRangeAt(end, today, idx - 1);\n // Wrap to Q4 of the prior fiscal year. Step `today` back 3 months\n // — that lands inside the prior fiscal year regardless of `end`,\n // and Q4 (closing) is index 3 within whichever FY contains it.\n const stepped = new Date(today.getFullYear(), today.getMonth() - 3, 1);\n return quarterRangeAt(end, stepped, 3);\n}\n\n/** Current fiscal year — Q0 start through Q3 close. */\nexport function currentFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const first = quarterRangeAt(end, today, 0);\n const last = quarterRangeAt(end, today, 3);\n return { from: first.from, to: last.to };\n}\n\nexport function previousFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n // Step a year back so `quarterRangeAt` resolves the prior FY.\n const stepped = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());\n return currentFiscalYearRange(end, stepped);\n}\n","// Country utilities for the accounting plugin.\n//\n// The book's country (ISO 3166-1 alpha-2) identifies the tax\n// jurisdiction the book is kept under. The Accounting role uses it\n// to give country-aware advice — Japanese T-number under\n// インボイス制度, EU VAT ID, UK VAT, GSTIN, ABN, etc.\n//\n// Curated against the supported currency list and the tax-regime\n// guidance in `src/config/roles.ts` (Accounting role prompt).\n// Intl.DisplayNames provides the localized human name at render\n// time, so this stays a flat list of codes.\n\n/** ISO 3166-1 alpha-2 country codes shown in the book country\n * dropdown. Curated to cover every jurisdiction the Accounting role\n * has explicit tax-registration advice for, plus the major economies\n * represented in `SUPPORTED_CURRENCY_CODES`. */\nexport const SUPPORTED_COUNTRY_CODES = [\n \"US\",\n \"JP\",\n \"GB\",\n \"CA\",\n \"AU\",\n \"NZ\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"CH\",\n \"NO\",\n \"CN\",\n \"KR\",\n \"TW\",\n \"HK\",\n \"SG\",\n \"IN\",\n \"BR\",\n \"MX\",\n] as const;\n\nexport type SupportedCountryCode = (typeof SUPPORTED_COUNTRY_CODES)[number];\n\n/** EU member states as of 2026. Used by the role-prompt advice path\n * to recommend a VAT identification number when the book country is\n * in the EU. */\nexport const EU_COUNTRY_CODES: ReadonlySet<string> = new Set([\n \"AT\",\n \"BE\",\n \"BG\",\n \"CY\",\n \"CZ\",\n \"DE\",\n \"DK\",\n \"EE\",\n \"ES\",\n \"FI\",\n \"FR\",\n \"GR\",\n \"HR\",\n \"HU\",\n \"IE\",\n \"IT\",\n \"LT\",\n \"LU\",\n \"LV\",\n \"MT\",\n \"NL\",\n \"PL\",\n \"PT\",\n \"RO\",\n \"SE\",\n \"SI\",\n \"SK\",\n]);\n\n/** Localized human name for a country code. Falls back to the code\n * itself if the runtime can't resolve the name. */\nexport function localizedCountryName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"region\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Runtime guard for `BookSummary.country`. The type is the union\n * `SupportedCountryCode`, but every entry point that takes user /\n * LLM input arrives as raw `string` (form submit, JSON-RPC body),\n * so the service layer narrows here before persisting. */\nexport function isSupportedCountryCode(value: unknown): value is SupportedCountryCode {\n return typeof value === \"string\" && (SUPPORTED_COUNTRY_CODES as readonly string[]).includes(value);\n}\n\n/** Country-gated UI features. Each key is a feature name; the value\n * is the set of country codes for which the feature is enabled.\n * Components ask `countryHasFeature(\"...\", country)` instead of\n * hard-coding country lists at the call site.\n *\n * Add a new country-specific feature by adding a new key here and\n * reading it via `countryHasFeature`. An unknown / undefined\n * country never has any feature — components fall back to neutral\n * default UI rather than guessing.\n *\n * Mirrors the \"Country-aware tax behaviour\" prose in the\n * Accounting role prompt (`src/config/roles.ts`). The two MUST\n * stay in sync — drift means the LLM and the form give the user\n * contradictory advice. The prompt is the source of truth for\n * agent behaviour; this table is structured-data sibling for the\n * form. */\nexport const COUNTRY_FEATURES = {\n /** Show an amber \"missing tax ID\" warning + helper text on a\n * postable 14xx (input-tax) line whose taxRegistrationId is\n * blank. Limited to jurisdictions where the role prompt\n * explicitly requires the counterparty registration number\n * (JP T-number, EU VAT ID, GB VAT, GSTIN, ABN, NZ GST, CA BN).\n * The \"other countries\" bucket and US (no federal sales-tax\n * registration) intentionally stay quiet. 24xx output-tax\n * lines don't trigger the warning — see `isTaxAccountCode`. */\n warnMissingTaxRegistrationId: new Set<SupportedCountryCode>([\n \"JP\",\n \"GB\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"IN\",\n \"AU\",\n \"NZ\",\n \"CA\",\n ]),\n} as const;\n\nexport type CountryFeature = keyof typeof COUNTRY_FEATURES;\n\n/** Resolve a country-gated feature flag. Returns `false` when the\n * country is undefined / unsupported — components default to the\n * neutral path (no warning, no extra UI) rather than guessing. */\nexport function countryHasFeature(feature: CountryFeature, country: SupportedCountryCode | undefined): boolean {\n if (!country) return false;\n return COUNTRY_FEATURES[feature].has(country);\n}\n","// Currency utilities for the accounting plugin.\n//\n// We expose a curated list of ISO 4217 codes for the New Book\n// dropdown — covering the major reserve currencies plus the most\n// requested Asian / regional ones — plus per-currency formatting\n// helpers built on Intl.NumberFormat.\n//\n// The book's currency is per-book metadata (BookSummary.currency)\n// and only matters once the user has opened the book; cross-book\n// aggregation isn't supported.\n\n/** ISO 4217 codes shown in the New Book dropdown. Curated for\n * recognisability — Intl.DisplayNames provides the localised\n * human name at render time, so this stays a flat list of codes. */\nexport const SUPPORTED_CURRENCY_CODES = [\"USD\", \"EUR\", \"JPY\", \"GBP\", \"CNY\", \"KRW\", \"TWD\", \"HKD\", \"SGD\", \"AUD\", \"CAD\", \"CHF\", \"INR\", \"BRL\", \"MXN\"] as const;\n\nexport type SupportedCurrencyCode = (typeof SUPPORTED_CURRENCY_CODES)[number];\n\nconst DEFAULT_FALLBACK_DIGITS = 2;\n\n/** Localised human name for a currency code. Falls back to the\n * code itself if the runtime can't resolve the name. */\nexport function localizedCurrencyName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"currency\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Number of fraction digits ISO 4217 specifies for a currency.\n * JPY = 0, USD = 2, KWD = 3. Used both for amount formatting and\n * for the HTML input step on debit/credit fields. */\nexport function fractionDigitsFor(currency: string): number {\n try {\n const opts = new Intl.NumberFormat(\"en\", { style: \"currency\", currency }).resolvedOptions();\n return opts.maximumFractionDigits ?? DEFAULT_FALLBACK_DIGITS;\n } catch {\n return DEFAULT_FALLBACK_DIGITS;\n }\n}\n\n/** \"1\" for JPY, \"0.01\" for USD, \"0.001\" for KWD. Used as the HTML\n * input step on debit/credit fields so a JPY book doesn't let the\n * user type cents that would just round-trip back through the\n * decimal validator. */\nexport function inputStepFor(currency: string): string {\n const digits = fractionDigitsFor(currency);\n if (digits === 0) return \"1\";\n return (1 / 10 ** digits).toFixed(digits);\n}\n\n/** Locale-aware currency formatter — returns \"¥1,130\" / \"$1,130.00\"\n * etc. Falls back to fixed-point formatting if the runtime can't\n * resolve the currency code; the fallback still respects the\n * currency's natural fraction-digit count so JPY shows whole\n * numbers even on the slow path. */\nexport function formatAmount(value: number, currency: string, locale?: string): string {\n try {\n return new Intl.NumberFormat(locale, { style: \"currency\", currency }).format(value);\n } catch {\n return value.toFixed(fractionDigitsFor(currency));\n }\n}\n\n/** Currency-agnostic amount formatter — \"1,130.00\" — for places that\n * don't carry the currency code on the data path (compact preview\n * envelopes etc.). Use `formatAmount(value, currency)` whenever the\n * currency IS available — the currency-aware path picks the right\n * fraction-digit count automatically (JPY = 0, USD = 2).\n *\n * `locale` mirrors `formatAmount`'s signature: pass an explicit BCP-47\n * locale (`\"en-US\"`, `\"ja-JP\"`, …) when the caller knows the desired\n * grouping / digit-shape; omit to fall back to the runtime default. */\nexport function formatAmountNumeric(value: number, decimals = 2, locale?: string): string {\n return value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n}\n","// Local-calendar date helpers for the accounting forms.\n//\n// Why not `new Date().toISOString().slice(0, 10)`? `toISOString` is\n// UTC. In a negative-offset zone (US Pacific, Eastern, …) the UTC\n// date crosses to \"tomorrow\" several hours before midnight local,\n// so a naively prefilled date input would post entries into the\n// wrong accounting day. Same mistake near month boundaries flips\n// the default Balance Sheet period to the next month.\n//\n// All four helpers below are pure local-calendar formatters built\n// from `getFullYear` / `getMonth` / `getDate`, which the JS engine\n// resolves in the user's local timezone.\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\n/** Today as `YYYY-MM-DD` in the user's local timezone. */\nexport function localDateString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}`;\n}\n\n/** Current month as `YYYY-MM` in the user's local timezone. */\nexport function localMonthString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}`;\n}\n\n/** First day of the current calendar year as `YYYY-MM-DD`. */\nexport function localStartOfYearString(now: Date = new Date()): string {\n return `${now.getFullYear()}-01-01`;\n}\n\n/** Previous calendar month as `YYYY-MM` in the user's local timezone. */\nexport function previousMonthString(now: Date = new Date()): string {\n const target = new Date(now.getFullYear(), now.getMonth() - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** Last month of the previous calendar quarter as `YYYY-MM`. Calendar\n * quarters: Q1=Jan–Mar, Q2=Apr–Jun, Q3=Jul–Sep, Q4=Oct–Dec. When the\n * current month is in Q1, this rolls back to December of last year. */\nexport function lastMonthOfPreviousQuarterString(now: Date = new Date()): string {\n const firstMonthOfCurrentQuarter = Math.floor(now.getMonth() / 3) * 3;\n const target = new Date(now.getFullYear(), firstMonthOfCurrentQuarter - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** December of the previous calendar year as `YYYY-MM`. */\nexport function decemberOfPreviousYearString(now: Date = new Date()): string {\n return `${now.getFullYear() - 1}-12`;\n}\n","// Single source of truth for the `getTimeSeries` action's enum\n// surfaces — kept outside the server module so the frontend tool\n// definition (`definition.ts`) and the server validator\n// (`server/accounting/timeSeries.ts`) can both import without\n// crossing the src ↔ server boundary in the wrong direction.\n//\n// Adding a new metric / granularity: extend the array here, then\n// extend the corresponding switch / aggregation in\n// `server/accounting/timeSeries.ts`. The LLM tool schema picks up\n// the new value automatically via `definition.ts`'s `enum` field.\n\nexport const TIME_SERIES_METRICS = [\"revenue\", \"expense\", \"netIncome\", \"accountBalance\"] as const;\nexport type TimeSeriesMetric = (typeof TIME_SERIES_METRICS)[number];\n\nexport const TIME_SERIES_GRANULARITIES = [\"month\", \"quarter\", \"year\"] as const;\nexport type TimeSeriesGranularity = (typeof TIME_SERIES_GRANULARITIES)[number];\n"],"mappings":";;AAeA,IAAa,qBAAqB;CAChC,UAAU;CACV,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,eAAe;CACf,YAAY;CACZ,WAAW;CACX,mBAAmB;CACnB,oBAAoB;CACpB,oBAAoB;CACpB,WAAW;CACX,eAAe;CACf,kBAAkB;AACpB;;;ACrBA,IAAa,iBAAiB,EAC5B,UAAU;CACR,MAAM;CACN,QAAQ;AACV,EACF;;;;;;ACIA,SAAgB,YAAY,QAAwB;CAClD,OAAO,cAAc;AACvB;;;;;;AAOA,IAAa,2BAA2B;;;;;;;;;;;;;;;;;;;;AAqBxC,IAAa,mBAAmB;CAC9B,SAAS;CACT,SAAS;CACT,UAAU;CACV,qBAAqB;CACrB,gBAAgB;AAClB;;;ACjDA,SAAgB,aAAa,KAAc,UAA2B;CACpE,IAAI,eAAe,OAAO,OAAO,IAAI;CACrC,IAAI,QAAQ,QAAQ,OAAO,QAAQ,UAAU;EAC3C,MAAM,MAAM;EACZ,IAAI,OAAO,IAAI,YAAY,YAAY,IAAI,SAAS,OAAO,IAAI;EAC/D,IAAI,OAAO,IAAI,YAAY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#region src/shared/fiscalYear.ts
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
var FISCAL_YEAR_END_MONTHS = [
|
|
88
|
+
1,
|
|
89
|
+
2,
|
|
90
|
+
3,
|
|
91
|
+
4,
|
|
92
|
+
5,
|
|
93
|
+
6,
|
|
94
|
+
7,
|
|
95
|
+
8,
|
|
96
|
+
9,
|
|
97
|
+
10,
|
|
98
|
+
11,
|
|
99
|
+
12
|
|
92
100
|
];
|
|
93
|
-
var DEFAULT_FISCAL_YEAR_END =
|
|
101
|
+
var DEFAULT_FISCAL_YEAR_END = 12;
|
|
102
|
+
/** Legacy calendar-quarter tokens → closing month, for books written
|
|
103
|
+
* before the field became a month number. */
|
|
104
|
+
var LEGACY_QUARTER_MONTHS = {
|
|
105
|
+
Q1: 3,
|
|
106
|
+
Q2: 6,
|
|
107
|
+
Q3: 9,
|
|
108
|
+
Q4: 12
|
|
109
|
+
};
|
|
94
110
|
function isFiscalYearEnd(value) {
|
|
95
|
-
return typeof value === "
|
|
111
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 12;
|
|
96
112
|
}
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
113
|
+
/** Normalise any stored / inbound value to a concrete closing month.
|
|
114
|
+
* Absent or unrecognised → the default (December); a legacy "Q1".."Q4"
|
|
115
|
+
* token → its closing month; a valid 1-12 number → itself. Kept
|
|
116
|
+
* tolerant (unknown input) so a legacy book read from disk — or shared
|
|
117
|
+
* with an older MulmoTerminal — never breaks the UI or a report. */
|
|
100
118
|
function resolveFiscalYearEnd(value) {
|
|
101
|
-
|
|
119
|
+
if (isFiscalYearEnd(value)) return value;
|
|
120
|
+
if (typeof value === "string" && Object.hasOwn(LEGACY_QUARTER_MONTHS, value)) return LEGACY_QUARTER_MONTHS[value];
|
|
121
|
+
return 12;
|
|
102
122
|
}
|
|
103
|
-
/** Last calendar month (1-12) of the fiscal year
|
|
123
|
+
/** Last calendar month (1-12) of the fiscal year. The stored token IS
|
|
124
|
+
* the closing month now, so this reads as `resolveFiscalYearEnd` under
|
|
125
|
+
* a name that states intent at the call sites (and still absorbs a
|
|
126
|
+
* stray legacy token defensively). */
|
|
104
127
|
function fiscalYearEndMonth(end) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
128
|
+
return resolveFiscalYearEnd(end);
|
|
129
|
+
}
|
|
130
|
+
/** Localised label for a fiscal-year-end month, showing that month's
|
|
131
|
+
* last day — e.g. 8 → "August 31" / "8月31日" / "31 de agosto". Uses a
|
|
132
|
+
* fixed non-leap reference year, so February reads as the 28th; this
|
|
133
|
+
* is display only — the engine still computes the real last day
|
|
134
|
+
* (Feb 29 in a leap year) at runtime. */
|
|
135
|
+
function fiscalYearEndMonthLabel(month, locale) {
|
|
136
|
+
const lastDay = new Date(Date.UTC(2001, month, 0));
|
|
137
|
+
try {
|
|
138
|
+
return new Intl.DateTimeFormat(locale, {
|
|
139
|
+
month: "long",
|
|
140
|
+
day: "numeric",
|
|
141
|
+
timeZone: "UTC"
|
|
142
|
+
}).format(lastDay);
|
|
143
|
+
} catch {
|
|
144
|
+
return String(month);
|
|
145
|
+
}
|
|
109
146
|
}
|
|
110
147
|
function pad2$1(num) {
|
|
111
148
|
return String(num).padStart(2, "0");
|
|
@@ -441,6 +478,6 @@ var TIME_SERIES_GRANULARITIES = [
|
|
|
441
478
|
"year"
|
|
442
479
|
];
|
|
443
480
|
//#endregion
|
|
444
|
-
export { ACCOUNTING_ACTIONS, ACCOUNTING_API, ACCOUNTING_BOOKS_CHANNEL, ACCOUNTING_DIRS, BOOK_EVENT_KINDS, COUNTRY_FEATURES, DEFAULT_FISCAL_YEAR_END, EU_COUNTRY_CODES,
|
|
481
|
+
export { ACCOUNTING_ACTIONS, ACCOUNTING_API, ACCOUNTING_BOOKS_CHANNEL, ACCOUNTING_DIRS, BOOK_EVENT_KINDS, COUNTRY_FEATURES, DEFAULT_FISCAL_YEAR_END, EU_COUNTRY_CODES, FISCAL_YEAR_END_MONTHS, SUPPORTED_COUNTRY_CODES, SUPPORTED_CURRENCY_CODES, TIME_SERIES_GRANULARITIES, TIME_SERIES_METRICS, bookChannel, countryHasFeature, currentFiscalYearRange, currentQuarterRange, decemberOfPreviousYearString, errorMessage, fiscalYearEndMonth, fiscalYearEndMonthLabel, formatAmount, formatAmountNumeric, fractionDigitsFor, inputStepFor, isFiscalYearEnd, isSupportedCountryCode, lastMonthOfPreviousQuarterString, localDateString, localMonthString, localStartOfYearString, localizedCountryName, localizedCurrencyName, previousFiscalYearRange, previousMonthString, previousQuarterRange, resolveFiscalYearEnd };
|
|
445
482
|
|
|
446
483
|
//# sourceMappingURL=shared.js.map
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","names":[],"sources":["../src/shared/actions.ts","../src/shared/api.ts","../src/shared/channels.ts","../src/shared/errors.ts","../src/shared/paths.ts","../src/shared/fiscalYear.ts","../src/shared/countries.ts","../src/shared/currencies.ts","../src/shared/dates.ts","../src/shared/timeSeriesEnums.ts"],"sourcesContent":["// Single source of truth for the manageAccounting LLM-facing action\n// names. Used by:\n// - definition.ts (the JSON-schema action enum exposed to the LLM)\n// - api.ts (the View's REST helpers — `call(action, args)`)\n// - server/api/routes/accounting.ts (handler-table keys, PREVIEW\n// and MESSAGE_BUILDERS membership)\n// - e2e/fixtures/accounting.ts (mock dispatcher's handler-table)\n//\n// Stays in its own module so server-side callers can import the\n// const without pulling in apiPost / Vue plumbing from `api.ts`.\n//\n// CLAUDE.md \"no magic literals — use existing `as const` objects\"\n// applies here: never reference an action by raw string at any of\n// the call sites above.\n\nexport const ACCOUNTING_ACTIONS = {\n openBook: \"openBook\",\n getBooks: \"getBooks\",\n createBook: \"createBook\",\n updateBook: \"updateBook\",\n deleteBook: \"deleteBook\",\n getAccounts: \"getAccounts\",\n upsertAccount: \"upsertAccount\",\n addEntries: \"addEntries\",\n voidEntry: \"voidEntry\",\n getJournalEntries: \"getJournalEntries\",\n getOpeningBalances: \"getOpeningBalances\",\n setOpeningBalances: \"setOpeningBalances\",\n getReport: \"getReport\",\n getTimeSeries: \"getTimeSeries\",\n rebuildSnapshots: \"rebuildSnapshots\",\n} as const;\n\nexport type AccountingAction = (typeof ACCOUNTING_ACTIONS)[keyof typeof ACCOUNTING_ACTIONS];\n","// Single source of truth for the accounting REST contract — the one\n// dispatch route the plugin owns. Consumed by BOTH the Vue api client\n// (./vue/api.ts) and the server router (./server/router.ts) so the path\n// can't drift between them. Mirrors the host META's\n// `{ apiNamespace: \"accounting\", dispatch: { method: \"POST\", path: \"\" } }`\n// resolved to a full URL.\n//\n// (CLAUDE.md: API routes go through `as const` objects, never hardcoded\n// strings at the call site.)\n\nexport const ACCOUNTING_API = {\n dispatch: {\n path: \"/api/accounting\",\n method: \"POST\",\n },\n} as const;\n","// Per-book event-stream contract for the accounting plugin — the\n// reusable channel-name factory + event-kind enum + payload shape.\n// Single source of truth for both publishers (the package's server\n// surface, `eventPublisher`) and subscribers (the Vue View's\n// `useAccountingChannel`), so anyone branching on event kind imports\n// from here and the type system catches drift on either side.\n//\n// Lives in the package's `./shared` (browser-safe) rather than the\n// host META because the backend needs it too — keeping it host-side\n// would force an uphill import. The host-wiring META (toolName /\n// apiNamespace / workspaceDirs / staticChannels) stays in the host's\n// `src/plugins/accounting/meta.ts` so the plugin-barrel codegen\n// discovers it.\n//\n// Browser-safe: no Vue imports, no server-only imports.\n\n/** Channel factory for per-book event streams. Subscribers:\n * `useAccountingChannel(bookId)`. Publisher: the package's server\n * surface `eventPublisher`. */\nexport function bookChannel(bookId: string): string {\n return `accounting:${bookId}`;\n}\n\n/** Book-list-level channel — a book was created / deleted. Subscribers\n * refetch the BookSwitcher dropdown. Mirrors the host META's\n * `staticChannels.accountingBooks` literal (kept in sync by value;\n * the host META stays the codegen-discoverable source for the\n * aggregator merge). */\nexport const ACCOUNTING_BOOKS_CHANNEL = \"accounting:books\";\n\n/** Event kinds that ride `bookChannel(bookId)`. Single source of\n * truth for both publishers (server/accounting) and subscribers\n * (the View) — anyone branching on event kind imports from here\n * and the type system catches drift on either side.\n *\n * - `journal` — addEntry / voidEntry hit the books at `period`.\n * Refetch the journal list and (if the View is\n * showing balances at or after `period`) the\n * relevant report.\n * - `opening` — setOpeningBalances. Affects every period from\n * the opening date forward; refetch everything.\n * - `accounts` — chart-of-accounts mutation that may affect\n * aggregation (account type changed). Refetch\n * accounts and the active report.\n * - `snapshotsRebuilding` / `snapshotsReady` — purely informational;\n * the View can show a \"calculating\" spinner\n * during rebuild, but the lazy-rebuild safety\n * net means a refetch always returns the right\n * answer regardless. */\nexport const BOOK_EVENT_KINDS = {\n journal: \"journal\",\n opening: \"opening\",\n accounts: \"accounts\",\n snapshotsRebuilding: \"snapshots-rebuilding\",\n snapshotsReady: \"snapshots-ready\",\n} as const;\n\nexport type BookEventKind = (typeof BOOK_EVENT_KINDS)[keyof typeof BOOK_EVENT_KINDS];\n\n/** Payload published on `bookChannel(bookId)`. */\nexport interface BookChannelPayload {\n kind: BookEventKind;\n /** YYYY-MM. Present for `journal` (entry month) and the snapshot\n * events (the earliest invalidated month). Absent for `opening`\n * (which invalidates everything) and `accounts`. */\n period?: string;\n}\n","// Normalise an unknown thrown value into a human-readable string.\n// Isomorphic (used by both the Vue surface and the server surface) so\n// it lives in ./shared. Mirrors the host's `src/utils/errors.ts`\n// `errorMessage` — kept in the package so neither surface reaches\n// uphill into the host for it.\n\nexport function errorMessage(err: unknown, fallback?: string): string {\n if (err instanceof Error) return err.message;\n if (err !== null && typeof err === \"object\") {\n const obj = err as { details?: unknown; message?: unknown };\n if (typeof obj.details === \"string\" && obj.details) return obj.details;\n if (typeof obj.message === \"string\" && obj.message) return obj.message;\n }\n if (fallback !== undefined) return fallback;\n return String(err);\n}\n","// Workspace-relative directories this plugin owns. Single source of\n// truth, consumed by BOTH the server io layer (./server/io.ts) and the\n// host META (src/plugins/accounting/meta.ts → the WORKSPACE_DIRS\n// aggregator), so the on-disk layout can't drift between the backend\n// and the rest of the app.\n//\n// Browser-safe: no node:* imports.\n\nexport const ACCOUNTING_DIRS = {\n /** `data/accounting/config.json` + the books tree below. */\n accounting: \"data/accounting\",\n /** `data/accounting/books/<bookId>/{accounts.json, journal/, snapshots/}`. */\n accountingBooks: \"data/accounting/books\",\n} as const;\n","// Fiscal-year arithmetic for the accounting plugin.\n//\n// Each book stores a `fiscalYearEnd` token (Q1..Q4) that says which\n// calendar-quarter end is the book's fiscal year end:\n//\n// Q1 → fiscal year ends March 31 (FY runs Apr 1 → Mar 31)\n// Q2 → fiscal year ends June 30 (FY runs Jul 1 → Jun 30)\n// Q3 → fiscal year ends September 30 (FY runs Oct 1 → Sep 30)\n// Q4 → fiscal year ends December 31 (FY runs Jan 1 → Dec 31; default)\n//\n// \"Current quarter\" / \"current year\" everywhere in the UI refer to\n// the *fiscal* quarter / *fiscal* year that contains today, under the\n// active book's `fiscalYearEnd`. For Q4 books fiscal quarters and\n// fiscal years coincide with calendar quarters / calendar years; for\n// the other three a shift applies.\n//\n// All helpers return `YYYY-MM-DD` strings in the user's local\n// timezone — same convention as `dates.ts`.\n\nexport const FISCAL_YEAR_ENDS = [\"Q1\", \"Q2\", \"Q3\", \"Q4\"] as const;\nexport type FiscalYearEnd = (typeof FISCAL_YEAR_ENDS)[number];\n\nexport const DEFAULT_FISCAL_YEAR_END: FiscalYearEnd = \"Q4\";\n\nexport function isFiscalYearEnd(value: unknown): value is FiscalYearEnd {\n return typeof value === \"string\" && (FISCAL_YEAR_ENDS as readonly string[]).includes(value);\n}\n\n/** Books written before the field existed are treated as Q4 in code\n * but never auto-rewritten on disk. The settings UI persists through\n * the field the next time the user saves anything on the book. */\nexport function resolveFiscalYearEnd(value: FiscalYearEnd | undefined): FiscalYearEnd {\n return value ?? DEFAULT_FISCAL_YEAR_END;\n}\n\n/** Last calendar month (1-12) of the fiscal year for the given Q. */\nexport function fiscalYearEndMonth(end: FiscalYearEnd): 3 | 6 | 9 | 12 {\n if (end === \"Q1\") return 3;\n if (end === \"Q2\") return 6;\n if (end === \"Q3\") return 9;\n return 12;\n}\n\nexport interface DateRange {\n /** Inclusive lower bound (YYYY-MM-DD). Empty string = unbounded. */\n from: string;\n /** Inclusive upper bound (YYYY-MM-DD). Empty string = unbounded. */\n to: string;\n}\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\nfunction lastDayOfMonth(year: number, monthZeroBased: number): number {\n // Day 0 of next month = last day of this month, all in local time.\n return new Date(year, monthZeroBased + 1, 0).getDate();\n}\n\nfunction ymd(year: number, monthOneBased: number, day: number): string {\n return `${year}-${pad2(monthOneBased)}-${pad2(day)}`;\n}\n\n/** Fiscal quarter index (0..3) of the given local date under `end`,\n * where 0 is the first quarter of the fiscal year (right after the\n * prior year's close) and 3 is the closing quarter. */\nfunction fiscalQuarterIndex(end: FiscalYearEnd, today: Date): number {\n const closingMonth = fiscalYearEndMonth(end); // 1-based\n const month = today.getMonth() + 1; // 1-based local month\n // Months past the close of the prior fiscal year, mod 12.\n const offset = (month - closingMonth - 1 + 12) % 12;\n return Math.floor(offset / 3);\n}\n\n/** Calendar (year, monthOneBased) of the *first* month of the fiscal\n * quarter at index `index` in the fiscal year that *contains*\n * `today`. Returned both as the first day of that month and as the\n * count of months covered (always 3 — exposed as a constant). */\nfunction fiscalQuarterStart(end: FiscalYearEnd, today: Date, index: number): { year: number; month: number } {\n const closingMonth = fiscalYearEndMonth(end);\n const todayMonth = today.getMonth() + 1;\n const todayYear = today.getFullYear();\n // Month after the close of the prior fiscal year — fiscal-year start month.\n const startMonth = (closingMonth % 12) + 1;\n // The fiscal year that contains `today` started in the calendar\n // year ≤ today's year. Specifically: if today's calendar month is\n // ≥ startMonth (or startMonth is 1, which is the Q4 case), the FY\n // started this calendar year; otherwise it started last year.\n const fyStartYear = todayMonth >= startMonth ? todayYear : todayYear - 1;\n // Month of the requested fiscal quarter's first month, expressed\n // as a 1-based offset from January of fyStartYear.\n const flatMonth = startMonth + index * 3; // 1-based, may exceed 12\n const year = fyStartYear + Math.floor((flatMonth - 1) / 12);\n const month = ((flatMonth - 1) % 12) + 1;\n return { year, month };\n}\n\nfunction quarterRangeAt(end: FiscalYearEnd, today: Date, index: number): DateRange {\n const start = fiscalQuarterStart(end, today, index);\n // Quarter spans 3 calendar months starting at `start`.\n const lastMonthFlat = start.month - 1 + 2; // 0-based offset of the third month\n const lastMonthYear = start.year + Math.floor(lastMonthFlat / 12);\n const lastMonth = (lastMonthFlat % 12) + 1; // 1-based\n const lastDay = lastDayOfMonth(lastMonthYear, lastMonth - 1);\n return {\n from: ymd(start.year, start.month, 1),\n to: ymd(lastMonthYear, lastMonth, lastDay),\n };\n}\n\nexport function currentQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n return quarterRangeAt(end, today, fiscalQuarterIndex(end, today));\n}\n\nexport function previousQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const idx = fiscalQuarterIndex(end, today);\n if (idx > 0) return quarterRangeAt(end, today, idx - 1);\n // Wrap to Q4 of the prior fiscal year. Step `today` back 3 months\n // — that lands inside the prior fiscal year regardless of `end`,\n // and Q4 (closing) is index 3 within whichever FY contains it.\n const stepped = new Date(today.getFullYear(), today.getMonth() - 3, 1);\n return quarterRangeAt(end, stepped, 3);\n}\n\n/** Current fiscal year — Q0 start through Q3 close. */\nexport function currentFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const first = quarterRangeAt(end, today, 0);\n const last = quarterRangeAt(end, today, 3);\n return { from: first.from, to: last.to };\n}\n\nexport function previousFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n // Step a year back so `quarterRangeAt` resolves the prior FY.\n const stepped = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());\n return currentFiscalYearRange(end, stepped);\n}\n","// Country utilities for the accounting plugin.\n//\n// The book's country (ISO 3166-1 alpha-2) identifies the tax\n// jurisdiction the book is kept under. The Accounting role uses it\n// to give country-aware advice — Japanese T-number under\n// インボイス制度, EU VAT ID, UK VAT, GSTIN, ABN, etc.\n//\n// Curated against the supported currency list and the tax-regime\n// guidance in `src/config/roles.ts` (Accounting role prompt).\n// Intl.DisplayNames provides the localized human name at render\n// time, so this stays a flat list of codes.\n\n/** ISO 3166-1 alpha-2 country codes shown in the book country\n * dropdown. Curated to cover every jurisdiction the Accounting role\n * has explicit tax-registration advice for, plus the major economies\n * represented in `SUPPORTED_CURRENCY_CODES`. */\nexport const SUPPORTED_COUNTRY_CODES = [\n \"US\",\n \"JP\",\n \"GB\",\n \"CA\",\n \"AU\",\n \"NZ\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"CH\",\n \"NO\",\n \"CN\",\n \"KR\",\n \"TW\",\n \"HK\",\n \"SG\",\n \"IN\",\n \"BR\",\n \"MX\",\n] as const;\n\nexport type SupportedCountryCode = (typeof SUPPORTED_COUNTRY_CODES)[number];\n\n/** EU member states as of 2026. Used by the role-prompt advice path\n * to recommend a VAT identification number when the book country is\n * in the EU. */\nexport const EU_COUNTRY_CODES: ReadonlySet<string> = new Set([\n \"AT\",\n \"BE\",\n \"BG\",\n \"CY\",\n \"CZ\",\n \"DE\",\n \"DK\",\n \"EE\",\n \"ES\",\n \"FI\",\n \"FR\",\n \"GR\",\n \"HR\",\n \"HU\",\n \"IE\",\n \"IT\",\n \"LT\",\n \"LU\",\n \"LV\",\n \"MT\",\n \"NL\",\n \"PL\",\n \"PT\",\n \"RO\",\n \"SE\",\n \"SI\",\n \"SK\",\n]);\n\n/** Localized human name for a country code. Falls back to the code\n * itself if the runtime can't resolve the name. */\nexport function localizedCountryName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"region\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Runtime guard for `BookSummary.country`. The type is the union\n * `SupportedCountryCode`, but every entry point that takes user /\n * LLM input arrives as raw `string` (form submit, JSON-RPC body),\n * so the service layer narrows here before persisting. */\nexport function isSupportedCountryCode(value: unknown): value is SupportedCountryCode {\n return typeof value === \"string\" && (SUPPORTED_COUNTRY_CODES as readonly string[]).includes(value);\n}\n\n/** Country-gated UI features. Each key is a feature name; the value\n * is the set of country codes for which the feature is enabled.\n * Components ask `countryHasFeature(\"...\", country)` instead of\n * hard-coding country lists at the call site.\n *\n * Add a new country-specific feature by adding a new key here and\n * reading it via `countryHasFeature`. An unknown / undefined\n * country never has any feature — components fall back to neutral\n * default UI rather than guessing.\n *\n * Mirrors the \"Country-aware tax behaviour\" prose in the\n * Accounting role prompt (`src/config/roles.ts`). The two MUST\n * stay in sync — drift means the LLM and the form give the user\n * contradictory advice. The prompt is the source of truth for\n * agent behaviour; this table is structured-data sibling for the\n * form. */\nexport const COUNTRY_FEATURES = {\n /** Show an amber \"missing tax ID\" warning + helper text on a\n * postable 14xx (input-tax) line whose taxRegistrationId is\n * blank. Limited to jurisdictions where the role prompt\n * explicitly requires the counterparty registration number\n * (JP T-number, EU VAT ID, GB VAT, GSTIN, ABN, NZ GST, CA BN).\n * The \"other countries\" bucket and US (no federal sales-tax\n * registration) intentionally stay quiet. 24xx output-tax\n * lines don't trigger the warning — see `isTaxAccountCode`. */\n warnMissingTaxRegistrationId: new Set<SupportedCountryCode>([\n \"JP\",\n \"GB\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"IN\",\n \"AU\",\n \"NZ\",\n \"CA\",\n ]),\n} as const;\n\nexport type CountryFeature = keyof typeof COUNTRY_FEATURES;\n\n/** Resolve a country-gated feature flag. Returns `false` when the\n * country is undefined / unsupported — components default to the\n * neutral path (no warning, no extra UI) rather than guessing. */\nexport function countryHasFeature(feature: CountryFeature, country: SupportedCountryCode | undefined): boolean {\n if (!country) return false;\n return COUNTRY_FEATURES[feature].has(country);\n}\n","// Currency utilities for the accounting plugin.\n//\n// We expose a curated list of ISO 4217 codes for the New Book\n// dropdown — covering the major reserve currencies plus the most\n// requested Asian / regional ones — plus per-currency formatting\n// helpers built on Intl.NumberFormat.\n//\n// The book's currency is per-book metadata (BookSummary.currency)\n// and only matters once the user has opened the book; cross-book\n// aggregation isn't supported.\n\n/** ISO 4217 codes shown in the New Book dropdown. Curated for\n * recognisability — Intl.DisplayNames provides the localised\n * human name at render time, so this stays a flat list of codes. */\nexport const SUPPORTED_CURRENCY_CODES = [\"USD\", \"EUR\", \"JPY\", \"GBP\", \"CNY\", \"KRW\", \"TWD\", \"HKD\", \"SGD\", \"AUD\", \"CAD\", \"CHF\", \"INR\", \"BRL\", \"MXN\"] as const;\n\nexport type SupportedCurrencyCode = (typeof SUPPORTED_CURRENCY_CODES)[number];\n\nconst DEFAULT_FALLBACK_DIGITS = 2;\n\n/** Localised human name for a currency code. Falls back to the\n * code itself if the runtime can't resolve the name. */\nexport function localizedCurrencyName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"currency\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Number of fraction digits ISO 4217 specifies for a currency.\n * JPY = 0, USD = 2, KWD = 3. Used both for amount formatting and\n * for the HTML input step on debit/credit fields. */\nexport function fractionDigitsFor(currency: string): number {\n try {\n const opts = new Intl.NumberFormat(\"en\", { style: \"currency\", currency }).resolvedOptions();\n return opts.maximumFractionDigits ?? DEFAULT_FALLBACK_DIGITS;\n } catch {\n return DEFAULT_FALLBACK_DIGITS;\n }\n}\n\n/** \"1\" for JPY, \"0.01\" for USD, \"0.001\" for KWD. Used as the HTML\n * input step on debit/credit fields so a JPY book doesn't let the\n * user type cents that would just round-trip back through the\n * decimal validator. */\nexport function inputStepFor(currency: string): string {\n const digits = fractionDigitsFor(currency);\n if (digits === 0) return \"1\";\n return (1 / 10 ** digits).toFixed(digits);\n}\n\n/** Locale-aware currency formatter — returns \"¥1,130\" / \"$1,130.00\"\n * etc. Falls back to fixed-point formatting if the runtime can't\n * resolve the currency code; the fallback still respects the\n * currency's natural fraction-digit count so JPY shows whole\n * numbers even on the slow path. */\nexport function formatAmount(value: number, currency: string, locale?: string): string {\n try {\n return new Intl.NumberFormat(locale, { style: \"currency\", currency }).format(value);\n } catch {\n return value.toFixed(fractionDigitsFor(currency));\n }\n}\n\n/** Currency-agnostic amount formatter — \"1,130.00\" — for places that\n * don't carry the currency code on the data path (compact preview\n * envelopes etc.). Use `formatAmount(value, currency)` whenever the\n * currency IS available — the currency-aware path picks the right\n * fraction-digit count automatically (JPY = 0, USD = 2).\n *\n * `locale` mirrors `formatAmount`'s signature: pass an explicit BCP-47\n * locale (`\"en-US\"`, `\"ja-JP\"`, …) when the caller knows the desired\n * grouping / digit-shape; omit to fall back to the runtime default. */\nexport function formatAmountNumeric(value: number, decimals = 2, locale?: string): string {\n return value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n}\n","// Local-calendar date helpers for the accounting forms.\n//\n// Why not `new Date().toISOString().slice(0, 10)`? `toISOString` is\n// UTC. In a negative-offset zone (US Pacific, Eastern, …) the UTC\n// date crosses to \"tomorrow\" several hours before midnight local,\n// so a naively prefilled date input would post entries into the\n// wrong accounting day. Same mistake near month boundaries flips\n// the default Balance Sheet period to the next month.\n//\n// All four helpers below are pure local-calendar formatters built\n// from `getFullYear` / `getMonth` / `getDate`, which the JS engine\n// resolves in the user's local timezone.\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\n/** Today as `YYYY-MM-DD` in the user's local timezone. */\nexport function localDateString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}`;\n}\n\n/** Current month as `YYYY-MM` in the user's local timezone. */\nexport function localMonthString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}`;\n}\n\n/** First day of the current calendar year as `YYYY-MM-DD`. */\nexport function localStartOfYearString(now: Date = new Date()): string {\n return `${now.getFullYear()}-01-01`;\n}\n\n/** Previous calendar month as `YYYY-MM` in the user's local timezone. */\nexport function previousMonthString(now: Date = new Date()): string {\n const target = new Date(now.getFullYear(), now.getMonth() - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** Last month of the previous calendar quarter as `YYYY-MM`. Calendar\n * quarters: Q1=Jan–Mar, Q2=Apr–Jun, Q3=Jul–Sep, Q4=Oct–Dec. When the\n * current month is in Q1, this rolls back to December of last year. */\nexport function lastMonthOfPreviousQuarterString(now: Date = new Date()): string {\n const firstMonthOfCurrentQuarter = Math.floor(now.getMonth() / 3) * 3;\n const target = new Date(now.getFullYear(), firstMonthOfCurrentQuarter - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** December of the previous calendar year as `YYYY-MM`. */\nexport function decemberOfPreviousYearString(now: Date = new Date()): string {\n return `${now.getFullYear() - 1}-12`;\n}\n","// Single source of truth for the `getTimeSeries` action's enum\n// surfaces — kept outside the server module so the frontend tool\n// definition (`definition.ts`) and the server validator\n// (`server/accounting/timeSeries.ts`) can both import without\n// crossing the src ↔ server boundary in the wrong direction.\n//\n// Adding a new metric / granularity: extend the array here, then\n// extend the corresponding switch / aggregation in\n// `server/accounting/timeSeries.ts`. The LLM tool schema picks up\n// the new value automatically via `definition.ts`'s `enum` field.\n\nexport const TIME_SERIES_METRICS = [\"revenue\", \"expense\", \"netIncome\", \"accountBalance\"] as const;\nexport type TimeSeriesMetric = (typeof TIME_SERIES_METRICS)[number];\n\nexport const TIME_SERIES_GRANULARITIES = [\"month\", \"quarter\", \"year\"] as const;\nexport type TimeSeriesGranularity = (typeof TIME_SERIES_GRANULARITIES)[number];\n"],"mappings":";AAeA,IAAa,qBAAqB;CAChC,UAAU;CACV,UAAU;CACV,YAAY;C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;CAAW;CAAa;AAAgB;AAGvF,IAAa,4BAA4B;CAAC;CAAS;CAAW;AAAM"}
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../src/shared/actions.ts","../src/shared/api.ts","../src/shared/channels.ts","../src/shared/errors.ts","../src/shared/paths.ts","../src/shared/fiscalYear.ts","../src/shared/countries.ts","../src/shared/currencies.ts","../src/shared/dates.ts","../src/shared/timeSeriesEnums.ts"],"sourcesContent":["// Single source of truth for the manageAccounting LLM-facing action\n// names. Used by:\n// - definition.ts (the JSON-schema action enum exposed to the LLM)\n// - api.ts (the View's REST helpers — `call(action, args)`)\n// - server/api/routes/accounting.ts (handler-table keys, PREVIEW\n// and MESSAGE_BUILDERS membership)\n// - e2e/fixtures/accounting.ts (mock dispatcher's handler-table)\n//\n// Stays in its own module so server-side callers can import the\n// const without pulling in apiPost / Vue plumbing from `api.ts`.\n//\n// CLAUDE.md \"no magic literals — use existing `as const` objects\"\n// applies here: never reference an action by raw string at any of\n// the call sites above.\n\nexport const ACCOUNTING_ACTIONS = {\n openBook: \"openBook\",\n getBooks: \"getBooks\",\n createBook: \"createBook\",\n updateBook: \"updateBook\",\n deleteBook: \"deleteBook\",\n getAccounts: \"getAccounts\",\n upsertAccount: \"upsertAccount\",\n addEntries: \"addEntries\",\n voidEntry: \"voidEntry\",\n getJournalEntries: \"getJournalEntries\",\n getOpeningBalances: \"getOpeningBalances\",\n setOpeningBalances: \"setOpeningBalances\",\n getReport: \"getReport\",\n getTimeSeries: \"getTimeSeries\",\n rebuildSnapshots: \"rebuildSnapshots\",\n} as const;\n\nexport type AccountingAction = (typeof ACCOUNTING_ACTIONS)[keyof typeof ACCOUNTING_ACTIONS];\n","// Single source of truth for the accounting REST contract — the one\n// dispatch route the plugin owns. Consumed by BOTH the Vue api client\n// (./vue/api.ts) and the server router (./server/router.ts) so the path\n// can't drift between them. Mirrors the host META's\n// `{ apiNamespace: \"accounting\", dispatch: { method: \"POST\", path: \"\" } }`\n// resolved to a full URL.\n//\n// (CLAUDE.md: API routes go through `as const` objects, never hardcoded\n// strings at the call site.)\n\nexport const ACCOUNTING_API = {\n dispatch: {\n path: \"/api/accounting\",\n method: \"POST\",\n },\n} as const;\n","// Per-book event-stream contract for the accounting plugin — the\n// reusable channel-name factory + event-kind enum + payload shape.\n// Single source of truth for both publishers (the package's server\n// surface, `eventPublisher`) and subscribers (the Vue View's\n// `useAccountingChannel`), so anyone branching on event kind imports\n// from here and the type system catches drift on either side.\n//\n// Lives in the package's `./shared` (browser-safe) rather than the\n// host META because the backend needs it too — keeping it host-side\n// would force an uphill import. The host-wiring META (toolName /\n// apiNamespace / workspaceDirs / staticChannels) stays in the host's\n// `src/plugins/accounting/meta.ts` so the plugin-barrel codegen\n// discovers it.\n//\n// Browser-safe: no Vue imports, no server-only imports.\n\n/** Channel factory for per-book event streams. Subscribers:\n * `useAccountingChannel(bookId)`. Publisher: the package's server\n * surface `eventPublisher`. */\nexport function bookChannel(bookId: string): string {\n return `accounting:${bookId}`;\n}\n\n/** Book-list-level channel — a book was created / deleted. Subscribers\n * refetch the BookSwitcher dropdown. Mirrors the host META's\n * `staticChannels.accountingBooks` literal (kept in sync by value;\n * the host META stays the codegen-discoverable source for the\n * aggregator merge). */\nexport const ACCOUNTING_BOOKS_CHANNEL = \"accounting:books\";\n\n/** Event kinds that ride `bookChannel(bookId)`. Single source of\n * truth for both publishers (server/accounting) and subscribers\n * (the View) — anyone branching on event kind imports from here\n * and the type system catches drift on either side.\n *\n * - `journal` — addEntry / voidEntry hit the books at `period`.\n * Refetch the journal list and (if the View is\n * showing balances at or after `period`) the\n * relevant report.\n * - `opening` — setOpeningBalances. Affects every period from\n * the opening date forward; refetch everything.\n * - `accounts` — chart-of-accounts mutation that may affect\n * aggregation (account type changed). Refetch\n * accounts and the active report.\n * - `snapshotsRebuilding` / `snapshotsReady` — purely informational;\n * the View can show a \"calculating\" spinner\n * during rebuild, but the lazy-rebuild safety\n * net means a refetch always returns the right\n * answer regardless. */\nexport const BOOK_EVENT_KINDS = {\n journal: \"journal\",\n opening: \"opening\",\n accounts: \"accounts\",\n snapshotsRebuilding: \"snapshots-rebuilding\",\n snapshotsReady: \"snapshots-ready\",\n} as const;\n\nexport type BookEventKind = (typeof BOOK_EVENT_KINDS)[keyof typeof BOOK_EVENT_KINDS];\n\n/** Payload published on `bookChannel(bookId)`. */\nexport interface BookChannelPayload {\n kind: BookEventKind;\n /** YYYY-MM. Present for `journal` (entry month) and the snapshot\n * events (the earliest invalidated month). Absent for `opening`\n * (which invalidates everything) and `accounts`. */\n period?: string;\n}\n","// Normalise an unknown thrown value into a human-readable string.\n// Isomorphic (used by both the Vue surface and the server surface) so\n// it lives in ./shared. Mirrors the host's `src/utils/errors.ts`\n// `errorMessage` — kept in the package so neither surface reaches\n// uphill into the host for it.\n\nexport function errorMessage(err: unknown, fallback?: string): string {\n if (err instanceof Error) return err.message;\n if (err !== null && typeof err === \"object\") {\n const obj = err as { details?: unknown; message?: unknown };\n if (typeof obj.details === \"string\" && obj.details) return obj.details;\n if (typeof obj.message === \"string\" && obj.message) return obj.message;\n }\n if (fallback !== undefined) return fallback;\n return String(err);\n}\n","// Workspace-relative directories this plugin owns. Single source of\n// truth, consumed by BOTH the server io layer (./server/io.ts) and the\n// host META (src/plugins/accounting/meta.ts → the WORKSPACE_DIRS\n// aggregator), so the on-disk layout can't drift between the backend\n// and the rest of the app.\n//\n// Browser-safe: no node:* imports.\n\nexport const ACCOUNTING_DIRS = {\n /** `data/accounting/config.json` + the books tree below. */\n accounting: \"data/accounting\",\n /** `data/accounting/books/<bookId>/{accounts.json, journal/, snapshots/}`. */\n accountingBooks: \"data/accounting/books\",\n} as const;\n","// Fiscal-year arithmetic for the accounting plugin.\n//\n// Each book stores a `fiscalYearEnd` = the calendar month (1-12) on\n// whose LAST DAY the book's fiscal year closes:\n//\n// 3 → fiscal year ends March 31 (FY runs Apr 1 → Mar 31)\n// 6 → fiscal year ends June 30 (FY runs Jul 1 → Jun 30)\n// 8 → fiscal year ends August 31 (FY runs Sep 1 → Aug 31)\n// 12 → fiscal year ends December 31 (FY runs Jan 1 → Dec 31; default)\n//\n// Any month is allowed — a corporation whose statutory closing date\n// is August 31 stores 8. The quarter / year arithmetic below is fully\n// parametric on the closing month, so a non-calendar-quarter close\n// (e.g. 8) just shifts the fiscal quarters accordingly.\n//\n// \"Current quarter\" / \"current year\" everywhere in the UI refer to\n// the *fiscal* quarter / *fiscal* year that contains today, under the\n// active book's `fiscalYearEnd`. For a December (12) book fiscal\n// quarters and fiscal years coincide with calendar quarters / calendar\n// years; for any other close a shift applies.\n//\n// Legacy books (written when the field was a calendar-quarter token\n// \"Q1\"..\"Q4\") are absorbed by `resolveFiscalYearEnd`, which maps the\n// old tokens to their closing month (Q1→3, Q2→6, Q3→9, Q4→12). The\n// on-disk value is only rewritten the next time the user saves the\n// book — same no-auto-migrate policy the field has always had.\n//\n// All helpers return `YYYY-MM-DD` strings in the user's local\n// timezone — same convention as `dates.ts`.\n\nexport const FISCAL_YEAR_END_MONTHS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] as const;\nexport type FiscalYearEnd = (typeof FISCAL_YEAR_END_MONTHS)[number];\n\nexport const DEFAULT_FISCAL_YEAR_END: FiscalYearEnd = 12;\n\n/** Legacy calendar-quarter tokens → closing month, for books written\n * before the field became a month number. */\nconst LEGACY_QUARTER_MONTHS: Record<string, FiscalYearEnd> = { Q1: 3, Q2: 6, Q3: 9, Q4: 12 };\n\nexport function isFiscalYearEnd(value: unknown): value is FiscalYearEnd {\n return typeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= 12;\n}\n\n/** Normalise any stored / inbound value to a concrete closing month.\n * Absent or unrecognised → the default (December); a legacy \"Q1\"..\"Q4\"\n * token → its closing month; a valid 1-12 number → itself. Kept\n * tolerant (unknown input) so a legacy book read from disk — or shared\n * with an older MulmoTerminal — never breaks the UI or a report. */\nexport function resolveFiscalYearEnd(value: unknown): FiscalYearEnd {\n if (isFiscalYearEnd(value)) return value;\n if (typeof value === \"string\" && Object.hasOwn(LEGACY_QUARTER_MONTHS, value)) return LEGACY_QUARTER_MONTHS[value];\n return DEFAULT_FISCAL_YEAR_END;\n}\n\n/** Last calendar month (1-12) of the fiscal year. The stored token IS\n * the closing month now, so this reads as `resolveFiscalYearEnd` under\n * a name that states intent at the call sites (and still absorbs a\n * stray legacy token defensively). */\nexport function fiscalYearEndMonth(end: FiscalYearEnd): number {\n return resolveFiscalYearEnd(end);\n}\n\n/** Localised label for a fiscal-year-end month, showing that month's\n * last day — e.g. 8 → \"August 31\" / \"8月31日\" / \"31 de agosto\". Uses a\n * fixed non-leap reference year, so February reads as the 28th; this\n * is display only — the engine still computes the real last day\n * (Feb 29 in a leap year) at runtime. */\nexport function fiscalYearEndMonthLabel(month: FiscalYearEnd, locale: string): string {\n // UTC day 0 of the *next* month = last day of `month`, in a fixed\n // non-leap reference year (2001) so the label is stable and\n // timezone-independent.\n const lastDay = new Date(Date.UTC(2001, month, 0));\n try {\n return new Intl.DateTimeFormat(locale, { month: \"long\", day: \"numeric\", timeZone: \"UTC\" }).format(lastDay);\n } catch {\n return String(month);\n }\n}\n\nexport interface DateRange {\n /** Inclusive lower bound (YYYY-MM-DD). Empty string = unbounded. */\n from: string;\n /** Inclusive upper bound (YYYY-MM-DD). Empty string = unbounded. */\n to: string;\n}\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\nfunction lastDayOfMonth(year: number, monthZeroBased: number): number {\n // Day 0 of next month = last day of this month, all in local time.\n return new Date(year, monthZeroBased + 1, 0).getDate();\n}\n\nfunction ymd(year: number, monthOneBased: number, day: number): string {\n return `${year}-${pad2(monthOneBased)}-${pad2(day)}`;\n}\n\n/** Fiscal quarter index (0..3) of the given local date under `end`,\n * where 0 is the first quarter of the fiscal year (right after the\n * prior year's close) and 3 is the closing quarter. */\nfunction fiscalQuarterIndex(end: FiscalYearEnd, today: Date): number {\n const closingMonth = fiscalYearEndMonth(end); // 1-based\n const month = today.getMonth() + 1; // 1-based local month\n // Months past the close of the prior fiscal year, mod 12.\n const offset = (month - closingMonth - 1 + 12) % 12;\n return Math.floor(offset / 3);\n}\n\n/** Calendar (year, monthOneBased) of the *first* month of the fiscal\n * quarter at index `index` in the fiscal year that *contains*\n * `today`. Returned both as the first day of that month and as the\n * count of months covered (always 3 — exposed as a constant). */\nfunction fiscalQuarterStart(end: FiscalYearEnd, today: Date, index: number): { year: number; month: number } {\n const closingMonth = fiscalYearEndMonth(end);\n const todayMonth = today.getMonth() + 1;\n const todayYear = today.getFullYear();\n // Month after the close of the prior fiscal year — fiscal-year start month.\n const startMonth = (closingMonth % 12) + 1;\n // The fiscal year that contains `today` started in the calendar\n // year ≤ today's year. Specifically: if today's calendar month is\n // ≥ startMonth (or startMonth is 1, which is the Q4 case), the FY\n // started this calendar year; otherwise it started last year.\n const fyStartYear = todayMonth >= startMonth ? todayYear : todayYear - 1;\n // Month of the requested fiscal quarter's first month, expressed\n // as a 1-based offset from January of fyStartYear.\n const flatMonth = startMonth + index * 3; // 1-based, may exceed 12\n const year = fyStartYear + Math.floor((flatMonth - 1) / 12);\n const month = ((flatMonth - 1) % 12) + 1;\n return { year, month };\n}\n\nfunction quarterRangeAt(end: FiscalYearEnd, today: Date, index: number): DateRange {\n const start = fiscalQuarterStart(end, today, index);\n // Quarter spans 3 calendar months starting at `start`.\n const lastMonthFlat = start.month - 1 + 2; // 0-based offset of the third month\n const lastMonthYear = start.year + Math.floor(lastMonthFlat / 12);\n const lastMonth = (lastMonthFlat % 12) + 1; // 1-based\n const lastDay = lastDayOfMonth(lastMonthYear, lastMonth - 1);\n return {\n from: ymd(start.year, start.month, 1),\n to: ymd(lastMonthYear, lastMonth, lastDay),\n };\n}\n\nexport function currentQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n return quarterRangeAt(end, today, fiscalQuarterIndex(end, today));\n}\n\nexport function previousQuarterRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const idx = fiscalQuarterIndex(end, today);\n if (idx > 0) return quarterRangeAt(end, today, idx - 1);\n // Wrap to Q4 of the prior fiscal year. Step `today` back 3 months\n // — that lands inside the prior fiscal year regardless of `end`,\n // and Q4 (closing) is index 3 within whichever FY contains it.\n const stepped = new Date(today.getFullYear(), today.getMonth() - 3, 1);\n return quarterRangeAt(end, stepped, 3);\n}\n\n/** Current fiscal year — Q0 start through Q3 close. */\nexport function currentFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n const first = quarterRangeAt(end, today, 0);\n const last = quarterRangeAt(end, today, 3);\n return { from: first.from, to: last.to };\n}\n\nexport function previousFiscalYearRange(end: FiscalYearEnd, today: Date = new Date()): DateRange {\n // Step a year back so `quarterRangeAt` resolves the prior FY.\n const stepped = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());\n return currentFiscalYearRange(end, stepped);\n}\n","// Country utilities for the accounting plugin.\n//\n// The book's country (ISO 3166-1 alpha-2) identifies the tax\n// jurisdiction the book is kept under. The Accounting role uses it\n// to give country-aware advice — Japanese T-number under\n// インボイス制度, EU VAT ID, UK VAT, GSTIN, ABN, etc.\n//\n// Curated against the supported currency list and the tax-regime\n// guidance in `src/config/roles.ts` (Accounting role prompt).\n// Intl.DisplayNames provides the localized human name at render\n// time, so this stays a flat list of codes.\n\n/** ISO 3166-1 alpha-2 country codes shown in the book country\n * dropdown. Curated to cover every jurisdiction the Accounting role\n * has explicit tax-registration advice for, plus the major economies\n * represented in `SUPPORTED_CURRENCY_CODES`. */\nexport const SUPPORTED_COUNTRY_CODES = [\n \"US\",\n \"JP\",\n \"GB\",\n \"CA\",\n \"AU\",\n \"NZ\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"CH\",\n \"NO\",\n \"CN\",\n \"KR\",\n \"TW\",\n \"HK\",\n \"SG\",\n \"IN\",\n \"BR\",\n \"MX\",\n] as const;\n\nexport type SupportedCountryCode = (typeof SUPPORTED_COUNTRY_CODES)[number];\n\n/** EU member states as of 2026. Used by the role-prompt advice path\n * to recommend a VAT identification number when the book country is\n * in the EU. */\nexport const EU_COUNTRY_CODES: ReadonlySet<string> = new Set([\n \"AT\",\n \"BE\",\n \"BG\",\n \"CY\",\n \"CZ\",\n \"DE\",\n \"DK\",\n \"EE\",\n \"ES\",\n \"FI\",\n \"FR\",\n \"GR\",\n \"HR\",\n \"HU\",\n \"IE\",\n \"IT\",\n \"LT\",\n \"LU\",\n \"LV\",\n \"MT\",\n \"NL\",\n \"PL\",\n \"PT\",\n \"RO\",\n \"SE\",\n \"SI\",\n \"SK\",\n]);\n\n/** Localized human name for a country code. Falls back to the code\n * itself if the runtime can't resolve the name. */\nexport function localizedCountryName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"region\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Runtime guard for `BookSummary.country`. The type is the union\n * `SupportedCountryCode`, but every entry point that takes user /\n * LLM input arrives as raw `string` (form submit, JSON-RPC body),\n * so the service layer narrows here before persisting. */\nexport function isSupportedCountryCode(value: unknown): value is SupportedCountryCode {\n return typeof value === \"string\" && (SUPPORTED_COUNTRY_CODES as readonly string[]).includes(value);\n}\n\n/** Country-gated UI features. Each key is a feature name; the value\n * is the set of country codes for which the feature is enabled.\n * Components ask `countryHasFeature(\"...\", country)` instead of\n * hard-coding country lists at the call site.\n *\n * Add a new country-specific feature by adding a new key here and\n * reading it via `countryHasFeature`. An unknown / undefined\n * country never has any feature — components fall back to neutral\n * default UI rather than guessing.\n *\n * Mirrors the \"Country-aware tax behaviour\" prose in the\n * Accounting role prompt (`src/config/roles.ts`). The two MUST\n * stay in sync — drift means the LLM and the form give the user\n * contradictory advice. The prompt is the source of truth for\n * agent behaviour; this table is structured-data sibling for the\n * form. */\nexport const COUNTRY_FEATURES = {\n /** Show an amber \"missing tax ID\" warning + helper text on a\n * postable 14xx (input-tax) line whose taxRegistrationId is\n * blank. Limited to jurisdictions where the role prompt\n * explicitly requires the counterparty registration number\n * (JP T-number, EU VAT ID, GB VAT, GSTIN, ABN, NZ GST, CA BN).\n * The \"other countries\" bucket and US (no federal sales-tax\n * registration) intentionally stay quiet. 24xx output-tax\n * lines don't trigger the warning — see `isTaxAccountCode`. */\n warnMissingTaxRegistrationId: new Set<SupportedCountryCode>([\n \"JP\",\n \"GB\",\n \"DE\",\n \"FR\",\n \"IT\",\n \"ES\",\n \"NL\",\n \"BE\",\n \"AT\",\n \"IE\",\n \"PT\",\n \"FI\",\n \"SE\",\n \"DK\",\n \"PL\",\n \"IN\",\n \"AU\",\n \"NZ\",\n \"CA\",\n ]),\n} as const;\n\nexport type CountryFeature = keyof typeof COUNTRY_FEATURES;\n\n/** Resolve a country-gated feature flag. Returns `false` when the\n * country is undefined / unsupported — components default to the\n * neutral path (no warning, no extra UI) rather than guessing. */\nexport function countryHasFeature(feature: CountryFeature, country: SupportedCountryCode | undefined): boolean {\n if (!country) return false;\n return COUNTRY_FEATURES[feature].has(country);\n}\n","// Currency utilities for the accounting plugin.\n//\n// We expose a curated list of ISO 4217 codes for the New Book\n// dropdown — covering the major reserve currencies plus the most\n// requested Asian / regional ones — plus per-currency formatting\n// helpers built on Intl.NumberFormat.\n//\n// The book's currency is per-book metadata (BookSummary.currency)\n// and only matters once the user has opened the book; cross-book\n// aggregation isn't supported.\n\n/** ISO 4217 codes shown in the New Book dropdown. Curated for\n * recognisability — Intl.DisplayNames provides the localised\n * human name at render time, so this stays a flat list of codes. */\nexport const SUPPORTED_CURRENCY_CODES = [\"USD\", \"EUR\", \"JPY\", \"GBP\", \"CNY\", \"KRW\", \"TWD\", \"HKD\", \"SGD\", \"AUD\", \"CAD\", \"CHF\", \"INR\", \"BRL\", \"MXN\"] as const;\n\nexport type SupportedCurrencyCode = (typeof SUPPORTED_CURRENCY_CODES)[number];\n\nconst DEFAULT_FALLBACK_DIGITS = 2;\n\n/** Localised human name for a currency code. Falls back to the\n * code itself if the runtime can't resolve the name. */\nexport function localizedCurrencyName(code: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: \"currency\" }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\n/** Number of fraction digits ISO 4217 specifies for a currency.\n * JPY = 0, USD = 2, KWD = 3. Used both for amount formatting and\n * for the HTML input step on debit/credit fields. */\nexport function fractionDigitsFor(currency: string): number {\n try {\n const opts = new Intl.NumberFormat(\"en\", { style: \"currency\", currency }).resolvedOptions();\n return opts.maximumFractionDigits ?? DEFAULT_FALLBACK_DIGITS;\n } catch {\n return DEFAULT_FALLBACK_DIGITS;\n }\n}\n\n/** \"1\" for JPY, \"0.01\" for USD, \"0.001\" for KWD. Used as the HTML\n * input step on debit/credit fields so a JPY book doesn't let the\n * user type cents that would just round-trip back through the\n * decimal validator. */\nexport function inputStepFor(currency: string): string {\n const digits = fractionDigitsFor(currency);\n if (digits === 0) return \"1\";\n return (1 / 10 ** digits).toFixed(digits);\n}\n\n/** Locale-aware currency formatter — returns \"¥1,130\" / \"$1,130.00\"\n * etc. Falls back to fixed-point formatting if the runtime can't\n * resolve the currency code; the fallback still respects the\n * currency's natural fraction-digit count so JPY shows whole\n * numbers even on the slow path. */\nexport function formatAmount(value: number, currency: string, locale?: string): string {\n try {\n return new Intl.NumberFormat(locale, { style: \"currency\", currency }).format(value);\n } catch {\n return value.toFixed(fractionDigitsFor(currency));\n }\n}\n\n/** Currency-agnostic amount formatter — \"1,130.00\" — for places that\n * don't carry the currency code on the data path (compact preview\n * envelopes etc.). Use `formatAmount(value, currency)` whenever the\n * currency IS available — the currency-aware path picks the right\n * fraction-digit count automatically (JPY = 0, USD = 2).\n *\n * `locale` mirrors `formatAmount`'s signature: pass an explicit BCP-47\n * locale (`\"en-US\"`, `\"ja-JP\"`, …) when the caller knows the desired\n * grouping / digit-shape; omit to fall back to the runtime default. */\nexport function formatAmountNumeric(value: number, decimals = 2, locale?: string): string {\n return value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n}\n","// Local-calendar date helpers for the accounting forms.\n//\n// Why not `new Date().toISOString().slice(0, 10)`? `toISOString` is\n// UTC. In a negative-offset zone (US Pacific, Eastern, …) the UTC\n// date crosses to \"tomorrow\" several hours before midnight local,\n// so a naively prefilled date input would post entries into the\n// wrong accounting day. Same mistake near month boundaries flips\n// the default Balance Sheet period to the next month.\n//\n// All four helpers below are pure local-calendar formatters built\n// from `getFullYear` / `getMonth` / `getDate`, which the JS engine\n// resolves in the user's local timezone.\n\nfunction pad2(num: number): string {\n return String(num).padStart(2, \"0\");\n}\n\n/** Today as `YYYY-MM-DD` in the user's local timezone. */\nexport function localDateString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}`;\n}\n\n/** Current month as `YYYY-MM` in the user's local timezone. */\nexport function localMonthString(now: Date = new Date()): string {\n return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}`;\n}\n\n/** First day of the current calendar year as `YYYY-MM-DD`. */\nexport function localStartOfYearString(now: Date = new Date()): string {\n return `${now.getFullYear()}-01-01`;\n}\n\n/** Previous calendar month as `YYYY-MM` in the user's local timezone. */\nexport function previousMonthString(now: Date = new Date()): string {\n const target = new Date(now.getFullYear(), now.getMonth() - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** Last month of the previous calendar quarter as `YYYY-MM`. Calendar\n * quarters: Q1=Jan–Mar, Q2=Apr–Jun, Q3=Jul–Sep, Q4=Oct–Dec. When the\n * current month is in Q1, this rolls back to December of last year. */\nexport function lastMonthOfPreviousQuarterString(now: Date = new Date()): string {\n const firstMonthOfCurrentQuarter = Math.floor(now.getMonth() / 3) * 3;\n const target = new Date(now.getFullYear(), firstMonthOfCurrentQuarter - 1, 1);\n return `${target.getFullYear()}-${pad2(target.getMonth() + 1)}`;\n}\n\n/** December of the previous calendar year as `YYYY-MM`. */\nexport function decemberOfPreviousYearString(now: Date = new Date()): string {\n return `${now.getFullYear() - 1}-12`;\n}\n","// Single source of truth for the `getTimeSeries` action's enum\n// surfaces — kept outside the server module so the frontend tool\n// definition (`definition.ts`) and the server validator\n// (`server/accounting/timeSeries.ts`) can both import without\n// crossing the src ↔ server boundary in the wrong direction.\n//\n// Adding a new metric / granularity: extend the array here, then\n// extend the corresponding switch / aggregation in\n// `server/accounting/timeSeries.ts`. The LLM tool schema picks up\n// the new value automatically via `definition.ts`'s `enum` field.\n\nexport const TIME_SERIES_METRICS = [\"revenue\", \"expense\", \"netIncome\", \"accountBalance\"] as const;\nexport type TimeSeriesMetric = (typeof TIME_SERIES_METRICS)[number];\n\nexport const TIME_SERIES_GRANULARITIES = [\"month\", \"quarter\", \"year\"] as const;\nexport type TimeSeriesGranularity = (typeof TIME_SERIES_GRANULARITIES)[number];\n"],"mappings":";AAeA,IAAa,qBAAqB;CAChC,UAAU;CACV,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,eAAe;CACf,YAAY;CACZ,WAAW;CACX,mBAAmB;CACnB,oBAAoB;CACpB,oBAAoB;CACpB,WAAW;CACX,eAAe;CACf,kBAAkB;AACpB;;;ACrBA,IAAa,iBAAiB,EAC5B,UAAU;CACR,MAAM;CACN,QAAQ;AACV,EACF;;;;;;ACIA,SAAgB,YAAY,QAAwB;CAClD,OAAO,cAAc;AACvB;;;;;;AAOA,IAAa,2BAA2B;;;;;;;;;;;;;;;;;;;;AAqBxC,IAAa,mBAAmB;CAC9B,SAAS;CACT,SAAS;CACT,UAAU;CACV,qBAAqB;CACrB,gBAAgB;AAClB;;;ACjDA,SAAgB,aAAa,KAAc,UAA2B;CACpE,IAAI,eAAe,OAAO,OAAO,IAAI;CACrC,IAAI,QAAQ,QAAQ,OAAO,QAAQ,UAAU;EAC3C,MAAM,MAAM;EACZ,IAAI,OAAO,IAAI,YAAY,YAAY,IAAI,SAAS,OAAO,IAAI;EAC/D,IAAI,O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v4.3.2 | MIT License | https://tailwindcss.com */
|
|
2
2
|
@layer properties {
|
|
3
3
|
@supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {
|
|
4
4
|
*, :before, :after, ::backdrop {
|