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