@happyvertical/smrt-ledgers 0.51.24 → 0.51.25

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.
@@ -2,243 +2,176 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-ledgers",
5
- "packageVersion": "0.51.24",
5
+ "packageVersion": "0.51.25",
6
6
  "objects": {
7
- "@happyvertical/smrt-ledgers:Account": {
8
- "name": "account",
9
- "className": "Account",
10
- "qualifiedName": "@happyvertical/smrt-ledgers:Account",
7
+ "@happyvertical/smrt-ledgers:AccountCollection": {
8
+ "name": "accountcollection",
9
+ "className": "AccountCollection",
10
+ "qualifiedName": "@happyvertical/smrt-ledgers:AccountCollection",
11
11
  "collection": "accounts",
12
- "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/models/Account.ts",
12
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Accounts.ts",
13
13
  "packageName": "@happyvertical/smrt-ledgers",
14
- "fields": {
15
- "parentId": {
16
- "type": "foreignKey",
17
- "required": false,
18
- "related": "Account",
19
- "_meta": {
20
- "nullable": true
21
- }
22
- },
23
- "tenantId": {
24
- "type": "text",
25
- "required": false,
26
- "_meta": {
27
- "sqlType": "UUID",
28
- "nullable": true,
29
- "__tenancy": {
30
- "isTenantIdField": true,
31
- "autoFilter": true,
32
- "required": false,
33
- "autoPopulate": true,
34
- "nullable": true,
35
- "mode": "optional",
36
- "field": "tenantId",
37
- "allowSuperAdminBypass": false
38
- }
39
- }
40
- },
41
- "number": {
42
- "type": "text",
43
- "required": false,
44
- "default": ""
45
- },
46
- "name": {
47
- "type": "text",
48
- "required": false,
49
- "default": ""
50
- },
51
- "description": {
52
- "type": "text",
53
- "required": false,
54
- "default": ""
55
- },
56
- "type": {
57
- "type": "text",
58
- "required": false,
59
- "default": "asset"
60
- },
61
- "active": {
62
- "type": "boolean",
63
- "required": false,
64
- "default": true
65
- },
66
- "metadata": {
67
- "type": "json",
68
- "required": false,
69
- "default": {}
70
- }
71
- },
14
+ "fields": {},
72
15
  "methods": {
73
- "getParent": {
74
- "name": "getParent",
75
- "async": true,
76
- "parameters": [],
77
- "returnType": "Promise<this | null>",
78
- "isStatic": false,
79
- "isPublic": true
80
- },
81
- "getChildren": {
82
- "name": "getChildren",
16
+ "findByNumber": {
17
+ "name": "findByNumber",
83
18
  "async": true,
84
- "parameters": [],
85
- "returnType": "Promise<this[]>",
19
+ "parameters": [
20
+ {
21
+ "name": "number",
22
+ "type": "string",
23
+ "optional": false
24
+ }
25
+ ],
26
+ "returnType": "Promise<Account | null>",
86
27
  "isStatic": false,
87
28
  "isPublic": true
88
29
  },
89
- "getAncestors": {
90
- "name": "getAncestors",
30
+ "findByType": {
31
+ "name": "findByType",
91
32
  "async": true,
92
- "parameters": [],
93
- "returnType": "Promise<this[]>",
33
+ "parameters": [
34
+ {
35
+ "name": "type",
36
+ "type": "AccountType",
37
+ "optional": false
38
+ }
39
+ ],
40
+ "returnType": "Promise<Account[]>",
94
41
  "isStatic": false,
95
42
  "isPublic": true
96
43
  },
97
- "getDescendants": {
98
- "name": "getDescendants",
44
+ "findActive": {
45
+ "name": "findActive",
99
46
  "async": true,
100
47
  "parameters": [],
101
- "returnType": "Promise<this[]>",
48
+ "returnType": "Promise<Account[]>",
102
49
  "isStatic": false,
103
50
  "isPublic": true
104
51
  },
105
- "getHierarchy": {
106
- "name": "getHierarchy",
52
+ "findTopLevel": {
53
+ "name": "findTopLevel",
107
54
  "async": true,
108
55
  "parameters": [],
109
- "returnType": "Promise<HierarchyView<this>>",
56
+ "returnType": "Promise<Account[]>",
110
57
  "isStatic": false,
111
58
  "isPublic": true
112
59
  },
113
- "moveTo": {
114
- "name": "moveTo",
60
+ "findChildren": {
61
+ "name": "findChildren",
115
62
  "async": true,
116
63
  "parameters": [
117
64
  {
118
- "name": "newParent",
119
- "type": "this | string | null",
120
- "optional": false,
121
- "unionBranches": [
122
- {
123
- "type": "this"
124
- },
125
- {
126
- "type": "string"
127
- },
128
- {
129
- "type": "null"
130
- }
131
- ]
65
+ "name": "parentId",
66
+ "type": "string",
67
+ "optional": false
132
68
  }
133
69
  ],
134
- "returnType": "Promise<void>",
135
- "isStatic": false,
136
- "isPublic": true
137
- },
138
- "isTopLevel": {
139
- "name": "isTopLevel",
140
- "async": false,
141
- "parameters": [],
142
- "returnType": "boolean",
70
+ "returnType": "Promise<Account[]>",
143
71
  "isStatic": false,
144
72
  "isPublic": true
145
73
  },
146
- "isDebitNormal": {
147
- "name": "isDebitNormal",
148
- "async": false,
74
+ "getTree": {
75
+ "name": "getTree",
76
+ "async": true,
149
77
  "parameters": [],
150
- "returnType": "boolean",
78
+ "returnType": "Promise<AccountTree>",
151
79
  "isStatic": false,
152
80
  "isPublic": true
153
81
  },
154
- "isCreditNormal": {
155
- "name": "isCreditNormal",
156
- "async": false,
157
- "parameters": [],
158
- "returnType": "boolean",
82
+ "getOrCreateByNumber": {
83
+ "name": "getOrCreateByNumber",
84
+ "async": true,
85
+ "parameters": [
86
+ {
87
+ "name": "number",
88
+ "type": "string",
89
+ "optional": false
90
+ },
91
+ {
92
+ "name": "defaults",
93
+ "type": "Partial<object>",
94
+ "optional": true,
95
+ "memberTypes": [
96
+ "string",
97
+ "AccountType",
98
+ "string | null"
99
+ ]
100
+ }
101
+ ],
102
+ "returnType": "Promise<Account>",
159
103
  "isStatic": false,
160
104
  "isPublic": true
161
105
  },
162
- "getFullPath": {
163
- "name": "getFullPath",
106
+ "groupByType": {
107
+ "name": "groupByType",
164
108
  "async": true,
165
109
  "parameters": [],
166
- "returnType": "Promise<string>",
110
+ "returnType": "Promise<Record<AccountType, Account[]>>",
167
111
  "isStatic": false,
168
112
  "isPublic": true
169
113
  },
170
- "toTreeNode": {
171
- "name": "toTreeNode",
114
+ "getDescendants": {
115
+ "name": "getDescendants",
172
116
  "async": true,
173
- "parameters": [],
174
- "returnType": "Promise<AccountTreeNode>",
117
+ "parameters": [
118
+ {
119
+ "name": "accountId",
120
+ "type": "string",
121
+ "optional": false
122
+ }
123
+ ],
124
+ "returnType": "Promise<Account[]>",
175
125
  "isStatic": false,
176
126
  "isPublic": true
177
127
  },
178
- "getBalance": {
179
- "name": "getBalance",
128
+ "findByTenant": {
129
+ "name": "findByTenant",
180
130
  "async": true,
181
131
  "parameters": [
182
132
  {
183
- "name": "asOfDate",
184
- "type": "Date",
185
- "optional": true
133
+ "name": "tenantId",
134
+ "type": "string",
135
+ "optional": false
186
136
  }
187
137
  ],
188
- "returnType": "Promise<number>",
138
+ "returnType": "Promise<Account[]>",
189
139
  "isStatic": false,
190
140
  "isPublic": true
191
141
  },
192
- "createChild": {
193
- "name": "createChild",
142
+ "findGlobal": {
143
+ "name": "findGlobal",
144
+ "async": true,
145
+ "parameters": [],
146
+ "returnType": "Promise<Account[]>",
147
+ "isStatic": false,
148
+ "isPublic": true
149
+ },
150
+ "findWithGlobals": {
151
+ "name": "findWithGlobals",
194
152
  "async": true,
195
153
  "parameters": [
196
154
  {
197
- "name": "options",
198
- "type": "Omit<AccountOptions, 'parentId' | 'type'>",
155
+ "name": "tenantId",
156
+ "type": "string",
199
157
  "optional": false
200
158
  }
201
159
  ],
202
- "returnType": "Promise<Account>",
160
+ "returnType": "Promise<Account[]>",
203
161
  "isStatic": false,
204
162
  "isPublic": true
205
163
  }
206
164
  },
207
165
  "decoratorConfig": {
208
- "api": {
209
- "include": [
210
- "list",
211
- "get",
212
- "create",
213
- "update",
214
- "delete"
215
- ]
216
- },
217
- "mcp": {
218
- "include": [
219
- "list",
220
- "get",
221
- "create"
222
- ]
223
- },
224
- "cli": {
225
- "skipApiCheck": true
226
- },
227
- "tenantScoped": {
228
- "mode": "optional"
229
- },
230
- "conflictColumns": [
231
- "tenant_id",
232
- "slug",
233
- "context"
234
- ]
166
+ "tableName": "ledger_accounts"
235
167
  },
236
- "extends": "SmrtHierarchical",
237
- "exportName": "Account",
238
- "collectionExportName": "AccountCollection",
168
+ "extends": "SmrtCollection",
169
+ "extendsTypeArg": "Account",
170
+ "exportName": "AccountCollection",
171
+ "collectionExportName": "AccountCollectionCollection",
239
172
  "schema": {
240
- "tableName": "accounts",
241
- "ddl": "CREATE TABLE IF NOT EXISTS \"accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
173
+ "tableName": "ledger_accounts",
174
+ "ddl": "CREATE TABLE IF NOT EXISTS \"ledger_accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
242
175
  "columns": {
243
176
  "id": {
244
177
  "type": "UUID",
@@ -271,7 +204,7 @@
271
204
  "notNull": false,
272
205
  "unique": false,
273
206
  "foreignKey": {
274
- "table": "accounts",
207
+ "table": "ledger_accounts",
275
208
  "column": "id",
276
209
  "onDelete": "NO ACTION",
277
210
  "onUpdate": "CASCADE"
@@ -322,7 +255,7 @@
322
255
  },
323
256
  "indexes": [
324
257
  {
325
- "name": "accounts_slug_context_idx",
258
+ "name": "ledger_accounts_slug_context_idx",
326
259
  "columns": [
327
260
  "tenant_id",
328
261
  "slug",
@@ -332,238 +265,185 @@
332
265
  "nullsNotDistinct": true
333
266
  },
334
267
  {
335
- "name": "accounts_tenant_id_created_at_idx",
268
+ "name": "ledger_accounts_tenant_id_created_at_idx",
336
269
  "columns": [
337
270
  "tenant_id",
338
271
  "created_at"
339
272
  ]
340
273
  },
341
274
  {
342
- "name": "accounts_parent_id_idx",
275
+ "name": "ledger_accounts_parent_id_idx",
343
276
  "columns": [
344
277
  "parent_id"
345
278
  ]
346
279
  }
347
280
  ],
348
- "version": "62bb562a"
281
+ "version": "49630dae"
349
282
  },
350
283
  "importPath": "@happyvertical/smrt-ledgers"
351
284
  },
352
- "@happyvertical/smrt-ledgers:Journal": {
353
- "name": "journal",
354
- "className": "Journal",
355
- "qualifiedName": "@happyvertical/smrt-ledgers:Journal",
356
- "collection": "journals",
357
- "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/models/Journal.ts",
285
+ "@happyvertical/smrt-ledgers:JournalEntryCollection": {
286
+ "name": "journalentrycollection",
287
+ "className": "JournalEntryCollection",
288
+ "qualifiedName": "@happyvertical/smrt-ledgers:JournalEntryCollection",
289
+ "collection": "journalentries",
290
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/collections/JournalEntries.ts",
358
291
  "packageName": "@happyvertical/smrt-ledgers",
359
- "fields": {
360
- "tenantId": {
361
- "type": "text",
362
- "required": false,
363
- "_meta": {
364
- "sqlType": "UUID",
365
- "nullable": true,
366
- "__tenancy": {
367
- "isTenantIdField": true,
368
- "autoFilter": true,
369
- "required": false,
370
- "autoPopulate": true,
371
- "nullable": true,
372
- "mode": "optional",
373
- "field": "tenantId",
374
- "allowSuperAdminBypass": false
375
- }
376
- }
377
- },
378
- "number": {
379
- "type": "text",
380
- "required": false,
381
- "default": ""
382
- },
383
- "date": {
384
- "type": "datetime",
385
- "required": false
386
- },
387
- "description": {
388
- "type": "text",
389
- "required": false,
390
- "default": ""
391
- },
392
- "sourceModule": {
393
- "type": "text",
394
- "required": false,
395
- "default": ""
396
- },
397
- "sourceRef": {
398
- "type": "text",
399
- "required": false
400
- },
401
- "status": {
402
- "type": "text",
403
- "required": false,
404
- "default": "draft"
405
- },
406
- "postedAt": {
407
- "type": "datetime",
408
- "required": false
409
- },
410
- "voidedAt": {
411
- "type": "datetime",
412
- "required": false
413
- },
414
- "voidReason": {
415
- "type": "text",
416
- "required": false
417
- },
418
- "metadata": {
419
- "type": "json",
420
- "required": false,
421
- "default": {}
422
- }
423
- },
292
+ "fields": {},
424
293
  "methods": {
425
- "isDraft": {
426
- "name": "isDraft",
427
- "async": false,
428
- "parameters": [],
429
- "returnType": "boolean",
430
- "isStatic": false,
431
- "isPublic": true
432
- },
433
- "isPosted": {
434
- "name": "isPosted",
435
- "async": false,
436
- "parameters": [],
437
- "returnType": "boolean",
294
+ "findByJournal": {
295
+ "name": "findByJournal",
296
+ "async": true,
297
+ "parameters": [
298
+ {
299
+ "name": "journalId",
300
+ "type": "string",
301
+ "optional": false
302
+ }
303
+ ],
304
+ "returnType": "Promise<JournalEntry[]>",
438
305
  "isStatic": false,
439
306
  "isPublic": true
440
307
  },
441
- "isVoided": {
442
- "name": "isVoided",
443
- "async": false,
444
- "parameters": [],
445
- "returnType": "boolean",
308
+ "findByAccount": {
309
+ "name": "findByAccount",
310
+ "async": true,
311
+ "parameters": [
312
+ {
313
+ "name": "accountId",
314
+ "type": "string",
315
+ "optional": false
316
+ }
317
+ ],
318
+ "returnType": "Promise<JournalEntry[]>",
446
319
  "isStatic": false,
447
320
  "isPublic": true
448
321
  },
449
- "isEditable": {
450
- "name": "isEditable",
451
- "async": false,
452
- "parameters": [],
453
- "returnType": "boolean",
322
+ "getAccountBalance": {
323
+ "name": "getAccountBalance",
324
+ "async": true,
325
+ "parameters": [
326
+ {
327
+ "name": "accountId",
328
+ "type": "string",
329
+ "optional": false
330
+ },
331
+ {
332
+ "name": "asOfDate",
333
+ "type": "Date",
334
+ "optional": true
335
+ }
336
+ ],
337
+ "returnType": "Promise<number>",
454
338
  "isStatic": false,
455
339
  "isPublic": true
456
340
  },
457
- "getEntries": {
458
- "name": "getEntries",
341
+ "getTrialBalance": {
342
+ "name": "getTrialBalance",
459
343
  "async": true,
460
- "parameters": [],
461
- "returnType": "any",
344
+ "parameters": [
345
+ {
346
+ "name": "asOfDate",
347
+ "type": "Date",
348
+ "optional": true
349
+ }
350
+ ],
351
+ "returnType": "Promise<TrialBalanceRow[]>",
462
352
  "isStatic": false,
463
353
  "isPublic": true
464
354
  },
465
- "getTotalDebits": {
466
- "name": "getTotalDebits",
355
+ "getTotalsForDateRange": {
356
+ "name": "getTotalsForDateRange",
467
357
  "async": true,
468
- "parameters": [],
469
- "returnType": "Promise<number>",
358
+ "parameters": [
359
+ {
360
+ "name": "start",
361
+ "type": "Date",
362
+ "optional": false
363
+ },
364
+ {
365
+ "name": "end",
366
+ "type": "Date",
367
+ "optional": false
368
+ }
369
+ ],
370
+ "returnType": "Promise<object>",
470
371
  "isStatic": false,
471
372
  "isPublic": true
472
373
  },
473
- "getTotalCredits": {
474
- "name": "getTotalCredits",
374
+ "findByAccounts": {
375
+ "name": "findByAccounts",
475
376
  "async": true,
476
- "parameters": [],
477
- "returnType": "Promise<number>",
377
+ "parameters": [
378
+ {
379
+ "name": "accountIds",
380
+ "type": "string[]",
381
+ "optional": false
382
+ }
383
+ ],
384
+ "returnType": "Promise<JournalEntry[]>",
478
385
  "isStatic": false,
479
386
  "isPublic": true
480
387
  },
481
- "isBalanced": {
482
- "name": "isBalanced",
388
+ "getAccountLedger": {
389
+ "name": "getAccountLedger",
483
390
  "async": true,
484
- "parameters": [],
485
- "returnType": "Promise<boolean>",
391
+ "parameters": [
392
+ {
393
+ "name": "accountId",
394
+ "type": "string",
395
+ "optional": false
396
+ }
397
+ ],
398
+ "returnType": "Promise<Array<object>>",
486
399
  "isStatic": false,
487
400
  "isPublic": true
488
401
  },
489
- "addEntry": {
490
- "name": "addEntry",
402
+ "findByTenant": {
403
+ "name": "findByTenant",
491
404
  "async": true,
492
405
  "parameters": [
493
406
  {
494
- "name": "data",
495
- "type": "JournalEntryData",
407
+ "name": "tenantId",
408
+ "type": "string",
496
409
  "optional": false
497
410
  }
498
411
  ],
499
- "returnType": "Promise<void>",
412
+ "returnType": "Promise<JournalEntry[]>",
500
413
  "isStatic": false,
501
414
  "isPublic": true
502
415
  },
503
- "post": {
504
- "name": "post",
416
+ "findGlobal": {
417
+ "name": "findGlobal",
505
418
  "async": true,
506
419
  "parameters": [],
507
- "returnType": "Promise<void>",
420
+ "returnType": "Promise<JournalEntry[]>",
508
421
  "isStatic": false,
509
422
  "isPublic": true
510
423
  },
511
- "void": {
512
- "name": "void",
424
+ "findWithGlobals": {
425
+ "name": "findWithGlobals",
513
426
  "async": true,
514
427
  "parameters": [
515
428
  {
516
- "name": "reason",
429
+ "name": "tenantId",
517
430
  "type": "string",
518
431
  "optional": false
519
432
  }
520
433
  ],
521
- "returnType": "Promise<void>",
522
- "isStatic": false,
523
- "isPublic": true
524
- },
525
- "summarize": {
526
- "name": "summarize",
527
- "async": true,
528
- "parameters": [],
529
- "returnType": "Promise<string>",
434
+ "returnType": "Promise<JournalEntry[]>",
530
435
  "isStatic": false,
531
436
  "isPublic": true
532
437
  }
533
438
  },
534
- "decoratorConfig": {
535
- "api": {
536
- "include": [
537
- "list",
538
- "get",
539
- "create"
540
- ]
541
- },
542
- "mcp": {
543
- "include": [
544
- "list",
545
- "get",
546
- "create"
547
- ]
548
- },
549
- "cli": {
550
- "skipApiCheck": true
551
- },
552
- "tenantScoped": {
553
- "mode": "optional"
554
- },
555
- "conflictColumns": [
556
- "tenant_id",
557
- "slug",
558
- "context"
559
- ]
560
- },
561
- "extends": "SmrtObject",
562
- "exportName": "Journal",
563
- "collectionExportName": "JournalCollection",
439
+ "decoratorConfig": {},
440
+ "extends": "SmrtCollection",
441
+ "extendsTypeArg": "JournalEntry",
442
+ "exportName": "JournalEntryCollection",
443
+ "collectionExportName": "JournalEntryCollectionCollection",
564
444
  "schema": {
565
- "tableName": "journals",
566
- "ddl": "CREATE TABLE IF NOT EXISTS \"journals\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"date\" TIMESTAMP,\n \"description\" TEXT DEFAULT '',\n \"source_module\" TEXT DEFAULT '',\n \"source_ref\" TEXT,\n \"status\" TEXT DEFAULT 'draft',\n \"posted_at\" TIMESTAMP,\n \"voided_at\" TIMESTAMP,\n \"void_reason\" TEXT,\n \"metadata\" JSON DEFAULT '{}'\n);",
445
+ "tableName": "journal_entries",
446
+ "ddl": "CREATE TABLE IF NOT EXISTS \"journal_entries\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"journal_id\" UUID,\n \"account_id\" UUID,\n \"debit\" REAL DEFAULT 0,\n \"credit\" REAL DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"exchange_rate\" REAL DEFAULT 1,\n \"memo\" TEXT DEFAULT '',\n \"metadata\" JSON DEFAULT '{}'\n);",
567
447
  "columns": {
568
448
  "id": {
569
449
  "type": "UUID",
@@ -596,54 +476,59 @@
596
476
  "notNull": false,
597
477
  "unique": false
598
478
  },
599
- "number": {
600
- "type": "TEXT",
479
+ "journal_id": {
480
+ "type": "UUID",
481
+ "referenceKind": "foreignKey",
601
482
  "notNull": false,
602
483
  "unique": false,
603
- "default": ""
604
- },
605
- "date": {
606
- "type": "TIMESTAMP",
607
- "notNull": false,
608
- "unique": false
484
+ "foreignKey": {
485
+ "table": "journals",
486
+ "column": "id",
487
+ "onDelete": "NO ACTION",
488
+ "onUpdate": "CASCADE"
489
+ }
609
490
  },
610
- "description": {
611
- "type": "TEXT",
491
+ "account_id": {
492
+ "type": "UUID",
493
+ "referenceKind": "foreignKey",
612
494
  "notNull": false,
613
495
  "unique": false,
614
- "default": ""
496
+ "foreignKey": {
497
+ "table": "ledger_accounts",
498
+ "column": "id",
499
+ "onDelete": "NO ACTION",
500
+ "onUpdate": "CASCADE"
501
+ }
615
502
  },
616
- "source_module": {
617
- "type": "TEXT",
503
+ "debit": {
504
+ "type": "REAL",
618
505
  "notNull": false,
619
506
  "unique": false,
620
- "default": ""
507
+ "default": 0
621
508
  },
622
- "source_ref": {
623
- "type": "TEXT",
509
+ "credit": {
510
+ "type": "REAL",
624
511
  "notNull": false,
625
- "unique": false
512
+ "unique": false,
513
+ "default": 0
626
514
  },
627
- "status": {
515
+ "currency": {
628
516
  "type": "TEXT",
629
517
  "notNull": false,
630
518
  "unique": false,
631
- "default": "draft"
632
- },
633
- "posted_at": {
634
- "type": "TIMESTAMP",
635
- "notNull": false,
636
- "unique": false
519
+ "default": "USD"
637
520
  },
638
- "voided_at": {
639
- "type": "TIMESTAMP",
521
+ "exchange_rate": {
522
+ "type": "REAL",
640
523
  "notNull": false,
641
- "unique": false
524
+ "unique": false,
525
+ "default": 1
642
526
  },
643
- "void_reason": {
527
+ "memo": {
644
528
  "type": "TEXT",
645
529
  "notNull": false,
646
- "unique": false
530
+ "unique": false,
531
+ "default": ""
647
532
  },
648
533
  "metadata": {
649
534
  "type": "JSON",
@@ -654,7 +539,7 @@
654
539
  },
655
540
  "indexes": [
656
541
  {
657
- "name": "journals_slug_context_idx",
542
+ "name": "journal_entries_slug_context_idx",
658
543
  "columns": [
659
544
  "tenant_id",
660
545
  "slug",
@@ -664,173 +549,240 @@
664
549
  "nullsNotDistinct": true
665
550
  },
666
551
  {
667
- "name": "journals_tenant_id_created_at_idx",
552
+ "name": "journal_entries_tenant_id_created_at_idx",
668
553
  "columns": [
669
554
  "tenant_id",
670
555
  "created_at"
671
556
  ]
557
+ },
558
+ {
559
+ "name": "journal_entries_journal_id_idx",
560
+ "columns": [
561
+ "journal_id"
562
+ ]
563
+ },
564
+ {
565
+ "name": "journal_entries_account_id_idx",
566
+ "columns": [
567
+ "account_id"
568
+ ]
672
569
  }
673
570
  ],
674
- "version": "4b51d204"
571
+ "version": "93cdc848"
675
572
  },
676
573
  "importPath": "@happyvertical/smrt-ledgers"
677
574
  },
678
- "@happyvertical/smrt-ledgers:JournalEntry": {
679
- "name": "journalentry",
680
- "className": "JournalEntry",
681
- "qualifiedName": "@happyvertical/smrt-ledgers:JournalEntry",
682
- "collection": "journalentries",
683
- "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/models/JournalEntry.ts",
575
+ "@happyvertical/smrt-ledgers:JournalCollection": {
576
+ "name": "journalcollection",
577
+ "className": "JournalCollection",
578
+ "qualifiedName": "@happyvertical/smrt-ledgers:JournalCollection",
579
+ "collection": "journals",
580
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Journals.ts",
684
581
  "packageName": "@happyvertical/smrt-ledgers",
685
- "fields": {
686
- "tenantId": {
687
- "type": "text",
688
- "required": false,
689
- "_meta": {
690
- "sqlType": "UUID",
691
- "nullable": true,
692
- "__tenancy": {
693
- "isTenantIdField": true,
694
- "autoFilter": true,
695
- "required": false,
696
- "autoPopulate": true,
697
- "nullable": true,
698
- "mode": "optional",
699
- "field": "tenantId",
700
- "allowSuperAdminBypass": false
582
+ "fields": {},
583
+ "methods": {
584
+ "findByNumber": {
585
+ "name": "findByNumber",
586
+ "async": true,
587
+ "parameters": [
588
+ {
589
+ "name": "number",
590
+ "type": "string",
591
+ "optional": false
701
592
  }
702
- }
703
- },
704
- "journalId": {
705
- "type": "foreignKey",
706
- "required": false,
707
- "related": "Journal"
708
- },
709
- "accountId": {
710
- "type": "foreignKey",
711
- "required": false,
712
- "related": "Account"
713
- },
714
- "debit": {
715
- "type": "decimal",
716
- "required": false,
717
- "default": 0
718
- },
719
- "credit": {
720
- "type": "decimal",
721
- "required": false,
722
- "default": 0
723
- },
724
- "currency": {
725
- "type": "text",
726
- "required": false,
727
- "default": "USD"
593
+ ],
594
+ "returnType": "Promise<Journal | null>",
595
+ "isStatic": false,
596
+ "isPublic": true
728
597
  },
729
- "exchangeRate": {
730
- "type": "decimal",
731
- "required": false,
732
- "default": 1
598
+ "findByDateRange": {
599
+ "name": "findByDateRange",
600
+ "async": true,
601
+ "parameters": [
602
+ {
603
+ "name": "start",
604
+ "type": "Date",
605
+ "optional": false
606
+ },
607
+ {
608
+ "name": "end",
609
+ "type": "Date",
610
+ "optional": false
611
+ }
612
+ ],
613
+ "returnType": "Promise<Journal[]>",
614
+ "isStatic": false,
615
+ "isPublic": true
733
616
  },
734
- "memo": {
735
- "type": "text",
736
- "required": false,
737
- "default": ""
617
+ "findBySource": {
618
+ "name": "findBySource",
619
+ "async": true,
620
+ "parameters": [
621
+ {
622
+ "name": "sourceModule",
623
+ "type": "string",
624
+ "optional": false
625
+ }
626
+ ],
627
+ "returnType": "Promise<Journal[]>",
628
+ "isStatic": false,
629
+ "isPublic": true
738
630
  },
739
- "metadata": {
740
- "type": "json",
741
- "required": false,
742
- "default": {}
743
- }
744
- },
745
- "methods": {
746
- "isDebit": {
747
- "name": "isDebit",
748
- "async": false,
749
- "parameters": [],
750
- "returnType": "boolean",
631
+ "findByStatus": {
632
+ "name": "findByStatus",
633
+ "async": true,
634
+ "parameters": [
635
+ {
636
+ "name": "status",
637
+ "type": "JournalStatus",
638
+ "optional": false
639
+ }
640
+ ],
641
+ "returnType": "Promise<Journal[]>",
751
642
  "isStatic": false,
752
643
  "isPublic": true
753
644
  },
754
- "isCredit": {
755
- "name": "isCredit",
756
- "async": false,
645
+ "findDrafts": {
646
+ "name": "findDrafts",
647
+ "async": true,
757
648
  "parameters": [],
758
- "returnType": "boolean",
649
+ "returnType": "Promise<Journal[]>",
759
650
  "isStatic": false,
760
651
  "isPublic": true
761
652
  },
762
- "getAmount": {
763
- "name": "getAmount",
764
- "async": false,
653
+ "findPosted": {
654
+ "name": "findPosted",
655
+ "async": true,
765
656
  "parameters": [],
766
- "returnType": "number",
657
+ "returnType": "Promise<Journal[]>",
767
658
  "isStatic": false,
768
659
  "isPublic": true
769
660
  },
770
- "getBaseAmount": {
771
- "name": "getBaseAmount",
772
- "async": false,
773
- "parameters": [],
774
- "returnType": "number",
661
+ "createWithEntries": {
662
+ "name": "createWithEntries",
663
+ "async": true,
664
+ "parameters": [
665
+ {
666
+ "name": "data",
667
+ "type": "CreateJournalData",
668
+ "optional": false
669
+ }
670
+ ],
671
+ "returnType": "Promise<Journal>",
775
672
  "isStatic": false,
776
673
  "isPublic": true
777
674
  },
778
- "getJournal": {
779
- "name": "getJournal",
675
+ "post": {
676
+ "name": "post",
780
677
  "async": true,
781
- "parameters": [],
782
- "returnType": "any",
678
+ "parameters": [
679
+ {
680
+ "name": "journalId",
681
+ "type": "string",
682
+ "optional": false
683
+ }
684
+ ],
685
+ "returnType": "Promise<Journal>",
783
686
  "isStatic": false,
784
687
  "isPublic": true
785
688
  },
786
- "getAccount": {
787
- "name": "getAccount",
689
+ "void": {
690
+ "name": "void",
788
691
  "async": true,
789
- "parameters": [],
790
- "returnType": "any",
692
+ "parameters": [
693
+ {
694
+ "name": "journalId",
695
+ "type": "string",
696
+ "optional": false
697
+ },
698
+ {
699
+ "name": "reason",
700
+ "type": "string",
701
+ "optional": false
702
+ }
703
+ ],
704
+ "returnType": "Promise<Journal>",
791
705
  "isStatic": false,
792
706
  "isPublic": true
793
707
  },
794
- "getDescription": {
795
- "name": "getDescription",
708
+ "findBySourceRef": {
709
+ "name": "findBySourceRef",
796
710
  "async": true,
797
- "parameters": [],
798
- "returnType": "Promise<string>",
711
+ "parameters": [
712
+ {
713
+ "name": "sourceRef",
714
+ "type": "string",
715
+ "optional": false
716
+ }
717
+ ],
718
+ "returnType": "Promise<Journal[]>",
799
719
  "isStatic": false,
800
720
  "isPublic": true
801
- }
802
- },
803
- "decoratorConfig": {
804
- "api": {
805
- "include": [
806
- "list",
807
- "get"
808
- ]
809
721
  },
810
- "mcp": {
811
- "include": [
812
- "list",
813
- "get"
814
- ]
722
+ "findByMonth": {
723
+ "name": "findByMonth",
724
+ "async": true,
725
+ "parameters": [
726
+ {
727
+ "name": "year",
728
+ "type": "number",
729
+ "optional": false
730
+ },
731
+ {
732
+ "name": "month",
733
+ "type": "number",
734
+ "optional": false
735
+ }
736
+ ],
737
+ "returnType": "Promise<Journal[]>",
738
+ "isStatic": false,
739
+ "isPublic": true
815
740
  },
816
- "cli": {
817
- "skipApiCheck": true
741
+ "findByTenant": {
742
+ "name": "findByTenant",
743
+ "async": true,
744
+ "parameters": [
745
+ {
746
+ "name": "tenantId",
747
+ "type": "string",
748
+ "optional": false
749
+ }
750
+ ],
751
+ "returnType": "Promise<Journal[]>",
752
+ "isStatic": false,
753
+ "isPublic": true
818
754
  },
819
- "tenantScoped": {
820
- "mode": "optional"
755
+ "findGlobal": {
756
+ "name": "findGlobal",
757
+ "async": true,
758
+ "parameters": [],
759
+ "returnType": "Promise<Journal[]>",
760
+ "isStatic": false,
761
+ "isPublic": true
821
762
  },
822
- "conflictColumns": [
823
- "tenant_id",
824
- "slug",
825
- "context"
826
- ]
763
+ "findWithGlobals": {
764
+ "name": "findWithGlobals",
765
+ "async": true,
766
+ "parameters": [
767
+ {
768
+ "name": "tenantId",
769
+ "type": "string",
770
+ "optional": false
771
+ }
772
+ ],
773
+ "returnType": "Promise<Journal[]>",
774
+ "isStatic": false,
775
+ "isPublic": true
776
+ }
827
777
  },
828
- "extends": "SmrtObject",
829
- "exportName": "JournalEntry",
830
- "collectionExportName": "JournalEntryCollection",
778
+ "decoratorConfig": {},
779
+ "extends": "SmrtCollection",
780
+ "extendsTypeArg": "Journal",
781
+ "exportName": "JournalCollection",
782
+ "collectionExportName": "JournalCollectionCollection",
831
783
  "schema": {
832
- "tableName": "journal_entries",
833
- "ddl": "CREATE TABLE IF NOT EXISTS \"journal_entries\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"journal_id\" UUID,\n \"account_id\" UUID,\n \"debit\" REAL DEFAULT 0,\n \"credit\" REAL DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"exchange_rate\" REAL DEFAULT 1,\n \"memo\" TEXT DEFAULT '',\n \"metadata\" JSON DEFAULT '{}'\n);",
784
+ "tableName": "journals",
785
+ "ddl": "CREATE TABLE IF NOT EXISTS \"journals\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"date\" TIMESTAMP,\n \"description\" TEXT DEFAULT '',\n \"source_module\" TEXT DEFAULT '',\n \"source_ref\" TEXT,\n \"status\" TEXT DEFAULT 'draft',\n \"posted_at\" TIMESTAMP,\n \"voided_at\" TIMESTAMP,\n \"void_reason\" TEXT,\n \"metadata\" JSON DEFAULT '{}'\n);",
834
786
  "columns": {
835
787
  "id": {
836
788
  "type": "UUID",
@@ -863,59 +815,54 @@
863
815
  "notNull": false,
864
816
  "unique": false
865
817
  },
866
- "journal_id": {
867
- "type": "UUID",
868
- "referenceKind": "foreignKey",
818
+ "number": {
819
+ "type": "TEXT",
869
820
  "notNull": false,
870
821
  "unique": false,
871
- "foreignKey": {
872
- "table": "journals",
873
- "column": "id",
874
- "onDelete": "NO ACTION",
875
- "onUpdate": "CASCADE"
876
- }
822
+ "default": ""
877
823
  },
878
- "account_id": {
879
- "type": "UUID",
880
- "referenceKind": "foreignKey",
824
+ "date": {
825
+ "type": "TIMESTAMP",
881
826
  "notNull": false,
882
- "unique": false,
883
- "foreignKey": {
884
- "table": "accounts",
885
- "column": "id",
886
- "onDelete": "NO ACTION",
887
- "onUpdate": "CASCADE"
888
- }
827
+ "unique": false
889
828
  },
890
- "debit": {
891
- "type": "REAL",
829
+ "description": {
830
+ "type": "TEXT",
892
831
  "notNull": false,
893
832
  "unique": false,
894
- "default": 0
833
+ "default": ""
895
834
  },
896
- "credit": {
897
- "type": "REAL",
835
+ "source_module": {
836
+ "type": "TEXT",
898
837
  "notNull": false,
899
838
  "unique": false,
900
- "default": 0
839
+ "default": ""
901
840
  },
902
- "currency": {
841
+ "source_ref": {
842
+ "type": "TEXT",
843
+ "notNull": false,
844
+ "unique": false
845
+ },
846
+ "status": {
903
847
  "type": "TEXT",
904
848
  "notNull": false,
905
849
  "unique": false,
906
- "default": "USD"
850
+ "default": "draft"
851
+ },
852
+ "posted_at": {
853
+ "type": "TIMESTAMP",
854
+ "notNull": false,
855
+ "unique": false
907
856
  },
908
- "exchange_rate": {
909
- "type": "REAL",
857
+ "voided_at": {
858
+ "type": "TIMESTAMP",
910
859
  "notNull": false,
911
- "unique": false,
912
- "default": 1
860
+ "unique": false
913
861
  },
914
- "memo": {
862
+ "void_reason": {
915
863
  "type": "TEXT",
916
864
  "notNull": false,
917
- "unique": false,
918
- "default": ""
865
+ "unique": false
919
866
  },
920
867
  "metadata": {
921
868
  "type": "JSON",
@@ -926,7 +873,7 @@
926
873
  },
927
874
  "indexes": [
928
875
  {
929
- "name": "journal_entries_slug_context_idx",
876
+ "name": "journals_slug_context_idx",
930
877
  "columns": [
931
878
  "tenant_id",
932
879
  "slug",
@@ -936,195 +883,253 @@
936
883
  "nullsNotDistinct": true
937
884
  },
938
885
  {
939
- "name": "journal_entries_tenant_id_created_at_idx",
886
+ "name": "journals_tenant_id_created_at_idx",
940
887
  "columns": [
941
888
  "tenant_id",
942
889
  "created_at"
943
890
  ]
944
- },
945
- {
946
- "name": "journal_entries_journal_id_idx",
947
- "columns": [
948
- "journal_id"
949
- ]
950
- },
951
- {
952
- "name": "journal_entries_account_id_idx",
953
- "columns": [
954
- "account_id"
955
- ]
956
891
  }
957
892
  ],
958
- "version": "0457e0e4"
893
+ "version": "4b51d204"
959
894
  },
960
895
  "importPath": "@happyvertical/smrt-ledgers"
961
896
  },
962
- "@happyvertical/smrt-ledgers:AccountCollection": {
963
- "name": "accountcollection",
964
- "className": "AccountCollection",
965
- "qualifiedName": "@happyvertical/smrt-ledgers:AccountCollection",
897
+ "@happyvertical/smrt-ledgers:Account": {
898
+ "name": "account",
899
+ "className": "Account",
900
+ "qualifiedName": "@happyvertical/smrt-ledgers:Account",
966
901
  "collection": "accounts",
967
- "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Accounts.ts",
902
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/models/Account.ts",
968
903
  "packageName": "@happyvertical/smrt-ledgers",
969
- "fields": {},
970
- "methods": {
971
- "findByNumber": {
972
- "name": "findByNumber",
973
- "async": true,
974
- "parameters": [
975
- {
976
- "name": "number",
977
- "type": "string",
978
- "optional": false
904
+ "fields": {
905
+ "parentId": {
906
+ "type": "foreignKey",
907
+ "required": false,
908
+ "related": "Account",
909
+ "_meta": {
910
+ "nullable": true
911
+ }
912
+ },
913
+ "tenantId": {
914
+ "type": "text",
915
+ "required": false,
916
+ "_meta": {
917
+ "sqlType": "UUID",
918
+ "nullable": true,
919
+ "__tenancy": {
920
+ "isTenantIdField": true,
921
+ "autoFilter": true,
922
+ "required": false,
923
+ "autoPopulate": true,
924
+ "nullable": true,
925
+ "mode": "optional",
926
+ "field": "tenantId",
927
+ "allowSuperAdminBypass": false
979
928
  }
980
- ],
981
- "returnType": "Promise<Account | null>",
982
- "isStatic": false,
983
- "isPublic": true
929
+ }
984
930
  },
985
- "findByType": {
986
- "name": "findByType",
931
+ "number": {
932
+ "type": "text",
933
+ "required": false,
934
+ "default": ""
935
+ },
936
+ "name": {
937
+ "type": "text",
938
+ "required": false,
939
+ "default": ""
940
+ },
941
+ "description": {
942
+ "type": "text",
943
+ "required": false,
944
+ "default": ""
945
+ },
946
+ "type": {
947
+ "type": "text",
948
+ "required": false,
949
+ "default": "asset"
950
+ },
951
+ "active": {
952
+ "type": "boolean",
953
+ "required": false,
954
+ "default": true
955
+ },
956
+ "metadata": {
957
+ "type": "json",
958
+ "required": false,
959
+ "default": {}
960
+ }
961
+ },
962
+ "methods": {
963
+ "getParent": {
964
+ "name": "getParent",
987
965
  "async": true,
988
- "parameters": [
989
- {
990
- "name": "type",
991
- "type": "AccountType",
992
- "optional": false
993
- }
994
- ],
995
- "returnType": "Promise<Account[]>",
966
+ "parameters": [],
967
+ "returnType": "Promise<this | null>",
996
968
  "isStatic": false,
997
969
  "isPublic": true
998
970
  },
999
- "findActive": {
1000
- "name": "findActive",
971
+ "getChildren": {
972
+ "name": "getChildren",
1001
973
  "async": true,
1002
974
  "parameters": [],
1003
- "returnType": "Promise<Account[]>",
975
+ "returnType": "Promise<this[]>",
1004
976
  "isStatic": false,
1005
977
  "isPublic": true
1006
978
  },
1007
- "findTopLevel": {
1008
- "name": "findTopLevel",
979
+ "getAncestors": {
980
+ "name": "getAncestors",
1009
981
  "async": true,
1010
982
  "parameters": [],
1011
- "returnType": "Promise<Account[]>",
983
+ "returnType": "Promise<this[]>",
1012
984
  "isStatic": false,
1013
985
  "isPublic": true
1014
986
  },
1015
- "findChildren": {
1016
- "name": "findChildren",
987
+ "getDescendants": {
988
+ "name": "getDescendants",
1017
989
  "async": true,
1018
- "parameters": [
1019
- {
1020
- "name": "parentId",
1021
- "type": "string",
1022
- "optional": false
1023
- }
1024
- ],
1025
- "returnType": "Promise<Account[]>",
990
+ "parameters": [],
991
+ "returnType": "Promise<this[]>",
1026
992
  "isStatic": false,
1027
993
  "isPublic": true
1028
994
  },
1029
- "getTree": {
1030
- "name": "getTree",
995
+ "getHierarchy": {
996
+ "name": "getHierarchy",
1031
997
  "async": true,
1032
998
  "parameters": [],
1033
- "returnType": "Promise<AccountTree>",
999
+ "returnType": "Promise<HierarchyView<this>>",
1034
1000
  "isStatic": false,
1035
1001
  "isPublic": true
1036
1002
  },
1037
- "getOrCreateByNumber": {
1038
- "name": "getOrCreateByNumber",
1003
+ "moveTo": {
1004
+ "name": "moveTo",
1039
1005
  "async": true,
1040
1006
  "parameters": [
1041
1007
  {
1042
- "name": "number",
1043
- "type": "string",
1044
- "optional": false
1045
- },
1046
- {
1047
- "name": "defaults",
1048
- "type": "Partial<object>",
1049
- "optional": true,
1050
- "memberTypes": [
1051
- "string",
1052
- "AccountType",
1053
- "string | null"
1008
+ "name": "newParent",
1009
+ "type": "this | string | null",
1010
+ "optional": false,
1011
+ "unionBranches": [
1012
+ {
1013
+ "type": "this"
1014
+ },
1015
+ {
1016
+ "type": "string"
1017
+ },
1018
+ {
1019
+ "type": "null"
1020
+ }
1054
1021
  ]
1055
1022
  }
1056
1023
  ],
1057
- "returnType": "Promise<Account>",
1024
+ "returnType": "Promise<void>",
1058
1025
  "isStatic": false,
1059
1026
  "isPublic": true
1060
1027
  },
1061
- "groupByType": {
1062
- "name": "groupByType",
1028
+ "isTopLevel": {
1029
+ "name": "isTopLevel",
1030
+ "async": false,
1031
+ "parameters": [],
1032
+ "returnType": "boolean",
1033
+ "isStatic": false,
1034
+ "isPublic": true
1035
+ },
1036
+ "isDebitNormal": {
1037
+ "name": "isDebitNormal",
1038
+ "async": false,
1039
+ "parameters": [],
1040
+ "returnType": "boolean",
1041
+ "isStatic": false,
1042
+ "isPublic": true
1043
+ },
1044
+ "isCreditNormal": {
1045
+ "name": "isCreditNormal",
1046
+ "async": false,
1047
+ "parameters": [],
1048
+ "returnType": "boolean",
1049
+ "isStatic": false,
1050
+ "isPublic": true
1051
+ },
1052
+ "getFullPath": {
1053
+ "name": "getFullPath",
1063
1054
  "async": true,
1064
1055
  "parameters": [],
1065
- "returnType": "Promise<Record<AccountType, Account[]>>",
1056
+ "returnType": "Promise<string>",
1066
1057
  "isStatic": false,
1067
1058
  "isPublic": true
1068
1059
  },
1069
- "getDescendants": {
1070
- "name": "getDescendants",
1060
+ "toTreeNode": {
1061
+ "name": "toTreeNode",
1071
1062
  "async": true,
1072
- "parameters": [
1073
- {
1074
- "name": "accountId",
1075
- "type": "string",
1076
- "optional": false
1077
- }
1078
- ],
1079
- "returnType": "Promise<Account[]>",
1063
+ "parameters": [],
1064
+ "returnType": "Promise<AccountTreeNode>",
1080
1065
  "isStatic": false,
1081
1066
  "isPublic": true
1082
1067
  },
1083
- "findByTenant": {
1084
- "name": "findByTenant",
1068
+ "getBalance": {
1069
+ "name": "getBalance",
1085
1070
  "async": true,
1086
1071
  "parameters": [
1087
1072
  {
1088
- "name": "tenantId",
1089
- "type": "string",
1090
- "optional": false
1073
+ "name": "asOfDate",
1074
+ "type": "Date",
1075
+ "optional": true
1091
1076
  }
1092
1077
  ],
1093
- "returnType": "Promise<Account[]>",
1094
- "isStatic": false,
1095
- "isPublic": true
1096
- },
1097
- "findGlobal": {
1098
- "name": "findGlobal",
1099
- "async": true,
1100
- "parameters": [],
1101
- "returnType": "Promise<Account[]>",
1078
+ "returnType": "Promise<number>",
1102
1079
  "isStatic": false,
1103
1080
  "isPublic": true
1104
1081
  },
1105
- "findWithGlobals": {
1106
- "name": "findWithGlobals",
1082
+ "createChild": {
1083
+ "name": "createChild",
1107
1084
  "async": true,
1108
1085
  "parameters": [
1109
1086
  {
1110
- "name": "tenantId",
1111
- "type": "string",
1087
+ "name": "options",
1088
+ "type": "Omit<AccountOptions, 'parentId' | 'type'>",
1112
1089
  "optional": false
1113
1090
  }
1114
1091
  ],
1115
- "returnType": "Promise<Account[]>",
1092
+ "returnType": "Promise<Account>",
1116
1093
  "isStatic": false,
1117
1094
  "isPublic": true
1118
1095
  }
1119
1096
  },
1120
- "decoratorConfig": {},
1121
- "extends": "SmrtCollection",
1122
- "extendsTypeArg": "Account",
1123
- "exportName": "AccountCollection",
1124
- "collectionExportName": "AccountCollectionCollection",
1097
+ "decoratorConfig": {
1098
+ "tableName": "ledger_accounts",
1099
+ "api": {
1100
+ "include": [
1101
+ "list",
1102
+ "get",
1103
+ "create",
1104
+ "update",
1105
+ "delete"
1106
+ ]
1107
+ },
1108
+ "mcp": {
1109
+ "include": [
1110
+ "list",
1111
+ "get",
1112
+ "create"
1113
+ ]
1114
+ },
1115
+ "cli": {
1116
+ "skipApiCheck": true
1117
+ },
1118
+ "tenantScoped": {
1119
+ "mode": "optional"
1120
+ },
1121
+ "conflictColumns": [
1122
+ "tenant_id",
1123
+ "slug",
1124
+ "context"
1125
+ ]
1126
+ },
1127
+ "extends": "SmrtHierarchical",
1128
+ "exportName": "Account",
1129
+ "collectionExportName": "AccountCollection",
1125
1130
  "schema": {
1126
- "tableName": "accounts",
1127
- "ddl": "CREATE TABLE IF NOT EXISTS \"accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
1131
+ "tableName": "ledger_accounts",
1132
+ "ddl": "CREATE TABLE IF NOT EXISTS \"ledger_accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
1128
1133
  "columns": {
1129
1134
  "id": {
1130
1135
  "type": "UUID",
@@ -1157,7 +1162,7 @@
1157
1162
  "notNull": false,
1158
1163
  "unique": false,
1159
1164
  "foreignKey": {
1160
- "table": "accounts",
1165
+ "table": "ledger_accounts",
1161
1166
  "column": "id",
1162
1167
  "onDelete": "NO ACTION",
1163
1168
  "onUpdate": "CASCADE"
@@ -1208,7 +1213,7 @@
1208
1213
  },
1209
1214
  "indexes": [
1210
1215
  {
1211
- "name": "accounts_slug_context_idx",
1216
+ "name": "ledger_accounts_slug_context_idx",
1212
1217
  "columns": [
1213
1218
  "tenant_id",
1214
1219
  "slug",
@@ -1218,185 +1223,238 @@
1218
1223
  "nullsNotDistinct": true
1219
1224
  },
1220
1225
  {
1221
- "name": "accounts_tenant_id_created_at_idx",
1226
+ "name": "ledger_accounts_tenant_id_created_at_idx",
1222
1227
  "columns": [
1223
1228
  "tenant_id",
1224
1229
  "created_at"
1225
1230
  ]
1226
1231
  },
1227
1232
  {
1228
- "name": "accounts_parent_id_idx",
1233
+ "name": "ledger_accounts_parent_id_idx",
1229
1234
  "columns": [
1230
1235
  "parent_id"
1231
1236
  ]
1232
1237
  }
1233
1238
  ],
1234
- "version": "62bb562a"
1239
+ "version": "49630dae"
1235
1240
  },
1236
1241
  "importPath": "@happyvertical/smrt-ledgers"
1237
1242
  },
1238
- "@happyvertical/smrt-ledgers:JournalEntryCollection": {
1239
- "name": "journalentrycollection",
1240
- "className": "JournalEntryCollection",
1241
- "qualifiedName": "@happyvertical/smrt-ledgers:JournalEntryCollection",
1242
- "collection": "journalentries",
1243
- "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/collections/JournalEntries.ts",
1243
+ "@happyvertical/smrt-ledgers:Journal": {
1244
+ "name": "journal",
1245
+ "className": "Journal",
1246
+ "qualifiedName": "@happyvertical/smrt-ledgers:Journal",
1247
+ "collection": "journals",
1248
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/models/Journal.ts",
1244
1249
  "packageName": "@happyvertical/smrt-ledgers",
1245
- "fields": {},
1246
- "methods": {
1247
- "findByJournal": {
1248
- "name": "findByJournal",
1249
- "async": true,
1250
- "parameters": [
1251
- {
1252
- "name": "journalId",
1253
- "type": "string",
1254
- "optional": false
1250
+ "fields": {
1251
+ "tenantId": {
1252
+ "type": "text",
1253
+ "required": false,
1254
+ "_meta": {
1255
+ "sqlType": "UUID",
1256
+ "nullable": true,
1257
+ "__tenancy": {
1258
+ "isTenantIdField": true,
1259
+ "autoFilter": true,
1260
+ "required": false,
1261
+ "autoPopulate": true,
1262
+ "nullable": true,
1263
+ "mode": "optional",
1264
+ "field": "tenantId",
1265
+ "allowSuperAdminBypass": false
1255
1266
  }
1256
- ],
1257
- "returnType": "Promise<JournalEntry[]>",
1267
+ }
1268
+ },
1269
+ "number": {
1270
+ "type": "text",
1271
+ "required": false,
1272
+ "default": ""
1273
+ },
1274
+ "date": {
1275
+ "type": "datetime",
1276
+ "required": false
1277
+ },
1278
+ "description": {
1279
+ "type": "text",
1280
+ "required": false,
1281
+ "default": ""
1282
+ },
1283
+ "sourceModule": {
1284
+ "type": "text",
1285
+ "required": false,
1286
+ "default": ""
1287
+ },
1288
+ "sourceRef": {
1289
+ "type": "text",
1290
+ "required": false
1291
+ },
1292
+ "status": {
1293
+ "type": "text",
1294
+ "required": false,
1295
+ "default": "draft"
1296
+ },
1297
+ "postedAt": {
1298
+ "type": "datetime",
1299
+ "required": false
1300
+ },
1301
+ "voidedAt": {
1302
+ "type": "datetime",
1303
+ "required": false
1304
+ },
1305
+ "voidReason": {
1306
+ "type": "text",
1307
+ "required": false
1308
+ },
1309
+ "metadata": {
1310
+ "type": "json",
1311
+ "required": false,
1312
+ "default": {}
1313
+ }
1314
+ },
1315
+ "methods": {
1316
+ "isDraft": {
1317
+ "name": "isDraft",
1318
+ "async": false,
1319
+ "parameters": [],
1320
+ "returnType": "boolean",
1258
1321
  "isStatic": false,
1259
1322
  "isPublic": true
1260
1323
  },
1261
- "findByAccount": {
1262
- "name": "findByAccount",
1263
- "async": true,
1264
- "parameters": [
1265
- {
1266
- "name": "accountId",
1267
- "type": "string",
1268
- "optional": false
1269
- }
1270
- ],
1271
- "returnType": "Promise<JournalEntry[]>",
1324
+ "isPosted": {
1325
+ "name": "isPosted",
1326
+ "async": false,
1327
+ "parameters": [],
1328
+ "returnType": "boolean",
1272
1329
  "isStatic": false,
1273
1330
  "isPublic": true
1274
1331
  },
1275
- "getAccountBalance": {
1276
- "name": "getAccountBalance",
1277
- "async": true,
1278
- "parameters": [
1279
- {
1280
- "name": "accountId",
1281
- "type": "string",
1282
- "optional": false
1283
- },
1284
- {
1285
- "name": "asOfDate",
1286
- "type": "Date",
1287
- "optional": true
1288
- }
1289
- ],
1290
- "returnType": "Promise<number>",
1332
+ "isVoided": {
1333
+ "name": "isVoided",
1334
+ "async": false,
1335
+ "parameters": [],
1336
+ "returnType": "boolean",
1291
1337
  "isStatic": false,
1292
1338
  "isPublic": true
1293
1339
  },
1294
- "getTrialBalance": {
1295
- "name": "getTrialBalance",
1340
+ "isEditable": {
1341
+ "name": "isEditable",
1342
+ "async": false,
1343
+ "parameters": [],
1344
+ "returnType": "boolean",
1345
+ "isStatic": false,
1346
+ "isPublic": true
1347
+ },
1348
+ "getEntries": {
1349
+ "name": "getEntries",
1296
1350
  "async": true,
1297
- "parameters": [
1298
- {
1299
- "name": "asOfDate",
1300
- "type": "Date",
1301
- "optional": true
1302
- }
1303
- ],
1304
- "returnType": "Promise<TrialBalanceRow[]>",
1351
+ "parameters": [],
1352
+ "returnType": "any",
1305
1353
  "isStatic": false,
1306
1354
  "isPublic": true
1307
1355
  },
1308
- "getTotalsForDateRange": {
1309
- "name": "getTotalsForDateRange",
1356
+ "getTotalDebits": {
1357
+ "name": "getTotalDebits",
1310
1358
  "async": true,
1311
- "parameters": [
1312
- {
1313
- "name": "start",
1314
- "type": "Date",
1315
- "optional": false
1316
- },
1317
- {
1318
- "name": "end",
1319
- "type": "Date",
1320
- "optional": false
1321
- }
1322
- ],
1323
- "returnType": "Promise<object>",
1359
+ "parameters": [],
1360
+ "returnType": "Promise<number>",
1324
1361
  "isStatic": false,
1325
1362
  "isPublic": true
1326
1363
  },
1327
- "findByAccounts": {
1328
- "name": "findByAccounts",
1364
+ "getTotalCredits": {
1365
+ "name": "getTotalCredits",
1329
1366
  "async": true,
1330
- "parameters": [
1331
- {
1332
- "name": "accountIds",
1333
- "type": "string[]",
1334
- "optional": false
1335
- }
1336
- ],
1337
- "returnType": "Promise<JournalEntry[]>",
1367
+ "parameters": [],
1368
+ "returnType": "Promise<number>",
1338
1369
  "isStatic": false,
1339
1370
  "isPublic": true
1340
1371
  },
1341
- "getAccountLedger": {
1342
- "name": "getAccountLedger",
1372
+ "isBalanced": {
1373
+ "name": "isBalanced",
1343
1374
  "async": true,
1344
- "parameters": [
1345
- {
1346
- "name": "accountId",
1347
- "type": "string",
1348
- "optional": false
1349
- }
1350
- ],
1351
- "returnType": "Promise<Array<object>>",
1375
+ "parameters": [],
1376
+ "returnType": "Promise<boolean>",
1352
1377
  "isStatic": false,
1353
1378
  "isPublic": true
1354
1379
  },
1355
- "findByTenant": {
1356
- "name": "findByTenant",
1380
+ "addEntry": {
1381
+ "name": "addEntry",
1357
1382
  "async": true,
1358
1383
  "parameters": [
1359
1384
  {
1360
- "name": "tenantId",
1361
- "type": "string",
1385
+ "name": "data",
1386
+ "type": "JournalEntryData",
1362
1387
  "optional": false
1363
1388
  }
1364
1389
  ],
1365
- "returnType": "Promise<JournalEntry[]>",
1390
+ "returnType": "Promise<void>",
1366
1391
  "isStatic": false,
1367
1392
  "isPublic": true
1368
1393
  },
1369
- "findGlobal": {
1370
- "name": "findGlobal",
1394
+ "post": {
1395
+ "name": "post",
1371
1396
  "async": true,
1372
1397
  "parameters": [],
1373
- "returnType": "Promise<JournalEntry[]>",
1398
+ "returnType": "Promise<void>",
1374
1399
  "isStatic": false,
1375
1400
  "isPublic": true
1376
1401
  },
1377
- "findWithGlobals": {
1378
- "name": "findWithGlobals",
1402
+ "void": {
1403
+ "name": "void",
1379
1404
  "async": true,
1380
1405
  "parameters": [
1381
1406
  {
1382
- "name": "tenantId",
1407
+ "name": "reason",
1383
1408
  "type": "string",
1384
1409
  "optional": false
1385
1410
  }
1386
1411
  ],
1387
- "returnType": "Promise<JournalEntry[]>",
1412
+ "returnType": "Promise<void>",
1413
+ "isStatic": false,
1414
+ "isPublic": true
1415
+ },
1416
+ "summarize": {
1417
+ "name": "summarize",
1418
+ "async": true,
1419
+ "parameters": [],
1420
+ "returnType": "Promise<string>",
1388
1421
  "isStatic": false,
1389
1422
  "isPublic": true
1390
1423
  }
1391
1424
  },
1392
- "decoratorConfig": {},
1393
- "extends": "SmrtCollection",
1394
- "extendsTypeArg": "JournalEntry",
1395
- "exportName": "JournalEntryCollection",
1396
- "collectionExportName": "JournalEntryCollectionCollection",
1425
+ "decoratorConfig": {
1426
+ "api": {
1427
+ "include": [
1428
+ "list",
1429
+ "get",
1430
+ "create"
1431
+ ]
1432
+ },
1433
+ "mcp": {
1434
+ "include": [
1435
+ "list",
1436
+ "get",
1437
+ "create"
1438
+ ]
1439
+ },
1440
+ "cli": {
1441
+ "skipApiCheck": true
1442
+ },
1443
+ "tenantScoped": {
1444
+ "mode": "optional"
1445
+ },
1446
+ "conflictColumns": [
1447
+ "tenant_id",
1448
+ "slug",
1449
+ "context"
1450
+ ]
1451
+ },
1452
+ "extends": "SmrtObject",
1453
+ "exportName": "Journal",
1454
+ "collectionExportName": "JournalCollection",
1397
1455
  "schema": {
1398
- "tableName": "journal_entries",
1399
- "ddl": "CREATE TABLE IF NOT EXISTS \"journal_entries\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"journal_id\" UUID,\n \"account_id\" UUID,\n \"debit\" REAL DEFAULT 0,\n \"credit\" REAL DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"exchange_rate\" REAL DEFAULT 1,\n \"memo\" TEXT DEFAULT '',\n \"metadata\" JSON DEFAULT '{}'\n);",
1456
+ "tableName": "journals",
1457
+ "ddl": "CREATE TABLE IF NOT EXISTS \"journals\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"date\" TIMESTAMP,\n \"description\" TEXT DEFAULT '',\n \"source_module\" TEXT DEFAULT '',\n \"source_ref\" TEXT,\n \"status\" TEXT DEFAULT 'draft',\n \"posted_at\" TIMESTAMP,\n \"voided_at\" TIMESTAMP,\n \"void_reason\" TEXT,\n \"metadata\" JSON DEFAULT '{}'\n);",
1400
1458
  "columns": {
1401
1459
  "id": {
1402
1460
  "type": "UUID",
@@ -1429,59 +1487,54 @@
1429
1487
  "notNull": false,
1430
1488
  "unique": false
1431
1489
  },
1432
- "journal_id": {
1433
- "type": "UUID",
1434
- "referenceKind": "foreignKey",
1490
+ "number": {
1491
+ "type": "TEXT",
1435
1492
  "notNull": false,
1436
1493
  "unique": false,
1437
- "foreignKey": {
1438
- "table": "journals",
1439
- "column": "id",
1440
- "onDelete": "NO ACTION",
1441
- "onUpdate": "CASCADE"
1442
- }
1494
+ "default": ""
1443
1495
  },
1444
- "account_id": {
1445
- "type": "UUID",
1446
- "referenceKind": "foreignKey",
1496
+ "date": {
1497
+ "type": "TIMESTAMP",
1447
1498
  "notNull": false,
1448
- "unique": false,
1449
- "foreignKey": {
1450
- "table": "accounts",
1451
- "column": "id",
1452
- "onDelete": "NO ACTION",
1453
- "onUpdate": "CASCADE"
1454
- }
1499
+ "unique": false
1455
1500
  },
1456
- "debit": {
1457
- "type": "REAL",
1501
+ "description": {
1502
+ "type": "TEXT",
1458
1503
  "notNull": false,
1459
1504
  "unique": false,
1460
- "default": 0
1505
+ "default": ""
1461
1506
  },
1462
- "credit": {
1463
- "type": "REAL",
1507
+ "source_module": {
1508
+ "type": "TEXT",
1464
1509
  "notNull": false,
1465
1510
  "unique": false,
1466
- "default": 0
1511
+ "default": ""
1467
1512
  },
1468
- "currency": {
1513
+ "source_ref": {
1469
1514
  "type": "TEXT",
1470
1515
  "notNull": false,
1471
- "unique": false,
1472
- "default": "USD"
1516
+ "unique": false
1473
1517
  },
1474
- "exchange_rate": {
1475
- "type": "REAL",
1518
+ "status": {
1519
+ "type": "TEXT",
1476
1520
  "notNull": false,
1477
1521
  "unique": false,
1478
- "default": 1
1522
+ "default": "draft"
1479
1523
  },
1480
- "memo": {
1524
+ "posted_at": {
1525
+ "type": "TIMESTAMP",
1526
+ "notNull": false,
1527
+ "unique": false
1528
+ },
1529
+ "voided_at": {
1530
+ "type": "TIMESTAMP",
1531
+ "notNull": false,
1532
+ "unique": false
1533
+ },
1534
+ "void_reason": {
1481
1535
  "type": "TEXT",
1482
1536
  "notNull": false,
1483
- "unique": false,
1484
- "default": ""
1537
+ "unique": false
1485
1538
  },
1486
1539
  "metadata": {
1487
1540
  "type": "JSON",
@@ -1492,7 +1545,7 @@
1492
1545
  },
1493
1546
  "indexes": [
1494
1547
  {
1495
- "name": "journal_entries_slug_context_idx",
1548
+ "name": "journals_slug_context_idx",
1496
1549
  "columns": [
1497
1550
  "tenant_id",
1498
1551
  "slug",
@@ -1502,240 +1555,173 @@
1502
1555
  "nullsNotDistinct": true
1503
1556
  },
1504
1557
  {
1505
- "name": "journal_entries_tenant_id_created_at_idx",
1558
+ "name": "journals_tenant_id_created_at_idx",
1506
1559
  "columns": [
1507
1560
  "tenant_id",
1508
1561
  "created_at"
1509
1562
  ]
1510
- },
1511
- {
1512
- "name": "journal_entries_journal_id_idx",
1513
- "columns": [
1514
- "journal_id"
1515
- ]
1516
- },
1517
- {
1518
- "name": "journal_entries_account_id_idx",
1519
- "columns": [
1520
- "account_id"
1521
- ]
1522
1563
  }
1523
1564
  ],
1524
- "version": "0457e0e4"
1565
+ "version": "4b51d204"
1525
1566
  },
1526
1567
  "importPath": "@happyvertical/smrt-ledgers"
1527
1568
  },
1528
- "@happyvertical/smrt-ledgers:JournalCollection": {
1529
- "name": "journalcollection",
1530
- "className": "JournalCollection",
1531
- "qualifiedName": "@happyvertical/smrt-ledgers:JournalCollection",
1532
- "collection": "journals",
1533
- "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Journals.ts",
1569
+ "@happyvertical/smrt-ledgers:JournalEntry": {
1570
+ "name": "journalentry",
1571
+ "className": "JournalEntry",
1572
+ "qualifiedName": "@happyvertical/smrt-ledgers:JournalEntry",
1573
+ "collection": "journalentries",
1574
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/models/JournalEntry.ts",
1534
1575
  "packageName": "@happyvertical/smrt-ledgers",
1535
- "fields": {},
1536
- "methods": {
1537
- "findByNumber": {
1538
- "name": "findByNumber",
1539
- "async": true,
1540
- "parameters": [
1541
- {
1542
- "name": "number",
1543
- "type": "string",
1544
- "optional": false
1576
+ "fields": {
1577
+ "tenantId": {
1578
+ "type": "text",
1579
+ "required": false,
1580
+ "_meta": {
1581
+ "sqlType": "UUID",
1582
+ "nullable": true,
1583
+ "__tenancy": {
1584
+ "isTenantIdField": true,
1585
+ "autoFilter": true,
1586
+ "required": false,
1587
+ "autoPopulate": true,
1588
+ "nullable": true,
1589
+ "mode": "optional",
1590
+ "field": "tenantId",
1591
+ "allowSuperAdminBypass": false
1545
1592
  }
1546
- ],
1547
- "returnType": "Promise<Journal | null>",
1548
- "isStatic": false,
1549
- "isPublic": true
1593
+ }
1550
1594
  },
1551
- "findByDateRange": {
1552
- "name": "findByDateRange",
1553
- "async": true,
1554
- "parameters": [
1555
- {
1556
- "name": "start",
1557
- "type": "Date",
1558
- "optional": false
1559
- },
1560
- {
1561
- "name": "end",
1562
- "type": "Date",
1563
- "optional": false
1564
- }
1565
- ],
1566
- "returnType": "Promise<Journal[]>",
1567
- "isStatic": false,
1568
- "isPublic": true
1595
+ "journalId": {
1596
+ "type": "foreignKey",
1597
+ "required": false,
1598
+ "related": "Journal"
1569
1599
  },
1570
- "findBySource": {
1571
- "name": "findBySource",
1572
- "async": true,
1573
- "parameters": [
1574
- {
1575
- "name": "sourceModule",
1576
- "type": "string",
1577
- "optional": false
1578
- }
1579
- ],
1580
- "returnType": "Promise<Journal[]>",
1581
- "isStatic": false,
1582
- "isPublic": true
1600
+ "accountId": {
1601
+ "type": "foreignKey",
1602
+ "required": false,
1603
+ "related": "Account"
1583
1604
  },
1584
- "findByStatus": {
1585
- "name": "findByStatus",
1586
- "async": true,
1587
- "parameters": [
1588
- {
1589
- "name": "status",
1590
- "type": "JournalStatus",
1591
- "optional": false
1592
- }
1593
- ],
1594
- "returnType": "Promise<Journal[]>",
1595
- "isStatic": false,
1596
- "isPublic": true
1605
+ "debit": {
1606
+ "type": "decimal",
1607
+ "required": false,
1608
+ "default": 0
1609
+ },
1610
+ "credit": {
1611
+ "type": "decimal",
1612
+ "required": false,
1613
+ "default": 0
1614
+ },
1615
+ "currency": {
1616
+ "type": "text",
1617
+ "required": false,
1618
+ "default": "USD"
1619
+ },
1620
+ "exchangeRate": {
1621
+ "type": "decimal",
1622
+ "required": false,
1623
+ "default": 1
1624
+ },
1625
+ "memo": {
1626
+ "type": "text",
1627
+ "required": false,
1628
+ "default": ""
1597
1629
  },
1598
- "findDrafts": {
1599
- "name": "findDrafts",
1600
- "async": true,
1630
+ "metadata": {
1631
+ "type": "json",
1632
+ "required": false,
1633
+ "default": {}
1634
+ }
1635
+ },
1636
+ "methods": {
1637
+ "isDebit": {
1638
+ "name": "isDebit",
1639
+ "async": false,
1601
1640
  "parameters": [],
1602
- "returnType": "Promise<Journal[]>",
1641
+ "returnType": "boolean",
1603
1642
  "isStatic": false,
1604
1643
  "isPublic": true
1605
1644
  },
1606
- "findPosted": {
1607
- "name": "findPosted",
1608
- "async": true,
1645
+ "isCredit": {
1646
+ "name": "isCredit",
1647
+ "async": false,
1609
1648
  "parameters": [],
1610
- "returnType": "Promise<Journal[]>",
1649
+ "returnType": "boolean",
1611
1650
  "isStatic": false,
1612
1651
  "isPublic": true
1613
1652
  },
1614
- "createWithEntries": {
1615
- "name": "createWithEntries",
1616
- "async": true,
1617
- "parameters": [
1618
- {
1619
- "name": "data",
1620
- "type": "CreateJournalData",
1621
- "optional": false
1622
- }
1623
- ],
1624
- "returnType": "Promise<Journal>",
1653
+ "getAmount": {
1654
+ "name": "getAmount",
1655
+ "async": false,
1656
+ "parameters": [],
1657
+ "returnType": "number",
1625
1658
  "isStatic": false,
1626
1659
  "isPublic": true
1627
1660
  },
1628
- "post": {
1629
- "name": "post",
1630
- "async": true,
1631
- "parameters": [
1632
- {
1633
- "name": "journalId",
1634
- "type": "string",
1635
- "optional": false
1636
- }
1637
- ],
1638
- "returnType": "Promise<Journal>",
1661
+ "getBaseAmount": {
1662
+ "name": "getBaseAmount",
1663
+ "async": false,
1664
+ "parameters": [],
1665
+ "returnType": "number",
1639
1666
  "isStatic": false,
1640
1667
  "isPublic": true
1641
1668
  },
1642
- "void": {
1643
- "name": "void",
1669
+ "getJournal": {
1670
+ "name": "getJournal",
1644
1671
  "async": true,
1645
- "parameters": [
1646
- {
1647
- "name": "journalId",
1648
- "type": "string",
1649
- "optional": false
1650
- },
1651
- {
1652
- "name": "reason",
1653
- "type": "string",
1654
- "optional": false
1655
- }
1656
- ],
1657
- "returnType": "Promise<Journal>",
1672
+ "parameters": [],
1673
+ "returnType": "any",
1658
1674
  "isStatic": false,
1659
1675
  "isPublic": true
1660
1676
  },
1661
- "findBySourceRef": {
1662
- "name": "findBySourceRef",
1677
+ "getAccount": {
1678
+ "name": "getAccount",
1663
1679
  "async": true,
1664
- "parameters": [
1665
- {
1666
- "name": "sourceRef",
1667
- "type": "string",
1668
- "optional": false
1669
- }
1670
- ],
1671
- "returnType": "Promise<Journal[]>",
1680
+ "parameters": [],
1681
+ "returnType": "any",
1672
1682
  "isStatic": false,
1673
1683
  "isPublic": true
1674
1684
  },
1675
- "findByMonth": {
1676
- "name": "findByMonth",
1685
+ "getDescription": {
1686
+ "name": "getDescription",
1677
1687
  "async": true,
1678
- "parameters": [
1679
- {
1680
- "name": "year",
1681
- "type": "number",
1682
- "optional": false
1683
- },
1684
- {
1685
- "name": "month",
1686
- "type": "number",
1687
- "optional": false
1688
- }
1689
- ],
1690
- "returnType": "Promise<Journal[]>",
1688
+ "parameters": [],
1689
+ "returnType": "Promise<string>",
1691
1690
  "isStatic": false,
1692
1691
  "isPublic": true
1692
+ }
1693
+ },
1694
+ "decoratorConfig": {
1695
+ "api": {
1696
+ "include": [
1697
+ "list",
1698
+ "get"
1699
+ ]
1693
1700
  },
1694
- "findByTenant": {
1695
- "name": "findByTenant",
1696
- "async": true,
1697
- "parameters": [
1698
- {
1699
- "name": "tenantId",
1700
- "type": "string",
1701
- "optional": false
1702
- }
1703
- ],
1704
- "returnType": "Promise<Journal[]>",
1705
- "isStatic": false,
1706
- "isPublic": true
1701
+ "mcp": {
1702
+ "include": [
1703
+ "list",
1704
+ "get"
1705
+ ]
1707
1706
  },
1708
- "findGlobal": {
1709
- "name": "findGlobal",
1710
- "async": true,
1711
- "parameters": [],
1712
- "returnType": "Promise<Journal[]>",
1713
- "isStatic": false,
1714
- "isPublic": true
1707
+ "cli": {
1708
+ "skipApiCheck": true
1715
1709
  },
1716
- "findWithGlobals": {
1717
- "name": "findWithGlobals",
1718
- "async": true,
1719
- "parameters": [
1720
- {
1721
- "name": "tenantId",
1722
- "type": "string",
1723
- "optional": false
1724
- }
1725
- ],
1726
- "returnType": "Promise<Journal[]>",
1727
- "isStatic": false,
1728
- "isPublic": true
1729
- }
1710
+ "tenantScoped": {
1711
+ "mode": "optional"
1712
+ },
1713
+ "conflictColumns": [
1714
+ "tenant_id",
1715
+ "slug",
1716
+ "context"
1717
+ ]
1730
1718
  },
1731
- "decoratorConfig": {},
1732
- "extends": "SmrtCollection",
1733
- "extendsTypeArg": "Journal",
1734
- "exportName": "JournalCollection",
1735
- "collectionExportName": "JournalCollectionCollection",
1719
+ "extends": "SmrtObject",
1720
+ "exportName": "JournalEntry",
1721
+ "collectionExportName": "JournalEntryCollection",
1736
1722
  "schema": {
1737
- "tableName": "journals",
1738
- "ddl": "CREATE TABLE IF NOT EXISTS \"journals\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"date\" TIMESTAMP,\n \"description\" TEXT DEFAULT '',\n \"source_module\" TEXT DEFAULT '',\n \"source_ref\" TEXT,\n \"status\" TEXT DEFAULT 'draft',\n \"posted_at\" TIMESTAMP,\n \"voided_at\" TIMESTAMP,\n \"void_reason\" TEXT,\n \"metadata\" JSON DEFAULT '{}'\n);",
1723
+ "tableName": "journal_entries",
1724
+ "ddl": "CREATE TABLE IF NOT EXISTS \"journal_entries\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"journal_id\" UUID,\n \"account_id\" UUID,\n \"debit\" REAL DEFAULT 0,\n \"credit\" REAL DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"exchange_rate\" REAL DEFAULT 1,\n \"memo\" TEXT DEFAULT '',\n \"metadata\" JSON DEFAULT '{}'\n);",
1739
1725
  "columns": {
1740
1726
  "id": {
1741
1727
  "type": "UUID",
@@ -1768,54 +1754,59 @@
1768
1754
  "notNull": false,
1769
1755
  "unique": false
1770
1756
  },
1771
- "number": {
1772
- "type": "TEXT",
1757
+ "journal_id": {
1758
+ "type": "UUID",
1759
+ "referenceKind": "foreignKey",
1773
1760
  "notNull": false,
1774
1761
  "unique": false,
1775
- "default": ""
1776
- },
1777
- "date": {
1778
- "type": "TIMESTAMP",
1779
- "notNull": false,
1780
- "unique": false
1762
+ "foreignKey": {
1763
+ "table": "journals",
1764
+ "column": "id",
1765
+ "onDelete": "NO ACTION",
1766
+ "onUpdate": "CASCADE"
1767
+ }
1781
1768
  },
1782
- "description": {
1783
- "type": "TEXT",
1769
+ "account_id": {
1770
+ "type": "UUID",
1771
+ "referenceKind": "foreignKey",
1784
1772
  "notNull": false,
1785
1773
  "unique": false,
1786
- "default": ""
1774
+ "foreignKey": {
1775
+ "table": "ledger_accounts",
1776
+ "column": "id",
1777
+ "onDelete": "NO ACTION",
1778
+ "onUpdate": "CASCADE"
1779
+ }
1787
1780
  },
1788
- "source_module": {
1789
- "type": "TEXT",
1781
+ "debit": {
1782
+ "type": "REAL",
1790
1783
  "notNull": false,
1791
1784
  "unique": false,
1792
- "default": ""
1785
+ "default": 0
1793
1786
  },
1794
- "source_ref": {
1795
- "type": "TEXT",
1787
+ "credit": {
1788
+ "type": "REAL",
1796
1789
  "notNull": false,
1797
- "unique": false
1790
+ "unique": false,
1791
+ "default": 0
1798
1792
  },
1799
- "status": {
1793
+ "currency": {
1800
1794
  "type": "TEXT",
1801
1795
  "notNull": false,
1802
1796
  "unique": false,
1803
- "default": "draft"
1804
- },
1805
- "posted_at": {
1806
- "type": "TIMESTAMP",
1807
- "notNull": false,
1808
- "unique": false
1797
+ "default": "USD"
1809
1798
  },
1810
- "voided_at": {
1811
- "type": "TIMESTAMP",
1799
+ "exchange_rate": {
1800
+ "type": "REAL",
1812
1801
  "notNull": false,
1813
- "unique": false
1802
+ "unique": false,
1803
+ "default": 1
1814
1804
  },
1815
- "void_reason": {
1805
+ "memo": {
1816
1806
  "type": "TEXT",
1817
1807
  "notNull": false,
1818
- "unique": false
1808
+ "unique": false,
1809
+ "default": ""
1819
1810
  },
1820
1811
  "metadata": {
1821
1812
  "type": "JSON",
@@ -1826,7 +1817,7 @@
1826
1817
  },
1827
1818
  "indexes": [
1828
1819
  {
1829
- "name": "journals_slug_context_idx",
1820
+ "name": "journal_entries_slug_context_idx",
1830
1821
  "columns": [
1831
1822
  "tenant_id",
1832
1823
  "slug",
@@ -1836,14 +1827,26 @@
1836
1827
  "nullsNotDistinct": true
1837
1828
  },
1838
1829
  {
1839
- "name": "journals_tenant_id_created_at_idx",
1830
+ "name": "journal_entries_tenant_id_created_at_idx",
1840
1831
  "columns": [
1841
1832
  "tenant_id",
1842
1833
  "created_at"
1843
1834
  ]
1835
+ },
1836
+ {
1837
+ "name": "journal_entries_journal_id_idx",
1838
+ "columns": [
1839
+ "journal_id"
1840
+ ]
1841
+ },
1842
+ {
1843
+ "name": "journal_entries_account_id_idx",
1844
+ "columns": [
1845
+ "account_id"
1846
+ ]
1844
1847
  }
1845
1848
  ],
1846
- "version": "4b51d204"
1849
+ "version": "93cdc848"
1847
1850
  },
1848
1851
  "importPath": "@happyvertical/smrt-ledgers"
1849
1852
  }