@happyvertical/smrt-expenses 0.55.24 → 0.56.1
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 +36 -5
- package/README.md +18 -4
- package/dist/actions/expense-actions.d.ts +77 -0
- package/dist/actions/expense-actions.d.ts.map +1 -0
- package/dist/actions/principal.d.ts +54 -0
- package/dist/actions/principal.d.ts.map +1 -0
- package/dist/chunks/{Expense-CY5jw_80.js → Expense-7afLcUTn.js} +12 -7
- package/dist/chunks/Expense-7afLcUTn.js.map +1 -0
- package/dist/chunks/ExpenseReceiptCollection-y1SlmnBS.js +304 -0
- package/dist/chunks/ExpenseReceiptCollection-y1SlmnBS.js.map +1 -0
- package/dist/chunks/expense-actions-Ce5CBaBE.js +132 -0
- package/dist/chunks/expense-actions-Ce5CBaBE.js.map +1 -0
- package/dist/chunks/principal-_1CdcvvW.js +107 -0
- package/dist/chunks/principal-_1CdcvvW.js.map +1 -0
- package/dist/collections/ExpenseCollection.d.ts +55 -3
- package/dist/collections/ExpenseCollection.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +180 -312
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +273 -8
- package/dist/models/Expense.d.ts +9 -5
- package/dist/models/Expense.d.ts.map +1 -1
- package/dist/recipes.d.ts +118 -0
- package/dist/recipes.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +277 -10
- package/package.json +9 -8
- package/dist/chunks/Expense-CY5jw_80.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/__smrt-register__.ts","../src/collections/ExpenseCollection.ts","../src/models/ExpenseReceipt.ts","../src/collections/ExpenseReceiptCollection.ts"],"sourcesContent":["// Generated by @happyvertical/smrt-core smrtPlugin at library build time.\n// The package manifest is inlined so self-registration cannot miss when a\n// downstream bundler relocates this module away from dist/manifest.json\n// (https://github.com/happyvertical/smrt/issues/1506,\n// https://github.com/happyvertical/smrt/issues/1507).\nimport { ObjectRegistry } from '@happyvertical/smrt-core';\n\nObjectRegistry.registerPackageManifest(JSON.parse(\"{\\\"version\\\":\\\"1.0.0\\\",\\\"timestamp\\\":0,\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"packageVersion\\\":\\\"0.55.24\\\",\\\"objects\\\":{\\\"@happyvertical/smrt-expenses:ExpenseCollection\\\":{\\\"name\\\":\\\"expensecollection\\\",\\\"className\\\":\\\"ExpenseCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseCollection\\\",\\\"collection\\\":\\\"expenses\\\",\\\"description\\\":\\\"Collection for Expense. Reads go through the normal tenant interceptors, so inside withTenant() every method here sees only that tenant's expenses.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/collections/ExpenseCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{},\\\"methods\\\":{\\\"forCostObject\\\":{\\\"name\\\":\\\"forCostObject\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"costObjectType\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"costObjectId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<Expense[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"totalsByCurrency\\\":{\\\"name\\\":\\\"totalsByCurrency\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"ExpenseTotalsOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<CurrencyTotals>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"commitmentPosition\\\":{\\\"name\\\":\\\"commitmentPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"commitmentId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"string\\\"]}],\\\"returnType\\\":\\\"Promise<CommitmentPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"tableName\\\":\\\"expenses\\\"},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"Expense\\\",\\\"exportName\\\":\\\"ExpenseCollection\\\",\\\"collectionExportName\\\":\\\"ExpenseCollectionCollection\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expenses\\\\\\\" (\\\\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 \\\\\\\"cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"category\\\\\\\" TEXT,\\\\n \\\\\\\"description\\\\\\\" TEXT,\\\\n \\\\\\\"amount\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT,\\\\n \\\\\\\"financial_breakdown\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"incurred_on\\\\\\\" TEXT,\\\\n \\\\\\\"recorded_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"recorded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"paid_by\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"vendor_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_line_id\\\\\\\" UUID,\\\\n \\\\\\\"review_status\\\\\\\" TEXT,\\\\n \\\\\\\"reviewed_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"reviewed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"review_note\\\\\\\" TEXT,\\\\n \\\\\\\"duplicate_of_id\\\\\\\" UUID,\\\\n \\\\\\\"reimbursable\\\\\\\" BOOLEAN,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT\\\\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},\\\"cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"category\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"description\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"financial_breakdown\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_name\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"refund_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"incurred_on\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"vendor_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_line_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_note\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"duplicate_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"SET NULL\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"reimbursable\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursement_reference\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expenses_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expenses_cost_object_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"cost_object_type\\\",\\\"cost_object_id\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_commitment_review_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"commitment_id\\\",\\\"review_status\\\"]},{\\\"name\\\":\\\"expenses_review_status_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"review_status\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expenses_refund_of_id_idx\\\",\\\"columns\\\":[\\\"refund_of_id\\\"]},{\\\"name\\\":\\\"expenses_recorded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"recorded_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_paid_by_profile_id_idx\\\",\\\"columns\\\":[\\\"paid_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_vendor_id_idx\\\",\\\"columns\\\":[\\\"vendor_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_id_idx\\\",\\\"columns\\\":[\\\"commitment_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_line_id_idx\\\",\\\"columns\\\":[\\\"commitment_line_id\\\"]},{\\\"name\\\":\\\"expenses_reviewed_by_profile_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_duplicate_of_id_idx\\\",\\\"columns\\\":[\\\"duplicate_of_id\\\"]}],\\\"version\\\":\\\"287668fa\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:ExpenseReceiptCollection\\\":{\\\"name\\\":\\\"expensereceiptcollection\\\",\\\"className\\\":\\\"ExpenseReceiptCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseReceiptCollection\\\",\\\"collection\\\":\\\"expensereceipts\\\",\\\"description\\\":\\\"Junction collection over expense_receipts (left: expense, right: asset). Reads go through the normal tenant interceptors.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/collections/ExpenseReceiptCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{},\\\"methods\\\":{\\\"byRight\\\":{\\\"name\\\":\\\"byRight\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"rightId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"opts\\\",\\\"type\\\":\\\"JunctionFilterOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<TItem[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"byLeft\\\":{\\\"name\\\":\\\"byLeft\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"leftId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"opts\\\",\\\"type\\\":\\\"JunctionFilterOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<TItem[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"attach\\\":{\\\"name\\\":\\\"attach\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"_expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_assetId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_opts\\\",\\\"type\\\":\\\"JunctionAttachOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<ExpenseReceipt>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"detach\\\":{\\\"name\\\":\\\"detach\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"leftId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"rightId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"opts\\\",\\\"type\\\":\\\"JunctionFilterOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"setLinks\\\":{\\\"name\\\":\\\"setLinks\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"_expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_assetIds\\\",\\\"type\\\":\\\"string[]\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_opts\\\",\\\"type\\\":\\\"JunctionAttachOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"attachReceipt\\\":{\\\"name\\\":\\\"attachReceipt\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"AttachReceiptInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseReceipt>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"receiptsFor\\\":{\\\"name\\\":\\\"receiptsFor\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseReceipt[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"findDuplicateReceipts\\\":{\\\"name\\\":\\\"findDuplicateReceipts\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"FindDuplicateReceiptsOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<DuplicateReceiptGroup[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"tableName\\\":\\\"expense_receipts\\\"},\\\"extends\\\":\\\"SmrtJunction\\\",\\\"extendsTypeArg\\\":\\\"ExpenseReceipt\\\",\\\"exportName\\\":\\\"ExpenseReceiptCollection\\\",\\\"collectionExportName\\\":\\\"ExpenseReceiptCollectionCollection\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_receipts\\\\\\\" (\\\\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 \\\\\\\"expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"asset_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"uploaded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"filename\\\\\\\" TEXT,\\\\n \\\\\\\"mime_type\\\\\\\" TEXT,\\\\n \\\\\\\"byte_count\\\\\\\" INTEGER,\\\\n \\\\\\\"content_sha256\\\\\\\" TEXT NOT NULL\\\\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},\\\"expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"CASCADE\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"asset_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"uploaded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"filename\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"mime_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"byte_count\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"content_sha256\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_receipts_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expense_receipts_expense_sha256_key\\\",\\\"columns\\\":[\\\"expense_id\\\",\\\"content_sha256\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_receipts_tenant_sha256_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"content_sha256\\\"]},{\\\"name\\\":\\\"expense_receipts_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_receipts_asset_id_idx\\\",\\\"columns\\\":[\\\"asset_id\\\"]},{\\\"name\\\":\\\"expense_receipts_uploaded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"uploaded_by_profile_id\\\"]}],\\\"version\\\":\\\"5aa77571\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:Expense\\\":{\\\"name\\\":\\\"expense\\\",\\\"className\\\":\\\"Expense\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:Expense\\\",\\\"collection\\\":\\\"expenses\\\",\\\"description\\\":\\\"A cost someone incurred.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/models/Expense.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"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}}},\\\"costObjectType\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"costObjectId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"category\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"description\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"amount\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"currency\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"financialBreakdown\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"paidByName\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"refundOfId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"incurredOn\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"recordedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false},\\\"recordedByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"PROFILE\\\"},\\\"paidBy\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{},\\\"enum\\\":[\\\"company\\\",\\\"person\\\",\\\"third-party\\\"]},\\\"paidByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"PROFILE\\\"},\\\"vendorId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:Vendor\\\"},\\\"commitmentId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:Contract\\\"},\\\"commitmentLineId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:ContractLineItem\\\"},\\\"reviewStatus\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"enum\\\":[\\\"unreviewed\\\",\\\"reviewed\\\",\\\"rejected\\\"],\\\"readonly\\\":true},\\\"reviewedByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"PROFILE\\\"},\\\"reviewedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"reviewNote\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"duplicateOfId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"onDelete\\\":\\\"SET NULL\\\"}},\\\"reimbursable\\\":{\\\"type\\\":\\\"boolean\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"reimbursedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false},\\\"reimbursementReference\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}}},\\\"methods\\\":{\\\"getFinancialBreakdown\\\":{\\\"name\\\":\\\"getFinancialBreakdown\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"ExpenseFinancialBreakdown | null\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"setFinancialBreakdown\\\":{\\\"name\\\":\\\"setFinancialBreakdown\\\",\\\"async\\\":false,\\\"parameters\\\":[{\\\"name\\\":\\\"value\\\",\\\"type\\\":\\\"ExpenseFinancialBreakdown | null\\\",\\\"optional\\\":false,\\\"unionBranches\\\":[{\\\"type\\\":\\\"ExpenseFinancialBreakdown\\\"},{\\\"type\\\":\\\"null\\\"}]}],\\\"returnType\\\":\\\"void\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getCostBasis\\\":{\\\"name\\\":\\\"getCostBasis\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"ExpenseCostBasis | null\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"isReimbursed\\\":{\\\"name\\\":\\\"isReimbursed\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"boolean\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"isCountable\\\":{\\\"name\\\":\\\"isCountable\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"boolean\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"review\\\":{\\\"name\\\":\\\"review\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"ReviewExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"reject\\\":{\\\"name\\\":\\\"reject\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RejectExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"markDuplicate\\\":{\\\"name\\\":\\\"markDuplicate\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"MarkDuplicateExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"reopen\\\":{\\\"name\\\":\\\"reopen\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"ReopenExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"markReimbursed\\\":{\\\"name\\\":\\\"markReimbursed\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"MarkReimbursedInput\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getCostObject\\\":{\\\"name\\\":\\\"getCostObject\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<T | null>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"save\\\":{\\\"name\\\":\\\"save\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"expenses_cost_object_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"costObjectType\\\",\\\"costObjectId\\\",\\\"incurredOn\\\"]},{\\\"name\\\":\\\"expenses_commitment_review_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"commitmentId\\\",\\\"reviewStatus\\\"]},{\\\"name\\\":\\\"expenses_review_status_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"reviewStatus\\\",\\\"incurredOn\\\"]}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"optional\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"Expense\\\",\\\"collectionExportName\\\":\\\"ExpenseCollection\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expenses\\\\\\\" (\\\\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 \\\\\\\"cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"category\\\\\\\" TEXT,\\\\n \\\\\\\"description\\\\\\\" TEXT,\\\\n \\\\\\\"amount\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT,\\\\n \\\\\\\"financial_breakdown\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"incurred_on\\\\\\\" TEXT,\\\\n \\\\\\\"recorded_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"recorded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"paid_by\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"vendor_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_line_id\\\\\\\" UUID,\\\\n \\\\\\\"review_status\\\\\\\" TEXT,\\\\n \\\\\\\"reviewed_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"reviewed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"review_note\\\\\\\" TEXT,\\\\n \\\\\\\"duplicate_of_id\\\\\\\" UUID,\\\\n \\\\\\\"reimbursable\\\\\\\" BOOLEAN,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT\\\\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},\\\"cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"category\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"description\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"financial_breakdown\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_name\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"refund_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"incurred_on\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"vendor_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_line_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_note\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"duplicate_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"SET NULL\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"reimbursable\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursement_reference\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expenses_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expenses_cost_object_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"cost_object_type\\\",\\\"cost_object_id\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_commitment_review_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"commitment_id\\\",\\\"review_status\\\"]},{\\\"name\\\":\\\"expenses_review_status_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"review_status\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expenses_refund_of_id_idx\\\",\\\"columns\\\":[\\\"refund_of_id\\\"]},{\\\"name\\\":\\\"expenses_recorded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"recorded_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_paid_by_profile_id_idx\\\",\\\"columns\\\":[\\\"paid_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_vendor_id_idx\\\",\\\"columns\\\":[\\\"vendor_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_id_idx\\\",\\\"columns\\\":[\\\"commitment_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_line_id_idx\\\",\\\"columns\\\":[\\\"commitment_line_id\\\"]},{\\\"name\\\":\\\"expenses_reviewed_by_profile_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_duplicate_of_id_idx\\\",\\\"columns\\\":[\\\"duplicate_of_id\\\"]}],\\\"version\\\":\\\"287668fa\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\":{\\\"name\\\":\\\"expensereceipt\\\",\\\"className\\\":\\\"ExpenseReceipt\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\",\\\"collection\\\":\\\"expensereceipts\\\",\\\"description\\\":\\\"A receipt file attached to an expense.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseReceipt.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"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}}},\\\"expenseId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":true,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"required\\\":true,\\\"onDelete\\\":\\\"CASCADE\\\"}},\\\"assetId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":true,\\\"related\\\":\\\"@happyvertical/smrt-assets:Asset\\\"},\\\"uploadedByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-profiles:Profile\\\"},\\\"filename\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"mimeType\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"byteCount\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"contentSha256\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":true,\\\"_meta\\\":{\\\"required\\\":true}}},\\\"methods\\\":{\\\"save\\\":{\\\"name\\\":\\\"save\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"expense_receipts_expense_sha256_key\\\",\\\"columns\\\":[\\\"expenseId\\\",\\\"contentSha256\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_receipts_tenant_sha256_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"contentSha256\\\"]}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"optional\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ExpenseReceipt\\\",\\\"collectionExportName\\\":\\\"ExpenseReceiptCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"expenseId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"},{\\\"field\\\":\\\"assetId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"crossPackageRef\\\"},{\\\"field\\\":\\\"contentSha256\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_receipts\\\\\\\" (\\\\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 \\\\\\\"expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"asset_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"uploaded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"filename\\\\\\\" TEXT,\\\\n \\\\\\\"mime_type\\\\\\\" TEXT,\\\\n \\\\\\\"byte_count\\\\\\\" INTEGER,\\\\n \\\\\\\"content_sha256\\\\\\\" TEXT NOT NULL\\\\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},\\\"expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"CASCADE\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"asset_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"uploaded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"filename\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"mime_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"byte_count\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"content_sha256\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_receipts_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expense_receipts_expense_sha256_key\\\",\\\"columns\\\":[\\\"expense_id\\\",\\\"content_sha256\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_receipts_tenant_sha256_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"content_sha256\\\"]},{\\\"name\\\":\\\"expense_receipts_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_receipts_asset_id_idx\\\",\\\"columns\\\":[\\\"asset_id\\\"]},{\\\"name\\\":\\\"expense_receipts_uploaded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"uploaded_by_profile_id\\\"]}],\\\"version\\\":\\\"5aa77571\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"}},\\\"moduleType\\\":\\\"smrt\\\",\\\"smrtDependencies\\\":[\\\"@happyvertical/smrt-assets\\\",\\\"@happyvertical/smrt-commerce\\\",\\\"@happyvertical/smrt-core\\\",\\\"@happyvertical/smrt-tenancy\\\"],\\\"browser\\\":{\\\"status\\\":\\\"server-only\\\",\\\"issues\\\":[\\\"#3615\\\",\\\"#3624\\\",\\\"#3626\\\",\\\"#3627\\\"],\\\"reason\\\":\\\"node:crypto\\\",\\\"via\\\":[\\\"@happyvertical/smrt-commerce\\\",\\\"@happyvertical/smrt-jobs\\\",\\\"@happyvertical/smrt-ledgers\\\",\\\"@happyvertical/smrt-subscriptions\\\",\\\"@happyvertical/smrt-tenancy\\\"]},\\\"stampsConstructors\\\":true}\"));\n","/**\n * ExpenseCollection — queries, per-currency totals, and commitment drawdown.\n *\n * @packageDocumentation\n */\n\nimport {\n ContractCollection,\n ContractLineItemCollection,\n} from '@happyvertical/smrt-commerce';\nimport { SmrtCollection, smrt } from '@happyvertical/smrt-core';\nimport { Expense } from '../models/Expense.js';\nimport {\n type CommitmentPosition,\n type CurrencyTotals,\n ExpenseError,\n type ExpenseReviewStatus,\n type ExpenseTotalsOptions,\n} from '../types.js';\n\n/** Plain projection read for sums: never hydrates objects. */\ninterface AmountRow {\n id: string;\n amount: number | string;\n currency: string;\n reviewStatus: ExpenseReviewStatus;\n duplicateOfId: string | null;\n}\n\nconst AMOUNT_FIELDS = [\n 'id',\n 'amount',\n 'currency',\n 'reviewStatus',\n 'duplicateOfId',\n] as const;\n\nfunction toMinorUnits(value: number | string): number {\n const amount = typeof value === 'number' ? value : Number(value);\n if (!Number.isSafeInteger(amount)) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n `Stored expense amount ${String(value)} is not a safe integer.`,\n );\n }\n return amount;\n}\n\nfunction addTo(totals: CurrencyTotals, currency: string, amount: number) {\n const entry = totals[currency] ?? { amount: 0, count: 0 };\n const sum = entry.amount + amount;\n if (!Number.isSafeInteger(sum)) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n `Total for ${currency} exceeds the safe integer range.`,\n );\n }\n totals[currency] = { amount: sum, count: entry.count + 1 };\n}\n\n/**\n * Collection for {@link Expense}. Reads go through the normal tenant\n * interceptors, so inside `withTenant()` every method here sees only that\n * tenant's expenses.\n *\n * Collection classes are registered too, so this one carries its own closed\n * surface; without it every public method here would become an MCP tool.\n */\n@smrt({ api: { include: [] }, mcp: { include: [] }, cli: false })\nexport class ExpenseCollection extends SmrtCollection<Expense> { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n static readonly _itemClass = Expense;\n\n /**\n * Expenses charged to one cost object, oldest incurred first.\n *\n * @param costObjectType - Qualified class name of the cost object.\n * @param costObjectId - Id of the cost object.\n */\n async forCostObject(\n costObjectType: string,\n costObjectId: string,\n ): Promise<Expense[]> {\n return this.list({\n where: { costObjectType, costObjectId },\n orderBy: ['incurred_on ASC', 'created_at ASC'],\n });\n }\n\n /**\n * Sum expenses per currency. Amounts in different currencies are never\n * added together: the result is keyed by ISO 4217 code.\n *\n * By default only `reviewed` expenses count; a duplicate never counts.\n *\n * @example\n * ```typescript\n * const totals = await expenses.totalsByCurrency({\n * where: { costObjectType: JOB, costObjectId: job.id },\n * });\n * // { USD: { amount: 125000, count: 3 }, CAD: { amount: 4000, count: 1 } }\n * ```\n */\n async totalsByCurrency(\n options: ExpenseTotalsOptions = {},\n ): Promise<CurrencyTotals> {\n const statuses = options.reviewStatuses ?? ['reviewed'];\n if (statuses.length === 0) return {};\n const rows = (await this.list({\n where: {\n ...(options.where ?? {}),\n reviewStatus: [...statuses],\n duplicateOfId: null,\n },\n select: [...AMOUNT_FIELDS],\n })) as unknown as AmountRow[];\n\n const totals: CurrencyTotals = {};\n const seen = new Set<string>();\n for (const row of rows) {\n if (seen.has(row.id)) continue;\n seen.add(row.id);\n addTo(totals, row.currency, toMinorUnits(row.amount));\n }\n return totals;\n }\n\n /**\n * What remains open on a commitment — a commerce `Contract`, normally a\n * `PurchaseOrder` — or on one of its lines.\n *\n * `committed` is the contract's `totalAmount` (or the line's `amount`);\n * `drawn` sums the matched actuals that are `reviewed` and not marked\n * duplicate, in the commitment's currency, each expense once. Unreviewed,\n * rejected and duplicate matches are counted in `excluded` and never\n * drawn. A 4,600 commitment with 1,000 reviewed leaves 3,600 open.\n *\n * @param commitmentId - The commitment's contract id.\n * @param options.lineId - Restrict to one line of the commitment.\n * @throws {ExpenseError} `EXPENSE_COMMITMENT_MISMATCH` when the commitment\n * (or line) is not visible in the current tenant.\n */\n async commitmentPosition(\n commitmentId: string,\n options: { lineId?: string } = {},\n ): Promise<CommitmentPosition> {\n const contracts = await ContractCollection.create({ db: this.db });\n const commitment = await contracts.get({ id: commitmentId });\n if (!commitment) {\n throw new ExpenseError(\n 'EXPENSE_COMMITMENT_MISMATCH',\n `Commitment ${commitmentId} was not found.`,\n );\n }\n let committed = toMinorUnits(commitment.totalAmount);\n if (options.lineId) {\n const lines = await ContractLineItemCollection.create({ db: this.db });\n const line = await lines.get({ id: options.lineId });\n if (!line || line.contractId !== commitmentId) {\n throw new ExpenseError(\n 'EXPENSE_COMMITMENT_MISMATCH',\n `Line ${options.lineId} is not a line of commitment ${commitmentId}.`,\n );\n }\n committed = toMinorUnits(line.amount);\n }\n const currency = String(commitment.currency).toUpperCase();\n\n const rows = (await this.list({\n where: {\n commitmentId,\n ...(options.lineId ? { commitmentLineId: options.lineId } : {}),\n },\n select: [...AMOUNT_FIELDS],\n })) as unknown as AmountRow[];\n\n const position: CommitmentPosition = {\n commitmentId,\n commitmentLineId: options.lineId ?? null,\n currency,\n committed,\n drawn: 0,\n open: 0,\n overrun: 0,\n countedExpenseIds: [],\n excluded: { unreviewed: 0, rejected: 0, duplicate: 0 },\n otherCurrencies: {},\n };\n const seen = new Set<string>();\n for (const row of rows) {\n if (seen.has(row.id)) continue;\n seen.add(row.id);\n if (row.duplicateOfId) {\n position.excluded.duplicate += 1;\n } else if (row.reviewStatus === 'unreviewed') {\n position.excluded.unreviewed += 1;\n } else if (row.reviewStatus === 'rejected') {\n position.excluded.rejected += 1;\n } else if (row.currency !== currency) {\n addTo(position.otherCurrencies, row.currency, toMinorUnits(row.amount));\n } else {\n const drawn = position.drawn + toMinorUnits(row.amount);\n if (!Number.isSafeInteger(drawn)) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n `Drawdown on commitment ${commitmentId} exceeds the safe range.`,\n );\n }\n position.drawn = drawn;\n position.countedExpenseIds.push(row.id);\n }\n }\n position.countedExpenseIds.sort();\n position.open = Math.max(committed - position.drawn, 0);\n position.overrun = Math.max(position.drawn - committed, 0);\n return position;\n }\n}\n","/**\n * ExpenseReceipt — the expense-owned join between an {@link Expense} and the\n * smrt-assets `Asset` that proves it.\n *\n * @packageDocumentation\n */\n\nimport { AssetCollection } from '@happyvertical/smrt-assets';\nimport {\n classifyDatabaseError,\n crossPackageRef,\n field,\n foreignKey,\n isUniqueViolationError,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport {\n DuplicateReceiptError,\n ExpenseError,\n type ExpenseReceiptOptions,\n} from '../types.js';\nimport {\n assertMinorUnits,\n effectiveTenant,\n identityConflict,\n normalizeSha256,\n normalizeTenantId,\n pinNaturalKey,\n} from '../validation.js';\nimport { Expense } from './Expense.js';\n\n/**\n * The unique index that refuses a second copy of a file on one expense. Kept\n * in step with the literal in the `@smrt()` indexes below (the scanner reads\n * that literal); the PostgreSQL schema test asserts the name.\n */\nconst RECEIPT_FILE_KEY = 'expense_receipts_expense_sha256_key';\n\n/** The columns of {@link RECEIPT_FILE_KEY}; no other unique key uses them. */\nconst RECEIPT_FILE_COLUMNS = new Set(['expense_id', 'content_sha256']);\n\n/**\n * The columns a unique violation reports. Core's typed write error carries\n * them in `details.fieldName` (recovered from PostgreSQL's\n * `Key (expense_id, content_sha256)=…` detail, or SQLite's column list) but\n * not the driver error itself, so this is where the violated key is named.\n */\nfunction violatedColumns(error: unknown): string[] {\n const details = (error as { details?: { fieldName?: unknown } } | null)\n ?.details;\n const fieldName =\n typeof details?.fieldName === 'string' ? details.fieldName : '';\n return fieldName\n .split(',')\n .map((column) => column.trim())\n .filter(Boolean);\n}\n\n/**\n * Columns a receipt keeps for life: it is evidence, not a draft. The tenant\n * is among them because it is derived from the expense on insert; letting a\n * later save (e.g. one without tenant context) change it would split the\n * receipt from its expense's tenant.\n */\nconst IMMUTABLE = [\n ['tenantId', 'tenant_id'],\n ['expenseId', 'expense_id'],\n ['assetId', 'asset_id'],\n ['contentSha256', 'content_sha256'],\n] as const;\n\n/**\n * A receipt file attached to an expense.\n *\n * Asset ownership uses a noun-specific join (`expense_receipts`), not the\n * generic `AssetAssociation`. The file's SHA-256 is stored so:\n *\n * - the same file attached twice to one expense is refused — a unique index\n * on `(expense_id, content_sha256)` plus a pre-insert check that raises\n * {@link DuplicateReceiptError}. The index leaves `tenant_id` out on\n * purpose: an expense belongs to exactly one tenant, so the key is already\n * tenant-scoped, and a NULL tenant would otherwise make every global row\n * distinct and the index unenforced;\n * - the same file on two different expenses is allowed, and surfaced for a\n * person to look at by `ExpenseReceiptCollection.findDuplicateReceipts()`.\n *\n * Attaching a receipt never changes the expense's review state. The receipt\n * takes its tenant from the expense, and its asset must be visible in that\n * tenant. The generated surface is closed, like {@link Expense}'s.\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'expense_receipts',\n api: { include: [] },\n mcp: { include: [] },\n cli: false,\n indexes: [\n {\n name: 'expense_receipts_expense_sha256_key',\n columns: ['expenseId', 'contentSha256'],\n unique: true,\n },\n {\n name: 'expense_receipts_tenant_sha256_idx',\n columns: ['tenantId', 'contentSha256'],\n },\n ],\n})\nexport class ExpenseReceipt extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n /** Owning tenant; always the expense's tenant. */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /** The expense this receipt proves. Deleting the expense removes the link. */\n @foreignKey(Expense, { required: true, onDelete: 'CASCADE' })\n expenseId: string = '';\n\n /** The smrt-assets `Asset` holding the file. */\n @crossPackageRef('@happyvertical/smrt-assets:Asset', { required: true })\n assetId: string = '';\n\n /** Profile that uploaded the file. */\n @crossPackageRef('@happyvertical/smrt-profiles:Profile')\n uploadedByProfileId: string | null = null;\n\n /** Original filename as uploaded. */\n @field({ type: 'text' })\n filename: string = '';\n\n /** MIME type of the file. */\n @field({ type: 'text' })\n mimeType: string = '';\n\n /** Size of the file in bytes. */\n @field({ type: 'integer' })\n byteCount: number = 0;\n\n /** Lowercase hex SHA-256 of the file's bytes. */\n @field({ type: 'text', required: true })\n contentSha256: string = '';\n\n constructor(options: ExpenseReceiptOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.expenseId !== undefined) this.expenseId = options.expenseId;\n if (options.assetId !== undefined) this.assetId = options.assetId;\n if (options.uploadedByProfileId !== undefined)\n this.uploadedByProfileId = options.uploadedByProfileId;\n if (options.filename !== undefined) this.filename = options.filename;\n if (options.mimeType !== undefined) this.mimeType = options.mimeType;\n if (options.byteCount !== undefined) this.byteCount = options.byteCount;\n if (options.contentSha256 !== undefined)\n this.contentSha256 = options.contentSha256;\n }\n\n /**\n * Validate the link, refuse a second copy of the same file on the same\n * expense, then persist. Never touches the expense.\n *\n * @throws {DuplicateReceiptError} when the expense already has this file.\n * @throws {ExpenseError} `EXPENSE_RECEIPT_INVALID` for a bad hash, a\n * missing or foreign-tenant expense or asset, or a change to an\n * immutable column.\n */\n override async save(): Promise<this> {\n const label = this.id || '<new>';\n this.tenantId = normalizeTenantId(this.tenantId);\n this.contentSha256 = normalizeSha256(\n 'ExpenseReceipt',\n label,\n this.contentSha256,\n );\n assertMinorUnits(\n 'ExpenseReceipt',\n label,\n 'byteCount',\n this.byteCount,\n 'EXPENSE_RECEIPT_INVALID',\n );\n if (!this.expenseId || !this.assetId) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: expenseId and assetId are required.`,\n );\n }\n\n const persisted = this.id\n ? (((await this.db.get(this.tableName, { id: this.id })) as\n | Record<string, unknown>\n | undefined\n | null) ?? null)\n : null;\n // The checks below are against `persisted`; pin the write to that row.\n const inserting = await pinNaturalKey('ExpenseReceipt', this, persisted);\n if (persisted) {\n const self = this as unknown as Record<string, unknown>;\n for (const [fieldName, column] of IMMUTABLE) {\n // The tenant is compared as it will be written: an empty tenantId\n // saved inside a tenant context is filled in by the interceptor.\n const value =\n fieldName === 'tenantId'\n ? effectiveTenant(this.tenantId)\n : self[fieldName];\n if (String(persisted[column] ?? '') !== String(value ?? '')) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${this.id}: ${fieldName} cannot change; attach ` +\n 'a new receipt instead.',\n );\n }\n }\n } else {\n await this.assertLinkTargets(label);\n await this.assertNotDuplicate();\n }\n\n try {\n return await super.save();\n } catch (error) {\n if (inserting && isUniqueViolationError(error)) {\n throw await this.classifyInsertConflict(error);\n }\n throw error;\n }\n }\n\n /**\n * A refused INSERT is either the same file racing onto the same expense,\n * or a natural-key collision with another receipt.\n *\n * Classified from the error first, by the violated key's name or columns\n * (no other unique key on this table uses `expense_id` or\n * `content_sha256`). That matters inside a caller's transaction,\n * which the violation has already aborted on PostgreSQL, so nothing could\n * be re-read there. Only an adapter that reports neither falls back to a\n * re-read; if that re-read fails too, the original error is kept rather\n * than guessed at.\n */\n private async classifyInsertConflict(error: unknown): Promise<unknown> {\n const info = classifyDatabaseError(error);\n const columns = violatedColumns(error);\n if (\n info.constraint === RECEIPT_FILE_KEY ||\n info.driverMessages.some((text) => text.includes(RECEIPT_FILE_KEY)) ||\n columns.some((column) => RECEIPT_FILE_COLUMNS.has(column))\n ) {\n return new DuplicateReceiptError(this.expenseId, this.contentSha256, {\n cause: error,\n });\n }\n if (info.constraint || columns.length > 0) {\n // Another named key: the natural key or the primary key.\n return identityConflict('ExpenseReceipt', this, error);\n }\n try {\n await this.assertNotDuplicate();\n } catch (duplicate) {\n if (duplicate instanceof DuplicateReceiptError) {\n return new DuplicateReceiptError(this.expenseId, this.contentSha256, {\n cause: error,\n });\n }\n return error;\n }\n return identityConflict('ExpenseReceipt', this, error);\n }\n\n private async assertLinkTargets(label: string): Promise<void> {\n const { ExpenseCollection } = await import(\n '../collections/ExpenseCollection.js'\n );\n const expenses = await ExpenseCollection.create({ db: this.db });\n const expense = await expenses.get({ id: this.expenseId });\n if (!expense) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: expense ${this.expenseId} was not found.`,\n );\n }\n if (this.tenantId === null || this.tenantId === undefined) {\n this.tenantId = expense.tenantId ?? null;\n }\n if ((this.tenantId ?? null) !== (expense.tenantId ?? null)) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: a receipt belongs to its expense's tenant.`,\n );\n }\n\n const assets = await AssetCollection.create({ db: this.db });\n const asset = await assets.get({ id: this.assetId });\n const assetTenant = asset?.tenantId ?? null;\n if (!asset || (assetTenant !== null && assetTenant !== this.tenantId)) {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n `ExpenseReceipt ${label}: asset ${this.assetId} was not found in ` +\n \"the expense's tenant.\",\n );\n }\n if (!this.filename) this.filename = asset.name ?? '';\n if (!this.mimeType) this.mimeType = asset.mimeType ?? '';\n }\n\n private async assertNotDuplicate(): Promise<void> {\n const { ExpenseReceiptCollection } = await import(\n '../collections/ExpenseReceiptCollection.js'\n );\n const receipts = await ExpenseReceiptCollection.create({ db: this.db });\n const existing = await receipts.list({\n where: {\n expenseId: this.expenseId,\n contentSha256: this.contentSha256,\n },\n limit: 1,\n });\n if (existing.length > 0) {\n throw new DuplicateReceiptError(this.expenseId, this.contentSha256);\n }\n }\n}\n","/**\n * ExpenseReceiptCollection — attach receipts and find files shared between\n * expenses.\n *\n * @packageDocumentation\n */\n\nimport {\n type JunctionAttachOptions,\n SmrtJunction,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { ExpenseReceipt } from '../models/ExpenseReceipt.js';\nimport {\n type AttachReceiptInput,\n type DuplicateReceiptGroup,\n ExpenseError,\n type FindDuplicateReceiptsOptions,\n} from '../types.js';\n\nconst DEFAULT_DUPLICATE_LIMIT = 100;\nconst MAX_DUPLICATE_LIMIT = 1000;\n\n/**\n * Junction collection over `expense_receipts` (left: expense, right: asset).\n * Reads go through the normal tenant interceptors.\n *\n * Writes: {@link attachReceipt} adds a receipt; the inherited `detach()`\n * removes one (an explicit act; the asset itself is kept). The inherited\n * `attach()` and `setLinks()` are refused because they cannot carry the\n * content hash and `setLinks()` deletes before it writes.\n *\n * Collection classes are registered too, so this one carries its own closed\n * surface; without it every public method here would become an MCP tool.\n */\n@smrt({ api: { include: [] }, mcp: { include: [] }, cli: false })\nexport class ExpenseReceiptCollection extends SmrtJunction<ExpenseReceipt> { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n static readonly _itemClass = ExpenseReceipt;\n protected leftField = 'expenseId';\n protected rightField = 'assetId';\n protected override sortField: string | null = 'createdAt';\n protected override positionField: string | null = null;\n\n /**\n * Attach a receipt file to an expense.\n *\n * Does not change the expense in any way — in particular not its review\n * state.\n *\n * @throws {DuplicateReceiptError} when this expense already carries a file\n * with the same SHA-256.\n */\n async attachReceipt(input: AttachReceiptInput): Promise<ExpenseReceipt> {\n const receipt = await this.create({\n expenseId: input.expenseId,\n assetId: input.assetId,\n contentSha256: input.contentSha256,\n uploadedByProfileId: input.uploadedByProfileId ?? null,\n filename: input.filename ?? '',\n mimeType: input.mimeType ?? '',\n byteCount: input.byteCount ?? 0,\n });\n await receipt.save();\n return receipt;\n }\n\n /**\n * Refused: a receipt is evidence and needs its content hash, which a\n * generic junction attach does not carry. Use {@link attachReceipt}.\n *\n * @throws {ExpenseError} `EXPENSE_RECEIPT_INVALID`, always.\n */\n override async attach(\n _expenseId: string,\n _assetId: string,\n _opts: JunctionAttachOptions = {},\n ): Promise<ExpenseReceipt> {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n 'ExpenseReceiptCollection.attach() is not supported: use ' +\n 'attachReceipt(), which records and checks the file hash.',\n );\n }\n\n /**\n * Refused before anything is deleted. The inherited replace-all deletes\n * every receipt of the expense and re-attaches without hashes, which would\n * lose the evidence. Attach with {@link attachReceipt}; remove a link with\n * `detach()`.\n *\n * @throws {ExpenseError} `EXPENSE_RECEIPT_INVALID`, always.\n */\n override async setLinks(\n _expenseId: string,\n _assetIds: string[],\n _opts: JunctionAttachOptions = {},\n ): Promise<void> {\n throw new ExpenseError(\n 'EXPENSE_RECEIPT_INVALID',\n 'ExpenseReceiptCollection.setLinks() is not supported: it would delete ' +\n 'receipt evidence. Use attachReceipt() to add and detach() to remove.',\n );\n }\n\n /** Receipts of one expense, oldest first. */\n async receiptsFor(expenseId: string): Promise<ExpenseReceipt[]> {\n return this.byLeft(expenseId);\n }\n\n /**\n * Files (by SHA-256) attached to more than one expense, for a person to\n * review. Nothing is changed or rejected: the same receipt on two expenses\n * may be a split cost or a double claim, and only a reviewer can tell.\n *\n * With `expenseId`, reports only files that expense shares with others;\n * without it, scans the visible tenant (largest groups first).\n */\n async findDuplicateReceipts(\n options: FindDuplicateReceiptsOptions = {},\n ): Promise<DuplicateReceiptGroup[]> {\n const limit = Math.min(\n Math.max(Math.trunc(options.limit ?? DEFAULT_DUPLICATE_LIMIT), 1),\n MAX_DUPLICATE_LIMIT,\n );\n\n let hashes: string[];\n if (options.expenseId) {\n const own = await this.byLeft(options.expenseId);\n hashes = [...new Set(own.map((receipt) => receipt.contentSha256))];\n } else {\n const [facet] = await this.facets({\n fields: [{ field: 'contentSha256', limit: MAX_DUPLICATE_LIMIT }],\n });\n // One row per (expense, hash) is enforced, so count > 1 means the\n // hash sits on more than one expense.\n // Already only shared hashes (largest groups first), so limiting the\n // hashes here limits the groups.\n hashes = (facet?.values ?? [])\n .filter((value) => value.count > 1)\n .map((value) => String(value.value))\n .slice(0, limit);\n }\n // The expense's own hashes include its unique receipts, so the limit is\n // applied to the groups below, after unshared hashes are dropped.\n if (hashes.length === 0) return [];\n\n const rows = await this.list({\n where: { contentSha256: hashes },\n orderBy: ['content_sha256 ASC', 'created_at ASC'],\n });\n const byHash = new Map<string, ExpenseReceipt[]>();\n for (const receipt of rows) {\n const group = byHash.get(receipt.contentSha256) ?? [];\n group.push(receipt);\n byHash.set(receipt.contentSha256, group);\n }\n\n const groups: DuplicateReceiptGroup[] = [];\n for (const [contentSha256, receipts] of byHash) {\n const expenseIds = [\n ...new Set(receipts.map((receipt) => receipt.expenseId)),\n ].sort();\n if (expenseIds.length < 2) continue;\n groups.push({ contentSha256, expenseIds, receipts });\n }\n groups.sort(\n (a, b) =>\n b.expenseIds.length - a.expenseIds.length ||\n a.contentSha256.localeCompare(b.contentSha256),\n );\n return groups.slice(0, limit);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,eAAe,wBAAwB,KAAK,MAAM,8mzBAAg85B,CAAC;;;;;;;;;;;;;;;;;;;ACsBn/5B,IAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,aAAa,OAAgC;CACpD,MAAM,SAAS,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK;CAC/D,IAAI,CAAC,OAAO,cAAc,MAAM,GAC9B,MAAM,IAAI,aACR,mBACA,yBAAyB,OAAO,KAAK,EAAC,wBACxC;CAEF,OAAO;AACT;AAEA,SAAS,MAAM,QAAwB,UAAkB,QAAgB;CACvE,MAAM,QAAQ,OAAO,aAAa;EAAE,QAAQ;EAAG,OAAO;CAAE;CACxD,MAAM,MAAM,MAAM,SAAS;CAC3B,IAAI,CAAC,OAAO,cAAc,GAAG,GAC3B,MAAM,IAAI,aACR,mBACA,aAAa,SAAQ,iCACvB;CAEF,OAAO,YAAY;EAAE,QAAQ;EAAK,OAAO,MAAM,QAAQ;CAAE;AAC3D;AAW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M,CAAC,CAAA,GACnD,wBAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/__smrt-register__.ts","../src/collections/ExpenseCollection.ts","../src/recipes.ts"],"sourcesContent":["// Generated by @happyvertical/smrt-core smrtPlugin at library build time.\n// The package manifest is inlined so self-registration cannot miss when a\n// downstream bundler relocates this module away from dist/manifest.json\n// (https://github.com/happyvertical/smrt/issues/1506,\n// https://github.com/happyvertical/smrt/issues/1507).\nimport { ObjectRegistry } from '@happyvertical/smrt-core';\n\nObjectRegistry.registerPackageManifest(JSON.parse(\"{\\\"version\\\":\\\"1.0.0\\\",\\\"timestamp\\\":0,\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"packageVersion\\\":\\\"0.56.1\\\",\\\"objects\\\":{\\\"@happyvertical/smrt-expenses:ExpenseCollection\\\":{\\\"name\\\":\\\"expensecollection\\\",\\\"className\\\":\\\"ExpenseCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseCollection\\\",\\\"collection\\\":\\\"expenses\\\",\\\"description\\\":\\\"Collection for Expense. Reads go through the normal tenant interceptors, so inside withTenant() every method here sees only that tenant's expenses.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/collections/ExpenseCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{},\\\"methods\\\":{\\\"record\\\":{\\\"name\\\":\\\"record\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"RecordExpenseActionInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<Expense>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true,\\\"decoratorConfig\\\":{\\\"httpMethod\\\":\\\"POST\\\",\\\"path\\\":\\\"record\\\",\\\"effect\\\":\\\"write\\\",\\\"idempotent\\\":false,\\\"openWorld\\\":false,\\\"description\\\":\\\"Record a new expense for review (service-backed).\\\"}},\\\"attachReceipt\\\":{\\\"name\\\":\\\"attachReceipt\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"AttachExpenseReceiptActionInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseReceipt>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true,\\\"decoratorConfig\\\":{\\\"httpMethod\\\":\\\"POST\\\",\\\"path\\\":\\\"attachReceipt\\\",\\\"effect\\\":\\\"write\\\",\\\"idempotent\\\":false,\\\"openWorld\\\":false,\\\"description\\\":\\\"Attach a receipt file to an expense (service-backed).\\\"}},\\\"recordReview\\\":{\\\"name\\\":\\\"recordReview\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"ReviewExpenseActionInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<Expense>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true,\\\"decoratorConfig\\\":{\\\"httpMethod\\\":\\\"POST\\\",\\\"path\\\":\\\"recordReview\\\",\\\"effect\\\":\\\"write\\\",\\\"idempotent\\\":false,\\\"openWorld\\\":false,\\\"description\\\":\\\"Approve or reject an expense with a reason (service-backed).\\\"}},\\\"recordReimbursement\\\":{\\\"name\\\":\\\"recordReimbursement\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"MarkExpenseReimbursedActionInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<Expense>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true,\\\"decoratorConfig\\\":{\\\"httpMethod\\\":\\\"POST\\\",\\\"path\\\":\\\"recordReimbursement\\\",\\\"effect\\\":\\\"write\\\",\\\"idempotent\\\":false,\\\"openWorld\\\":false,\\\"description\\\":\\\"Record that an expense was reimbursed (service-backed).\\\"}},\\\"forCostObject\\\":{\\\"name\\\":\\\"forCostObject\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"costObjectType\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"costObjectId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<Expense[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"totalsByCurrency\\\":{\\\"name\\\":\\\"totalsByCurrency\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"ExpenseTotalsOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<CurrencyTotals>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"listReviewedTaxFacts\\\":{\\\"name\\\":\\\"listReviewedTaxFacts\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"ReviewedExpenseTaxFactsOptions\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ReviewedExpenseTaxFact[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"commitmentPosition\\\":{\\\"name\\\":\\\"commitmentPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"commitmentId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"string\\\"]}],\\\"returnType\\\":\\\"Promise<CommitmentPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"api\\\":{\\\"include\\\":[\\\"record\\\",\\\"attachReceipt\\\",\\\"recordReview\\\",\\\"recordReimbursement\\\"]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"tableName\\\":\\\"expenses\\\"},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"Expense\\\",\\\"exportName\\\":\\\"ExpenseCollection\\\",\\\"collectionExportName\\\":\\\"ExpenseCollectionCollection\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expenses\\\\\\\" (\\\\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 \\\\\\\"cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"category\\\\\\\" TEXT,\\\\n \\\\\\\"description\\\\\\\" TEXT,\\\\n \\\\\\\"amount\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT,\\\\n \\\\\\\"financial_breakdown\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"incurred_on\\\\\\\" TEXT,\\\\n \\\\\\\"recorded_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"recorded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"paid_by\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"vendor_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_line_id\\\\\\\" UUID,\\\\n \\\\\\\"review_status\\\\\\\" TEXT,\\\\n \\\\\\\"reviewed_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"reviewed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"review_note\\\\\\\" TEXT,\\\\n \\\\\\\"duplicate_of_id\\\\\\\" UUID,\\\\n \\\\\\\"reimbursable\\\\\\\" BOOLEAN,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT\\\\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},\\\"cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"category\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"description\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"financial_breakdown\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_name\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"refund_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"incurred_on\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"vendor_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_line_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_note\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"duplicate_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"SET NULL\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"reimbursable\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursement_reference\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expenses_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expenses_cost_object_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"cost_object_type\\\",\\\"cost_object_id\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_commitment_review_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"commitment_id\\\",\\\"review_status\\\"]},{\\\"name\\\":\\\"expenses_review_status_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"review_status\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expenses_refund_of_id_idx\\\",\\\"columns\\\":[\\\"refund_of_id\\\"]},{\\\"name\\\":\\\"expenses_recorded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"recorded_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_paid_by_profile_id_idx\\\",\\\"columns\\\":[\\\"paid_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_vendor_id_idx\\\",\\\"columns\\\":[\\\"vendor_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_id_idx\\\",\\\"columns\\\":[\\\"commitment_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_line_id_idx\\\",\\\"columns\\\":[\\\"commitment_line_id\\\"]},{\\\"name\\\":\\\"expenses_reviewed_by_profile_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_duplicate_of_id_idx\\\",\\\"columns\\\":[\\\"duplicate_of_id\\\"]}],\\\"version\\\":\\\"287668fa\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:ExpenseReceiptCollection\\\":{\\\"name\\\":\\\"expensereceiptcollection\\\",\\\"className\\\":\\\"ExpenseReceiptCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseReceiptCollection\\\",\\\"collection\\\":\\\"expensereceipts\\\",\\\"description\\\":\\\"Junction collection over expense_receipts (left: expense, right: asset). Reads go through the normal tenant interceptors.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/collections/ExpenseReceiptCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{},\\\"methods\\\":{\\\"byRight\\\":{\\\"name\\\":\\\"byRight\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"rightId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"opts\\\",\\\"type\\\":\\\"JunctionFilterOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<TItem[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"byLeft\\\":{\\\"name\\\":\\\"byLeft\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"leftId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"opts\\\",\\\"type\\\":\\\"JunctionFilterOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<TItem[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"attach\\\":{\\\"name\\\":\\\"attach\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"_expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_assetId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_opts\\\",\\\"type\\\":\\\"JunctionAttachOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<ExpenseReceipt>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"detach\\\":{\\\"name\\\":\\\"detach\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"leftId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"rightId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"opts\\\",\\\"type\\\":\\\"JunctionFilterOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"setLinks\\\":{\\\"name\\\":\\\"setLinks\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"_expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_assetIds\\\",\\\"type\\\":\\\"string[]\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"_opts\\\",\\\"type\\\":\\\"JunctionAttachOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"attachReceipt\\\":{\\\"name\\\":\\\"attachReceipt\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"AttachReceiptInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseReceipt>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"receiptsFor\\\":{\\\"name\\\":\\\"receiptsFor\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseReceipt[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"findDuplicateReceipts\\\":{\\\"name\\\":\\\"findDuplicateReceipts\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"FindDuplicateReceiptsOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<DuplicateReceiptGroup[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"tableName\\\":\\\"expense_receipts\\\"},\\\"extends\\\":\\\"SmrtJunction\\\",\\\"extendsTypeArg\\\":\\\"ExpenseReceipt\\\",\\\"exportName\\\":\\\"ExpenseReceiptCollection\\\",\\\"collectionExportName\\\":\\\"ExpenseReceiptCollectionCollection\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_receipts\\\\\\\" (\\\\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 \\\\\\\"expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"asset_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"uploaded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"filename\\\\\\\" TEXT,\\\\n \\\\\\\"mime_type\\\\\\\" TEXT,\\\\n \\\\\\\"byte_count\\\\\\\" INTEGER,\\\\n \\\\\\\"content_sha256\\\\\\\" TEXT NOT NULL\\\\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},\\\"expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"CASCADE\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"asset_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"uploaded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"filename\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"mime_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"byte_count\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"content_sha256\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_receipts_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expense_receipts_expense_sha256_key\\\",\\\"columns\\\":[\\\"expense_id\\\",\\\"content_sha256\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_receipts_tenant_sha256_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"content_sha256\\\"]},{\\\"name\\\":\\\"expense_receipts_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_receipts_asset_id_idx\\\",\\\"columns\\\":[\\\"asset_id\\\"]},{\\\"name\\\":\\\"expense_receipts_uploaded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"uploaded_by_profile_id\\\"]}],\\\"version\\\":\\\"5aa77571\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:Expense\\\":{\\\"name\\\":\\\"expense\\\",\\\"className\\\":\\\"Expense\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:Expense\\\",\\\"collection\\\":\\\"expenses\\\",\\\"description\\\":\\\"A cost someone incurred.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/models/Expense.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"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}}},\\\"costObjectType\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"costObjectId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"category\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"description\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"amount\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"currency\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"financialBreakdown\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"paidByName\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"refundOfId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"incurredOn\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"recordedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"recordedByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"PROFILE\\\"},\\\"paidBy\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{},\\\"enum\\\":[\\\"company\\\",\\\"person\\\",\\\"third-party\\\"]},\\\"paidByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"PROFILE\\\"},\\\"vendorId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:Vendor\\\"},\\\"commitmentId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:PurchaseContract\\\",\\\"_meta\\\":{\\\"validateSubtype\\\":true}},\\\"commitmentLineId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:ContractLineItem\\\"},\\\"reviewStatus\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"enum\\\":[\\\"unreviewed\\\",\\\"reviewed\\\",\\\"rejected\\\"],\\\"readonly\\\":true},\\\"reviewedByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"PROFILE\\\"},\\\"reviewedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"reviewNote\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"duplicateOfId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"onDelete\\\":\\\"SET NULL\\\"}},\\\"reimbursable\\\":{\\\"type\\\":\\\"boolean\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"reimbursedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"reimbursementReference\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}}},\\\"methods\\\":{\\\"getFinancialBreakdown\\\":{\\\"name\\\":\\\"getFinancialBreakdown\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"ExpenseFinancialBreakdown | null\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"setFinancialBreakdown\\\":{\\\"name\\\":\\\"setFinancialBreakdown\\\",\\\"async\\\":false,\\\"parameters\\\":[{\\\"name\\\":\\\"value\\\",\\\"type\\\":\\\"ExpenseFinancialBreakdown | null\\\",\\\"optional\\\":false,\\\"unionBranches\\\":[{\\\"type\\\":\\\"ExpenseFinancialBreakdown\\\"},{\\\"type\\\":\\\"null\\\"}]}],\\\"returnType\\\":\\\"void\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getCostBasis\\\":{\\\"name\\\":\\\"getCostBasis\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"ExpenseCostBasis | null\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"isReimbursed\\\":{\\\"name\\\":\\\"isReimbursed\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"boolean\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"isCountable\\\":{\\\"name\\\":\\\"isCountable\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"boolean\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"review\\\":{\\\"name\\\":\\\"review\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"ReviewExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"reject\\\":{\\\"name\\\":\\\"reject\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RejectExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"markDuplicate\\\":{\\\"name\\\":\\\"markDuplicate\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"MarkDuplicateExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"reopen\\\":{\\\"name\\\":\\\"reopen\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"ReopenExpenseInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"markReimbursed\\\":{\\\"name\\\":\\\"markReimbursed\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"MarkReimbursedInput\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getCostObject\\\":{\\\"name\\\":\\\"getCostObject\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<T | null>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"save\\\":{\\\"name\\\":\\\"save\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"api\\\":{\\\"include\\\":[\\\"record\\\",\\\"attachReceipt\\\",\\\"recordReview\\\",\\\"recordReimbursement\\\"]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"expenses_cost_object_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"costObjectType\\\",\\\"costObjectId\\\",\\\"incurredOn\\\"]},{\\\"name\\\":\\\"expenses_commitment_review_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"commitmentId\\\",\\\"reviewStatus\\\"]},{\\\"name\\\":\\\"expenses_review_status_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"reviewStatus\\\",\\\"incurredOn\\\"]}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"optional\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"Expense\\\",\\\"collectionExportName\\\":\\\"ExpenseCollection\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expenses\\\\\\\" (\\\\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 \\\\\\\"cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"category\\\\\\\" TEXT,\\\\n \\\\\\\"description\\\\\\\" TEXT,\\\\n \\\\\\\"amount\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT,\\\\n \\\\\\\"financial_breakdown\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"incurred_on\\\\\\\" TEXT,\\\\n \\\\\\\"recorded_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"recorded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"paid_by\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"vendor_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_id\\\\\\\" UUID,\\\\n \\\\\\\"commitment_line_id\\\\\\\" UUID,\\\\n \\\\\\\"review_status\\\\\\\" TEXT,\\\\n \\\\\\\"reviewed_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"reviewed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"review_note\\\\\\\" TEXT,\\\\n \\\\\\\"duplicate_of_id\\\\\\\" UUID,\\\\n \\\\\\\"reimbursable\\\\\\\" BOOLEAN,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT\\\\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},\\\"cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"category\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"description\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"financial_breakdown\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_name\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"refund_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"incurred_on\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"recorded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"vendor_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"commitment_line_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"review_note\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"duplicate_of_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"SET NULL\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"reimbursable\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursement_reference\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expenses_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expenses_cost_object_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"cost_object_type\\\",\\\"cost_object_id\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_commitment_review_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"commitment_id\\\",\\\"review_status\\\"]},{\\\"name\\\":\\\"expenses_review_status_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"review_status\\\",\\\"incurred_on\\\"]},{\\\"name\\\":\\\"expenses_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expenses_refund_of_id_idx\\\",\\\"columns\\\":[\\\"refund_of_id\\\"]},{\\\"name\\\":\\\"expenses_recorded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"recorded_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_paid_by_profile_id_idx\\\",\\\"columns\\\":[\\\"paid_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_vendor_id_idx\\\",\\\"columns\\\":[\\\"vendor_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_id_idx\\\",\\\"columns\\\":[\\\"commitment_id\\\"]},{\\\"name\\\":\\\"expenses_commitment_line_id_idx\\\",\\\"columns\\\":[\\\"commitment_line_id\\\"]},{\\\"name\\\":\\\"expenses_reviewed_by_profile_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_profile_id\\\"]},{\\\"name\\\":\\\"expenses_duplicate_of_id_idx\\\",\\\"columns\\\":[\\\"duplicate_of_id\\\"]}],\\\"version\\\":\\\"287668fa\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\":{\\\"name\\\":\\\"expensereceipt\\\",\\\"className\\\":\\\"ExpenseReceipt\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\",\\\"collection\\\":\\\"expensereceipts\\\",\\\"description\\\":\\\"A receipt file attached to an expense.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseReceipt.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"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}}},\\\"expenseId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":true,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"required\\\":true,\\\"onDelete\\\":\\\"CASCADE\\\"}},\\\"assetId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":true,\\\"related\\\":\\\"@happyvertical/smrt-assets:Asset\\\"},\\\"uploadedByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-profiles:Profile\\\"},\\\"filename\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"mimeType\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"byteCount\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"contentSha256\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":true,\\\"_meta\\\":{\\\"required\\\":true}}},\\\"methods\\\":{\\\"save\\\":{\\\"name\\\":\\\"save\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"expense_receipts_expense_sha256_key\\\",\\\"columns\\\":[\\\"expenseId\\\",\\\"contentSha256\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_receipts_tenant_sha256_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"contentSha256\\\"]}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"optional\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ExpenseReceipt\\\",\\\"collectionExportName\\\":\\\"ExpenseReceiptCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"expenseId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"},{\\\"field\\\":\\\"assetId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"crossPackageRef\\\"},{\\\"field\\\":\\\"contentSha256\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_receipts\\\\\\\" (\\\\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 \\\\\\\"expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"asset_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"uploaded_by_profile_id\\\\\\\" UUID,\\\\n \\\\\\\"filename\\\\\\\" TEXT,\\\\n \\\\\\\"mime_type\\\\\\\" TEXT,\\\\n \\\\\\\"byte_count\\\\\\\" INTEGER,\\\\n \\\\\\\"content_sha256\\\\\\\" TEXT NOT NULL\\\\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},\\\"expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"CASCADE\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"asset_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"uploaded_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"filename\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"mime_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"byte_count\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"content_sha256\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_receipts_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true,\\\"nullsNotDistinct\\\":true},{\\\"name\\\":\\\"expense_receipts_expense_sha256_key\\\",\\\"columns\\\":[\\\"expense_id\\\",\\\"content_sha256\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_receipts_tenant_sha256_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"content_sha256\\\"]},{\\\"name\\\":\\\"expense_receipts_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_receipts_asset_id_idx\\\",\\\"columns\\\":[\\\"asset_id\\\"]},{\\\"name\\\":\\\"expense_receipts_uploaded_by_profile_id_idx\\\",\\\"columns\\\":[\\\"uploaded_by_profile_id\\\"]}],\\\"version\\\":\\\"5aa77571\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"}},\\\"moduleType\\\":\\\"smrt\\\",\\\"recipes\\\":[{\\\"id\\\":\\\"expenses.tracking\\\",\\\"className\\\":\\\"ExpensesRecipe\\\",\\\"label\\\":\\\"Expenses\\\",\\\"summary\\\":\\\"Record what the business spends, with receipts, and review it.\\\",\\\"synonyms\\\":[\\\"costs\\\",\\\"receipts\\\",\\\"spending\\\",\\\"reimbursements\\\"],\\\"models\\\":[\\\"@happyvertical/smrt-expenses:Expense\\\",\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\"],\\\"nav\\\":[{\\\"label\\\":\\\"Expenses\\\",\\\"model\\\":\\\"@happyvertical/smrt-expenses:Expense\\\",\\\"icon\\\":\\\"receipt\\\",\\\"description\\\":\\\"Costs you have paid, with the receipt and who paid.\\\"}],\\\"requires\\\":[],\\\"section\\\":{\\\"id\\\":\\\"accounting\\\",\\\"label\\\":\\\"Accounting\\\",\\\"icon\\\":\\\"bank\\\",\\\"description\\\":\\\"Your books: accounts, journals and balances.\\\"},\\\"options\\\":{\\\"@happyvertical/smrt-expenses:Expense\\\":{\\\"fields\\\":{\\\"description\\\":{\\\"order\\\":1,\\\"required\\\":true},\\\"amount\\\":{\\\"order\\\":2},\\\"currency\\\":{\\\"order\\\":3},\\\"incurredOn\\\":{\\\"label\\\":\\\"Date\\\",\\\"order\\\":4,\\\"help\\\":\\\"The date on the receipt, as YYYY-MM-DD.\\\"},\\\"category\\\":{\\\"order\\\":5,\\\"help\\\":\\\"One word, such as material, travel, freight or other.\\\"},\\\"vendorId\\\":{\\\"label\\\":\\\"Vendor\\\",\\\"order\\\":6},\\\"paidBy\\\":{\\\"order\\\":7},\\\"paidByProfileId\\\":{\\\"label\\\":\\\"Person who paid\\\",\\\"order\\\":8,\\\"help\\\":\\\"Who paid out of their own pocket, when a person paid.\\\"},\\\"paidByName\\\":{\\\"order\\\":9},\\\"reimbursable\\\":{\\\"order\\\":10},\\\"costObjectId\\\":{\\\"label\\\":\\\"Charged to\\\",\\\"order\\\":11,\\\"help\\\":\\\"The job, project or client the cost belongs to.\\\"},\\\"costObjectType\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"financialBreakdown\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"refundOfId\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"recordedByProfileId\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"commitmentId\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"commitmentLineId\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"reviewedByProfileId\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"duplicateOfId\\\":{\\\"visibility\\\":\\\"hidden\\\"}}},\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\":{\\\"fields\\\":{\\\"contentSha256\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"byteCount\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"uploadedByProfileId\\\":{\\\"visibility\\\":\\\"hidden\\\"}}}},\\\"help\\\":{\\\"markdown\\\":\\\"## Overview\\\\n\\\\nExpenses are the costs the business pays: a receipt, who paid it and what it\\\\nwas for. Each expense is reviewed once, and a reimbursable one is marked when\\\\nthe person is paid back.\\\\n\\\\n## Tasks\\\\n\\\\n### Record an expense\\\\n\\\\n1. Create a new expense and write a short **{field:description}**.\\\\n2. Enter the **{field:amount}** and its **{field:currency}**.\\\\n3. Set the **{field:incurredOn}** date from the receipt and pick a\\\\n **{field:category}**.\\\\n4. Choose who **{field:paidBy}**: the company, a person or a third party.\\\\n5. When a person paid, pick the **{field:paidByProfileId}** and tick\\\\n **{field:reimbursable}** when they are owed the money back.\\\\n\\\\n### Review it\\\\n\\\\n1. Open the expense and check the receipt attached to it.\\\\n2. **{field:reviewStatus}** moves from unreviewed to reviewed, or to rejected,\\\\n when someone reviews it. A rejected expense can be reopened.\\\\n\\\",\\\"fieldRefs\\\":[\\\"amount\\\",\\\"category\\\",\\\"currency\\\",\\\"description\\\",\\\"incurredOn\\\",\\\"paidBy\\\",\\\"paidByProfileId\\\",\\\"reimbursable\\\",\\\"reviewStatus\\\"]},\\\"demo\\\":{\\\"mode\\\":\\\"server\\\",\\\"reasons\\\":[\\\"Needs a server because its package does not build for a browser: node:crypto; and its package depends on @happyvertical/smrt-agents, @happyvertical/smrt-commerce, @happyvertical/smrt-jobs, @happyvertical/smrt-ledgers, @happyvertical/smrt-products, @happyvertical/smrt-profiles, @happyvertical/smrt-reports, @happyvertical/smrt-secrets, @happyvertical/smrt-subscriptions, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3616, #3617, #3624, #3625, #3626, #3627).\\\"]}}],\\\"smrtDependencies\\\":[\\\"@happyvertical/smrt-assets\\\",\\\"@happyvertical/smrt-commerce\\\",\\\"@happyvertical/smrt-core\\\",\\\"@happyvertical/smrt-tenancy\\\",\\\"@happyvertical/smrt-users\\\"],\\\"browser\\\":{\\\"status\\\":\\\"server-only\\\",\\\"issues\\\":[\\\"#3615\\\",\\\"#3616\\\",\\\"#3617\\\",\\\"#3624\\\",\\\"#3625\\\",\\\"#3626\\\",\\\"#3627\\\"],\\\"reason\\\":\\\"node:crypto\\\",\\\"via\\\":[\\\"@happyvertical/smrt-agents\\\",\\\"@happyvertical/smrt-commerce\\\",\\\"@happyvertical/smrt-jobs\\\",\\\"@happyvertical/smrt-ledgers\\\",\\\"@happyvertical/smrt-products\\\",\\\"@happyvertical/smrt-profiles\\\",\\\"@happyvertical/smrt-reports\\\",\\\"@happyvertical/smrt-secrets\\\",\\\"@happyvertical/smrt-subscriptions\\\",\\\"@happyvertical/smrt-tenancy\\\",\\\"@happyvertical/smrt-users\\\"]},\\\"stampsConstructors\\\":true}\"));\n","/**\n * ExpenseCollection — queries, per-currency totals, and commitment drawdown.\n *\n * @packageDocumentation\n */\n\nimport {\n ContractLineItemCollection,\n PurchaseContractCollection,\n} from '@happyvertical/smrt-commerce';\nimport { method, SmrtCollection, smrt } from '@happyvertical/smrt-core';\nimport type {\n AttachExpenseReceiptActionInput,\n MarkExpenseReimbursedActionInput,\n RecordExpenseActionInput,\n ReviewExpenseActionInput,\n} from '../actions/expense-actions.js';\nimport { Expense } from '../models/Expense.js';\nimport type { ExpenseReceipt } from '../models/ExpenseReceipt.js';\nimport {\n type CommitmentPosition,\n type CurrencyTotals,\n ExpenseError,\n type ExpenseFinancialBreakdown,\n type ExpenseReviewStatus,\n type ExpenseTotalsOptions,\n} from '../types.js';\n\n/** A reviewed, non-duplicate expense and its optional stored supplier facts. */\nexport interface ReviewedExpenseTaxFact {\n /** Legacy owner identity alias retained for existing callers. */\n id: string;\n /** Reporting identity consumed by commerce tax-summary facts. */\n expenseId: string;\n tenantId: string;\n incurredOn: string;\n currency: string;\n commitmentId: string | null;\n commitmentLineId: string | null;\n /** `null` is unknown legacy supplier tax, never an implied zero. */\n financialBreakdown: ExpenseFinancialBreakdown | null;\n}\n\nexport interface ReviewedExpenseTaxFactsOptions {\n tenantId: string;\n from: string;\n to: string;\n currency?: string;\n}\n\nfunction isCalendarDate(value: string): boolean {\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) return false;\n const date = new Date(`${value}T00:00:00.000Z`);\n return (\n !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === value\n );\n}\n\n/** Plain projection read for sums: never hydrates objects. */\ninterface AmountRow {\n id: string;\n amount: number | string;\n currency: string;\n reviewStatus: ExpenseReviewStatus;\n duplicateOfId: string | null;\n}\n\nconst AMOUNT_FIELDS = [\n 'id',\n 'amount',\n 'currency',\n 'reviewStatus',\n 'duplicateOfId',\n] as const;\n\nfunction toMinorUnits(value: number | string): number {\n const amount = typeof value === 'number' ? value : Number(value);\n if (!Number.isSafeInteger(amount)) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n `Stored expense amount ${String(value)} is not a safe integer.`,\n );\n }\n return amount;\n}\n\nfunction addTo(totals: CurrencyTotals, currency: string, amount: number) {\n const entry = totals[currency] ?? { amount: 0, count: 0 };\n const sum = entry.amount + amount;\n if (!Number.isSafeInteger(sum)) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n `Total for ${currency} exceeds the safe integer range.`,\n );\n }\n totals[currency] = { amount: sum, count: entry.count + 1 };\n}\n\n/**\n * Collection for {@link Expense}. Reads go through the normal tenant\n * interceptors, so inside `withTenant()` every method here sees only that\n * tenant's expenses.\n *\n * Collection classes are registered too, so this one carries its own\n * surface; without it every public method here would become an MCP tool. It\n * publishes only the service-backed write actions (#4001), on REST: each\n * authorizes the signed-in person itself (`expenses.<action>`) and delegates\n * to the guarded domain flow. Reads, MCP and CLI stay closed.\n */\n@smrt({\n api: {\n include: ['record', 'attachReceipt', 'recordReview', 'recordReimbursement'],\n },\n mcp: { include: [] },\n cli: false,\n})\nexport class ExpenseCollection extends SmrtCollection<Expense> { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n static readonly _itemClass = Expense;\n\n /**\n * Record a new, unreviewed expense for the signed-in person in their\n * tenant. Needs `expenses.record`; a person-paid expense for someone else\n * also needs `expenses.recordReview`.\n */\n @method({\n httpMethod: 'POST',\n path: 'record',\n effect: 'write',\n idempotent: false,\n openWorld: false,\n description: 'Record a new expense for review (service-backed).',\n })\n async record(options: RecordExpenseActionInput): Promise<Expense> {\n const { recordExpenseAction } = await import(\n '../actions/expense-actions.js'\n );\n return recordExpenseAction(this, options);\n }\n\n /**\n * Attach a stored asset to an expense as its receipt. Needs\n * `expenses.attachReceipt`; only the recorder or payer may attach unless\n * the caller holds `expenses.recordReview`.\n */\n @method({\n httpMethod: 'POST',\n path: 'attachReceipt',\n effect: 'write',\n idempotent: false,\n openWorld: false,\n description: 'Attach a receipt file to an expense (service-backed).',\n })\n async attachReceipt(\n options: AttachExpenseReceiptActionInput,\n ): Promise<ExpenseReceipt> {\n const { attachExpenseReceiptAction } = await import(\n '../actions/expense-actions.js'\n );\n return attachExpenseReceiptAction(this, options);\n }\n\n /**\n * Accept or refuse (with a reason) an expense, attributed to the signed-in\n * reviewer. Needs an explicit `expenses.recordReview` grant.\n */\n @method({\n httpMethod: 'POST',\n path: 'recordReview',\n effect: 'write',\n idempotent: false,\n openWorld: false,\n description: 'Approve or reject an expense with a reason (service-backed).',\n })\n async recordReview(options: ReviewExpenseActionInput): Promise<Expense> {\n const { reviewExpenseAction } = await import(\n '../actions/expense-actions.js'\n );\n return reviewExpenseAction(this, options);\n }\n\n /**\n * Record that the person who paid an expense has been paid back. Needs an\n * explicit `expenses.recordReimbursement` grant.\n */\n @method({\n httpMethod: 'POST',\n path: 'recordReimbursement',\n effect: 'write',\n idempotent: false,\n openWorld: false,\n description: 'Record that an expense was reimbursed (service-backed).',\n })\n async recordReimbursement(\n options: MarkExpenseReimbursedActionInput,\n ): Promise<Expense> {\n const { markExpenseReimbursedAction } = await import(\n '../actions/expense-actions.js'\n );\n return markExpenseReimbursedAction(this, options);\n }\n\n /**\n * Expenses charged to one cost object, oldest incurred first.\n *\n * @param costObjectType - Qualified class name of the cost object.\n * @param costObjectId - Id of the cost object.\n */\n async forCostObject(\n costObjectType: string,\n costObjectId: string,\n ): Promise<Expense[]> {\n return this.list({\n where: { costObjectType, costObjectId },\n orderBy: ['incurred_on ASC', 'created_at ASC'],\n });\n }\n\n /**\n * Sum expenses per currency. Amounts in different currencies are never\n * added together: the result is keyed by ISO 4217 code.\n *\n * By default only `reviewed` expenses count; a duplicate never counts.\n *\n * @example\n * ```typescript\n * const totals = await expenses.totalsByCurrency({\n * where: { costObjectType: JOB, costObjectId: job.id },\n * });\n * // { USD: { amount: 125000, count: 3 }, CAD: { amount: 4000, count: 1 } }\n * ```\n */\n async totalsByCurrency(\n options: ExpenseTotalsOptions = {},\n ): Promise<CurrencyTotals> {\n const statuses = options.reviewStatuses ?? ['reviewed'];\n if (statuses.length === 0) return {};\n const rows = (await this.list({\n where: {\n ...(options.where ?? {}),\n reviewStatus: [...statuses],\n duplicateOfId: null,\n },\n select: [...AMOUNT_FIELDS],\n })) as unknown as AmountRow[];\n\n const totals: CurrencyTotals = {};\n const seen = new Set<string>();\n for (const row of rows) {\n if (seen.has(row.id)) continue;\n seen.add(row.id);\n addTo(totals, row.currency, toMinorUnits(row.amount));\n }\n return totals;\n }\n\n /**\n * Stored supplier-tax facts for reporting. Only reviewed non-duplicate\n * expenses are returned; callers must retain a null breakdown as unknown.\n */\n async listReviewedTaxFacts(\n options: ReviewedExpenseTaxFactsOptions,\n ): Promise<ReviewedExpenseTaxFact[]> {\n if (\n !options.tenantId?.trim() ||\n !isCalendarDate(options.from) ||\n !isCalendarDate(options.to) ||\n options.from > options.to ||\n (options.currency !== undefined && !options.currency.trim())\n ) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n 'Tax facts require a tenant, an ordered calendar-date range, and a nonempty currency when supplied.',\n );\n }\n const expenses = await this.list({\n where: {\n tenantId: options.tenantId,\n reviewStatus: 'reviewed',\n duplicateOfId: null,\n 'incurredOn >=': options.from,\n 'incurredOn <=': options.to,\n ...(options.currency ? { currency: options.currency } : {}),\n },\n orderBy: ['incurred_on ASC', 'id ASC'],\n });\n return expenses.map((expense) => {\n if (!expense.id || expense.tenantId !== options.tenantId) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n 'Tenant tax-fact query returned a row without its requested tenant identity.',\n );\n }\n return {\n id: expense.id,\n expenseId: expense.id,\n tenantId: expense.tenantId,\n incurredOn: expense.incurredOn,\n currency: expense.currency,\n commitmentId: expense.commitmentId,\n commitmentLineId: expense.commitmentLineId,\n financialBreakdown: expense.getFinancialBreakdown(),\n };\n });\n }\n\n /**\n * What remains open on a commitment — a commerce `Contract`, normally a\n * `PurchaseOrder` — or on one of its lines.\n *\n * `committed` is the contract's `totalAmount` (or the line's `amount`);\n * `drawn` sums the matched actuals that are `reviewed` and not marked\n * duplicate, in the commitment's currency, each expense once. Unreviewed,\n * rejected and duplicate matches are counted in `excluded` and never\n * drawn. A 4,600 commitment with 1,000 reviewed leaves 3,600 open.\n *\n * @param commitmentId - The commitment's contract id.\n * @param options.lineId - Restrict to one line of the commitment.\n * @throws {ExpenseError} `EXPENSE_COMMITMENT_MISMATCH` when the commitment\n * (or line) is not visible in the current tenant.\n */\n async commitmentPosition(\n commitmentId: string,\n options: { lineId?: string } = {},\n ): Promise<CommitmentPosition> {\n const contracts = await PurchaseContractCollection.create({ db: this.db });\n const commitment = await contracts.get({ id: commitmentId });\n if (!commitment) {\n throw new ExpenseError(\n 'EXPENSE_COMMITMENT_MISMATCH',\n `Commitment ${commitmentId} was not found.`,\n );\n }\n let committed = toMinorUnits(commitment.totalAmount);\n if (options.lineId) {\n const lines = await ContractLineItemCollection.create({ db: this.db });\n const line = await lines.get({ id: options.lineId });\n if (!line || line.contractId !== commitmentId) {\n throw new ExpenseError(\n 'EXPENSE_COMMITMENT_MISMATCH',\n `Line ${options.lineId} is not a line of commitment ${commitmentId}.`,\n );\n }\n committed = toMinorUnits(line.amount);\n }\n const currency = String(commitment.currency).toUpperCase();\n\n const rows = (await this.list({\n where: {\n commitmentId,\n ...(options.lineId ? { commitmentLineId: options.lineId } : {}),\n },\n select: [...AMOUNT_FIELDS],\n })) as unknown as AmountRow[];\n\n const position: CommitmentPosition = {\n commitmentId,\n commitmentLineId: options.lineId ?? null,\n currency,\n committed,\n drawn: 0,\n open: 0,\n overrun: 0,\n countedExpenseIds: [],\n excluded: { unreviewed: 0, rejected: 0, duplicate: 0 },\n otherCurrencies: {},\n };\n const seen = new Set<string>();\n for (const row of rows) {\n if (seen.has(row.id)) continue;\n seen.add(row.id);\n if (row.duplicateOfId) {\n position.excluded.duplicate += 1;\n } else if (row.reviewStatus === 'unreviewed') {\n position.excluded.unreviewed += 1;\n } else if (row.reviewStatus === 'rejected') {\n position.excluded.rejected += 1;\n } else if (row.currency !== currency) {\n addTo(position.otherCurrencies, row.currency, toMinorUnits(row.amount));\n } else {\n const drawn = position.drawn + toMinorUnits(row.amount);\n if (!Number.isSafeInteger(drawn)) {\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n `Drawdown on commitment ${commitmentId} exceeds the safe range.`,\n );\n }\n position.drawn = drawn;\n position.countedExpenseIds.push(row.id);\n }\n }\n position.countedExpenseIds.sort();\n position.open = Math.max(committed - position.drawn, 0);\n position.overrun = Math.max(position.drawn - committed, 0);\n return position;\n }\n}\n","/**\n * Declared recipes for smrt-expenses (#3590, #3604): user-facing units of\n * functionality an app or agent can pick instead of the whole package.\n * The scanner reads these statics into the `recipes` array of `manifest.json`\n * and `smrt-knowledge.json`; nothing here runs at that point.\n *\n * @packageDocumentation\n */\n\nimport { SmrtRecipe } from '@happyvertical/smrt-core';\nimport { Expense } from './models/Expense.js';\nimport { ExpenseReceipt } from './models/ExpenseReceipt.js';\n\n/** Expenses: Record what the business spends, with receipts, and review it. */\nexport class ExpensesRecipe extends SmrtRecipe {\n static id = 'expenses.tracking';\n static help = './tracking.recipe.md';\n static label = 'Expenses';\n static summary =\n 'Record what the business spends, with receipts, and review it.';\n static synonyms = ['costs', 'receipts', 'spending', 'reimbursements'];\n static section = {\n id: 'accounting',\n label: 'Accounting',\n icon: 'bank',\n description: 'Your books: accounts, journals and balances.',\n };\n static models = [Expense, ExpenseReceipt];\n static nav = [\n {\n label: 'Expenses',\n model: Expense,\n icon: 'receipt',\n description: 'Costs you have paid, with the receipt and who paid.',\n },\n ];\n static options = {\n Expense: {\n fields: {\n description: { order: 1, required: true },\n amount: { order: 2 },\n currency: { order: 3 },\n incurredOn: {\n label: 'Date',\n order: 4,\n help: 'The date on the receipt, as YYYY-MM-DD.',\n },\n category: {\n order: 5,\n help: 'One word, such as material, travel, freight or other.',\n },\n vendorId: { label: 'Vendor', order: 6 },\n paidBy: { order: 7 },\n paidByProfileId: {\n label: 'Person who paid',\n order: 8,\n help: 'Who paid out of their own pocket, when a person paid.',\n },\n paidByName: { order: 9 },\n reimbursable: { order: 10 },\n costObjectId: {\n label: 'Charged to',\n order: 11,\n help: 'The job, project or client the cost belongs to.',\n },\n costObjectType: { visibility: 'hidden' },\n financialBreakdown: { visibility: 'hidden' },\n refundOfId: { visibility: 'hidden' },\n recordedByProfileId: { visibility: 'hidden' },\n commitmentId: { visibility: 'hidden' },\n commitmentLineId: { visibility: 'hidden' },\n reviewedByProfileId: { visibility: 'hidden' },\n duplicateOfId: { visibility: 'hidden' },\n },\n },\n ExpenseReceipt: {\n fields: {\n contentSha256: { visibility: 'hidden' },\n byteCount: { visibility: 'hidden' },\n uploadedByProfileId: { visibility: 'hidden' },\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