@happyvertical/smrt-ledgers 0.51.23 → 0.51.25
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.
- package/AGENTS.md +2 -1
- package/README.md +46 -0
- package/dist/chunks/Account-Dr4tA_Gn.js +128 -0
- package/dist/chunks/Account-Dr4tA_Gn.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +215 -129
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +23 -20
- package/dist/smrt-knowledge.json +7 -7
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import { t as Account } from "./chunks/Account-Dr4tA_Gn.js";
|
|
1
2
|
import { BALANCE_EPSILON } from "./types.js";
|
|
2
|
-
import { ObjectRegistry, SmrtCollection,
|
|
3
|
+
import { ObjectRegistry, SmrtCollection, SmrtObject, detectEngine, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
3
4
|
import { definePrompt, resolvePrompt } from "@happyvertical/smrt-prompts";
|
|
4
5
|
import { TenantScoped, queryGlobal, queryWithGlobals, tenantId } from "@happyvertical/smrt-tenancy";
|
|
6
|
+
import { BackfillTracker } from "@happyvertical/smrt-core/migrations";
|
|
5
7
|
//#region \0rolldown/runtime.js
|
|
6
|
-
var __defProp$
|
|
8
|
+
var __defProp$2 = Object.defineProperty;
|
|
7
9
|
var __exportAll = (all, no_symbols) => {
|
|
8
10
|
let target = {};
|
|
9
|
-
for (var name in all) __defProp$
|
|
11
|
+
for (var name in all) __defProp$2(target, name, {
|
|
10
12
|
get: all[name],
|
|
11
13
|
enumerable: true
|
|
12
14
|
});
|
|
13
|
-
if (!no_symbols) __defProp$
|
|
15
|
+
if (!no_symbols) __defProp$2(target, Symbol.toStringTag, { value: "Module" });
|
|
14
16
|
return target;
|
|
15
17
|
};
|
|
16
18
|
//#endregion
|
|
17
19
|
//#region src/__smrt-register__.ts
|
|
18
|
-
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-ledgers\",\"packageVersion\":\"0.51.23\",\"objects\":{\"@happyvertical/smrt-ledgers:AccountCollection\":{\"name\":\"accountcollection\",\"className\":\"AccountCollection\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:AccountCollection\",\"collection\":\"accounts\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Accounts.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{},\"methods\":{\"findByNumber\":{\"name\":\"findByNumber\",\"async\":true,\"parameters\":[{\"name\":\"number\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account | null>\",\"isStatic\":false,\"isPublic\":true},\"findByType\":{\"name\":\"findByType\",\"async\":true,\"parameters\":[{\"name\":\"type\",\"type\":\"AccountType\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findActive\":{\"name\":\"findActive\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findTopLevel\":{\"name\":\"findTopLevel\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findChildren\":{\"name\":\"findChildren\",\"async\":true,\"parameters\":[{\"name\":\"parentId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"getTree\":{\"name\":\"getTree\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AccountTree>\",\"isStatic\":false,\"isPublic\":true},\"getOrCreateByNumber\":{\"name\":\"getOrCreateByNumber\",\"async\":true,\"parameters\":[{\"name\":\"number\",\"type\":\"string\",\"optional\":false},{\"name\":\"defaults\",\"type\":\"Partial<object>\",\"optional\":true,\"memberTypes\":[\"string\",\"AccountType\",\"string | null\"]}],\"returnType\":\"Promise<Account>\",\"isStatic\":false,\"isPublic\":true},\"groupByType\":{\"name\":\"groupByType\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Record<AccountType, Account[]>>\",\"isStatic\":false,\"isPublic\":true},\"getDescendants\":{\"name\":\"getDescendants\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Account\",\"exportName\":\"AccountCollection\",\"collectionExportName\":\"AccountCollectionCollection\",\"schema\":{\"tableName\":\"accounts\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"parent_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"asset\"},\"active\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":true},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"accounts_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"accounts_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"accounts_parent_id_idx\",\"columns\":[\"parent_id\"]}],\"version\":\"62bb562a\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:JournalEntryCollection\":{\"name\":\"journalentrycollection\",\"className\":\"JournalEntryCollection\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:JournalEntryCollection\",\"collection\":\"journalentries\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/collections/JournalEntries.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{},\"methods\":{\"findByJournal\":{\"name\":\"findByJournal\",\"async\":true,\"parameters\":[{\"name\":\"journalId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"findByAccount\":{\"name\":\"findByAccount\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"getAccountBalance\":{\"name\":\"getAccountBalance\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false},{\"name\":\"asOfDate\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getTrialBalance\":{\"name\":\"getTrialBalance\",\"async\":true,\"parameters\":[{\"name\":\"asOfDate\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<TrialBalanceRow[]>\",\"isStatic\":false,\"isPublic\":true},\"getTotalsForDateRange\":{\"name\":\"getTotalsForDateRange\",\"async\":true,\"parameters\":[{\"name\":\"start\",\"type\":\"Date\",\"optional\":false},{\"name\":\"end\",\"type\":\"Date\",\"optional\":false}],\"returnType\":\"Promise<object>\",\"isStatic\":false,\"isPublic\":true},\"findByAccounts\":{\"name\":\"findByAccounts\",\"async\":true,\"parameters\":[{\"name\":\"accountIds\",\"type\":\"string[]\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"getAccountLedger\":{\"name\":\"getAccountLedger\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Array<object>>\",\"isStatic\":false,\"isPublic\":true},\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"JournalEntry\",\"exportName\":\"JournalEntryCollection\",\"collectionExportName\":\"JournalEntryCollectionCollection\",\"schema\":{\"tableName\":\"journal_entries\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"journal_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"journals\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"account_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"debit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"credit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"currency\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"USD\"},\"exchange_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":1},\"memo\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journal_entries_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journal_entries_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"journal_entries_journal_id_idx\",\"columns\":[\"journal_id\"]},{\"name\":\"journal_entries_account_id_idx\",\"columns\":[\"account_id\"]}],\"version\":\"0457e0e4\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:JournalCollection\":{\"name\":\"journalcollection\",\"className\":\"JournalCollection\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:JournalCollection\",\"collection\":\"journals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Journals.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{},\"methods\":{\"findByNumber\":{\"name\":\"findByNumber\",\"async\":true,\"parameters\":[{\"name\":\"number\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal | null>\",\"isStatic\":false,\"isPublic\":true},\"findByDateRange\":{\"name\":\"findByDateRange\",\"async\":true,\"parameters\":[{\"name\":\"start\",\"type\":\"Date\",\"optional\":false},{\"name\":\"end\",\"type\":\"Date\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findBySource\":{\"name\":\"findBySource\",\"async\":true,\"parameters\":[{\"name\":\"sourceModule\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByStatus\":{\"name\":\"findByStatus\",\"async\":true,\"parameters\":[{\"name\":\"status\",\"type\":\"JournalStatus\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findDrafts\":{\"name\":\"findDrafts\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findPosted\":{\"name\":\"findPosted\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"createWithEntries\":{\"name\":\"createWithEntries\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"CreateJournalData\",\"optional\":false}],\"returnType\":\"Promise<Journal>\",\"isStatic\":false,\"isPublic\":true},\"post\":{\"name\":\"post\",\"async\":true,\"parameters\":[{\"name\":\"journalId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal>\",\"isStatic\":false,\"isPublic\":true},\"void\":{\"name\":\"void\",\"async\":true,\"parameters\":[{\"name\":\"journalId\",\"type\":\"string\",\"optional\":false},{\"name\":\"reason\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal>\",\"isStatic\":false,\"isPublic\":true},\"findBySourceRef\":{\"name\":\"findBySourceRef\",\"async\":true,\"parameters\":[{\"name\":\"sourceRef\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByMonth\":{\"name\":\"findByMonth\",\"async\":true,\"parameters\":[{\"name\":\"year\",\"type\":\"number\",\"optional\":false},{\"name\":\"month\",\"type\":\"number\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Journal\",\"exportName\":\"JournalCollection\",\"collectionExportName\":\"JournalCollectionCollection\",\"schema\":{\"tableName\":\"journals\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"date\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_module\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_ref\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"draft\"},\"posted_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"voided_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"void_reason\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"4b51d204\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:Account\":{\"name\":\"account\",\"className\":\"Account\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:Account\",\"collection\":\"accounts\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/models/Account.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{\"parentId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Account\",\"_meta\":{\"nullable\":true}},\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"number\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"type\":{\"type\":\"text\",\"required\":false,\"default\":\"asset\"},\"active\":{\"type\":\"boolean\",\"required\":false,\"default\":true},\"metadata\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"getParent\":{\"name\":\"getParent\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this | null>\",\"isStatic\":false,\"isPublic\":true},\"getChildren\":{\"name\":\"getChildren\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this[]>\",\"isStatic\":false,\"isPublic\":true},\"getAncestors\":{\"name\":\"getAncestors\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this[]>\",\"isStatic\":false,\"isPublic\":true},\"getDescendants\":{\"name\":\"getDescendants\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this[]>\",\"isStatic\":false,\"isPublic\":true},\"getHierarchy\":{\"name\":\"getHierarchy\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<HierarchyView<this>>\",\"isStatic\":false,\"isPublic\":true},\"moveTo\":{\"name\":\"moveTo\",\"async\":true,\"parameters\":[{\"name\":\"newParent\",\"type\":\"this | string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"this\"},{\"type\":\"string\"},{\"type\":\"null\"}]}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"isTopLevel\":{\"name\":\"isTopLevel\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isDebitNormal\":{\"name\":\"isDebitNormal\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isCreditNormal\":{\"name\":\"isCreditNormal\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getFullPath\":{\"name\":\"getFullPath\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<string>\",\"isStatic\":false,\"isPublic\":true},\"toTreeNode\":{\"name\":\"toTreeNode\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AccountTreeNode>\",\"isStatic\":false,\"isPublic\":true},\"getBalance\":{\"name\":\"getBalance\",\"async\":true,\"parameters\":[{\"name\":\"asOfDate\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"createChild\":{\"name\":\"createChild\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"Omit<AccountOptions, 'parentId' | 'type'>\",\"optional\":false}],\"returnType\":\"Promise<Account>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"mcp\":{\"include\":[\"list\",\"get\",\"create\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtHierarchical\",\"exportName\":\"Account\",\"collectionExportName\":\"AccountCollection\",\"schema\":{\"tableName\":\"accounts\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"parent_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"asset\"},\"active\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":true},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"accounts_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"accounts_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"accounts_parent_id_idx\",\"columns\":[\"parent_id\"]}],\"version\":\"62bb562a\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:Journal\":{\"name\":\"journal\",\"className\":\"Journal\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:Journal\",\"collection\":\"journals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/models/Journal.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"number\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"date\":{\"type\":\"datetime\",\"required\":false},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceModule\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceRef\":{\"type\":\"text\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"draft\"},\"postedAt\":{\"type\":\"datetime\",\"required\":false},\"voidedAt\":{\"type\":\"datetime\",\"required\":false},\"voidReason\":{\"type\":\"text\",\"required\":false},\"metadata\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"isDraft\":{\"name\":\"isDraft\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isPosted\":{\"name\":\"isPosted\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isVoided\":{\"name\":\"isVoided\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isEditable\":{\"name\":\"isEditable\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getEntries\":{\"name\":\"getEntries\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getTotalDebits\":{\"name\":\"getTotalDebits\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getTotalCredits\":{\"name\":\"getTotalCredits\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"isBalanced\":{\"name\":\"isBalanced\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true},\"addEntry\":{\"name\":\"addEntry\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"JournalEntryData\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"post\":{\"name\":\"post\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"void\":{\"name\":\"void\",\"async\":true,\"parameters\":[{\"name\":\"reason\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"summarize\":{\"name\":\"summarize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<string>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\",\"create\"]},\"mcp\":{\"include\":[\"list\",\"get\",\"create\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Journal\",\"collectionExportName\":\"JournalCollection\",\"schema\":{\"tableName\":\"journals\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"date\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_module\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_ref\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"draft\"},\"posted_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"voided_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"void_reason\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"4b51d204\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:JournalEntry\":{\"name\":\"journalentry\",\"className\":\"JournalEntry\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:JournalEntry\",\"collection\":\"journalentries\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/models/JournalEntry.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"journalId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Journal\"},\"accountId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Account\"},\"debit\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"credit\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"exchangeRate\":{\"type\":\"decimal\",\"required\":false,\"default\":1},\"memo\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"metadata\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"isDebit\":{\"name\":\"isDebit\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isCredit\":{\"name\":\"isCredit\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getAmount\":{\"name\":\"getAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getBaseAmount\":{\"name\":\"getBaseAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getJournal\":{\"name\":\"getJournal\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getAccount\":{\"name\":\"getAccount\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getDescription\":{\"name\":\"getDescription\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<string>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"JournalEntry\",\"collectionExportName\":\"JournalEntryCollection\",\"schema\":{\"tableName\":\"journal_entries\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"journal_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"journals\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"account_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"debit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"credit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"currency\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"USD\"},\"exchange_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":1},\"memo\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journal_entries_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journal_entries_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"journal_entries_journal_id_idx\",\"columns\":[\"journal_id\"]},{\"name\":\"journal_entries_account_id_idx\",\"columns\":[\"account_id\"]}],\"version\":\"0457e0e4\"},\"importPath\":\"@happyvertical/smrt-ledgers\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-prompts\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
20
|
+
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-ledgers\",\"packageVersion\":\"0.51.25\",\"objects\":{\"@happyvertical/smrt-ledgers:AccountCollection\":{\"name\":\"accountcollection\",\"className\":\"AccountCollection\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:AccountCollection\",\"collection\":\"accounts\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Accounts.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{},\"methods\":{\"findByNumber\":{\"name\":\"findByNumber\",\"async\":true,\"parameters\":[{\"name\":\"number\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account | null>\",\"isStatic\":false,\"isPublic\":true},\"findByType\":{\"name\":\"findByType\",\"async\":true,\"parameters\":[{\"name\":\"type\",\"type\":\"AccountType\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findActive\":{\"name\":\"findActive\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findTopLevel\":{\"name\":\"findTopLevel\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findChildren\":{\"name\":\"findChildren\",\"async\":true,\"parameters\":[{\"name\":\"parentId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"getTree\":{\"name\":\"getTree\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AccountTree>\",\"isStatic\":false,\"isPublic\":true},\"getOrCreateByNumber\":{\"name\":\"getOrCreateByNumber\",\"async\":true,\"parameters\":[{\"name\":\"number\",\"type\":\"string\",\"optional\":false},{\"name\":\"defaults\",\"type\":\"Partial<object>\",\"optional\":true,\"memberTypes\":[\"string\",\"AccountType\",\"string | null\"]}],\"returnType\":\"Promise<Account>\",\"isStatic\":false,\"isPublic\":true},\"groupByType\":{\"name\":\"groupByType\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Record<AccountType, Account[]>>\",\"isStatic\":false,\"isPublic\":true},\"getDescendants\":{\"name\":\"getDescendants\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Account[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"ledger_accounts\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Account\",\"exportName\":\"AccountCollection\",\"collectionExportName\":\"AccountCollectionCollection\",\"schema\":{\"tableName\":\"ledger_accounts\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"parent_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"ledger_accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"asset\"},\"active\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":true},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"ledger_accounts_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"ledger_accounts_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"ledger_accounts_parent_id_idx\",\"columns\":[\"parent_id\"]}],\"version\":\"49630dae\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:JournalEntryCollection\":{\"name\":\"journalentrycollection\",\"className\":\"JournalEntryCollection\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:JournalEntryCollection\",\"collection\":\"journalentries\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/collections/JournalEntries.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{},\"methods\":{\"findByJournal\":{\"name\":\"findByJournal\",\"async\":true,\"parameters\":[{\"name\":\"journalId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"findByAccount\":{\"name\":\"findByAccount\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"getAccountBalance\":{\"name\":\"getAccountBalance\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false},{\"name\":\"asOfDate\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getTrialBalance\":{\"name\":\"getTrialBalance\",\"async\":true,\"parameters\":[{\"name\":\"asOfDate\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<TrialBalanceRow[]>\",\"isStatic\":false,\"isPublic\":true},\"getTotalsForDateRange\":{\"name\":\"getTotalsForDateRange\",\"async\":true,\"parameters\":[{\"name\":\"start\",\"type\":\"Date\",\"optional\":false},{\"name\":\"end\",\"type\":\"Date\",\"optional\":false}],\"returnType\":\"Promise<object>\",\"isStatic\":false,\"isPublic\":true},\"findByAccounts\":{\"name\":\"findByAccounts\",\"async\":true,\"parameters\":[{\"name\":\"accountIds\",\"type\":\"string[]\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"getAccountLedger\":{\"name\":\"getAccountLedger\",\"async\":true,\"parameters\":[{\"name\":\"accountId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Array<object>>\",\"isStatic\":false,\"isPublic\":true},\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<JournalEntry[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"JournalEntry\",\"exportName\":\"JournalEntryCollection\",\"collectionExportName\":\"JournalEntryCollectionCollection\",\"schema\":{\"tableName\":\"journal_entries\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"journal_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"journals\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"account_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"ledger_accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"debit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"credit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"currency\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"USD\"},\"exchange_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":1},\"memo\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journal_entries_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journal_entries_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"journal_entries_journal_id_idx\",\"columns\":[\"journal_id\"]},{\"name\":\"journal_entries_account_id_idx\",\"columns\":[\"account_id\"]}],\"version\":\"93cdc848\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:JournalCollection\":{\"name\":\"journalcollection\",\"className\":\"JournalCollection\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:JournalCollection\",\"collection\":\"journals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/collections/Journals.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{},\"methods\":{\"findByNumber\":{\"name\":\"findByNumber\",\"async\":true,\"parameters\":[{\"name\":\"number\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal | null>\",\"isStatic\":false,\"isPublic\":true},\"findByDateRange\":{\"name\":\"findByDateRange\",\"async\":true,\"parameters\":[{\"name\":\"start\",\"type\":\"Date\",\"optional\":false},{\"name\":\"end\",\"type\":\"Date\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findBySource\":{\"name\":\"findBySource\",\"async\":true,\"parameters\":[{\"name\":\"sourceModule\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByStatus\":{\"name\":\"findByStatus\",\"async\":true,\"parameters\":[{\"name\":\"status\",\"type\":\"JournalStatus\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findDrafts\":{\"name\":\"findDrafts\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findPosted\":{\"name\":\"findPosted\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"createWithEntries\":{\"name\":\"createWithEntries\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"CreateJournalData\",\"optional\":false}],\"returnType\":\"Promise<Journal>\",\"isStatic\":false,\"isPublic\":true},\"post\":{\"name\":\"post\",\"async\":true,\"parameters\":[{\"name\":\"journalId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal>\",\"isStatic\":false,\"isPublic\":true},\"void\":{\"name\":\"void\",\"async\":true,\"parameters\":[{\"name\":\"journalId\",\"type\":\"string\",\"optional\":false},{\"name\":\"reason\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal>\",\"isStatic\":false,\"isPublic\":true},\"findBySourceRef\":{\"name\":\"findBySourceRef\",\"async\":true,\"parameters\":[{\"name\":\"sourceRef\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByMonth\":{\"name\":\"findByMonth\",\"async\":true,\"parameters\":[{\"name\":\"year\",\"type\":\"number\",\"optional\":false},{\"name\":\"month\",\"type\":\"number\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Journal[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Journal\",\"exportName\":\"JournalCollection\",\"collectionExportName\":\"JournalCollectionCollection\",\"schema\":{\"tableName\":\"journals\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"date\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_module\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_ref\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"draft\"},\"posted_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"voided_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"void_reason\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"4b51d204\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:Account\":{\"name\":\"account\",\"className\":\"Account\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:Account\",\"collection\":\"accounts\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/models/Account.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{\"parentId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Account\",\"_meta\":{\"nullable\":true}},\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"number\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"type\":{\"type\":\"text\",\"required\":false,\"default\":\"asset\"},\"active\":{\"type\":\"boolean\",\"required\":false,\"default\":true},\"metadata\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"getParent\":{\"name\":\"getParent\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this | null>\",\"isStatic\":false,\"isPublic\":true},\"getChildren\":{\"name\":\"getChildren\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this[]>\",\"isStatic\":false,\"isPublic\":true},\"getAncestors\":{\"name\":\"getAncestors\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this[]>\",\"isStatic\":false,\"isPublic\":true},\"getDescendants\":{\"name\":\"getDescendants\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this[]>\",\"isStatic\":false,\"isPublic\":true},\"getHierarchy\":{\"name\":\"getHierarchy\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<HierarchyView<this>>\",\"isStatic\":false,\"isPublic\":true},\"moveTo\":{\"name\":\"moveTo\",\"async\":true,\"parameters\":[{\"name\":\"newParent\",\"type\":\"this | string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"this\"},{\"type\":\"string\"},{\"type\":\"null\"}]}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"isTopLevel\":{\"name\":\"isTopLevel\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isDebitNormal\":{\"name\":\"isDebitNormal\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isCreditNormal\":{\"name\":\"isCreditNormal\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getFullPath\":{\"name\":\"getFullPath\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<string>\",\"isStatic\":false,\"isPublic\":true},\"toTreeNode\":{\"name\":\"toTreeNode\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AccountTreeNode>\",\"isStatic\":false,\"isPublic\":true},\"getBalance\":{\"name\":\"getBalance\",\"async\":true,\"parameters\":[{\"name\":\"asOfDate\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"createChild\":{\"name\":\"createChild\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"Omit<AccountOptions, 'parentId' | 'type'>\",\"optional\":false}],\"returnType\":\"Promise<Account>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"ledger_accounts\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"mcp\":{\"include\":[\"list\",\"get\",\"create\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtHierarchical\",\"exportName\":\"Account\",\"collectionExportName\":\"AccountCollection\",\"schema\":{\"tableName\":\"ledger_accounts\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"parent_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"ledger_accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"asset\"},\"active\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":true},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"ledger_accounts_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"ledger_accounts_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"ledger_accounts_parent_id_idx\",\"columns\":[\"parent_id\"]}],\"version\":\"49630dae\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:Journal\":{\"name\":\"journal\",\"className\":\"Journal\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:Journal\",\"collection\":\"journals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/models/Journal.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"number\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"date\":{\"type\":\"datetime\",\"required\":false},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceModule\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceRef\":{\"type\":\"text\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"draft\"},\"postedAt\":{\"type\":\"datetime\",\"required\":false},\"voidedAt\":{\"type\":\"datetime\",\"required\":false},\"voidReason\":{\"type\":\"text\",\"required\":false},\"metadata\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"isDraft\":{\"name\":\"isDraft\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isPosted\":{\"name\":\"isPosted\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isVoided\":{\"name\":\"isVoided\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isEditable\":{\"name\":\"isEditable\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getEntries\":{\"name\":\"getEntries\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getTotalDebits\":{\"name\":\"getTotalDebits\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getTotalCredits\":{\"name\":\"getTotalCredits\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"isBalanced\":{\"name\":\"isBalanced\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true},\"addEntry\":{\"name\":\"addEntry\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"JournalEntryData\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"post\":{\"name\":\"post\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"void\":{\"name\":\"void\",\"async\":true,\"parameters\":[{\"name\":\"reason\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"summarize\":{\"name\":\"summarize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<string>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\",\"create\"]},\"mcp\":{\"include\":[\"list\",\"get\",\"create\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Journal\",\"collectionExportName\":\"JournalCollection\",\"schema\":{\"tableName\":\"journals\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"number\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"date\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_module\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_ref\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"draft\"},\"posted_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"voided_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"void_reason\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"4b51d204\"},\"importPath\":\"@happyvertical/smrt-ledgers\"},\"@happyvertical/smrt-ledgers:JournalEntry\":{\"name\":\"journalentry\",\"className\":\"JournalEntry\",\"qualifiedName\":\"@happyvertical/smrt-ledgers:JournalEntry\",\"collection\":\"journalentries\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/ledgers/src/models/JournalEntry.ts\",\"packageName\":\"@happyvertical/smrt-ledgers\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"journalId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Journal\"},\"accountId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Account\"},\"debit\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"credit\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"exchangeRate\":{\"type\":\"decimal\",\"required\":false,\"default\":1},\"memo\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"metadata\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"isDebit\":{\"name\":\"isDebit\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isCredit\":{\"name\":\"isCredit\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getAmount\":{\"name\":\"getAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getBaseAmount\":{\"name\":\"getBaseAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getJournal\":{\"name\":\"getJournal\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getAccount\":{\"name\":\"getAccount\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getDescription\":{\"name\":\"getDescription\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<string>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"JournalEntry\",\"collectionExportName\":\"JournalEntryCollection\",\"schema\":{\"tableName\":\"journal_entries\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"journal_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"journals\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"account_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"ledger_accounts\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"debit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"credit\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"currency\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"USD\"},\"exchange_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":1},\"memo\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"journal_entries_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"journal_entries_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"journal_entries_journal_id_idx\",\"columns\":[\"journal_id\"]},{\"name\":\"journal_entries_account_id_idx\",\"columns\":[\"account_id\"]}],\"version\":\"93cdc848\"},\"importPath\":\"@happyvertical/smrt-ledgers\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-prompts\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
19
21
|
//#endregion
|
|
20
22
|
//#region src/prompts.ts
|
|
21
23
|
var smrtLedgersJournalSummarizePrompt = definePrompt({
|
|
@@ -44,128 +46,6 @@ function promptMessageOptions(ai) {
|
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
//#endregion
|
|
47
|
-
//#region src/models/Account.ts
|
|
48
|
-
var __defProp$2 = Object.defineProperty;
|
|
49
|
-
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
50
|
-
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
51
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
|
|
52
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
53
|
-
if (kind && result) __defProp$2(target, key, result);
|
|
54
|
-
return result;
|
|
55
|
-
};
|
|
56
|
-
var Account = class extends SmrtHierarchical {
|
|
57
|
-
tenantId = null;
|
|
58
|
-
/**
|
|
59
|
-
* Account number (e.g., "1000", "5030")
|
|
60
|
-
*/
|
|
61
|
-
number = "";
|
|
62
|
-
/**
|
|
63
|
-
* Account name (e.g., "Cash", "Coffee Expense")
|
|
64
|
-
*/
|
|
65
|
-
name = "";
|
|
66
|
-
/**
|
|
67
|
-
* Account description
|
|
68
|
-
*/
|
|
69
|
-
description = "";
|
|
70
|
-
/**
|
|
71
|
-
* Account type - one of the 5 core types
|
|
72
|
-
*/
|
|
73
|
-
type = "asset";
|
|
74
|
-
/**
|
|
75
|
-
* Whether the account is active
|
|
76
|
-
*/
|
|
77
|
-
active = true;
|
|
78
|
-
/**
|
|
79
|
-
* Extensible metadata
|
|
80
|
-
*/
|
|
81
|
-
metadata = {};
|
|
82
|
-
constructor(options = {}) {
|
|
83
|
-
super(options);
|
|
84
|
-
if (options.number !== void 0) this.number = options.number;
|
|
85
|
-
if (options.name !== void 0) this.name = options.name;
|
|
86
|
-
if (options.description !== void 0) this.description = options.description;
|
|
87
|
-
if (options.type !== void 0) this.type = options.type;
|
|
88
|
-
if (options.parentId !== void 0) this.parentId = options.parentId;
|
|
89
|
-
if (options.active !== void 0) this.active = options.active;
|
|
90
|
-
if (options.metadata !== void 0) this.metadata = options.metadata;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Check if this is a top-level account (no parent)
|
|
94
|
-
*/
|
|
95
|
-
isTopLevel() {
|
|
96
|
-
return this.parentId === null;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Check if this is a debit-normal account (Asset, Expense)
|
|
100
|
-
* Debit-normal accounts increase with debits
|
|
101
|
-
*/
|
|
102
|
-
isDebitNormal() {
|
|
103
|
-
return this.type === "asset" || this.type === "expense";
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Check if this is a credit-normal account (Liability, Equity, Revenue)
|
|
107
|
-
* Credit-normal accounts increase with credits
|
|
108
|
-
*/
|
|
109
|
-
isCreditNormal() {
|
|
110
|
-
return this.type === "liability" || this.type === "equity" || this.type === "revenue";
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Get full account path (e.g., "Assets > Current > Cash")
|
|
114
|
-
*/
|
|
115
|
-
async getFullPath() {
|
|
116
|
-
return [...(await this.getAncestors()).map((a) => a.name), this.name].join(" > ");
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Build tree node for this account and its children
|
|
120
|
-
*/
|
|
121
|
-
async toTreeNode() {
|
|
122
|
-
const children = await this.getChildren();
|
|
123
|
-
const childNodes = await Promise.all(children.map((c) => c.toTreeNode()));
|
|
124
|
-
return {
|
|
125
|
-
account: this,
|
|
126
|
-
children: childNodes
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Get the current balance of this account
|
|
131
|
-
*/
|
|
132
|
-
async getBalance(asOfDate) {
|
|
133
|
-
if (!this.id) return 0;
|
|
134
|
-
const { JournalEntryCollection } = await Promise.resolve().then(() => JournalEntries_exports);
|
|
135
|
-
return await (await JournalEntryCollection.create(this.options)).getAccountBalance(this.id, asOfDate);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Create a sub-account under this account
|
|
139
|
-
*/
|
|
140
|
-
async createChild(options) {
|
|
141
|
-
if (!this.id) throw new Error("Account must be saved before creating children");
|
|
142
|
-
const { AccountCollection } = await Promise.resolve().then(() => Accounts_exports);
|
|
143
|
-
const account = await (await AccountCollection.create(this.options)).create({
|
|
144
|
-
...options,
|
|
145
|
-
parentId: this.id,
|
|
146
|
-
type: this.type
|
|
147
|
-
});
|
|
148
|
-
await account.save();
|
|
149
|
-
return account;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
__decorateClass$2([tenantId({ nullable: true })], Account.prototype, "tenantId", 2);
|
|
153
|
-
Account = __decorateClass$2([TenantScoped({ mode: "optional" }), smrt({
|
|
154
|
-
api: { include: [
|
|
155
|
-
"list",
|
|
156
|
-
"get",
|
|
157
|
-
"create",
|
|
158
|
-
"update",
|
|
159
|
-
"delete"
|
|
160
|
-
] },
|
|
161
|
-
mcp: { include: [
|
|
162
|
-
"list",
|
|
163
|
-
"get",
|
|
164
|
-
"create"
|
|
165
|
-
] },
|
|
166
|
-
cli: { skipApiCheck: true }
|
|
167
|
-
})], Account);
|
|
168
|
-
//#endregion
|
|
169
49
|
//#region src/collections/Accounts.ts
|
|
170
50
|
var Accounts_exports = /* @__PURE__ */ __exportAll({ AccountCollection: () => AccountCollection });
|
|
171
51
|
var AccountCollection = class extends SmrtCollection {
|
|
@@ -451,7 +331,7 @@ var JournalEntry = class extends SmrtObject {
|
|
|
451
331
|
};
|
|
452
332
|
__decorateClass$1([tenantId({ nullable: true })], JournalEntry.prototype, "tenantId", 2);
|
|
453
333
|
__decorateClass$1([foreignKey("Journal")], JournalEntry.prototype, "journalId", 2);
|
|
454
|
-
__decorateClass$1([foreignKey(
|
|
334
|
+
__decorateClass$1([foreignKey(Account)], JournalEntry.prototype, "accountId", 2);
|
|
455
335
|
JournalEntry = __decorateClass$1([TenantScoped({ mode: "optional" }), smrt({
|
|
456
336
|
api: { include: ["list", "get"] },
|
|
457
337
|
mcp: { include: ["list", "get"] },
|
|
@@ -1040,6 +920,212 @@ var JournalCollection = class extends SmrtCollection {
|
|
|
1040
920
|
}
|
|
1041
921
|
};
|
|
1042
922
|
//#endregion
|
|
1043
|
-
|
|
923
|
+
//#region src/migrations/ledger-accounts-table.ts
|
|
924
|
+
var LEDGER_ACCOUNTS_TABLE = "ledger_accounts";
|
|
925
|
+
var LEGACY_ACCOUNTS_TABLE = "accounts";
|
|
926
|
+
var LEDGER_ACCOUNTS_TABLE_MOVE = "@happyvertical/smrt-ledgers:ledger-accounts-table:v1";
|
|
927
|
+
var LEGACY_LEDGER_SIGNATURE = ["number", "type"];
|
|
928
|
+
var STI_DISCRIMINATOR = "_meta_type";
|
|
929
|
+
var MESSAGING_MARKERS = ["provider_type", "channel_type"];
|
|
930
|
+
var LedgerAccountsTableMoveError = class extends Error {
|
|
931
|
+
constructor(message) {
|
|
932
|
+
super(message);
|
|
933
|
+
this.name = "LedgerAccountsTableMoveError";
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
function quote(identifier) {
|
|
937
|
+
return `"${identifier.replace(/"/g, "\"\"")}"`;
|
|
938
|
+
}
|
|
939
|
+
function timeout(value, fallback) {
|
|
940
|
+
const milliseconds = value ?? fallback;
|
|
941
|
+
if (!Number.isInteger(milliseconds) || milliseconds < 0) throw new LedgerAccountsTableMoveError("Migration timeout must be a non-negative integer");
|
|
942
|
+
return `${milliseconds}ms`;
|
|
943
|
+
}
|
|
944
|
+
function assertPostgres(db) {
|
|
945
|
+
const withConfig = db;
|
|
946
|
+
if (detectEngine(db.url || withConfig.config?.url || "", withConfig.type || withConfig.config?.type) !== "postgres") throw new LedgerAccountsTableMoveError("The ledger accounts table move supports PostgreSQL only. For a SQLite database whose `accounts` table holds only ledger accounts, run `ALTER TABLE accounts RENAME TO ledger_accounts` before `db:migrate`; see the smrt-ledgers README.");
|
|
947
|
+
}
|
|
948
|
+
async function readLegacyShape(db) {
|
|
949
|
+
const schema = await db.getTableSchema?.(LEGACY_ACCOUNTS_TABLE);
|
|
950
|
+
if (!schema) return null;
|
|
951
|
+
const columns = new Set(Object.keys(schema.columns));
|
|
952
|
+
if (!LEGACY_LEDGER_SIGNATURE.every((column) => columns.has(column))) return null;
|
|
953
|
+
return {
|
|
954
|
+
columns,
|
|
955
|
+
hasDiscriminator: columns.has(STI_DISCRIMINATOR)
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function ledgerRowPredicate(shape) {
|
|
959
|
+
return shape.hasDiscriminator ? `(${quote(STI_DISCRIMINATOR)} IS NULL OR ${quote(STI_DISCRIMINATOR)} = '')` : "TRUE";
|
|
960
|
+
}
|
|
961
|
+
async function count(db, where) {
|
|
962
|
+
const result = await db.query(`SELECT COUNT(*) AS n FROM ${quote(LEGACY_ACCOUNTS_TABLE)} WHERE ${where}`);
|
|
963
|
+
return Number(result.rows[0].n);
|
|
964
|
+
}
|
|
965
|
+
async function classify(db, shape) {
|
|
966
|
+
const ledger = ledgerRowPredicate(shape);
|
|
967
|
+
const pending = await count(db, ledger);
|
|
968
|
+
const messagingRows = shape.hasDiscriminator ? await count(db, `NOT ${ledger}`) : 0;
|
|
969
|
+
if (shape.hasDiscriminator) {
|
|
970
|
+
const ledgerLooking = await count(db, `NOT ${ledger} AND COALESCE(${quote("number")}, '') <> ''`);
|
|
971
|
+
const markers = MESSAGING_MARKERS.filter((column) => shape.columns.has(column));
|
|
972
|
+
const messagingLooking = markers.length === 0 ? 0 : await count(db, `${ledger} AND (${markers.map((column) => `COALESCE(${quote(column)}, '') <> ''`).join(" OR ")})`);
|
|
973
|
+
if (ledgerLooking > 0 || messagingLooking > 0) throw new LedgerAccountsTableMoveError(`Refusing to move ledger accounts: ${ledgerLooking} messaging row(s) carry a ledger account number and ${messagingLooking} ledger row(s) carry a messaging provider or channel in "${LEGACY_ACCOUNTS_TABLE}". Resolve their ownership by hand, then rerun.`);
|
|
974
|
+
}
|
|
975
|
+
return {
|
|
976
|
+
pending,
|
|
977
|
+
messagingRows
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
function registeredReferenceColumns() {
|
|
981
|
+
const ledger = /* @__PURE__ */ new Set();
|
|
982
|
+
const accounts = /* @__PURE__ */ new Set();
|
|
983
|
+
const schemas = ObjectRegistry.getAllSchemasAsDefinitions();
|
|
984
|
+
for (const [tableName, schema] of Object.entries(schemas)) for (const [columnName, column] of Object.entries(schema.columns ?? {})) {
|
|
985
|
+
const target = column.foreignKey?.table;
|
|
986
|
+
if (target === "ledger_accounts") ledger.add(`${tableName}.${columnName}`);
|
|
987
|
+
else if (target === "accounts") accounts.add(`${tableName}.${columnName}`);
|
|
988
|
+
}
|
|
989
|
+
return {
|
|
990
|
+
ledger,
|
|
991
|
+
accounts
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
function classifyForeignKeys(inbound, references) {
|
|
995
|
+
const disposition = {
|
|
996
|
+
composite: [],
|
|
997
|
+
undeclared: [],
|
|
998
|
+
detach: [],
|
|
999
|
+
keep: []
|
|
1000
|
+
};
|
|
1001
|
+
for (const fk of inbound) {
|
|
1002
|
+
const key = `${fk.table}.${fk.column}`;
|
|
1003
|
+
if (fk.arity > 1) disposition.composite.push(fk);
|
|
1004
|
+
else if (references.ledger.has(key)) disposition.detach.push(fk);
|
|
1005
|
+
else if (fk.table === "accounts" || references.accounts.has(key)) disposition.keep.push(fk);
|
|
1006
|
+
else disposition.undeclared.push(fk);
|
|
1007
|
+
}
|
|
1008
|
+
return disposition;
|
|
1009
|
+
}
|
|
1010
|
+
function foreignKeyRefusal(disposition) {
|
|
1011
|
+
if (disposition.composite.length > 0) return `Composite foreign key(s) ${disposition.composite.map((fk) => `${fk.constraint} on ${fk.table} (${fk.arity} columns)`).join(", ")} reference "${LEGACY_ACCOUNTS_TABLE}"; no model can declare one, so the move cannot carry it. Nothing was moved. Drop it, or replace it with a single-column reference, then rerun.`;
|
|
1012
|
+
if (disposition.undeclared.length > 0) return `Foreign key(s) ${disposition.undeclared.map((fk) => `${fk.table}.${fk.column}`).join(", ")} reference "${LEGACY_ACCOUNTS_TABLE}" but no registered model declares them; nothing was moved. Run the move from the application whose models declare them, or retarget each to "${LEDGER_ACCOUNTS_TABLE}" (or drop it) by hand, then rerun.`;
|
|
1013
|
+
}
|
|
1014
|
+
function copySelectList(columns, targetTypes, legacyTypes) {
|
|
1015
|
+
return columns.map((column) => {
|
|
1016
|
+
const to = targetTypes[column];
|
|
1017
|
+
return sameType(legacyTypes[column], to) ? quote(column) : `CAST(CAST(${quote(column)} AS TEXT) AS ${targetType(to)})`;
|
|
1018
|
+
}).join(", ");
|
|
1019
|
+
}
|
|
1020
|
+
async function legacyForeignKeys(db) {
|
|
1021
|
+
return (await db.query(`SELECT con.conname AS constraint_name,
|
|
1022
|
+
rel.relname AS table_name,
|
|
1023
|
+
att.attname AS column_name,
|
|
1024
|
+
array_length(con.conkey, 1) AS arity
|
|
1025
|
+
FROM pg_constraint con
|
|
1026
|
+
JOIN pg_class rel ON rel.oid = con.conrelid
|
|
1027
|
+
JOIN pg_attribute att
|
|
1028
|
+
ON att.attrelid = con.conrelid AND att.attnum = con.conkey[1]
|
|
1029
|
+
WHERE con.contype = 'f'
|
|
1030
|
+
AND con.confrelid = to_regclass(?)
|
|
1031
|
+
ORDER BY rel.relname, con.conname`, quote(LEGACY_ACCOUNTS_TABLE))).rows.map((row) => ({
|
|
1032
|
+
constraint: row.constraint_name,
|
|
1033
|
+
table: row.table_name,
|
|
1034
|
+
column: row.column_name,
|
|
1035
|
+
arity: Number(row.arity)
|
|
1036
|
+
}));
|
|
1037
|
+
}
|
|
1038
|
+
async function planLedgerAccountsTableMove(db) {
|
|
1039
|
+
const shape = await readLegacyShape(db);
|
|
1040
|
+
if (!shape) return {
|
|
1041
|
+
legacyTable: false,
|
|
1042
|
+
pending: 0,
|
|
1043
|
+
messagingRows: 0
|
|
1044
|
+
};
|
|
1045
|
+
return {
|
|
1046
|
+
legacyTable: true,
|
|
1047
|
+
...await classify(db, shape)
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
async function migrateLedgerAccountsTable(db, options = {}) {
|
|
1051
|
+
assertPostgres(db);
|
|
1052
|
+
if (!db.transaction) throw new LedgerAccountsTableMoveError("The ledger accounts table move requires a transaction-capable PostgreSQL adapter");
|
|
1053
|
+
const noop = (remainingLegacyRows = 0) => ({
|
|
1054
|
+
ran: false,
|
|
1055
|
+
moved: 0,
|
|
1056
|
+
remainingLegacyRows,
|
|
1057
|
+
detachedForeignKeys: []
|
|
1058
|
+
});
|
|
1059
|
+
const shape = await readLegacyShape(db);
|
|
1060
|
+
if (!shape) return noop();
|
|
1061
|
+
const target = await db.getTableSchema?.(LEDGER_ACCOUNTS_TABLE);
|
|
1062
|
+
if (!target) throw new LedgerAccountsTableMoveError(`"${LEDGER_ACCOUNTS_TABLE}" does not exist; run db:migrate before moving ledger accounts`);
|
|
1063
|
+
const legacy = await db.getTableSchema?.(LEGACY_ACCOUNTS_TABLE);
|
|
1064
|
+
const copyColumns = Object.keys(target.columns).filter((column) => shape.columns.has(column));
|
|
1065
|
+
const references = registeredReferenceColumns();
|
|
1066
|
+
await new BackfillTracker({ db }).initialize();
|
|
1067
|
+
const backfillName = options.backfillName ?? "@happyvertical/smrt-ledgers:ledger-accounts-table:v1";
|
|
1068
|
+
return db.transaction(async (tx) => {
|
|
1069
|
+
BackfillTracker.inheritInitialization(tx, db);
|
|
1070
|
+
const transactionTracker = new BackfillTracker({ db: tx });
|
|
1071
|
+
await tx.query(`SET LOCAL lock_timeout = '${timeout(options.lockTimeout, 3e4)}'`);
|
|
1072
|
+
await tx.query(`SET LOCAL statement_timeout = '${timeout(options.statementTimeout, 6e4)}'`);
|
|
1073
|
+
await tx.query(`LOCK TABLE ${quote(LEGACY_ACCOUNTS_TABLE)}, ${quote(LEDGER_ACCOUNTS_TABLE)} IN ACCESS EXCLUSIVE MODE`);
|
|
1074
|
+
const { pending, messagingRows } = await classify(tx, shape);
|
|
1075
|
+
if (await transactionTracker.isApplied(backfillName)) {
|
|
1076
|
+
if (pending > 0) throw new LedgerAccountsTableMoveError(`The ledger accounts table move is recorded as applied but "${LEGACY_ACCOUNTS_TABLE}" still holds ${pending} ledger row(s); refusing inconsistent state`);
|
|
1077
|
+
return noop(messagingRows);
|
|
1078
|
+
}
|
|
1079
|
+
const ledger = ledgerRowPredicate(shape);
|
|
1080
|
+
const clash = await tx.query(`SELECT COUNT(*) AS n FROM ${quote(LEGACY_ACCOUNTS_TABLE)} legacy
|
|
1081
|
+
WHERE ${ledger}
|
|
1082
|
+
AND EXISTS (SELECT 1 FROM ${quote(LEDGER_ACCOUNTS_TABLE)} moved
|
|
1083
|
+
WHERE CAST(moved.id AS TEXT) = CAST(legacy.id AS TEXT))`);
|
|
1084
|
+
if (Number(clash.rows[0].n) > 0) throw new LedgerAccountsTableMoveError(`"${LEDGER_ACCOUNTS_TABLE}" already holds ids of ledger rows still in "${LEGACY_ACCOUNTS_TABLE}"; refusing to overwrite`);
|
|
1085
|
+
const disposition = classifyForeignKeys(await legacyForeignKeys(tx), references);
|
|
1086
|
+
const refusal = foreignKeyRefusal(disposition);
|
|
1087
|
+
if (refusal) throw new LedgerAccountsTableMoveError(refusal);
|
|
1088
|
+
for (const fk of disposition.keep) {
|
|
1089
|
+
const survivor = fk.table === "accounts" ? ` AND NOT ${ledger}` : "";
|
|
1090
|
+
const pointing = await tx.query(`SELECT COUNT(*) AS n FROM ${quote(fk.table)}
|
|
1091
|
+
WHERE ${quote(fk.column)} IN
|
|
1092
|
+
(SELECT id FROM ${quote(LEGACY_ACCOUNTS_TABLE)} WHERE ${ledger})${survivor}`);
|
|
1093
|
+
if (Number(pointing.rows[0].n) > 0) throw new LedgerAccountsTableMoveError(`${fk.table}.${fk.column} references ledger accounts in "${LEGACY_ACCOUNTS_TABLE}" but is not a ledger reference; nothing was moved. Resolve those rows by hand, then rerun.`);
|
|
1094
|
+
}
|
|
1095
|
+
const selectList = copySelectList(copyColumns, columnTypes(target), columnTypes(legacy));
|
|
1096
|
+
await tx.query(`INSERT INTO ${quote(LEDGER_ACCOUNTS_TABLE)} (${copyColumns.map(quote).join(", ")})
|
|
1097
|
+
SELECT ${selectList} FROM ${quote(LEGACY_ACCOUNTS_TABLE)} WHERE ${ledger}`);
|
|
1098
|
+
const detached = [];
|
|
1099
|
+
for (const foreignKey of disposition.detach) {
|
|
1100
|
+
await tx.query(`ALTER TABLE ${quote(foreignKey.table)} DROP CONSTRAINT ${quote(foreignKey.constraint)}`);
|
|
1101
|
+
detached.push(`${foreignKey.table}.${foreignKey.column}`);
|
|
1102
|
+
}
|
|
1103
|
+
await tx.query(`DELETE FROM ${quote(LEGACY_ACCOUNTS_TABLE)} WHERE ${ledger}`);
|
|
1104
|
+
await transactionTracker.recordApplied(backfillName, {
|
|
1105
|
+
description: "Moved ledger accounts from the shared accounts table to ledger_accounts (#3098).",
|
|
1106
|
+
packageName: options.packageName ?? "@happyvertical/smrt-ledgers"
|
|
1107
|
+
});
|
|
1108
|
+
return {
|
|
1109
|
+
ran: true,
|
|
1110
|
+
moved: pending,
|
|
1111
|
+
remainingLegacyRows: messagingRows,
|
|
1112
|
+
detachedForeignKeys: detached
|
|
1113
|
+
};
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
var SQL_TYPE = /^[A-Za-z][A-Za-z0-9 _]*(\(\d+(,\s*\d+)?\))?(\[\])?$/;
|
|
1117
|
+
function columnTypes(schema) {
|
|
1118
|
+
return Object.fromEntries(Object.entries(schema?.columns ?? {}).map(([name, column]) => [name, column.type]));
|
|
1119
|
+
}
|
|
1120
|
+
function sameType(from, to) {
|
|
1121
|
+
return from !== void 0 && to !== void 0 && from.trim().toLowerCase() === to.trim().toLowerCase();
|
|
1122
|
+
}
|
|
1123
|
+
function targetType(declared) {
|
|
1124
|
+
const type = declared?.trim();
|
|
1125
|
+
if (!type || !SQL_TYPE.test(type)) throw new LedgerAccountsTableMoveError(`Cannot copy into "${LEDGER_ACCOUNTS_TABLE}": unsupported live column type ${JSON.stringify(type)}`);
|
|
1126
|
+
return type;
|
|
1127
|
+
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
export { Account, AccountCollection, Journal, JournalCollection, JournalEntry, JournalEntryCollection, LEDGER_ACCOUNTS_TABLE, LEDGER_ACCOUNTS_TABLE_MOVE, LEGACY_ACCOUNTS_TABLE, LedgerAccountsTableMoveError, migrateLedgerAccountsTable, Accounts_exports as n, planLedgerAccountsTableMove, promptMessageOptions, smrtLedgersJournalSummarizePrompt, JournalEntries_exports as t };
|
|
1044
1130
|
|
|
1045
1131
|
//# sourceMappingURL=index.js.map
|