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