@happyvertical/smrt-ledgers 0.49.5 → 0.49.7

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