@happyvertical/smrt-ledgers 0.30.0
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/AGENTS.md +36 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +124 -0
- package/dist/index.d.ts +647 -0
- package/dist/index.js +1172 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.json +1561 -0
- package/dist/smrt-knowledge.json +871 -0
- package/dist/types.d.ts +179 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
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 { }
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/**\n * Type definitions for smrt-ledgers\n */\n\nimport type { SmrtClassOptions } from '@happyvertical/smrt-core';\n\n/**\n * Epsilon value for floating-point balance comparisons.\n * Used to determine if debits and credits are balanced.\n */\nexport const BALANCE_EPSILON = 0.001;\n\n/**\n * The five core account types in double-entry accounting\n */\nexport type AccountType =\n | 'asset'\n | 'liability'\n | 'equity'\n | 'revenue'\n | 'expense';\n\n/**\n * Journal status lifecycle\n */\nexport type JournalStatus = 'draft' | 'posted' | 'voided';\n\n/**\n * Options for creating an Account\n */\nexport interface AccountOptions extends SmrtClassOptions {\n tenantId?: string | null;\n number?: string;\n name?: string;\n description?: string;\n type?: AccountType;\n parentId?: string | null;\n active?: boolean;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for creating a Journal\n */\nexport interface JournalOptions extends SmrtClassOptions {\n tenantId?: string | null;\n number?: string;\n date?: Date;\n description?: string;\n sourceModule?: string;\n sourceRef?: string | null;\n status?: JournalStatus;\n postedAt?: Date | null;\n voidedAt?: Date | null;\n voidReason?: string | null;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for creating a JournalEntry\n */\nexport interface JournalEntryOptions extends SmrtClassOptions {\n tenantId?: string | null;\n journalId?: string;\n accountId?: string;\n debit?: number;\n credit?: number;\n currency?: string;\n exchangeRate?: number;\n memo?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * A row in the trial balance report\n */\nexport interface TrialBalanceRow {\n accountId: string;\n accountNumber: string;\n accountName: string;\n accountType: AccountType;\n debitBalance: number;\n creditBalance: number;\n}\n\n/**\n * Account tree node for hierarchical display\n */\nexport interface AccountTreeNode {\n account: import('./models/Account').Account;\n children: AccountTreeNode[];\n}\n\n/**\n * Account tree structure\n */\nexport interface AccountTree {\n roots: AccountTreeNode[];\n}\n\n/**\n * Entry data for creating journal entries\n */\nexport interface JournalEntryData {\n accountId: string;\n debit?: number;\n credit?: number;\n currency?: string;\n exchangeRate?: number;\n memo?: string;\n}\n\n/**\n * Data for creating a complete journal with entries\n */\nexport interface CreateJournalData {\n date?: Date;\n description: string;\n sourceModule?: string;\n sourceRef?: string | null;\n entries: JournalEntryData[];\n metadata?: Record<string, unknown>;\n}\n"],"names":[],"mappings":"AAUO,MAAM,kBAAkB;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@happyvertical/smrt-ledgers",
|
|
3
|
+
"version": "0.30.0",
|
|
4
|
+
"description": "Double-entry accounting ledger for the SMRT framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./manifest": "./dist/manifest.json",
|
|
14
|
+
"./manifest.json": "./dist/manifest.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"CLAUDE.md",
|
|
19
|
+
"AGENTS.md"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"smrt",
|
|
23
|
+
"ledger",
|
|
24
|
+
"accounting",
|
|
25
|
+
"double-entry",
|
|
26
|
+
"journal",
|
|
27
|
+
"bookkeeping"
|
|
28
|
+
],
|
|
29
|
+
"author": "HappyVertical",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/happyvertical/smrt.git",
|
|
34
|
+
"directory": "packages/ledgers"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"registry": "https://registry.npmjs.org",
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@happyvertical/smrt-core": "0.30.0",
|
|
42
|
+
"@happyvertical/smrt-prompts": "0.30.0",
|
|
43
|
+
"@happyvertical/smrt-tenancy": "0.30.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "25.0.9",
|
|
47
|
+
"fast-glob": "^3.3.3",
|
|
48
|
+
"typescript": "^5.9.3",
|
|
49
|
+
"vite": "^7.3.1",
|
|
50
|
+
"vitest": "^4.0.17",
|
|
51
|
+
"@happyvertical/smrt-vitest": "0.30.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "vite build --mode library",
|
|
55
|
+
"dev": "vite build --watch",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"typecheck": "tsc -p tsconfig.typecheck.json"
|
|
58
|
+
}
|
|
59
|
+
}
|