@happyvertical/smrt-ledgers 0.51.32 → 0.51.34

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.
@@ -0,0 +1,80 @@
1
+ /**
2
+ * JournalEntry model - Individual ledger line
3
+ *
4
+ * The atomic unit of double-entry accounting - a single debit or credit.
5
+ * Each entry belongs to a Journal and references an Account.
6
+ */
7
+ import { SmrtObject } from '@happyvertical/smrt-core';
8
+ import type { JournalEntryOptions } from '../types';
9
+ export declare class JournalEntry extends SmrtObject {
10
+ /**
11
+ * Tenant ID for multi-tenancy support (nullable for global entries)
12
+ */
13
+ tenantId: string | null;
14
+ /**
15
+ * Parent journal ID (required)
16
+ */
17
+ journalId: string;
18
+ /**
19
+ * Account ID (required)
20
+ */
21
+ accountId: string;
22
+ /**
23
+ * Debit amount (left side)
24
+ */
25
+ debit: number;
26
+ /**
27
+ * Credit amount (right side)
28
+ */
29
+ credit: number;
30
+ /**
31
+ * Currency code (e.g., "USD", "CAD", "EUR")
32
+ */
33
+ currency: string;
34
+ /**
35
+ * Exchange rate to base currency
36
+ */
37
+ exchangeRate: number;
38
+ /**
39
+ * Line memo/description
40
+ */
41
+ memo: string;
42
+ /**
43
+ * Extensible metadata
44
+ */
45
+ metadata: Record<string, unknown>;
46
+ constructor(options?: JournalEntryOptions);
47
+ /**
48
+ * Validate entry before save
49
+ */
50
+ protected validateBeforeSave(): Promise<void>;
51
+ /**
52
+ * Check if this is a debit entry
53
+ */
54
+ isDebit(): boolean;
55
+ /**
56
+ * Check if this is a credit entry
57
+ */
58
+ isCredit(): boolean;
59
+ /**
60
+ * Get the entry amount (positive value regardless of debit/credit)
61
+ */
62
+ getAmount(): number;
63
+ /**
64
+ * Get the amount in base currency
65
+ */
66
+ getBaseAmount(): number;
67
+ /**
68
+ * Get the parent journal
69
+ */
70
+ getJournal(): Promise<import('./Journal').Journal | null>;
71
+ /**
72
+ * Get the account
73
+ */
74
+ getAccount(): Promise<import('./Account').Account | null>;
75
+ /**
76
+ * Get a formatted description of this entry
77
+ */
78
+ getDescription(): Promise<string>;
79
+ }
80
+ //# sourceMappingURL=JournalEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JournalEntry.d.ts","sourceRoot":"","sources":["../../src/models/JournalEntry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGpD,qBAMa,YAAa,SAAQ,UAAU;IAC1C;;OAEG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;OAEG;IAEH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG;IAIH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAO;IAEpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAO;IAErB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAS;IAEzB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAO;IAE3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAM;IAElB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;gBAE3B,OAAO,GAAE,mBAAwB;IAa7C;;OAEG;cACa,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BnD;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAO/D;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAO/D;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CAQxC"}
@@ -0,0 +1,4 @@
1
+ export { Account } from './Account';
2
+ export { Journal } from './Journal';
3
+ export { JournalEntry } from './JournalEntry';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Prompt registrations for the @happyvertical/smrt-ledgers package.
3
+ *
4
+ * Prompts are registered at module-load time via `definePrompt()` so that
5
+ * tenant-aware overrides can be applied at call time via `resolvePrompt()`.
6
+ *
7
+ * Mirrors the pattern used by `@happyvertical/smrt-properties` (see
8
+ * `prompts.ts`) and `@happyvertical/smrt-content` (see `content-prompts.ts`).
9
+ */
10
+ import { type ResolvedPromptAI } from '@happyvertical/smrt-prompts';
11
+ export declare const smrtLedgersJournalSummarizePrompt: import("@happyvertical/smrt-prompts").PromptDefinition;
12
+ export declare function promptMessageOptions(ai: ResolvedPromptAI): {
13
+ maxTokens?: number | undefined;
14
+ temperature?: number | undefined;
15
+ model?: string | undefined;
16
+ };
17
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AAiBrC,eAAO,MAAM,iCAAiC,wDAgB5C,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,gBAAgB;;;;EASxD"}
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-ledgers",
6
- "packageVersion": "0.51.32",
6
+ "packageVersion": "0.51.34",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "0323a123e4a958e811bf392ee87650452078f55c795ec348c28e39dcd4da307c",
11
- "packageJson": "a51fa96016adca9d7d1d3ac1fbe26d99d07d396e54c689ffe24a39db33210f7b",
10
+ "manifest": "72d1141b516e662631d09f37a536952e747df356166b150cf144150824594218",
11
+ "packageJson": "eca0cfc426f77736ac78450fd7b7124bd4783eada28125f6b2f48c950396fa17",
12
12
  "agents": "ae2190496d153852ff73d18f871a829303927e1c65053b5325b02c0d9f470bfe"
13
13
  },
14
14
  "exports": [
@@ -23,7 +23,7 @@
23
23
  "@happyvertical/smrt-vitest": "workspace:*",
24
24
  "@types/node": "24.13.6",
25
25
  "fast-glob": "^3.3.3",
26
- "typescript": "5.9.3",
26
+ "typescript": "6.0.3",
27
27
  "vite": "8.1.4",
28
28
  "vitest": "4.1.10"
29
29
  },
package/dist/types.d.ts CHANGED
@@ -1,179 +1,107 @@
1
- import { SmrtClassOptions } from '@happyvertical/smrt-core';
2
- import { SmrtHierarchical } from '@happyvertical/smrt-core';
3
-
4
- declare class Account extends SmrtHierarchical {
5
- /**
6
- * Tenant ID for multi-tenancy support (nullable for global accounts)
7
- */
8
- tenantId: string | null;
9
- /**
10
- * Account number (e.g., "1000", "5030")
11
- */
12
- number: string;
13
- /**
14
- * Account name (e.g., "Cash", "Coffee Expense")
15
- */
16
- name: string;
17
- /**
18
- * Account description
19
- */
20
- description: string;
21
- /**
22
- * Account type - one of the 5 core types
23
- */
24
- type: AccountType;
25
- /**
26
- * Whether the account is active
27
- */
28
- active: boolean;
29
- /**
30
- * Extensible metadata
31
- */
32
- metadata: Record<string, unknown>;
33
- constructor(options?: AccountOptions);
34
- /**
35
- * Check if this is a top-level account (no parent)
36
- */
37
- isTopLevel(): boolean;
38
- /**
39
- * Check if this is a debit-normal account (Asset, Expense)
40
- * Debit-normal accounts increase with debits
41
- */
42
- isDebitNormal(): boolean;
43
- /**
44
- * Check if this is a credit-normal account (Liability, Equity, Revenue)
45
- * Credit-normal accounts increase with credits
46
- */
47
- isCreditNormal(): boolean;
48
- /**
49
- * Get full account path (e.g., "Assets > Current > Cash")
50
- */
51
- getFullPath(): Promise<string>;
52
- /**
53
- * Build tree node for this account and its children
54
- */
55
- toTreeNode(): Promise<AccountTreeNode>;
56
- /**
57
- * Get the current balance of this account
58
- */
59
- getBalance(asOfDate?: Date): Promise<number>;
60
- /**
61
- * Create a sub-account under this account
62
- */
63
- createChild(options: Omit<AccountOptions, 'parentId' | 'type'>): Promise<Account>;
64
- }
65
-
66
- /**
67
- * Options for creating an Account
68
- */
69
- export declare interface AccountOptions extends SmrtClassOptions {
70
- tenantId?: string | null;
71
- number?: string;
72
- name?: string;
73
- description?: string;
74
- type?: AccountType;
75
- parentId?: string | null;
76
- active?: boolean;
77
- metadata?: Record<string, unknown>;
78
- }
79
-
80
- /**
81
- * Account tree structure
82
- */
83
- export declare interface AccountTree {
84
- roots: AccountTreeNode[];
85
- }
86
-
87
- /**
88
- * Account tree node for hierarchical display
89
- */
90
- export declare interface AccountTreeNode {
91
- account: Account;
92
- children: AccountTreeNode[];
93
- }
94
-
95
- /**
96
- * The five core account types in double-entry accounting
97
- */
98
- export declare type AccountType = 'asset' | 'liability' | 'equity' | 'revenue' | 'expense';
99
-
100
- /**
101
- * Epsilon value for floating-point balance comparisons.
102
- * Used to determine if debits and credits are balanced.
103
- */
104
- export declare const BALANCE_EPSILON = 0.001;
105
-
106
- /**
107
- * Data for creating a complete journal with entries
108
- */
109
- export declare interface CreateJournalData {
110
- date?: Date;
111
- description: string;
112
- sourceModule?: string;
113
- sourceRef?: string | null;
114
- entries: JournalEntryData[];
115
- metadata?: Record<string, unknown>;
116
- }
117
-
118
- /**
119
- * Entry data for creating journal entries
120
- */
121
- export declare interface JournalEntryData {
122
- accountId: string;
123
- debit?: number;
124
- credit?: number;
125
- currency?: string;
126
- exchangeRate?: number;
127
- memo?: string;
128
- }
129
-
130
- /**
131
- * Options for creating a JournalEntry
132
- */
133
- export declare interface JournalEntryOptions extends SmrtClassOptions {
134
- tenantId?: string | null;
135
- journalId?: string;
136
- accountId?: string;
137
- debit?: number;
138
- credit?: number;
139
- currency?: string;
140
- exchangeRate?: number;
141
- memo?: string;
142
- metadata?: Record<string, unknown>;
143
- }
144
-
145
- /**
146
- * Options for creating a Journal
147
- */
148
- export declare interface JournalOptions extends SmrtClassOptions {
149
- tenantId?: string | null;
150
- number?: string;
151
- date?: Date;
152
- description?: string;
153
- sourceModule?: string;
154
- sourceRef?: string | null;
155
- status?: JournalStatus;
156
- postedAt?: Date | null;
157
- voidedAt?: Date | null;
158
- voidReason?: string | null;
159
- metadata?: Record<string, unknown>;
160
- }
161
-
162
- /**
163
- * Journal status lifecycle
164
- */
165
- export declare type JournalStatus = 'draft' | 'posted' | 'voided';
166
-
167
- /**
168
- * A row in the trial balance report
169
- */
170
- export declare interface TrialBalanceRow {
171
- accountId: string;
172
- accountNumber: string;
173
- accountName: string;
174
- accountType: AccountType;
175
- debitBalance: number;
176
- creditBalance: number;
177
- }
178
-
179
- export { }
1
+ /**
2
+ * Type definitions for smrt-ledgers
3
+ */
4
+ import type { SmrtClassOptions } from '@happyvertical/smrt-core';
5
+ /**
6
+ * Epsilon value for floating-point balance comparisons.
7
+ * Used to determine if debits and credits are balanced.
8
+ */
9
+ export declare const BALANCE_EPSILON = 0.001;
10
+ /**
11
+ * The five core account types in double-entry accounting
12
+ */
13
+ export type AccountType = 'asset' | 'liability' | 'equity' | 'revenue' | 'expense';
14
+ /**
15
+ * Journal status lifecycle
16
+ */
17
+ export type JournalStatus = 'draft' | 'posted' | 'voided';
18
+ /**
19
+ * Options for creating an Account
20
+ */
21
+ export interface AccountOptions extends SmrtClassOptions {
22
+ tenantId?: string | null;
23
+ number?: string;
24
+ name?: string;
25
+ description?: string;
26
+ type?: AccountType;
27
+ parentId?: string | null;
28
+ active?: boolean;
29
+ metadata?: Record<string, unknown>;
30
+ }
31
+ /**
32
+ * Options for creating a Journal
33
+ */
34
+ export interface JournalOptions extends SmrtClassOptions {
35
+ tenantId?: string | null;
36
+ number?: string;
37
+ date?: Date;
38
+ description?: string;
39
+ sourceModule?: string;
40
+ sourceRef?: string | null;
41
+ status?: JournalStatus;
42
+ postedAt?: Date | null;
43
+ voidedAt?: Date | null;
44
+ voidReason?: string | null;
45
+ metadata?: Record<string, unknown>;
46
+ }
47
+ /**
48
+ * Options for creating a JournalEntry
49
+ */
50
+ export interface JournalEntryOptions extends SmrtClassOptions {
51
+ tenantId?: string | null;
52
+ journalId?: string;
53
+ accountId?: string;
54
+ debit?: number;
55
+ credit?: number;
56
+ currency?: string;
57
+ exchangeRate?: number;
58
+ memo?: string;
59
+ metadata?: Record<string, unknown>;
60
+ }
61
+ /**
62
+ * A row in the trial balance report
63
+ */
64
+ export interface TrialBalanceRow {
65
+ accountId: string;
66
+ accountNumber: string;
67
+ accountName: string;
68
+ accountType: AccountType;
69
+ debitBalance: number;
70
+ creditBalance: number;
71
+ }
72
+ /**
73
+ * Account tree node for hierarchical display
74
+ */
75
+ export interface AccountTreeNode {
76
+ account: import('./models/Account').Account;
77
+ children: AccountTreeNode[];
78
+ }
79
+ /**
80
+ * Account tree structure
81
+ */
82
+ export interface AccountTree {
83
+ roots: AccountTreeNode[];
84
+ }
85
+ /**
86
+ * Entry data for creating journal entries
87
+ */
88
+ export interface JournalEntryData {
89
+ accountId: string;
90
+ debit?: number;
91
+ credit?: number;
92
+ currency?: string;
93
+ exchangeRate?: number;
94
+ memo?: string;
95
+ }
96
+ /**
97
+ * Data for creating a complete journal with entries
98
+ */
99
+ export interface CreateJournalData {
100
+ date?: Date;
101
+ description: string;
102
+ sourceModule?: string;
103
+ sourceRef?: string | null;
104
+ entries: JournalEntryData[];
105
+ metadata?: Record<string, unknown>;
106
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AC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-ledgers",
3
- "version": "0.51.32",
3
+ "version": "0.51.34",
4
4
  "description": "Double-entry accounting ledger for the SMRT framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,15 +38,15 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@happyvertical/smrt-core": "0.51.32",
42
- "@happyvertical/smrt-prompts": "0.51.32",
43
- "@happyvertical/smrt-tenancy": "0.51.32"
41
+ "@happyvertical/smrt-core": "0.51.34",
42
+ "@happyvertical/smrt-prompts": "0.51.34",
43
+ "@happyvertical/smrt-tenancy": "0.51.34"
44
44
  },
45
45
  "devDependencies": {
46
- "@happyvertical/smrt-vitest": "0.51.32",
46
+ "@happyvertical/smrt-vitest": "0.51.34",
47
47
  "@types/node": "24.13.6",
48
48
  "fast-glob": "^3.3.3",
49
- "typescript": "5.9.3",
49
+ "typescript": "6.0.3",
50
50
  "vite": "8.1.4",
51
51
  "vitest": "4.1.10"
52
52
  },