@happyvertical/smrt-ledgers 0.57.1 → 0.57.3

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.
Files changed (38) hide show
  1. package/AGENTS.md +9 -0
  2. package/README.md +73 -0
  3. package/dist/chunks/{Account-b0RgfbjM.js → Account-IFuMKhPt.js} +42 -8
  4. package/dist/chunks/Account-IFuMKhPt.js.map +1 -0
  5. package/dist/chunks/Ledger-DwxK6NRF.js +68 -0
  6. package/dist/chunks/Ledger-DwxK6NRF.js.map +1 -0
  7. package/dist/collections/JournalEntries.d.ts +26 -0
  8. package/dist/collections/JournalEntries.d.ts.map +1 -1
  9. package/dist/collections/Journals.d.ts.map +1 -1
  10. package/dist/collections/Ledgers.d.ts +6 -0
  11. package/dist/collections/Ledgers.d.ts.map +1 -0
  12. package/dist/collections/index.d.ts +1 -0
  13. package/dist/collections/index.d.ts.map +1 -1
  14. package/dist/index.d.ts +5 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +380 -17
  17. package/dist/index.js.map +1 -1
  18. package/dist/manifest.json +639 -13
  19. package/dist/models/Account.d.ts +4 -0
  20. package/dist/models/Account.d.ts.map +1 -1
  21. package/dist/models/Journal.d.ts +9 -0
  22. package/dist/models/Journal.d.ts.map +1 -1
  23. package/dist/models/JournalEntry.d.ts +10 -0
  24. package/dist/models/JournalEntry.d.ts.map +1 -1
  25. package/dist/models/Ledger.d.ts +18 -0
  26. package/dist/models/Ledger.d.ts.map +1 -0
  27. package/dist/models/index.d.ts +1 -0
  28. package/dist/models/index.d.ts.map +1 -1
  29. package/dist/postings.d.ts +33 -0
  30. package/dist/postings.d.ts.map +1 -0
  31. package/dist/recipes.d.ts +9 -0
  32. package/dist/recipes.d.ts.map +1 -1
  33. package/dist/smrt-knowledge.json +475 -9
  34. package/dist/types.d.ts +23 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js.map +1 -1
  37. package/package.json +5 -5
  38. package/dist/chunks/Account-b0RgfbjM.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-ledgers",
5
- "packageVersion": "0.57.1",
5
+ "packageVersion": "0.57.3",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-ledgers:AccountCollection": {
8
8
  "name": "accountcollection",
@@ -187,7 +187,7 @@
187
187
  "collectionExportName": "AccountCollectionCollection",
188
188
  "schema": {
189
189
  "tableName": "ledger_accounts",
190
- "ddl": "CREATE TABLE IF NOT EXISTS \"ledger_accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
190
+ "ddl": "CREATE TABLE IF NOT EXISTS \"ledger_accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"ledger_id\" UUID,\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
191
191
  "columns": {
192
192
  "id": {
193
193
  "type": "UUID",
@@ -256,6 +256,18 @@
256
256
  "unique": false,
257
257
  "default": "asset"
258
258
  },
259
+ "ledger_id": {
260
+ "type": "UUID",
261
+ "referenceKind": "foreignKey",
262
+ "notNull": false,
263
+ "unique": false,
264
+ "foreignKey": {
265
+ "table": "ledgers",
266
+ "column": "id",
267
+ "onDelete": "NO ACTION",
268
+ "onUpdate": "CASCADE"
269
+ }
270
+ },
259
271
  "active": {
260
272
  "type": "BOOLEAN",
261
273
  "notNull": false,
@@ -292,9 +304,15 @@
292
304
  "columns": [
293
305
  "parent_id"
294
306
  ]
307
+ },
308
+ {
309
+ "name": "ledger_accounts_ledger_id_idx",
310
+ "columns": [
311
+ "ledger_id"
312
+ ]
295
313
  }
296
314
  ],
297
- "version": "49630dae"
315
+ "version": "caea63eb"
298
316
  },
299
317
  "importPath": "@happyvertical/smrt-ledgers"
300
318
  },
@@ -335,6 +353,39 @@
335
353
  "isStatic": false,
336
354
  "isPublic": true
337
355
  },
356
+ "getCounterpartyBalances": {
357
+ "name": "getCounterpartyBalances",
358
+ "async": true,
359
+ "parameters": [
360
+ {
361
+ "name": "options",
362
+ "type": "PostedJournalMovementOptions",
363
+ "optional": false
364
+ }
365
+ ],
366
+ "returnType": "Promise<CounterpartyBalance[]>",
367
+ "isStatic": false,
368
+ "isPublic": true
369
+ },
370
+ "getCounterpartyAging": {
371
+ "name": "getCounterpartyAging",
372
+ "async": true,
373
+ "parameters": [
374
+ {
375
+ "name": "options",
376
+ "type": "PostedJournalMovementOptions",
377
+ "optional": false
378
+ },
379
+ {
380
+ "name": "asOf",
381
+ "type": "Date",
382
+ "optional": false
383
+ }
384
+ ],
385
+ "returnType": "Promise<CounterpartyAgingRow[]>",
386
+ "isStatic": false,
387
+ "isPublic": true
388
+ },
338
389
  "getAccountBalance": {
339
390
  "name": "getAccountBalance",
340
391
  "async": true,
@@ -486,7 +537,7 @@
486
537
  "collectionExportName": "JournalEntryCollectionCollection",
487
538
  "schema": {
488
539
  "tableName": "journal_entries",
489
- "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);",
540
+ "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 \"counterparty_kind\" TEXT,\n \"counterparty_id\" TEXT,\n \"due_date\" TIMESTAMP,\n \"settles_source_ref\" TEXT,\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);",
490
541
  "columns": {
491
542
  "id": {
492
543
  "type": "UUID",
@@ -543,6 +594,26 @@
543
594
  "onUpdate": "CASCADE"
544
595
  }
545
596
  },
597
+ "counterparty_kind": {
598
+ "type": "TEXT",
599
+ "notNull": false,
600
+ "unique": false
601
+ },
602
+ "counterparty_id": {
603
+ "type": "TEXT",
604
+ "notNull": false,
605
+ "unique": false
606
+ },
607
+ "due_date": {
608
+ "type": "TIMESTAMP",
609
+ "notNull": false,
610
+ "unique": false
611
+ },
612
+ "settles_source_ref": {
613
+ "type": "TEXT",
614
+ "notNull": false,
615
+ "unique": false
616
+ },
546
617
  "debit": {
547
618
  "type": "REAL",
548
619
  "notNull": false,
@@ -611,7 +682,7 @@
611
682
  ]
612
683
  }
613
684
  ],
614
- "version": "93cdc848"
685
+ "version": "e96b76a2"
615
686
  },
616
687
  "importPath": "@happyvertical/smrt-ledgers"
617
688
  },
@@ -840,7 +911,7 @@
840
911
  "collectionExportName": "JournalCollectionCollection",
841
912
  "schema": {
842
913
  "tableName": "journals",
843
- "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);",
914
+ "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 \"ledger_id\" UUID,\n \"idempotency_key\" TEXT,\n \"request_digest\" TEXT,\n \"status\" TEXT DEFAULT 'draft',\n \"posted_at\" TIMESTAMP,\n \"voided_at\" TIMESTAMP,\n \"void_reason\" TEXT,\n \"metadata\" JSON DEFAULT '{}'\n);",
844
915
  "columns": {
845
916
  "id": {
846
917
  "type": "UUID",
@@ -901,6 +972,28 @@
901
972
  "notNull": false,
902
973
  "unique": false
903
974
  },
975
+ "ledger_id": {
976
+ "type": "UUID",
977
+ "referenceKind": "foreignKey",
978
+ "notNull": false,
979
+ "unique": false,
980
+ "foreignKey": {
981
+ "table": "ledgers",
982
+ "column": "id",
983
+ "onDelete": "NO ACTION",
984
+ "onUpdate": "CASCADE"
985
+ }
986
+ },
987
+ "idempotency_key": {
988
+ "type": "TEXT",
989
+ "notNull": false,
990
+ "unique": false
991
+ },
992
+ "request_digest": {
993
+ "type": "TEXT",
994
+ "notNull": false,
995
+ "unique": false
996
+ },
904
997
  "status": {
905
998
  "type": "TEXT",
906
999
  "notNull": false,
@@ -940,15 +1033,135 @@
940
1033
  "unique": true,
941
1034
  "nullsNotDistinct": true
942
1035
  },
1036
+ {
1037
+ "name": "journals_ledger_idempotency_key",
1038
+ "columns": [
1039
+ "tenant_id",
1040
+ "ledger_id",
1041
+ "idempotency_key"
1042
+ ],
1043
+ "unique": true
1044
+ },
943
1045
  {
944
1046
  "name": "journals_tenant_id_created_at_idx",
945
1047
  "columns": [
946
1048
  "tenant_id",
947
1049
  "created_at"
948
1050
  ]
1051
+ },
1052
+ {
1053
+ "name": "journals_ledger_id_idx",
1054
+ "columns": [
1055
+ "ledger_id"
1056
+ ]
1057
+ }
1058
+ ],
1059
+ "version": "1e73dd60"
1060
+ },
1061
+ "importPath": "@happyvertical/smrt-ledgers"
1062
+ },
1063
+ "@happyvertical/smrt-ledgers:LedgerCollection": {
1064
+ "name": "ledgercollection",
1065
+ "className": "LedgerCollection",
1066
+ "qualifiedName": "@happyvertical/smrt-ledgers:LedgerCollection",
1067
+ "collection": "ledgers",
1068
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Ledgers.ts",
1069
+ "packageName": "@happyvertical/smrt-ledgers",
1070
+ "fields": {},
1071
+ "methods": {},
1072
+ "decoratorConfig": {
1073
+ "api": {
1074
+ "include": [
1075
+ "list",
1076
+ "get",
1077
+ "create",
1078
+ "update"
1079
+ ]
1080
+ },
1081
+ "mcp": {
1082
+ "include": [
1083
+ "list",
1084
+ "get",
1085
+ "create"
1086
+ ]
1087
+ }
1088
+ },
1089
+ "extends": "SmrtCollection",
1090
+ "extendsTypeArg": "Ledger",
1091
+ "exportName": "LedgerCollection",
1092
+ "collectionExportName": "LedgerCollectionCollection",
1093
+ "schema": {
1094
+ "tableName": "ledgers",
1095
+ "ddl": "CREATE TABLE IF NOT EXISTS \"ledgers\" (\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 \"name\" TEXT,\n \"currency\" TEXT,\n \"balance_mode\" TEXT DEFAULT 'tolerant'\n);",
1096
+ "columns": {
1097
+ "id": {
1098
+ "type": "UUID",
1099
+ "primaryKey": true,
1100
+ "referenceKind": "id",
1101
+ "notNull": true
1102
+ },
1103
+ "slug": {
1104
+ "type": "TEXT",
1105
+ "notNull": true
1106
+ },
1107
+ "context": {
1108
+ "type": "TEXT",
1109
+ "notNull": true,
1110
+ "default": ""
1111
+ },
1112
+ "created_at": {
1113
+ "type": "TIMESTAMP",
1114
+ "notNull": true,
1115
+ "default": "current_timestamp"
1116
+ },
1117
+ "updated_at": {
1118
+ "type": "TIMESTAMP",
1119
+ "notNull": true,
1120
+ "default": "current_timestamp"
1121
+ },
1122
+ "tenant_id": {
1123
+ "type": "UUID",
1124
+ "referenceKind": "tenantId",
1125
+ "notNull": false,
1126
+ "unique": false
1127
+ },
1128
+ "name": {
1129
+ "type": "TEXT",
1130
+ "notNull": false,
1131
+ "unique": false
1132
+ },
1133
+ "currency": {
1134
+ "type": "TEXT",
1135
+ "notNull": false,
1136
+ "unique": false
1137
+ },
1138
+ "balance_mode": {
1139
+ "type": "TEXT",
1140
+ "notNull": false,
1141
+ "unique": false,
1142
+ "default": "tolerant"
1143
+ }
1144
+ },
1145
+ "indexes": [
1146
+ {
1147
+ "name": "ledgers_slug_context_idx",
1148
+ "columns": [
1149
+ "tenant_id",
1150
+ "slug",
1151
+ "context"
1152
+ ],
1153
+ "unique": true,
1154
+ "nullsNotDistinct": true
1155
+ },
1156
+ {
1157
+ "name": "ledgers_tenant_id_created_at_idx",
1158
+ "columns": [
1159
+ "tenant_id",
1160
+ "created_at"
1161
+ ]
949
1162
  }
950
1163
  ],
951
- "version": "4b51d204"
1164
+ "version": "be316e4f"
952
1165
  },
953
1166
  "importPath": "@happyvertical/smrt-ledgers"
954
1167
  },
@@ -1029,6 +1242,16 @@
1029
1242
  "expense"
1030
1243
  ]
1031
1244
  },
1245
+ "ledgerId": {
1246
+ "type": "foreignKey",
1247
+ "required": false,
1248
+ "related": "Ledger",
1249
+ "description": "The ledger policy this account belongs to.",
1250
+ "_meta": {
1251
+ "description": "The ledger policy this account belongs to.",
1252
+ "nullable": true
1253
+ }
1254
+ },
1032
1255
  "active": {
1033
1256
  "type": "boolean",
1034
1257
  "required": false,
@@ -1110,6 +1333,21 @@
1110
1333
  "isStatic": false,
1111
1334
  "isPublic": true
1112
1335
  },
1336
+ "delete": {
1337
+ "name": "delete",
1338
+ "async": true,
1339
+ "parameters": [
1340
+ {
1341
+ "name": "options",
1342
+ "type": "any",
1343
+ "optional": true,
1344
+ "typeUnresolved": true
1345
+ }
1346
+ ],
1347
+ "returnType": "Promise<void>",
1348
+ "isStatic": false,
1349
+ "isPublic": true
1350
+ },
1113
1351
  "isTopLevel": {
1114
1352
  "name": "isTopLevel",
1115
1353
  "async": false,
@@ -1215,7 +1453,7 @@
1215
1453
  "displayLabelField": "name",
1216
1454
  "schema": {
1217
1455
  "tableName": "ledger_accounts",
1218
- "ddl": "CREATE TABLE IF NOT EXISTS \"ledger_accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
1456
+ "ddl": "CREATE TABLE IF NOT EXISTS \"ledger_accounts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"number\" TEXT DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'asset',\n \"ledger_id\" UUID,\n \"active\" BOOLEAN DEFAULT TRUE,\n \"metadata\" JSON DEFAULT '{}'\n);",
1219
1457
  "columns": {
1220
1458
  "id": {
1221
1459
  "type": "UUID",
@@ -1284,6 +1522,18 @@
1284
1522
  "unique": false,
1285
1523
  "default": "asset"
1286
1524
  },
1525
+ "ledger_id": {
1526
+ "type": "UUID",
1527
+ "referenceKind": "foreignKey",
1528
+ "notNull": false,
1529
+ "unique": false,
1530
+ "foreignKey": {
1531
+ "table": "ledgers",
1532
+ "column": "id",
1533
+ "onDelete": "NO ACTION",
1534
+ "onUpdate": "CASCADE"
1535
+ }
1536
+ },
1287
1537
  "active": {
1288
1538
  "type": "BOOLEAN",
1289
1539
  "notNull": false,
@@ -1320,9 +1570,15 @@
1320
1570
  "columns": [
1321
1571
  "parent_id"
1322
1572
  ]
1573
+ },
1574
+ {
1575
+ "name": "ledger_accounts_ledger_id_idx",
1576
+ "columns": [
1577
+ "ledger_id"
1578
+ ]
1323
1579
  }
1324
1580
  ],
1325
- "version": "49630dae"
1581
+ "version": "caea63eb"
1326
1582
  },
1327
1583
  "importPath": "@happyvertical/smrt-ledgers"
1328
1584
  },
@@ -1387,6 +1643,27 @@
1387
1643
  "type": "text",
1388
1644
  "required": false
1389
1645
  },
1646
+ "ledgerId": {
1647
+ "type": "foreignKey",
1648
+ "required": false,
1649
+ "related": "Ledger",
1650
+ "description": "The ledger policy that governs this journal.",
1651
+ "_meta": {
1652
+ "description": "The ledger policy that governs this journal.",
1653
+ "nullable": true
1654
+ }
1655
+ },
1656
+ "idempotencyKey": {
1657
+ "type": "text",
1658
+ "required": false,
1659
+ "_meta": {
1660
+ "nullable": true
1661
+ }
1662
+ },
1663
+ "requestDigest": {
1664
+ "type": "text",
1665
+ "required": false
1666
+ },
1390
1667
  "status": {
1391
1668
  "type": "text",
1392
1669
  "required": false,
@@ -1488,6 +1765,14 @@
1488
1765
  "isStatic": false,
1489
1766
  "isPublic": true
1490
1767
  },
1768
+ "getLedger": {
1769
+ "name": "getLedger",
1770
+ "async": true,
1771
+ "parameters": [],
1772
+ "returnType": "any",
1773
+ "isStatic": false,
1774
+ "isPublic": true
1775
+ },
1491
1776
  "addEntry": {
1492
1777
  "name": "addEntry",
1493
1778
  "async": true,
@@ -1524,6 +1809,36 @@
1524
1809
  "isStatic": false,
1525
1810
  "isPublic": true
1526
1811
  },
1812
+ "save": {
1813
+ "name": "save",
1814
+ "async": true,
1815
+ "parameters": [
1816
+ {
1817
+ "name": "options",
1818
+ "type": "any",
1819
+ "optional": true,
1820
+ "typeUnresolved": true
1821
+ }
1822
+ ],
1823
+ "returnType": "Promise<this>",
1824
+ "isStatic": false,
1825
+ "isPublic": true
1826
+ },
1827
+ "delete": {
1828
+ "name": "delete",
1829
+ "async": true,
1830
+ "parameters": [
1831
+ {
1832
+ "name": "options",
1833
+ "type": "any",
1834
+ "optional": true,
1835
+ "typeUnresolved": true
1836
+ }
1837
+ ],
1838
+ "returnType": "Promise<void>",
1839
+ "isStatic": false,
1840
+ "isPublic": true
1841
+ },
1527
1842
  "summarize": {
1528
1843
  "name": "summarize",
1529
1844
  "async": true,
@@ -1551,6 +1866,17 @@
1551
1866
  "cli": {
1552
1867
  "skipApiCheck": true
1553
1868
  },
1869
+ "indexes": [
1870
+ {
1871
+ "name": "journals_ledger_idempotency_key",
1872
+ "columns": [
1873
+ "tenantId",
1874
+ "ledgerId",
1875
+ "idempotencyKey"
1876
+ ],
1877
+ "unique": true
1878
+ }
1879
+ ],
1554
1880
  "tenantScoped": {
1555
1881
  "mode": "optional"
1556
1882
  },
@@ -1565,7 +1891,7 @@
1565
1891
  "collectionExportName": "JournalCollection",
1566
1892
  "schema": {
1567
1893
  "tableName": "journals",
1568
- "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);",
1894
+ "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 \"ledger_id\" UUID,\n \"idempotency_key\" TEXT,\n \"request_digest\" TEXT,\n \"status\" TEXT DEFAULT 'draft',\n \"posted_at\" TIMESTAMP,\n \"voided_at\" TIMESTAMP,\n \"void_reason\" TEXT,\n \"metadata\" JSON DEFAULT '{}'\n);",
1569
1895
  "columns": {
1570
1896
  "id": {
1571
1897
  "type": "UUID",
@@ -1626,6 +1952,28 @@
1626
1952
  "notNull": false,
1627
1953
  "unique": false
1628
1954
  },
1955
+ "ledger_id": {
1956
+ "type": "UUID",
1957
+ "referenceKind": "foreignKey",
1958
+ "notNull": false,
1959
+ "unique": false,
1960
+ "foreignKey": {
1961
+ "table": "ledgers",
1962
+ "column": "id",
1963
+ "onDelete": "NO ACTION",
1964
+ "onUpdate": "CASCADE"
1965
+ }
1966
+ },
1967
+ "idempotency_key": {
1968
+ "type": "TEXT",
1969
+ "notNull": false,
1970
+ "unique": false
1971
+ },
1972
+ "request_digest": {
1973
+ "type": "TEXT",
1974
+ "notNull": false,
1975
+ "unique": false
1976
+ },
1629
1977
  "status": {
1630
1978
  "type": "TEXT",
1631
1979
  "notNull": false,
@@ -1665,15 +2013,30 @@
1665
2013
  "unique": true,
1666
2014
  "nullsNotDistinct": true
1667
2015
  },
2016
+ {
2017
+ "name": "journals_ledger_idempotency_key",
2018
+ "columns": [
2019
+ "tenant_id",
2020
+ "ledger_id",
2021
+ "idempotency_key"
2022
+ ],
2023
+ "unique": true
2024
+ },
1668
2025
  {
1669
2026
  "name": "journals_tenant_id_created_at_idx",
1670
2027
  "columns": [
1671
2028
  "tenant_id",
1672
2029
  "created_at"
1673
2030
  ]
2031
+ },
2032
+ {
2033
+ "name": "journals_ledger_id_idx",
2034
+ "columns": [
2035
+ "ledger_id"
2036
+ ]
1674
2037
  }
1675
2038
  ],
1676
- "version": "4b51d204"
2039
+ "version": "1e73dd60"
1677
2040
  },
1678
2041
  "importPath": "@happyvertical/smrt-ledgers"
1679
2042
  },
@@ -1721,6 +2084,36 @@
1721
2084
  "description": "The account this entry changes."
1722
2085
  }
1723
2086
  },
2087
+ "counterpartyKind": {
2088
+ "type": "text",
2089
+ "required": false,
2090
+ "description": "Generic counterparty type.",
2091
+ "_meta": {
2092
+ "description": "Generic counterparty type.",
2093
+ "nullable": true
2094
+ }
2095
+ },
2096
+ "counterpartyId": {
2097
+ "type": "text",
2098
+ "required": false,
2099
+ "description": "Generic counterparty identifier.",
2100
+ "_meta": {
2101
+ "description": "Generic counterparty identifier.",
2102
+ "nullable": true
2103
+ }
2104
+ },
2105
+ "dueDate": {
2106
+ "type": "datetime",
2107
+ "required": false,
2108
+ "description": "When this open receivable or payable is due.",
2109
+ "_meta": {
2110
+ "description": "When this open receivable or payable is due."
2111
+ }
2112
+ },
2113
+ "settlesSourceRef": {
2114
+ "type": "text",
2115
+ "required": false
2116
+ },
1724
2117
  "debit": {
1725
2118
  "type": "decimal",
1726
2119
  "required": false,
@@ -1769,6 +2162,36 @@
1769
2162
  }
1770
2163
  },
1771
2164
  "methods": {
2165
+ "save": {
2166
+ "name": "save",
2167
+ "async": true,
2168
+ "parameters": [
2169
+ {
2170
+ "name": "options",
2171
+ "type": "any",
2172
+ "optional": true,
2173
+ "typeUnresolved": true
2174
+ }
2175
+ ],
2176
+ "returnType": "Promise<this>",
2177
+ "isStatic": false,
2178
+ "isPublic": true
2179
+ },
2180
+ "delete": {
2181
+ "name": "delete",
2182
+ "async": true,
2183
+ "parameters": [
2184
+ {
2185
+ "name": "options",
2186
+ "type": "any",
2187
+ "optional": true,
2188
+ "typeUnresolved": true
2189
+ }
2190
+ ],
2191
+ "returnType": "Promise<void>",
2192
+ "isStatic": false,
2193
+ "isPublic": true
2194
+ },
1772
2195
  "isDebit": {
1773
2196
  "name": "isDebit",
1774
2197
  "async": false,
@@ -1856,7 +2279,7 @@
1856
2279
  "collectionExportName": "JournalEntryCollection",
1857
2280
  "schema": {
1858
2281
  "tableName": "journal_entries",
1859
- "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);",
2282
+ "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 \"counterparty_kind\" TEXT,\n \"counterparty_id\" TEXT,\n \"due_date\" TIMESTAMP,\n \"settles_source_ref\" TEXT,\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);",
1860
2283
  "columns": {
1861
2284
  "id": {
1862
2285
  "type": "UUID",
@@ -1913,6 +2336,26 @@
1913
2336
  "onUpdate": "CASCADE"
1914
2337
  }
1915
2338
  },
2339
+ "counterparty_kind": {
2340
+ "type": "TEXT",
2341
+ "notNull": false,
2342
+ "unique": false
2343
+ },
2344
+ "counterparty_id": {
2345
+ "type": "TEXT",
2346
+ "notNull": false,
2347
+ "unique": false
2348
+ },
2349
+ "due_date": {
2350
+ "type": "TIMESTAMP",
2351
+ "notNull": false,
2352
+ "unique": false
2353
+ },
2354
+ "settles_source_ref": {
2355
+ "type": "TEXT",
2356
+ "notNull": false,
2357
+ "unique": false
2358
+ },
1916
2359
  "debit": {
1917
2360
  "type": "REAL",
1918
2361
  "notNull": false,
@@ -1981,7 +2424,181 @@
1981
2424
  ]
1982
2425
  }
1983
2426
  ],
1984
- "version": "93cdc848"
2427
+ "version": "e96b76a2"
2428
+ },
2429
+ "importPath": "@happyvertical/smrt-ledgers"
2430
+ },
2431
+ "@happyvertical/smrt-ledgers:Ledger": {
2432
+ "name": "ledger",
2433
+ "className": "Ledger",
2434
+ "qualifiedName": "@happyvertical/smrt-ledgers:Ledger",
2435
+ "collection": "ledgers",
2436
+ "description": "A named accounting scope. Exact ledgers store one currency's minor units and reject fractional entries; legacy journals without a ledger retain the tolerant balance rule for backwards compatibility.",
2437
+ "filePath": "/home/runner/work/smrt/smrt/packages/ledgers/src/models/Ledger.ts",
2438
+ "packageName": "@happyvertical/smrt-ledgers",
2439
+ "fields": {
2440
+ "tenantId": {
2441
+ "type": "text",
2442
+ "required": false,
2443
+ "_meta": {
2444
+ "sqlType": "UUID",
2445
+ "nullable": true,
2446
+ "__tenancy": {
2447
+ "isTenantIdField": true,
2448
+ "autoFilter": true,
2449
+ "required": false,
2450
+ "autoPopulate": true,
2451
+ "nullable": true,
2452
+ "mode": "optional",
2453
+ "field": "tenantId",
2454
+ "allowSuperAdminBypass": false
2455
+ }
2456
+ }
2457
+ },
2458
+ "name": {
2459
+ "type": "text",
2460
+ "required": false,
2461
+ "description": "The accounting scope name.",
2462
+ "_meta": {
2463
+ "description": "The accounting scope name."
2464
+ }
2465
+ },
2466
+ "currency": {
2467
+ "type": "text",
2468
+ "required": false,
2469
+ "description": "ISO 4217 currency used by this ledger.",
2470
+ "_meta": {
2471
+ "description": "ISO 4217 currency used by this ledger."
2472
+ }
2473
+ },
2474
+ "balanceMode": {
2475
+ "type": "text",
2476
+ "required": false,
2477
+ "default": "tolerant",
2478
+ "description": "tolerant accepts decimal units; exact requires integer minor units.",
2479
+ "_meta": {
2480
+ "description": "tolerant accepts decimal units; exact requires integer minor units."
2481
+ },
2482
+ "enum": [
2483
+ "tolerant",
2484
+ "exact-integer"
2485
+ ]
2486
+ }
2487
+ },
2488
+ "methods": {
2489
+ "delete": {
2490
+ "name": "delete",
2491
+ "async": true,
2492
+ "parameters": [],
2493
+ "returnType": "Promise<void>",
2494
+ "isStatic": false,
2495
+ "isPublic": true
2496
+ }
2497
+ },
2498
+ "decoratorConfig": {
2499
+ "api": {
2500
+ "include": [
2501
+ "list",
2502
+ "get",
2503
+ "create",
2504
+ "update"
2505
+ ]
2506
+ },
2507
+ "mcp": {
2508
+ "include": [
2509
+ "list",
2510
+ "get",
2511
+ "create"
2512
+ ]
2513
+ },
2514
+ "cli": {
2515
+ "skipApiCheck": true
2516
+ },
2517
+ "tenantScoped": {
2518
+ "mode": "optional"
2519
+ },
2520
+ "conflictColumns": [
2521
+ "tenant_id",
2522
+ "slug",
2523
+ "context"
2524
+ ]
2525
+ },
2526
+ "extends": "SmrtObject",
2527
+ "exportName": "Ledger",
2528
+ "collectionExportName": "LedgerCollection",
2529
+ "displayLabelField": "name",
2530
+ "schema": {
2531
+ "tableName": "ledgers",
2532
+ "ddl": "CREATE TABLE IF NOT EXISTS \"ledgers\" (\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 \"name\" TEXT,\n \"currency\" TEXT,\n \"balance_mode\" TEXT DEFAULT 'tolerant'\n);",
2533
+ "columns": {
2534
+ "id": {
2535
+ "type": "UUID",
2536
+ "primaryKey": true,
2537
+ "referenceKind": "id",
2538
+ "notNull": true
2539
+ },
2540
+ "slug": {
2541
+ "type": "TEXT",
2542
+ "notNull": true
2543
+ },
2544
+ "context": {
2545
+ "type": "TEXT",
2546
+ "notNull": true,
2547
+ "default": ""
2548
+ },
2549
+ "created_at": {
2550
+ "type": "TIMESTAMP",
2551
+ "notNull": true,
2552
+ "default": "current_timestamp"
2553
+ },
2554
+ "updated_at": {
2555
+ "type": "TIMESTAMP",
2556
+ "notNull": true,
2557
+ "default": "current_timestamp"
2558
+ },
2559
+ "tenant_id": {
2560
+ "type": "UUID",
2561
+ "referenceKind": "tenantId",
2562
+ "notNull": false,
2563
+ "unique": false
2564
+ },
2565
+ "name": {
2566
+ "type": "TEXT",
2567
+ "notNull": false,
2568
+ "unique": false
2569
+ },
2570
+ "currency": {
2571
+ "type": "TEXT",
2572
+ "notNull": false,
2573
+ "unique": false
2574
+ },
2575
+ "balance_mode": {
2576
+ "type": "TEXT",
2577
+ "notNull": false,
2578
+ "unique": false,
2579
+ "default": "tolerant"
2580
+ }
2581
+ },
2582
+ "indexes": [
2583
+ {
2584
+ "name": "ledgers_slug_context_idx",
2585
+ "columns": [
2586
+ "tenant_id",
2587
+ "slug",
2588
+ "context"
2589
+ ],
2590
+ "unique": true,
2591
+ "nullsNotDistinct": true
2592
+ },
2593
+ {
2594
+ "name": "ledgers_tenant_id_created_at_idx",
2595
+ "columns": [
2596
+ "tenant_id",
2597
+ "created_at"
2598
+ ]
2599
+ }
2600
+ ],
2601
+ "version": "be316e4f"
1985
2602
  },
1986
2603
  "importPath": "@happyvertical/smrt-ledgers"
1987
2604
  }
@@ -2045,6 +2662,12 @@
2045
2662
  "sourceRef": {
2046
2663
  "visibility": "hidden"
2047
2664
  },
2665
+ "idempotencyKey": {
2666
+ "visibility": "hidden"
2667
+ },
2668
+ "requestDigest": {
2669
+ "visibility": "hidden"
2670
+ },
2048
2671
  "voidedAt": {
2049
2672
  "visibility": "hidden"
2050
2673
  },
@@ -2061,6 +2684,9 @@
2061
2684
  "exchangeRate": {
2062
2685
  "visibility": "hidden"
2063
2686
  },
2687
+ "settlesSourceRef": {
2688
+ "visibility": "hidden"
2689
+ },
2064
2690
  "metadata": {
2065
2691
  "visibility": "hidden"
2066
2692
  }