@happyvertical/smrt-ledgers 0.40.39 → 0.40.40

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