@happyvertical/smrt-expenses 0.60.13 → 0.60.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/AGENTS.md +15 -2
  2. package/README.md +8 -0
  3. package/agents/allocation-test-matrix.md +82 -0
  4. package/agents/reviewed-allocations.md +138 -0
  5. package/dist/allocation-internal.d.ts +6 -0
  6. package/dist/allocation-internal.d.ts.map +1 -0
  7. package/dist/chunks/{Expense-CimA4lxE.js → Expense-Deq19w2r.js} +28 -3
  8. package/dist/chunks/Expense-Deq19w2r.js.map +1 -0
  9. package/dist/chunks/{ExpenseReceiptCollection-CSBrNDzv.js → ExpenseReceiptCollection-D4Na93BF.js} +37 -3
  10. package/dist/chunks/ExpenseReceiptCollection-D4Na93BF.js.map +1 -0
  11. package/dist/chunks/{expense-actions-DiIhw0xO.js → expense-actions-DszuHacx.js} +2 -2
  12. package/dist/chunks/{expense-actions-DiIhw0xO.js.map → expense-actions-DszuHacx.js.map} +1 -1
  13. package/dist/collections/ExpenseCollection.d.ts +5 -5
  14. package/dist/collections/ExpenseCollection.d.ts.map +1 -1
  15. package/dist/expense-allocation.d.ts +133 -0
  16. package/dist/expense-allocation.d.ts.map +1 -0
  17. package/dist/index.d.ts +3 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1001 -21
  20. package/dist/index.js.map +1 -1
  21. package/dist/manifest.json +2359 -627
  22. package/dist/models/Expense.d.ts +2 -6
  23. package/dist/models/Expense.d.ts.map +1 -1
  24. package/dist/models/ExpenseAllocation.d.ts +117 -0
  25. package/dist/models/ExpenseAllocation.d.ts.map +1 -0
  26. package/dist/models/ExpenseReceipt.d.ts +7 -0
  27. package/dist/models/ExpenseReceipt.d.ts.map +1 -1
  28. package/dist/permissions.d.ts +5 -0
  29. package/dist/permissions.d.ts.map +1 -0
  30. package/dist/recipes.d.ts +3 -0
  31. package/dist/recipes.d.ts.map +1 -1
  32. package/dist/smrt-knowledge.json +746 -108
  33. package/dist/smrt-knowledge.okf.md +17 -3
  34. package/dist/types.d.ts +2 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js.map +1 -1
  37. package/package.json +9 -9
  38. package/dist/chunks/Expense-CimA4lxE.js.map +0 -1
  39. package/dist/chunks/ExpenseReceiptCollection-CSBrNDzv.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/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.60.13\\\",\\\"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\\\":{\\\"recordSupplierPayable\\\":{\\\"name\\\":\\\"recordSupplierPayable\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"recordSupplierPayableEvent\\\":{\\\"name\\\":\\\"recordSupplierPayableEvent\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableEventInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"completeSupplierPayableBasis\\\":{\\\"name\\\":\\\"completeSupplierPayableBasis\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"CompleteSupplierPayableBasisInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"supplierPayablePosition\\\":{\\\"name\\\":\\\"supplierPayablePosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"string\\\"]}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition | null>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"reimbursementPosition\\\":{\\\"name\\\":\\\"reimbursementPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"sourceId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseReimbursementPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"refundPosition\\\":{\\\"name\\\":\\\"refundPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"sourceId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseRefundPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"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\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-expenses:Expense\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expenses\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 \\\\\\\"supplier_payable_json\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"refund_recipient\\\\\\\" TEXT,\\\\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_amount\\\\\\\" INTEGER,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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},\\\"supplier_payable_json\\\":{\\\"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\\\"}},\\\"refund_recipient\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"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_amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"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\\\":\\\"81a9a368\\\"},\\\"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\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_receipts\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":\\\"8ed688ee\\\"},\\\"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\\\":{}},\\\"supplierPayableJson\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"nullable\\\":true,\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"paidByName\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"refundOfId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"refundRecipient\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"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\\\":{}},\\\"reimbursedAmount\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"nullable\\\":true,\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"reimbursedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"reimbursementReference\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true}},\\\"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},\\\"getRefundRecipient\\\":{\\\"name\\\":\\\"getRefundRecipient\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"ExpenseRefundRecipient | null\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"setRefundRecipient\\\":{\\\"name\\\":\\\"setRefundRecipient\\\",\\\"async\\\":false,\\\"parameters\\\":[{\\\"name\\\":\\\"value\\\",\\\"type\\\":\\\"ExpenseRefundRecipient | null\\\",\\\"optional\\\":false,\\\"unionBranches\\\":[{\\\"type\\\":\\\"ExpenseRefundRecipient\\\"},{\\\"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\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"SmrtSaveOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"recordSupplierPayable\\\":{\\\"name\\\":\\\"recordSupplierPayable\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"recordSupplierPayableEvent\\\":{\\\"name\\\":\\\"recordSupplierPayableEvent\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableEventInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"completeSupplierPayableBasis\\\":{\\\"name\\\":\\\"completeSupplierPayableBasis\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"CompleteSupplierPayableBasisInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getSupplierPayablePosition\\\":{\\\"name\\\":\\\"getSupplierPayablePosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"string\\\"]}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition | null>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"delete\\\":{\\\"name\\\":\\\"delete\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"Date | string\\\"]}],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getReimbursementPosition\\\":{\\\"name\\\":\\\"getReimbursementPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<ExpenseReimbursementPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getRefundPosition\\\":{\\\"name\\\":\\\"getRefundPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<ExpenseRefundPosition>\\\",\\\"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 \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 \\\\\\\"supplier_payable_json\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"refund_recipient\\\\\\\" TEXT,\\\\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_amount\\\\\\\" INTEGER,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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},\\\"supplier_payable_json\\\":{\\\"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\\\"}},\\\"refund_recipient\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"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_amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"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\\\":\\\"81a9a368\\\"},\\\"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\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"SmrtSaveOptions\\\",\\\"optional\\\":true}],\\\"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 \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":\\\"8ed688ee\\\"},\\\"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\\\"},\\\"supplierPayableJson\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"refundRecipient\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"reimbursedAmount\\\":{\\\"help\\\":\\\"The recorded amount paid back to the person who paid.\\\"},\\\"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 type {\n CompleteSupplierPayableBasisInput,\n RecordSupplierPayableEventInput,\n RecordSupplierPayableInput,\n SupplierPayablePosition,\n} from '../supplier-payable.js';\nimport {\n type CommitmentPosition,\n type CurrencyTotals,\n ExpenseError,\n type ExpenseFinancialBreakdown,\n type ExpenseRefundPosition,\n type ExpenseReimbursementPosition,\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 /** Record immutable original supplier retention/payable evidence on its Expense. */\n async recordSupplierPayable(\n expenseId: string,\n input: RecordSupplierPayableInput,\n ): Promise<SupplierPayablePosition> {\n const expense = await this.requireSupplierPayableExpense(expenseId);\n return expense.recordSupplierPayable(input);\n }\n\n /** Append a dated supplier event; no external money movement is executed. */\n async recordSupplierPayableEvent(\n expenseId: string,\n input: RecordSupplierPayableEventInput,\n ): Promise<SupplierPayablePosition> {\n return (\n await this.requireSupplierPayableExpense(expenseId)\n ).recordSupplierPayableEvent(input);\n }\n\n /** Independently review an originally unknown payable basis exactly once. */\n async completeSupplierPayableBasis(\n expenseId: string,\n input: CompleteSupplierPayableBasisInput,\n ): Promise<SupplierPayablePosition> {\n return (\n await this.requireSupplierPayableExpense(expenseId)\n ).completeSupplierPayableBasis(input);\n }\n\n /** Dated supplier position is independent of incurred cost and reimbursement. */\n async supplierPayablePosition(\n expenseId: string,\n input: { asOfDate?: string } = {},\n ): Promise<SupplierPayablePosition | null> {\n return (\n await this.requireSupplierPayableExpense(expenseId)\n ).getSupplierPayablePosition(input);\n }\n\n private async requireSupplierPayableExpense(\n expenseId: string,\n ): Promise<Expense> {\n const expense = await this.get({ id: expenseId }, { cache: false });\n if (!expense)\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n 'Supplier payable source was not found.',\n );\n return expense;\n }\n\n /** Cash claim after explicit refund receipts and retained historical payments. */\n async reimbursementPosition(\n sourceId: string,\n ): Promise<ExpenseReimbursementPosition> {\n const source = await this.get({ id: sourceId }, { cache: false });\n if (!source)\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n 'Reimbursement source was not found.',\n );\n return source.getReimbursementPosition();\n }\n\n /** All persisted linked refunds reserve source capacity, irrespective of review. */\n async refundPosition(sourceId: string): Promise<ExpenseRefundPosition> {\n const source = await this.get({ id: sourceId }, { cache: false });\n if (!source)\n throw new ExpenseError('EXPENSE_INVALID', 'Refund source was not found.');\n return source.getRefundPosition();\n }\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 supplierPayableJson: { visibility: 'hidden' },\n refundRecipient: { visibility: 'hidden' },\n reimbursedAmount: {\n help: 'The recorded amount paid back to the person who paid.',\n },\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' },\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,SAAS;GACnC,qBAAqB,EAAE,YAAY,SAAS;GAC5C,cAAc,EAAE,YAAY,SAAS;GACrC,kBAAkB,EAAE,YAAY,SAAS;GACzC,qBAAqB,EAAE,YAAY,SAAS;GAC5C,eAAe,EAAE,YAAY,SAAS;EACxC,EACF;EACA,gBAAgB,EACd,QAAQ;GACN,eAAe,EAAE,YAAY,SAAS;GACtC,WAAW,EAAE,YAAY,SAAS;GAClC,qBAAqB,EAAE,YAAY,SAAS;EAC9C,EACF;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["children","identity"],"sources":["../src/__smrt-register__.ts","../src/permissions.ts","../src/models/ExpenseAllocation.ts","../src/expense-allocation.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.60.15\\\",\\\"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\\\":{\\\"recordSupplierPayable\\\":{\\\"name\\\":\\\"recordSupplierPayable\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"recordSupplierPayableEvent\\\":{\\\"name\\\":\\\"recordSupplierPayableEvent\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableEventInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"completeSupplierPayableBasis\\\":{\\\"name\\\":\\\"completeSupplierPayableBasis\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"CompleteSupplierPayableBasisInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"supplierPayablePosition\\\":{\\\"name\\\":\\\"supplierPayablePosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"expenseId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"string\\\"]}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition | null>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"reimbursementPosition\\\":{\\\"name\\\":\\\"reimbursementPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"sourceId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseReimbursementPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"refundPosition\\\":{\\\"name\\\":\\\"refundPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"sourceId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseRefundPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"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},\\\"reviewAllocation\\\":{\\\"name\\\":\\\"reviewAllocation\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"ReviewExpenseAllocationInput\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"authority\\\",\\\"type\\\":\\\"ExpenseAllocationAuthority\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<ExpenseAllocationResult>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"withdrawAllocation\\\":{\\\"name\\\":\\\"withdrawAllocation\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"WithdrawExpenseAllocationInput\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"authority\\\",\\\"type\\\":\\\"ExpenseAllocationAuthority\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<WithdrawExpenseAllocationResult>\\\",\\\"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\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-expenses:Expense\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expenses\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expenses\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 \\\\\\\"supplier_payable_json\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"refund_recipient\\\\\\\" TEXT,\\\\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_amount\\\\\\\" INTEGER,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT,\\\\n \\\\\\\"active_allocation_revision_id\\\\\\\" UUID\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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},\\\"supplier_payable_json\\\":{\\\"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\\\"}},\\\"refund_recipient\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"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_amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursement_reference\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"active_allocation_revision_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_revisions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}}},\\\"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\\\"]},{\\\"name\\\":\\\"expenses_active_allocation_revision_id_idx\\\",\\\"columns\\\":[\\\"active_allocation_revision_id\\\"]}],\\\"version\\\":\\\"f8413307\\\"},\\\"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\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-expenses:ExpenseReceipt\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expense_receipts\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_receipts\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":\\\"8ed688ee\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:Revisions\\\":{\\\"name\\\":\\\"revisions\\\",\\\"className\\\":\\\"Revisions\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:Revisions\\\",\\\"collection\\\":\\\"expenseallocationrevisions\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/expense-allocation.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"tableName\\\":\\\"expense_allocation_revisions\\\"},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"ExpenseAllocationRevision\\\",\\\"exportName\\\":\\\"Revisions\\\",\\\"collectionExportName\\\":\\\"RevisionsCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-expenses:ExpenseAllocationRevision\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expense_allocation_revisions\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_allocation_revisions\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 \\\\\\\"kind\\\\\\\" TEXT DEFAULT 'allocation',\\\\n \\\\\\\"source_cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"source_cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"incurred_on\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by\\\\\\\" TEXT DEFAULT 'company',\\\\n \\\\\\\"reimbursable\\\\\\\" BOOLEAN NOT NULL DEFAULT FALSE,\\\\n \\\\\\\"has_supplier_tax\\\\\\\" BOOLEAN,\\\\n \\\\\\\"basis_equals_gross\\\\\\\" BOOLEAN NOT NULL DEFAULT FALSE,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"source_expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"previous_revision_id\\\\\\\" UUID,\\\\n \\\\\\\"request_id\\\\\\\" TEXT,\\\\n \\\\\\\"request_fingerprint\\\\\\\" TEXT,\\\\n \\\\\\\"source_fingerprint\\\\\\\" TEXT,\\\\n \\\\\\\"source_fingerprint_nonce\\\\\\\" TEXT,\\\\n \\\\\\\"source_revision\\\\\\\" TEXT,\\\\n \\\\\\\"amount_minor\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT,\\\\n \\\\\\\"reviewed_by_profile_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"reviewed_by_user_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"review_evidence\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\"},\\\"kind\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"default\\\":\\\"allocation\\\"},\\\"source_cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"incurred_on\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"default\\\":\\\"company\\\"},\\\"reimbursable\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":false},\\\"has_supplier_tax\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"basis_equals_gross\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":false},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"source_expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"previous_revision_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_revisions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"request_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_fingerprint\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_fingerprint\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_fingerprint_nonce\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_revision\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount_minor\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"reviewed_by_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"review_evidence\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_revisions_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_request_key\\\",\\\"columns\\\":[\\\"source_expense_id\\\",\\\"request_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_revision_successor\\\",\\\"columns\\\":[\\\"previous_revision_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_revisions_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_allocation_revisions_reviewed_by_profile_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_profile_id\\\"]},{\\\"name\\\":\\\"expense_allocation_revisions_reviewed_by_user_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_user_id\\\"]}],\\\"version\\\":\\\"83425a51\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:Portions\\\":{\\\"name\\\":\\\"portions\\\",\\\"className\\\":\\\"Portions\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:Portions\\\",\\\"collection\\\":\\\"expenseallocationportions\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/expense-allocation.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"tableName\\\":\\\"expense_allocation_portions\\\"},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"ExpenseAllocationPortion\\\",\\\"exportName\\\":\\\"Portions\\\",\\\"collectionExportName\\\":\\\"PortionsCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-expenses:ExpenseAllocationPortion\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expense_allocation_portions\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_allocation_portions\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 NOT NULL,\\\\n \\\\\\\"source_expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"revision_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"portion_key\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"cost_code_ref\\\\\\\" TEXT,\\\\n \\\\\\\"amount_minor\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":true,\\\"unique\\\":false},\\\"source_expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"revision_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_revisions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"portion_key\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_code_ref\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount_minor\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_portions_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_portion_key\\\",\\\"columns\\\":[\\\"revision_id\\\",\\\"portion_key\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_portions_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_allocation_portions_source_expense_id_idx\\\",\\\"columns\\\":[\\\"source_expense_id\\\"]}],\\\"version\\\":\\\"6b0600b1\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:Billings\\\":{\\\"name\\\":\\\"billings\\\",\\\"className\\\":\\\"Billings\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:Billings\\\",\\\"collection\\\":\\\"expenseallocationbillings\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/expense-allocation.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"tableName\\\":\\\"expense_allocation_billings\\\"},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"ExpenseAllocationBilling\\\",\\\"exportName\\\":\\\"Billings\\\",\\\"collectionExportName\\\":\\\"BillingsCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-expenses:ExpenseAllocationBilling\\\",\\\"schema\\\":{\\\"tableName\\\":\\\"expense_allocation_billings\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_allocation_billings\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 NOT NULL,\\\\n \\\\\\\"source_expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"portion_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"invoice_id\\\\\\\" UUID,\\\\n \\\\\\\"draft_type\\\\\\\" TEXT,\\\\n \\\\\\\"draft_id\\\\\\\" TEXT,\\\\n \\\\\\\"invoice_line_id\\\\\\\" UUID,\\\\n \\\\\\\"request_id\\\\\\\" TEXT,\\\\n \\\\\\\"request_fingerprint\\\\\\\" TEXT,\\\\n \\\\\\\"related_reservation_id\\\\\\\" UUID,\\\\n \\\\\\\"kind\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":true,\\\"unique\\\":false},\\\"source_expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"portion_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_portions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"invoice_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"draft_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"draft_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"invoice_line_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_fingerprint\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"related_reservation_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_billings\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"kind\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_billings_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_billing_request\\\",\\\"columns\\\":[\\\"source_expense_id\\\",\\\"request_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_billing_release\\\",\\\"columns\\\":[\\\"related_reservation_id\\\",\\\"kind\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_billings_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_allocation_billings_portion_id_idx\\\",\\\"columns\\\":[\\\"portion_id\\\"]},{\\\"name\\\":\\\"expense_allocation_billings_invoice_id_idx\\\",\\\"columns\\\":[\\\"invoice_id\\\"]},{\\\"name\\\":\\\"expense_allocation_billings_invoice_line_id_idx\\\",\\\"columns\\\":[\\\"invoice_line_id\\\"]}],\\\"version\\\":\\\"432aeb1f\\\"},\\\"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\\\":{}},\\\"supplierPayableJson\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"nullable\\\":true,\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"paidByName\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"refundOfId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"refundRecipient\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"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\\\":{}},\\\"reimbursedAmount\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"nullable\\\":true,\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"reimbursedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"reimbursementReference\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"readonly\\\":true},\\\"readonly\\\":true},\\\"activeAllocationRevisionId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"ExpenseAllocationRevision\\\",\\\"_meta\\\":{\\\"readonly\\\":true,\\\"nullable\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"},\\\"readonly\\\":true}},\\\"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},\\\"getRefundRecipient\\\":{\\\"name\\\":\\\"getRefundRecipient\\\",\\\"async\\\":false,\\\"parameters\\\":[],\\\"returnType\\\":\\\"ExpenseRefundRecipient | null\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"setRefundRecipient\\\":{\\\"name\\\":\\\"setRefundRecipient\\\",\\\"async\\\":false,\\\"parameters\\\":[{\\\"name\\\":\\\"value\\\",\\\"type\\\":\\\"ExpenseRefundRecipient | null\\\",\\\"optional\\\":false,\\\"unionBranches\\\":[{\\\"type\\\":\\\"ExpenseRefundRecipient\\\"},{\\\"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\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"SmrtSaveOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"recordSupplierPayable\\\":{\\\"name\\\":\\\"recordSupplierPayable\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"recordSupplierPayableEvent\\\":{\\\"name\\\":\\\"recordSupplierPayableEvent\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"RecordSupplierPayableEventInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"completeSupplierPayableBasis\\\":{\\\"name\\\":\\\"completeSupplierPayableBasis\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"CompleteSupplierPayableBasisInput\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getSupplierPayablePosition\\\":{\\\"name\\\":\\\"getSupplierPayablePosition\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"input\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"string\\\"]}],\\\"returnType\\\":\\\"Promise<SupplierPayablePosition | null>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"delete\\\":{\\\"name\\\":\\\"delete\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"Date | string\\\"]}],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getReimbursementPosition\\\":{\\\"name\\\":\\\"getReimbursementPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<ExpenseReimbursementPosition>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"getRefundPosition\\\":{\\\"name\\\":\\\"getRefundPosition\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<ExpenseRefundPosition>\\\",\\\"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 \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 \\\\\\\"supplier_payable_json\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by_name\\\\\\\" TEXT,\\\\n \\\\\\\"refund_of_id\\\\\\\" UUID,\\\\n \\\\\\\"refund_recipient\\\\\\\" TEXT,\\\\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_amount\\\\\\\" INTEGER,\\\\n \\\\\\\"reimbursed_at\\\\\\\" TIMESTAMP,\\\\n \\\\\\\"reimbursement_reference\\\\\\\" TEXT,\\\\n \\\\\\\"active_allocation_revision_id\\\\\\\" UUID\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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},\\\"supplier_payable_json\\\":{\\\"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\\\"}},\\\"refund_recipient\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"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_amount\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursed_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reimbursement_reference\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"active_allocation_revision_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_revisions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}}},\\\"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\\\"]},{\\\"name\\\":\\\"expenses_active_allocation_revision_id_idx\\\",\\\"columns\\\":[\\\"active_allocation_revision_id\\\"]}],\\\"version\\\":\\\"f8413307\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:ExpenseAllocationRevision\\\":{\\\"name\\\":\\\"expenseallocationrevision\\\",\\\"className\\\":\\\"ExpenseAllocationRevision\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseAllocationRevision\\\",\\\"collection\\\":\\\"expenseallocationrevisions\\\",\\\"description\\\":\\\"Persisted command-owned ExpenseAllocationRevision evidence.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseAllocation.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{\\\"kind\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"default\\\":\\\"allocation\\\",\\\"enum\\\":[\\\"allocation\\\",\\\"withdrawal\\\"]},\\\"sourceCostObjectType\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"sourceCostObjectId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"incurredOn\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"paidBy\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false,\\\"default\\\":\\\"company\\\",\\\"enum\\\":[\\\"company\\\",\\\"person\\\",\\\"third-party\\\"]},\\\"reimbursable\\\":{\\\"type\\\":\\\"boolean\\\",\\\"required\\\":true,\\\"default\\\":false},\\\"hasSupplierTax\\\":{\\\"type\\\":\\\"boolean\\\",\\\"required\\\":false,\\\"_meta\\\":{\\\"nullable\\\":true}},\\\"basisEqualsGross\\\":{\\\"type\\\":\\\"boolean\\\",\\\"required\\\":true,\\\"default\\\":false},\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":true,\\\"_meta\\\":{\\\"sqlType\\\":\\\"UUID\\\",\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false}}},\\\"sourceExpenseId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":true,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"required\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"previousRevisionId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"ExpenseAllocationRevision\\\",\\\"_meta\\\":{\\\"nullable\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"requestId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"requestFingerprint\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"sourceFingerprint\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"sourceFingerprintNonce\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"sourceRevision\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"amountMinor\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"currency\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"reviewedByProfileId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":true,\\\"related\\\":\\\"@happyvertical/smrt-profiles:Profile\\\"},\\\"reviewedByUserId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":true,\\\"related\\\":\\\"@happyvertical/smrt-users:User\\\"},\\\"reviewEvidence\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false}},\\\"methods\\\":{\\\"save\\\":{\\\"name\\\":\\\"save\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"SmrtSaveOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"delete\\\":{\\\"name\\\":\\\"delete\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"expense_allocation_revisions\\\",\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_request_key\\\",\\\"columns\\\":[\\\"sourceExpenseId\\\",\\\"requestId\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_revision_successor\\\",\\\"columns\\\":[\\\"previousRevisionId\\\"],\\\"unique\\\":true}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ExpenseAllocationRevision\\\",\\\"collectionExportName\\\":\\\"ExpenseAllocationRevisionCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"reimbursable\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"boolean\\\"},{\\\"field\\\":\\\"basisEqualsGross\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"boolean\\\"},{\\\"field\\\":\\\"sourceExpenseId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"},{\\\"field\\\":\\\"reviewedByProfileId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"crossPackageRef\\\"},{\\\"field\\\":\\\"reviewedByUserId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"crossPackageRef\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"expense_allocation_revisions\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_allocation_revisions\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 \\\\\\\"kind\\\\\\\" TEXT DEFAULT 'allocation',\\\\n \\\\\\\"source_cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"source_cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"incurred_on\\\\\\\" TEXT,\\\\n \\\\\\\"paid_by\\\\\\\" TEXT DEFAULT 'company',\\\\n \\\\\\\"reimbursable\\\\\\\" BOOLEAN NOT NULL DEFAULT FALSE,\\\\n \\\\\\\"has_supplier_tax\\\\\\\" BOOLEAN,\\\\n \\\\\\\"basis_equals_gross\\\\\\\" BOOLEAN NOT NULL DEFAULT FALSE,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"source_expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"previous_revision_id\\\\\\\" UUID,\\\\n \\\\\\\"request_id\\\\\\\" TEXT,\\\\n \\\\\\\"request_fingerprint\\\\\\\" TEXT,\\\\n \\\\\\\"source_fingerprint\\\\\\\" TEXT,\\\\n \\\\\\\"source_fingerprint_nonce\\\\\\\" TEXT,\\\\n \\\\\\\"source_revision\\\\\\\" TEXT,\\\\n \\\\\\\"amount_minor\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT,\\\\n \\\\\\\"reviewed_by_profile_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"reviewed_by_user_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"review_evidence\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\"},\\\"kind\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"default\\\":\\\"allocation\\\"},\\\"source_cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"incurred_on\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"paid_by\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"default\\\":\\\"company\\\"},\\\"reimbursable\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":false},\\\"has_supplier_tax\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"basis_equals_gross\\\":{\\\"type\\\":\\\"BOOLEAN\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":false},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"source_expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"previous_revision_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_revisions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"request_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_fingerprint\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_fingerprint\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_fingerprint_nonce\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"source_revision\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount_minor\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reviewed_by_profile_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"reviewed_by_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"review_evidence\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_revisions_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_request_key\\\",\\\"columns\\\":[\\\"source_expense_id\\\",\\\"request_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_revision_successor\\\",\\\"columns\\\":[\\\"previous_revision_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_revisions_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_allocation_revisions_reviewed_by_profile_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_profile_id\\\"]},{\\\"name\\\":\\\"expense_allocation_revisions_reviewed_by_user_id_idx\\\",\\\"columns\\\":[\\\"reviewed_by_user_id\\\"]}],\\\"version\\\":\\\"83425a51\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:ExpenseAllocationPortion\\\":{\\\"name\\\":\\\"expenseallocationportion\\\",\\\"className\\\":\\\"ExpenseAllocationPortion\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseAllocationPortion\\\",\\\"collection\\\":\\\"expenseallocationportions\\\",\\\"description\\\":\\\"Persisted command-owned ExpenseAllocationPortion evidence.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseAllocation.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":true,\\\"_meta\\\":{\\\"sqlType\\\":\\\"UUID\\\",\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false}}},\\\"sourceExpenseId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":true,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"required\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"revisionId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":true,\\\"related\\\":\\\"ExpenseAllocationRevision\\\",\\\"_meta\\\":{\\\"required\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"portionKey\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"costObjectType\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"costObjectId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"costCodeRef\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"amountMinor\\\":{\\\"type\\\":\\\"integer\\\",\\\"required\\\":false,\\\"_meta\\\":{}},\\\"currency\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false}},\\\"methods\\\":{\\\"save\\\":{\\\"name\\\":\\\"save\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"SmrtSaveOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"delete\\\":{\\\"name\\\":\\\"delete\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"expense_allocation_portions\\\",\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_portion_key\\\",\\\"columns\\\":[\\\"revisionId\\\",\\\"portionKey\\\"],\\\"unique\\\":true}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ExpenseAllocationPortion\\\",\\\"collectionExportName\\\":\\\"ExpenseAllocationPortionCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"sourceExpenseId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"},{\\\"field\\\":\\\"revisionId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"expense_allocation_portions\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_allocation_portions\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 NOT NULL,\\\\n \\\\\\\"source_expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"revision_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"portion_key\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_type\\\\\\\" TEXT,\\\\n \\\\\\\"cost_object_id\\\\\\\" TEXT,\\\\n \\\\\\\"cost_code_ref\\\\\\\" TEXT,\\\\n \\\\\\\"amount_minor\\\\\\\" INTEGER,\\\\n \\\\\\\"currency\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":true,\\\"unique\\\":false},\\\"source_expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"revision_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_revisions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"portion_key\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_object_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"cost_code_ref\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"amount_minor\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"currency\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_portions_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_portion_key\\\",\\\"columns\\\":[\\\"revision_id\\\",\\\"portion_key\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_portions_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_allocation_portions_source_expense_id_idx\\\",\\\"columns\\\":[\\\"source_expense_id\\\"]}],\\\"version\\\":\\\"6b0600b1\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-expenses\\\"},\\\"@happyvertical/smrt-expenses:ExpenseAllocationBilling\\\":{\\\"name\\\":\\\"expenseallocationbilling\\\",\\\"className\\\":\\\"ExpenseAllocationBilling\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-expenses:ExpenseAllocationBilling\\\",\\\"collection\\\":\\\"expenseallocationbillings\\\",\\\"description\\\":\\\"Persisted command-owned ExpenseAllocationBilling evidence.\\\",\\\"filePath\\\":\\\"/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseAllocation.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-expenses\\\",\\\"fields\\\":{\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":true,\\\"_meta\\\":{\\\"sqlType\\\":\\\"UUID\\\",\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false}}},\\\"sourceExpenseId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":true,\\\"related\\\":\\\"Expense\\\",\\\"_meta\\\":{\\\"required\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"portionId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":true,\\\"related\\\":\\\"ExpenseAllocationPortion\\\",\\\"_meta\\\":{\\\"required\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"invoiceId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:Invoice\\\",\\\"_meta\\\":{\\\"nullable\\\":true}},\\\"draftType\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"draftId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"invoiceLineId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-commerce:InvoiceLineItem\\\",\\\"_meta\\\":{\\\"nullable\\\":true}},\\\"requestId\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"requestFingerprint\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false},\\\"relatedReservationId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"required\\\":false,\\\"related\\\":\\\"ExpenseAllocationBilling\\\",\\\"_meta\\\":{\\\"nullable\\\":true,\\\"onDelete\\\":\\\"RESTRICT\\\"}},\\\"kind\\\":{\\\"type\\\":\\\"text\\\",\\\"required\\\":false}},\\\"methods\\\":{\\\"save\\\":{\\\"name\\\":\\\"save\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"SmrtSaveOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"delete\\\":{\\\"name\\\":\\\"delete\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"expense_allocation_billings\\\",\\\"api\\\":{\\\"include\\\":[]},\\\"mcp\\\":{\\\"include\\\":[]},\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_billing_request\\\",\\\"columns\\\":[\\\"sourceExpenseId\\\",\\\"requestId\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_billing_release\\\",\\\"columns\\\":[\\\"relatedReservationId\\\",\\\"kind\\\"],\\\"unique\\\":true}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ExpenseAllocationBilling\\\",\\\"collectionExportName\\\":\\\"ExpenseAllocationBillingCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"sourceExpenseId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"},{\\\"field\\\":\\\"portionId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"expense_allocation_billings\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"expense_allocation_billings\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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 NOT NULL,\\\\n \\\\\\\"source_expense_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"portion_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"invoice_id\\\\\\\" UUID,\\\\n \\\\\\\"draft_type\\\\\\\" TEXT,\\\\n \\\\\\\"draft_id\\\\\\\" TEXT,\\\\n \\\\\\\"invoice_line_id\\\\\\\" UUID,\\\\n \\\\\\\"request_id\\\\\\\" TEXT,\\\\n \\\\\\\"request_fingerprint\\\\\\\" TEXT,\\\\n \\\\\\\"related_reservation_id\\\\\\\" UUID,\\\\n \\\\\\\"kind\\\\\\\" TEXT\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":true,\\\"unique\\\":false},\\\"source_expense_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expenses\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"portion_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_portions\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"invoice_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"draft_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"draft_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"invoice_line_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_fingerprint\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"related_reservation_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"foreignKey\\\":{\\\"table\\\":\\\"expense_allocation_billings\\\",\\\"column\\\":\\\"id\\\",\\\"onDelete\\\":\\\"RESTRICT\\\",\\\"onUpdate\\\":\\\"CASCADE\\\"}},\\\"kind\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"expense_allocation_billings_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_billing_request\\\",\\\"columns\\\":[\\\"source_expense_id\\\",\\\"request_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_billing_release\\\",\\\"columns\\\":[\\\"related_reservation_id\\\",\\\"kind\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"expense_allocation_billings_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"expense_allocation_billings_portion_id_idx\\\",\\\"columns\\\":[\\\"portion_id\\\"]},{\\\"name\\\":\\\"expense_allocation_billings_invoice_id_idx\\\",\\\"columns\\\":[\\\"invoice_id\\\"]},{\\\"name\\\":\\\"expense_allocation_billings_invoice_line_id_idx\\\",\\\"columns\\\":[\\\"invoice_line_id\\\"]}],\\\"version\\\":\\\"432aeb1f\\\"},\\\"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\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"SmrtSaveOptions\\\",\\\"optional\\\":true}],\\\"returnType\\\":\\\"Promise<this>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true},\\\"delete\\\":{\\\"name\\\":\\\"delete\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"options\\\",\\\"type\\\":\\\"object\\\",\\\"optional\\\":true,\\\"memberTypes\\\":[\\\"Date | string\\\"]}],\\\"returnType\\\":\\\"Promise<void>\\\",\\\"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 \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\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\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"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\\\":\\\"8ed688ee\\\"},\\\"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\\\"},\\\"activeAllocationRevisionId\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"financialBreakdown\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"supplierPayableJson\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"refundRecipient\\\":{\\\"visibility\\\":\\\"hidden\\\"},\\\"reimbursedAmount\\\":{\\\"help\\\":\\\"The recorded amount paid back to the person who paid.\\\"},\\\"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","/** Explicit bounded-read permission independent of the deliberately closed generated expense surface. */\nimport {\n type PermissionDefinition,\n registerPermissionDefinitions,\n} from '@happyvertical/smrt-users';\n/** Hosts grant this real catalog permission alongside their project cost visibility policy. */\nexport const EXPENSE_ALLOCATION_PERMISSION_DEFINITIONS: PermissionDefinition[] =\n [\n {\n slug: 'expenses.read',\n name: 'Read allocated expense portions',\n description:\n 'Read bounded expense allocation portions through current host target authority; does not expose original expense or receipt records.',\n category: 'accounting',\n },\n ];\nregisterPermissionDefinitions(EXPENSE_ALLOCATION_PERMISSION_DEFINITIONS);\n","/** Immutable reviewed allocations and local invoice reservations. No generated surface. */\nimport {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n type SmrtSaveOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport { allocationWrites } from '../allocation-internal.js';\n\nexport interface ExpenseAllocationRevisionOptions extends SmrtObjectOptions {\n kind?: 'allocation' | 'withdrawal';\n sourceCostObjectType?: string;\n sourceCostObjectId?: string;\n incurredOn?: string;\n paidBy?: 'company' | 'person' | 'third-party';\n reimbursable?: boolean;\n hasSupplierTax?: boolean | null;\n basisEqualsGross?: boolean;\n tenantId?: string;\n sourceExpenseId?: string;\n previousRevisionId?: string | null;\n requestId?: string;\n requestFingerprint?: string;\n sourceFingerprint?: string;\n sourceFingerprintNonce?: string;\n sourceRevision?: string;\n amountMinor?: number;\n currency?: string;\n reviewedByProfileId?: string;\n reviewedByUserId?: string;\n reviewEvidence?: string;\n}\n/** Persisted command-owned ExpenseAllocationRevision evidence. */\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'expense_allocation_revisions',\n api: { include: [] },\n mcp: { include: [] },\n cli: false,\n indexes: [\n {\n name: 'expense_allocation_request_key',\n columns: ['sourceExpenseId', 'requestId'],\n unique: true,\n },\n {\n name: 'expense_allocation_revision_successor',\n columns: ['previousRevisionId'],\n unique: true,\n },\n ],\n})\nexport class ExpenseAllocationRevision extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n kind: 'allocation' | 'withdrawal' = 'allocation';\n /** Immutable bounded source facts retained even after unbilled withdrawal/correction. */\n sourceCostObjectType = '';\n sourceCostObjectId = '';\n incurredOn = '';\n paidBy: 'company' | 'person' | 'third-party' = 'company';\n reimbursable = false;\n @field({ type: 'boolean', nullable: true })\n hasSupplierTax: boolean | null = null;\n basisEqualsGross = false;\n @tenantId() tenantId = '';\n @foreignKey('Expense', { required: true, onDelete: 'RESTRICT' })\n sourceExpenseId = '';\n @foreignKey('ExpenseAllocationRevision', {\n nullable: true,\n onDelete: 'RESTRICT',\n })\n previousRevisionId: string | null = null;\n requestId = '';\n requestFingerprint = '';\n sourceFingerprint = '';\n /** Secret to bounded portion readers; prevents low-entropy source-total guessing from its digest. */\n sourceFingerprintNonce = '';\n sourceRevision = '';\n @field({ type: 'integer' })\n amountMinor = 0;\n currency = '';\n @crossPackageRef('@happyvertical/smrt-profiles:Profile', { required: true })\n reviewedByProfileId = '';\n @crossPackageRef('@happyvertical/smrt-users:User', { required: true })\n reviewedByUserId = '';\n reviewEvidence = '';\n constructor(options: ExpenseAllocationRevisionOptions = {}) {\n super(options);\n for (const key of [\n 'kind',\n 'sourceCostObjectType',\n 'sourceCostObjectId',\n 'incurredOn',\n 'paidBy',\n 'reimbursable',\n 'hasSupplierTax',\n 'basisEqualsGross',\n 'tenantId',\n 'sourceExpenseId',\n 'previousRevisionId',\n 'requestId',\n 'requestFingerprint',\n 'sourceFingerprint',\n 'sourceFingerprintNonce',\n 'sourceRevision',\n 'amountMinor',\n 'currency',\n 'reviewedByProfileId',\n 'reviewedByUserId',\n 'reviewEvidence',\n ] as const)\n if (options[key] !== undefined)\n Object.assign(this, { [key]: options[key] });\n }\n /** Refuse all writes except command-owned inserts, including same-id adoption. */\n override async save(options?: SmrtSaveOptions): Promise<this> {\n if (!allocationWrites.has(this) || !this.tenantId || this.isPersisted)\n throw new Error(\n 'Expense allocation evidence is command-owned and immutable',\n );\n this.requireInsertOnSave();\n return super.save(options);\n }\n /** Evidence cannot be erased, including superseded revisions. */\n override async delete(): Promise<void> {\n throw new Error('Expense allocation evidence cannot be deleted');\n }\n}\n\nexport interface ExpenseAllocationPortionOptions extends SmrtObjectOptions {\n tenantId?: string;\n sourceExpenseId?: string;\n revisionId?: string;\n portionKey?: string;\n costObjectType?: string;\n costObjectId?: string;\n costCodeRef?: string;\n amountMinor?: number;\n currency?: string;\n}\n/** Persisted command-owned ExpenseAllocationPortion evidence. */\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'expense_allocation_portions',\n api: { include: [] },\n mcp: { include: [] },\n cli: false,\n indexes: [\n {\n name: 'expense_allocation_portion_key',\n columns: ['revisionId', 'portionKey'],\n unique: true,\n },\n ],\n})\nexport class ExpenseAllocationPortion extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n @tenantId() tenantId = '';\n @foreignKey('Expense', { required: true, onDelete: 'RESTRICT' })\n sourceExpenseId = '';\n @foreignKey('ExpenseAllocationRevision', {\n required: true,\n onDelete: 'RESTRICT',\n })\n revisionId = '';\n portionKey = '';\n costObjectType = '';\n costObjectId = '';\n costCodeRef = '';\n @field({ type: 'integer' })\n amountMinor = 0;\n currency = '';\n constructor(options: ExpenseAllocationPortionOptions = {}) {\n super(options);\n for (const key of [\n 'tenantId',\n 'sourceExpenseId',\n 'revisionId',\n 'portionKey',\n 'costObjectType',\n 'costObjectId',\n 'costCodeRef',\n 'amountMinor',\n 'currency',\n ] as const)\n if (options[key] !== undefined)\n Object.assign(this, { [key]: options[key] });\n }\n /** Refuse all writes except command-owned inserts, including same-id adoption. */\n override async save(options?: SmrtSaveOptions): Promise<this> {\n if (!allocationWrites.has(this) || !this.tenantId || this.isPersisted)\n throw new Error(\n 'Expense allocation evidence is command-owned and immutable',\n );\n this.requireInsertOnSave();\n return super.save(options);\n }\n /** Evidence cannot be erased, including superseded revisions. */\n override async delete(): Promise<void> {\n throw new Error('Expense allocation evidence cannot be deleted');\n }\n}\n\nexport interface ExpenseAllocationBillingOptions extends SmrtObjectOptions {\n tenantId?: string;\n sourceExpenseId?: string;\n portionId?: string;\n invoiceId?: string | null;\n draftType?: string;\n draftId?: string;\n invoiceLineId?: string | null;\n requestId?: string;\n requestFingerprint?: string;\n relatedReservationId?: string | null;\n kind?: string;\n}\n/** Persisted command-owned ExpenseAllocationBilling evidence. */\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'expense_allocation_billings',\n api: { include: [] },\n mcp: { include: [] },\n cli: false,\n indexes: [\n {\n name: 'expense_allocation_billing_request',\n columns: ['sourceExpenseId', 'requestId'],\n unique: true,\n },\n {\n name: 'expense_allocation_billing_release',\n columns: ['relatedReservationId', 'kind'],\n unique: true,\n },\n ],\n})\nexport class ExpenseAllocationBilling extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n @tenantId() tenantId = '';\n @foreignKey('Expense', { required: true, onDelete: 'RESTRICT' })\n sourceExpenseId = '';\n @foreignKey('ExpenseAllocationPortion', {\n required: true,\n onDelete: 'RESTRICT',\n })\n portionId = '';\n @crossPackageRef('@happyvertical/smrt-commerce:Invoice', { nullable: true })\n invoiceId: string | null = null;\n draftType = '';\n draftId = '';\n @crossPackageRef('@happyvertical/smrt-commerce:InvoiceLineItem', {\n nullable: true,\n })\n invoiceLineId: string | null = null;\n requestId = '';\n requestFingerprint = '';\n @foreignKey('ExpenseAllocationBilling', {\n nullable: true,\n onDelete: 'RESTRICT',\n })\n relatedReservationId: string | null = null;\n kind = 'reserve';\n constructor(options: ExpenseAllocationBillingOptions = {}) {\n super(options);\n for (const key of [\n 'tenantId',\n 'sourceExpenseId',\n 'portionId',\n 'invoiceId',\n 'draftType',\n 'draftId',\n 'invoiceLineId',\n 'requestId',\n 'requestFingerprint',\n 'relatedReservationId',\n 'kind',\n ] as const)\n if (options[key] !== undefined)\n Object.assign(this, { [key]: options[key] });\n }\n /** Refuse all writes except command-owned inserts, including same-id adoption. */\n override async save(options?: SmrtSaveOptions): Promise<this> {\n if (!allocationWrites.has(this) || !this.tenantId || this.isPersisted)\n throw new Error(\n 'Expense allocation evidence is command-owned and immutable',\n );\n this.requireInsertOnSave();\n return super.save(options);\n }\n /** Evidence cannot be erased, including superseded revisions. */\n override async delete(): Promise<void> {\n throw new Error('Expense allocation evidence cannot be deleted');\n }\n}\n","import './permissions.js';\n/** Reviewed expense attribution. The original expense remains the only spend/cash authority. */\nimport { createHash, randomBytes } from 'node:crypto';\nimport {\n bindInvoiceLineSource,\n InvoiceCollection,\n InvoiceLineItemCollection,\n registerInvoiceSourceBinding,\n unbindInvoiceLineSource,\n} from '@happyvertical/smrt-commerce';\nimport {\n isPostgresDatabase,\n ObjectRegistry,\n SmrtCollection,\n type SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';\nimport {\n authorizeExpenseAction,\n type ExpenseActionPrincipal,\n withActionPrincipal,\n} from './actions/principal.js';\nimport { allocationHeads, insertAllocation } from './allocation-internal.js';\nimport type { Expense } from './models/Expense.js';\nimport {\n ExpenseAllocationBilling,\n ExpenseAllocationPortion,\n ExpenseAllocationRevision,\n} from './models/ExpenseAllocation.js';\nimport { ExpenseError, type ExpensePayer } from './types.js';\nimport { assertQualifiedClassName, instantMs } from './validation.js';\n\n/** Explicit full attribution; no remainder or customer price is inferred. */\nexport interface ExpenseAllocationTarget {\n portionKey: string;\n costObjectType: string;\n costObjectId: string;\n costCodeRef: string;\n amountMinor: number;\n}\n/** Current host project authority, called for each old and proposed target. */\nexport interface ExpenseAllocationBillingAuthority\n extends ExpenseAllocationAuthority {\n /** Required when reserving against a host draft before a commerce invoice exists. */\n authorizeDraft?(\n principal: ExpenseActionPrincipal,\n target: Readonly<ExpenseAllocationTarget>,\n draft: { type: string; id: string },\n executor: DatabaseInterface,\n ): Promise<void>;\n /** Host must verify current invoice permissions and its project matches the portion target. */\n authorizeInvoice(\n principal: ExpenseActionPrincipal,\n target: Readonly<ExpenseAllocationTarget>,\n invoiceId: string,\n executor: DatabaseInterface,\n ): Promise<void>;\n}\n/** Source privacy decision distinguishes complete allocation editing from bounded portion billing. */\nexport interface ExpenseAllocationAuthorizationContext {\n action:\n | 'reviewAllocation'\n | 'reserveAllocation'\n | 'bindAllocation'\n | 'releaseAllocation'\n | 'withdrawAllocation';\n /** Present only for billing; contains the actor-authorized target's bounded facts, never source gross/receipts. */\n portion?: Readonly<ExpenseAllocationTarget> & { portionId: string };\n}\nexport interface ExpenseAllocationAuthority {\n /** Mandatory for withdrawal: current authority for the restored original unsplit destination, without a fabricated cost code. */\n authorizeUnsplitTarget?(\n principal: ExpenseActionPrincipal,\n target: Readonly<{\n sourceExpenseId: string;\n costObjectType: string;\n costObjectId: string;\n }>,\n executor: DatabaseInterface,\n ): Promise<void>;\n /** Required for full allocation review/history: enforce original-source privacy independently of target grants. */\n authorizeSource(\n principal: ExpenseActionPrincipal,\n sourceExpenseId: string,\n executor: DatabaseInterface,\n context: ExpenseAllocationAuthorizationContext,\n ): Promise<void>;\n authorizeTarget(\n principal: ExpenseActionPrincipal,\n target: Readonly<ExpenseAllocationTarget>,\n executor: DatabaseInterface,\n ): Promise<void>;\n}\n/** One review of a positive reviewed original. Revision is the loaded source updated_at. */\nexport interface ReviewExpenseAllocationInput {\n sourceExpenseId: string;\n expectedSourceRevision: Date | string;\n requestId: string;\n portions: readonly ExpenseAllocationTarget[];\n reviewEvidence: string;\n}\n/** Detached projection safe to expose only after target authorization. No receipt URLs or other portions. */\nexport interface ExpenseAllocationIdentity extends ExpenseAllocationTarget {\n portionId: string;\n sourceExpenseId: string;\n revisionId: string;\n sourceFingerprint: string;\n /** Frozen source calendar date; no sibling or private receipt data. */\n incurredOn: string;\n /** Bounded economic facts, without payer identity or original source money. */\n paidBy: ExpensePayer;\n reimbursable: boolean;\n hasSupplierTax: boolean | null;\n hasRefunds: boolean;\n /** Exact only when known original basis equals gross and no refunds exist; never prorated tax. */\n costBasisMinor: number | null;\n currency: string;\n active: boolean;\n}\n/** Snapshot of a committed review; callers must authorize before exposing its complete target list. */\nexport interface ExpenseAllocationResult {\n revision: ExpenseAllocationRevision;\n portions: ExpenseAllocationIdentity[];\n}\n\n@smrt({ api: { include: [] }, mcp: { include: [] }, cli: false })\nclass Revisions extends SmrtCollection<ExpenseAllocationRevision> { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n static readonly _itemClass = ExpenseAllocationRevision;\n}\n@smrt({ api: { include: [] }, mcp: { include: [] }, cli: false })\nclass Portions extends SmrtCollection<ExpenseAllocationPortion> { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n static readonly _itemClass = ExpenseAllocationPortion;\n}\n@smrt({ api: { include: [] }, mcp: { include: [] }, cli: false })\nclass Billings extends SmrtCollection<ExpenseAllocationBilling> { static __smrtPackage__ = \"@happyvertical/smrt-expenses\";\n static readonly _itemClass = ExpenseAllocationBilling;\n}\nfunction invalid(message: string): never {\n throw new ExpenseError('EXPENSE_INVALID', `Expense allocation: ${message}`);\n}\nfunction text(value: unknown): asserts value is string {\n if (\n typeof value !== 'string' ||\n !value.trim() ||\n value !== value.trim() ||\n value.length > 1000\n )\n invalid('bounded nonempty identifiers/evidence required.');\n}\nfunction digest(value: unknown): string {\n return createHash('sha256').update(JSON.stringify(value)).digest('hex');\n}\nfunction target(row: ExpenseAllocationTarget): ExpenseAllocationTarget {\n if (\n !row ||\n Object.keys(row).some(\n (key) =>\n ![\n 'portionKey',\n 'costObjectType',\n 'costObjectId',\n 'costCodeRef',\n 'amountMinor',\n ].includes(key),\n )\n )\n invalid('unknown portion field.');\n for (const value of [\n row.portionKey,\n row.costObjectType,\n row.costObjectId,\n row.costCodeRef,\n ])\n text(value);\n assertQualifiedClassName(\n 'ExpenseAllocation',\n row.portionKey,\n row.costObjectType,\n );\n if (!Number.isSafeInteger(row.amountMinor) || row.amountMinor <= 0)\n invalid('portions require positive safe integer minor units.');\n return {\n portionKey: row.portionKey,\n costObjectType: row.costObjectType,\n costObjectId: row.costObjectId,\n costCodeRef: row.costCodeRef,\n amountMinor: row.amountMinor,\n };\n}\n/** Read immutable children using a bounded-by-source relational query, never metadata. */\nasync function portionsFor(\n source: Expense,\n revisionId: string,\n): Promise<ExpenseAllocationPortion[]> {\n return (await Portions.create({ db: source.db })).list({\n where: { tenantId: source.tenantId, revisionId },\n limit: 1000,\n orderBy: ['portion_key ASC'],\n });\n}\nasync function sourceFor(\n db: DatabaseInterface,\n id: string,\n tenant: string,\n): Promise<Expense> {\n const { ExpenseCollection } = await import(\n './collections/ExpenseCollection.js'\n );\n const source = await (await ExpenseCollection.create({ db })).get(\n { id, tenantId: tenant },\n { cache: false },\n );\n if (!source || source.tenantId !== tenant) invalid('owned source required.');\n return source;\n}\nasync function lock(source: Expense): Promise<void> {\n if (isPostgresDatabase(source.db))\n await source.db.query(\n `SELECT id FROM \"${source.tableName}\" WHERE id = ? AND tenant_id = ? FOR UPDATE`,\n source.id,\n source.tenantId,\n );\n await source.loadFromId();\n}\nasync function authorize(\n source: Expense,\n principal: ExpenseActionPrincipal,\n authority: ExpenseAllocationAuthority,\n targets: readonly ExpenseAllocationTarget[],\n): Promise<void> {\n if (typeof authority?.authorizeTarget !== 'function')\n invalid('host target authorization is required.');\n for (const item of targets) {\n const registered = ObjectRegistry.getClassByQualifiedName(\n item.costObjectType,\n );\n if (!registered) invalid('unknown cost-object type.');\n const collection = await ObjectRegistry.getCollection<SmrtObject>(\n item.costObjectType,\n { db: source.db },\n );\n const object = await collection.get(\n { id: item.costObjectId },\n { cache: false },\n );\n if (\n !object ||\n (object as unknown as { tenantId?: string }).tenantId !==\n principal.tenantId\n )\n invalid('target must exist in the active tenant.');\n await authority.authorizeTarget(\n principal,\n Object.freeze({ ...item }),\n source.db,\n );\n }\n}\nasync function identity(\n source: Expense,\n revision: ExpenseAllocationRevision,\n row: ExpenseAllocationPortion,\n): Promise<ExpenseAllocationIdentity> {\n if (!row.id || !source.id || !revision.id)\n invalid('persisted allocation identities required.');\n const { ExpenseCollection } = await import(\n './collections/ExpenseCollection.js'\n );\n const refunds = await (\n await ExpenseCollection.create({ db: source.db })\n ).list({\n where: { refundOfId: source.id, tenantId: source.tenantId },\n select: ['id'],\n limit: 1,\n });\n const hasRefunds = refunds.length > 0;\n return {\n portionId: row.id,\n sourceExpenseId: source.id,\n revisionId: revision.id,\n sourceFingerprint: revision.sourceFingerprint,\n incurredOn: revision.incurredOn,\n paidBy: revision.paidBy,\n reimbursable: revision.reimbursable,\n hasSupplierTax: revision.hasSupplierTax,\n hasRefunds,\n costBasisMinor:\n !hasRefunds && revision.basisEqualsGross ? row.amountMinor : null,\n currency: revision.currency,\n active: source.activeAllocationRevisionId === revision.id,\n portionKey: row.portionKey,\n costObjectType: row.costObjectType,\n costObjectId: row.costObjectId,\n costCodeRef: row.costCodeRef,\n amountMinor: row.amountMinor,\n };\n}\nasync function activeReservations(\n source: Expense,\n): Promise<{ id: string; portionId: string }[]> {\n const result = await source.db.query(\n `SELECT r.id, r.portion_id FROM expense_allocation_billings r\n WHERE r.source_expense_id = ? AND r.tenant_id = ? AND r.kind = 'reserve'\n AND NOT EXISTS (SELECT 1 FROM expense_allocation_billings x\n WHERE x.related_reservation_id = r.id AND x.tenant_id = r.tenant_id AND x.kind = 'release')`,\n source.id,\n source.tenantId,\n );\n return (result.rows as { id: string; portion_id: string }[]).map((row) => ({\n id: row.id,\n portionId: row.portion_id,\n }));\n}\n\n/** The one immutable chain leaf, independent of a nullable active attribution head. */\nasync function latestRevision(\n source: Expense,\n): Promise<ExpenseAllocationRevision | null> {\n const result = await source.db.query(\n `SELECT r.id FROM expense_allocation_revisions r\n WHERE r.source_expense_id = ? AND r.tenant_id = ? AND NOT EXISTS\n (SELECT 1 FROM expense_allocation_revisions n WHERE n.previous_revision_id = r.id AND n.source_expense_id = r.source_expense_id AND n.tenant_id = r.tenant_id)\n LIMIT 2`,\n source.id,\n source.tenantId,\n );\n if (result.rows.length > 1) invalid('allocation audit chain is ambiguous.');\n const id = (result.rows[0] as { id?: string } | undefined)?.id;\n return id\n ? (await Revisions.create({ db: source.db })).get(\n { id, sourceExpenseId: source.id, tenantId: source.tenantId },\n { cache: false },\n )\n : null;\n}\n\n/** Atomically review a full allocation or supersede an unreserved revision. Identical retries reauthorize. */\nexport async function reviewExpenseAllocation(\n db: DatabaseInterface,\n input: ReviewExpenseAllocationInput,\n authority: ExpenseAllocationAuthority,\n): Promise<ExpenseAllocationResult> {\n if (\n !input ||\n Object.keys(input).some(\n (key) =>\n ![\n 'sourceExpenseId',\n 'expectedSourceRevision',\n 'requestId',\n 'portions',\n 'reviewEvidence',\n ].includes(key),\n )\n )\n invalid('unknown input field.');\n text(input.sourceExpenseId);\n text(input.requestId);\n text(input.reviewEvidence);\n if (\n instantMs(input.expectedSourceRevision) === null ||\n !Array.isArray(input.portions) ||\n input.portions.length < 1 ||\n input.portions.length > 1000\n )\n invalid('source revision and 1–1000 portions required.');\n const proposed = input.portions\n .map(target)\n .sort((a, b) =>\n a.portionKey < b.portionKey ? -1 : a.portionKey > b.portionKey ? 1 : 0,\n );\n if (new Set(proposed.map((row) => row.portionKey)).size !== proposed.length)\n invalid('duplicate portion key.');\n const fingerprint = digest({\n sourceExpenseId: input.sourceExpenseId,\n expectedSourceRevision: new Date(\n input.expectedSourceRevision,\n ).toISOString(),\n portions: proposed,\n reviewEvidence: input.reviewEvidence,\n });\n const principal = await authorizeExpenseAction(\n 'expenses',\n 'recordReview',\n { db },\n { allowSuperAdminBypass: false },\n );\n return withActionPrincipal(principal, async () => {\n const initial = await sourceFor(\n db,\n input.sourceExpenseId,\n principal.tenantId,\n );\n return initial.withTransaction(async (source) => {\n await lock(source);\n if (typeof authority?.authorizeSource !== 'function')\n invalid('host original-source authorization is required.');\n await authority.authorizeSource(principal, source.id!, source.db, {\n action: 'reviewAllocation',\n });\n const revisions = await Revisions.create({ db: source.db });\n const prior = await revisions.get(\n {\n sourceExpenseId: source.id,\n tenantId: principal.tenantId,\n requestId: input.requestId,\n },\n { cache: false },\n );\n if (prior) {\n if (\n prior.kind !== 'allocation' ||\n prior.requestFingerprint !== fingerprint\n )\n invalid('idempotency key payload conflict.');\n const children = await portionsFor(source, prior.id!);\n await authorize(source, principal, authority, children);\n return {\n revision: prior,\n portions: await Promise.all(\n children.map((row) => identity(source, prior, row)),\n ),\n };\n }\n if (\n instantMs(source.updated_at) !== instantMs(input.expectedSourceRevision)\n )\n invalid('stale source revision.');\n if (\n source.reviewStatus !== 'reviewed' ||\n source.duplicateOfId ||\n source.amount <= 0 ||\n source.refundOfId\n )\n invalid('positive reviewed original required.');\n const total = proposed.reduce(\n (sum, row) => sum + BigInt(row.amountMinor),\n 0n,\n );\n if (total !== BigInt(source.amount))\n invalid('portions must exactly equal source amount; no remainder.');\n const old = source.activeAllocationRevisionId\n ? await portionsFor(source, source.activeAllocationRevisionId)\n : [];\n await authorize(source, principal, authority, [...old, ...proposed]);\n if ((await activeReservations(source)).length)\n invalid(\n 'release draft reservations before correction; issued portions require explicit credit/reversal.',\n );\n await source.claimRevision(input.expectedSourceRevision);\n const previous = await latestRevision(source);\n if (\n source.activeAllocationRevisionId\n ? previous?.id !== source.activeAllocationRevisionId ||\n previous.kind !== 'allocation'\n : previous && previous.kind !== 'withdrawal'\n )\n invalid('allocation audit chain disagrees with its active head.');\n const sourceNonce =\n previous?.sourceFingerprintNonce || randomBytes(32).toString('hex');\n const revision = await insertAllocation(\n new ExpenseAllocationRevision({\n db: source.db,\n tenantId: principal.tenantId,\n sourceExpenseId: source.id!,\n previousRevisionId: previous?.id ?? null,\n kind: 'allocation',\n sourceCostObjectType: source.costObjectType,\n sourceCostObjectId: source.costObjectId,\n incurredOn: source.incurredOn,\n paidBy: source.paidBy,\n reimbursable: source.reimbursable,\n hasSupplierTax:\n source\n .getFinancialBreakdown()\n ?.taxes.some((tax) => tax.amount !== 0) ?? null,\n basisEqualsGross: source.getCostBasis()?.costBasis === source.amount,\n requestId: input.requestId,\n requestFingerprint: fingerprint,\n sourceFingerprintNonce: sourceNonce,\n sourceFingerprint: digest({\n nonce: sourceNonce,\n id: source.id,\n amount: source.amount,\n currency: source.currency,\n incurredOn: source.incurredOn,\n financialBreakdown: source.financialBreakdown,\n vendorId: source.vendorId,\n paidBy: source.paidBy,\n reimbursable: source.reimbursable,\n category: source.category,\n costObjectType: source.costObjectType,\n costObjectId: source.costObjectId,\n commitmentId: source.commitmentId,\n commitmentLineId: source.commitmentLineId,\n paidByProfileId: source.paidByProfileId,\n paidByName: source.paidByName,\n }),\n sourceRevision: new Date(input.expectedSourceRevision).toISOString(),\n amountMinor: source.amount,\n currency: source.currency,\n reviewedByProfileId: principal.profileId,\n reviewedByUserId: principal.userId,\n reviewEvidence: input.reviewEvidence,\n }),\n );\n const children: ExpenseAllocationPortion[] = [];\n for (const item of proposed)\n children.push(\n await insertAllocation(\n new ExpenseAllocationPortion({\n db: source.db,\n ...item,\n tenantId: principal.tenantId,\n sourceExpenseId: source.id!,\n revisionId: revision.id!,\n currency: source.currency,\n }),\n ),\n );\n source.activeAllocationRevisionId = revision.id!;\n allocationHeads.set(source, revision.id!);\n try {\n await source.save();\n } finally {\n allocationHeads.delete(source);\n }\n return {\n revision,\n portions: await Promise.all(\n children.map((row) => identity(source, revision, row)),\n ),\n };\n });\n });\n}\n\n/** An explicit decision to restore the original attribution before correcting unbilled source facts. */\nexport interface WithdrawExpenseAllocationInput {\n sourceExpenseId: string;\n expectedActiveRevisionId: string;\n expectedSourceRevision: Date | string;\n requestId: string;\n reviewEvidence: string;\n}\n/** Immutable historical result; callers reload the source for its current state/revision. */\nexport interface WithdrawExpenseAllocationResult {\n revision: ExpenseAllocationRevision;\n withdrawnRevisionId: string;\n}\nasync function authorizeUnsplit(\n source: Expense,\n principal: ExpenseActionPrincipal,\n revision: ExpenseAllocationRevision,\n authority: ExpenseAllocationAuthority,\n): Promise<void> {\n if (typeof authority.authorizeUnsplitTarget !== 'function')\n invalid('host restored-unsplit target authorization is required.');\n const costObjectType = revision.sourceCostObjectType;\n const costObjectId = revision.sourceCostObjectId;\n if (Boolean(costObjectType) !== Boolean(costObjectId))\n invalid('restored unsplit destination is malformed.');\n if (costObjectType) {\n if (!ObjectRegistry.getClassByQualifiedName(costObjectType))\n invalid('restored unsplit type is unknown.');\n const collection = await ObjectRegistry.getCollection<SmrtObject>(\n costObjectType,\n { db: source.db },\n );\n const object = await collection.get({ id: costObjectId }, { cache: false });\n if (\n !object ||\n (object as unknown as { tenantId?: string }).tenantId !==\n principal.tenantId\n )\n invalid('restored unsplit destination must exist in the active tenant.');\n }\n await authority.authorizeUnsplitTarget(\n principal,\n Object.freeze({\n sourceExpenseId: source.id!,\n costObjectType,\n costObjectId,\n }),\n source.db,\n );\n}\n/** Withdraw only entirely unreserved attribution, preserving source review state and all historical evidence. */\nexport async function withdrawExpenseAllocation(\n db: DatabaseInterface,\n input: WithdrawExpenseAllocationInput,\n authority: ExpenseAllocationAuthority,\n): Promise<WithdrawExpenseAllocationResult> {\n if (\n !input ||\n Object.keys(input).some(\n (key) =>\n ![\n 'sourceExpenseId',\n 'expectedActiveRevisionId',\n 'expectedSourceRevision',\n 'requestId',\n 'reviewEvidence',\n ].includes(key),\n )\n )\n invalid('unknown withdrawal input field.');\n text(input.sourceExpenseId);\n text(input.expectedActiveRevisionId);\n text(input.requestId);\n text(input.reviewEvidence);\n if (instantMs(input.expectedSourceRevision) === null)\n invalid('withdrawal source revision is required.');\n const fingerprint = digest({\n action: 'withdrawAllocation',\n sourceExpenseId: input.sourceExpenseId,\n expectedActiveRevisionId: input.expectedActiveRevisionId,\n expectedSourceRevision: new Date(\n input.expectedSourceRevision,\n ).toISOString(),\n reviewEvidence: input.reviewEvidence,\n });\n const principal = await billingPrincipal(db);\n return withActionPrincipal(principal, async () => {\n return (\n await sourceFor(db, input.sourceExpenseId, principal.tenantId)\n ).withTransaction(async (source) => {\n await lock(source);\n if (typeof authority?.authorizeSource !== 'function')\n invalid('host original-source authorization is required.');\n await authority.authorizeSource(principal, source.id!, source.db, {\n action: 'withdrawAllocation',\n });\n const revisions = await Revisions.create({ db: source.db });\n const replay = await revisions.get(\n {\n sourceExpenseId: source.id,\n tenantId: principal.tenantId,\n requestId: input.requestId,\n },\n { cache: false },\n );\n if (\n replay &&\n (replay.kind !== 'withdrawal' ||\n replay.requestFingerprint !== fingerprint)\n )\n invalid('withdrawal idempotency key payload conflict.');\n const targetRevisionId =\n replay?.previousRevisionId ?? input.expectedActiveRevisionId;\n const previous = await revisions.get(\n {\n id: targetRevisionId,\n sourceExpenseId: source.id,\n tenantId: principal.tenantId,\n },\n { cache: false },\n );\n if (!previous || previous.kind !== 'allocation')\n invalid(\n 'withdrawal requires the original reviewed allocation revision.',\n );\n const old = await portionsFor(source, previous.id!);\n await authorize(source, principal, authority, old);\n await authorizeUnsplit(source, principal, previous, authority);\n if (replay)\n return { revision: replay, withdrawnRevisionId: previous.id! };\n if (\n source.activeAllocationRevisionId !== input.expectedActiveRevisionId ||\n instantMs(source.updated_at) !== instantMs(input.expectedSourceRevision)\n )\n invalid('stale active allocation or source revision.');\n if ((await latestRevision(source))?.id !== previous.id)\n invalid('withdrawal audit chain is not current.');\n if ((await activeReservations(source)).length)\n invalid(\n 'reserved, bound or issued portions cannot be withdrawn; release authorized draft claims explicitly.',\n );\n await source.claimRevision(input.expectedSourceRevision);\n const revision = await insertAllocation(\n new ExpenseAllocationRevision({\n db: source.db,\n tenantId: principal.tenantId,\n sourceExpenseId: source.id!,\n previousRevisionId: previous.id!,\n kind: 'withdrawal',\n requestId: input.requestId,\n requestFingerprint: fingerprint,\n sourceFingerprint: previous.sourceFingerprint,\n sourceFingerprintNonce: previous.sourceFingerprintNonce,\n sourceRevision: new Date(input.expectedSourceRevision).toISOString(),\n amountMinor: previous.amountMinor,\n currency: previous.currency,\n sourceCostObjectType: previous.sourceCostObjectType,\n sourceCostObjectId: previous.sourceCostObjectId,\n incurredOn: previous.incurredOn,\n paidBy: previous.paidBy,\n reimbursable: previous.reimbursable,\n hasSupplierTax: previous.hasSupplierTax,\n basisEqualsGross: previous.basisEqualsGross,\n reviewedByProfileId: principal.profileId,\n reviewedByUserId: principal.userId,\n reviewEvidence: input.reviewEvidence,\n }),\n );\n source.activeAllocationRevisionId = null;\n allocationHeads.set(source, null);\n try {\n await source.save();\n } finally {\n allocationHeads.delete(source);\n }\n return { revision, withdrawnRevisionId: previous.id! };\n });\n });\n}\n\n/** Resolve one canonical portion with current project authority, including historical billed revisions. */\nexport async function resolveExpenseAllocationPortion(\n db: DatabaseInterface,\n portionId: string,\n authority: ExpenseAllocationAuthority,\n): Promise<ExpenseAllocationIdentity> {\n text(portionId);\n const principal = await authorizeExpenseAction(\n 'expenses',\n 'get',\n { db },\n { allowSuperAdminBypass: false },\n );\n return withActionPrincipal(principal, async () => {\n const row = await (await Portions.create({ db })).get(\n { id: portionId, tenantId: principal.tenantId },\n { cache: false },\n );\n if (!row) invalid('owned portion required.');\n const source = await sourceFor(db, row.sourceExpenseId, principal.tenantId);\n if (\n source.activeAllocationRevisionId === row.revisionId &&\n (source.reviewStatus !== 'reviewed' || source.duplicateOfId)\n )\n invalid('source review is no longer usable.');\n const revision = await (await Revisions.create({ db })).get(\n { id: row.revisionId, tenantId: principal.tenantId },\n { cache: false },\n );\n if (!revision || revision.sourceExpenseId !== source.id)\n invalid('owned revision required.');\n await authorize(source, principal, authority, [row]);\n return identity(source, revision, row);\n });\n}\n\n/** Internal monetary projection: source rows remain canonical for cash/tax/commitment. */\nexport async function allocationTargetAmount(\n source: Expense,\n filter: Record<string, unknown>,\n): Promise<number | null> {\n if (!source.activeAllocationRevisionId) {\n if (Object.keys(filter).some((key) => key.startsWith('costCodeRef')))\n return null;\n const { ExpenseCollection } = await import(\n './collections/ExpenseCollection.js'\n );\n const match = await (await ExpenseCollection.create({ db: source.db })).get(\n { ...filter, id: source.id, tenantId: source.tenantId },\n { cache: false },\n );\n return match ? source.amount : null;\n }\n const rows = await (await Portions.create({ db: source.db })).list({\n where: {\n ...filter,\n revisionId: source.activeAllocationRevisionId,\n tenantId: source.tenantId,\n },\n limit: 1000,\n });\n if (!rows.length) return null;\n const total = rows.reduce((sum, row) => sum + BigInt(row.amountMinor), 0n);\n if (total > BigInt(Number.MAX_SAFE_INTEGER))\n invalid('target sum exceeds safe range.');\n return Number(total);\n}\n\n/** Protected commerce source protocol. Unqualified/ordinary invoice sources retain their old behavior. */\nexport const EXPENSE_ALLOCATION_INVOICE_SOURCE =\n 'billable:@happyvertical/smrt-expenses:ExpenseAllocationPortion';\n/** Reserve against a host-owned draft first, or bind directly to a prepared commerce line. */\nexport interface ReserveExpenseAllocationInput {\n portionId: string;\n requestId: string;\n draftType?: string;\n draftId?: string;\n invoiceId?: string;\n invoiceLineId?: string;\n}\nasync function reservationFor(\n db: DatabaseInterface,\n id: string,\n tenantId: string,\n): Promise<ExpenseAllocationBilling> {\n const reservation = await (await Billings.create({ db })).get(\n { id, tenantId },\n { cache: false },\n );\n if (\n !reservation ||\n reservation.kind !== 'reserve' ||\n reservation.tenantId !== tenantId\n )\n invalid('owned reservation required.');\n return reservation;\n}\nasync function bindingFor(\n source: Expense,\n reservationId: string,\n): Promise<ExpenseAllocationBilling | null> {\n return (await Billings.create({ db: source.db })).get(\n {\n sourceExpenseId: source.id,\n relatedReservationId: reservationId,\n kind: 'bind',\n tenantId: source.tenantId,\n },\n { cache: false },\n );\n}\nasync function billingPrincipal(\n db: DatabaseInterface,\n): Promise<ExpenseActionPrincipal> {\n return authorizeExpenseAction(\n 'expenses',\n 'recordReview',\n { db },\n { allowSuperAdminBypass: false },\n );\n}\nasync function billingPortion(\n source: Expense,\n id: string,\n principal: ExpenseActionPrincipal,\n authority: ExpenseAllocationBillingAuthority,\n action: ExpenseAllocationAuthorizationContext['action'],\n): Promise<ExpenseAllocationPortion> {\n const portion = await (await Portions.create({ db: source.db })).get(\n { id, sourceExpenseId: source.id, tenantId: principal.tenantId },\n { cache: false },\n );\n if (!portion) invalid('owned source portion required.');\n await authorize(source, principal, authority, [portion]);\n if (typeof authority.authorizeSource !== 'function')\n invalid('host source authority required.');\n await authority.authorizeSource(principal, source.id!, source.db, {\n action,\n portion: {\n portionId: portion.id!,\n portionKey: portion.portionKey,\n costObjectType: portion.costObjectType,\n costObjectId: portion.costObjectId,\n costCodeRef: portion.costCodeRef,\n amountMinor: portion.amountMinor,\n },\n });\n return portion;\n}\n/** Reserve full exact source capacity once, without implying customer price or creating another expense. */\nexport async function reserveExpenseAllocationPortion(\n db: DatabaseInterface,\n input: ReserveExpenseAllocationInput,\n authority: ExpenseAllocationBillingAuthority,\n): Promise<ExpenseAllocationBilling> {\n text(input.portionId);\n text(input.requestId);\n if (\n Object.keys(input).some(\n (key) =>\n ![\n 'portionId',\n 'requestId',\n 'draftType',\n 'draftId',\n 'invoiceId',\n 'invoiceLineId',\n ].includes(key),\n )\n )\n invalid('unknown reservation field.');\n const principal = await billingPrincipal(db);\n return withActionPrincipal(principal, async () => {\n const row = await (await Portions.create({ db })).get(\n { id: input.portionId, tenantId: principal.tenantId },\n { cache: false },\n );\n if (!row) invalid('owned portion required.');\n return (\n await sourceFor(db, row.sourceExpenseId, principal.tenantId)\n ).withTransaction(async (source) => {\n await lock(source);\n const portion = await billingPortion(\n source,\n row.id!,\n principal,\n authority,\n 'reserveAllocation',\n );\n const invoiceBound = Boolean(input.invoiceId || input.invoiceLineId);\n if (invoiceBound) {\n text(input.invoiceId);\n text(input.invoiceLineId);\n if (typeof authority.authorizeInvoice !== 'function')\n invalid('host invoice authority required.');\n await authority.authorizeInvoice(\n principal,\n portion,\n input.invoiceId,\n source.db,\n );\n } else {\n text(input.draftType);\n text(input.draftId);\n if (typeof authority.authorizeDraft !== 'function')\n invalid('host draft authority required.');\n await authority.authorizeDraft(\n principal,\n portion,\n { type: input.draftType, id: input.draftId },\n source.db,\n );\n }\n const fingerprint = digest({\n portionId: input.portionId,\n requestId: input.requestId,\n draftType: input.draftType ?? null,\n draftId: input.draftId ?? null,\n invoiceId: input.invoiceId ?? null,\n invoiceLineId: input.invoiceLineId ?? null,\n });\n const billings = await Billings.create({ db: source.db });\n const prior = await billings.get(\n {\n sourceExpenseId: source.id,\n tenantId: principal.tenantId,\n requestId: input.requestId,\n },\n { cache: false },\n );\n if (prior) {\n if (\n prior.requestFingerprint !== fingerprint ||\n prior.kind !== 'reserve'\n )\n invalid('reservation idempotency conflict.');\n return prior;\n }\n if ((await source.getRefundPosition()).refundIds.length)\n invalid('refunded source needs explicit billing reversal policy.');\n if (source.activeAllocationRevisionId !== portion.revisionId)\n invalid('superseded portion cannot be reserved.');\n if (\n (await activeReservations(source)).some(\n (item) => item.portionId === portion.id,\n )\n )\n invalid('portion capacity already reserved.');\n if (!source.updated_at) invalid('source revision required.');\n await source.claimRevision(source.updated_at);\n const reservation = await insertAllocation(\n new ExpenseAllocationBilling({\n db: source.db,\n tenantId: principal.tenantId,\n sourceExpenseId: source.id!,\n portionId: portion.id!,\n requestId: input.requestId,\n requestFingerprint: fingerprint,\n kind: 'reserve',\n draftType: input.draftType ?? '',\n draftId: input.draftId ?? '',\n }),\n );\n if (invoiceBound)\n await bindReservation(\n source,\n reservation,\n portion,\n {\n invoiceId: input.invoiceId!,\n invoiceLineId: input.invoiceLineId!,\n requestId: `${input.requestId}:bind`,\n },\n principal,\n authority,\n );\n return reservation;\n });\n });\n}\nasync function bindReservation(\n source: Expense,\n reservation: ExpenseAllocationBilling,\n portion: ExpenseAllocationPortion,\n input: { invoiceId: string; invoiceLineId: string; requestId: string },\n principal: ExpenseActionPrincipal,\n authority: ExpenseAllocationBillingAuthority,\n): Promise<ExpenseAllocationBilling> {\n if (typeof authority.authorizeInvoice !== 'function')\n invalid('host invoice authority required.');\n await authority.authorizeInvoice(\n principal,\n portion,\n input.invoiceId,\n source.db,\n );\n const billings = await Billings.create({ db: source.db });\n const fingerprint = digest({ reservationId: reservation.id, ...input });\n const previous = await bindingFor(source, reservation.id!);\n if (previous) {\n if (\n previous.requestId !== input.requestId ||\n previous.requestFingerprint !== fingerprint\n )\n invalid('reservation already bound or payload changed.');\n return previous;\n }\n if ((await source.getRefundPosition()).refundIds.length)\n invalid('refunded source needs explicit billing reversal policy.');\n if (\n !(await activeReservations(source)).some(\n (item) => item.id === reservation.id,\n )\n )\n invalid('released reservation cannot bind.');\n if (\n await billings.get(\n {\n sourceExpenseId: source.id,\n tenantId: principal.tenantId,\n requestId: input.requestId,\n },\n { cache: false },\n )\n )\n invalid('request identity already used.');\n const invoice = await (await InvoiceCollection.create({ db: source.db })).get(\n { id: input.invoiceId, tenantId: principal.tenantId },\n { cache: false },\n );\n const line = await (\n await InvoiceLineItemCollection.create({ db: source.db })\n ).get(\n { id: input.invoiceLineId, tenantId: principal.tenantId },\n { cache: false },\n );\n if (\n !invoice ||\n invoice.tenantId !== principal.tenantId ||\n invoice.status !== 'draft' ||\n invoice.currency !== portion.currency ||\n !line ||\n line.tenantId !== principal.tenantId ||\n line.invoiceId !== invoice.id ||\n line.sourceType !== EXPENSE_ALLOCATION_INVOICE_SOURCE ||\n line.sourceId !== portion.id ||\n !invoice.updated_at ||\n !source.updated_at\n )\n invalid('owned same-currency draft and canonical source line required.');\n await invoice.claimRevision(invoice.updated_at);\n await source.claimRevision(source.updated_at);\n const binding = await insertAllocation(\n new ExpenseAllocationBilling({\n db: source.db,\n tenantId: principal.tenantId,\n sourceExpenseId: source.id!,\n portionId: portion.id!,\n invoiceId: input.invoiceId,\n invoiceLineId: input.invoiceLineId,\n requestId: input.requestId,\n requestFingerprint: fingerprint,\n kind: 'bind',\n relatedReservationId: reservation.id!,\n }),\n );\n await bindInvoiceLineSource({\n db: source.db,\n tenantId: principal.tenantId,\n lineId: input.invoiceLineId,\n reservationId: reservation.id!,\n });\n return binding;\n}\n/** Transition the existing host draft claim to exactly one commerce line, without reserving twice. */\nexport async function bindExpenseAllocationPortion(\n db: DatabaseInterface,\n reservationId: string,\n input: { invoiceId: string; invoiceLineId: string; requestId: string },\n authority: ExpenseAllocationBillingAuthority,\n): Promise<ExpenseAllocationBilling> {\n text(reservationId);\n text(input.invoiceId);\n text(input.invoiceLineId);\n text(input.requestId);\n const principal = await billingPrincipal(db);\n return withActionPrincipal(principal, async () => {\n const reservation = await reservationFor(\n db,\n reservationId,\n principal.tenantId,\n );\n return (\n await sourceFor(db, reservation.sourceExpenseId, principal.tenantId)\n ).withTransaction(async (source) => {\n await lock(source);\n const portion = await billingPortion(\n source,\n reservation.portionId,\n principal,\n authority,\n 'bindAllocation',\n );\n return bindReservation(\n source,\n reservation,\n portion,\n input,\n principal,\n authority,\n );\n });\n });\n}\n/** Release an unissued draft claim and its commerce pointer atomically; issued reservations remain consumed. */\nexport async function releaseExpenseAllocationPortion(\n db: DatabaseInterface,\n reservationId: string,\n requestId: string,\n authority: ExpenseAllocationBillingAuthority,\n): Promise<ExpenseAllocationBilling> {\n text(reservationId);\n text(requestId);\n const principal = await billingPrincipal(db);\n return withActionPrincipal(principal, async () => {\n const reservation = await reservationFor(\n db,\n reservationId,\n principal.tenantId,\n );\n return (\n await sourceFor(db, reservation.sourceExpenseId, principal.tenantId)\n ).withTransaction(async (source) => {\n await lock(source);\n const portion = await billingPortion(\n source,\n reservation.portionId,\n principal,\n authority,\n 'releaseAllocation',\n );\n const binding = await bindingFor(source, reservation.id!);\n if (binding?.invoiceId) {\n if (typeof authority.authorizeInvoice !== 'function')\n invalid('host invoice authority required.');\n await authority.authorizeInvoice(\n principal,\n portion,\n binding.invoiceId,\n source.db,\n );\n } else {\n if (typeof authority.authorizeDraft !== 'function')\n invalid('host draft authority required.');\n await authority.authorizeDraft(\n principal,\n portion,\n { type: reservation.draftType, id: reservation.draftId },\n source.db,\n );\n }\n const billings = await Billings.create({ db: source.db });\n const fingerprint = digest({ reservationId, requestId });\n const prior = await billings.get(\n { sourceExpenseId: source.id, tenantId: principal.tenantId, requestId },\n { cache: false },\n );\n if (prior) {\n if (\n prior.requestFingerprint !== fingerprint ||\n prior.kind !== 'release'\n )\n invalid('release idempotency conflict.');\n return prior;\n }\n if (\n !(await activeReservations(source)).some(\n (item) => item.id === reservationId,\n )\n )\n invalid('reservation already released.');\n if (binding?.invoiceId) {\n const invoice = await (\n await InvoiceCollection.create({ db: source.db })\n ).get(\n { id: binding.invoiceId, tenantId: principal.tenantId },\n { cache: false },\n );\n if (!invoice || invoice.status !== 'draft' || !invoice.updated_at)\n invalid(\n 'issued reservation cannot be released; use explicit credit/reversal.',\n );\n await invoice.claimRevision(invoice.updated_at);\n }\n if (!source.updated_at) invalid('source revision required.');\n await source.claimRevision(source.updated_at);\n const released = await insertAllocation(\n new ExpenseAllocationBilling({\n db: source.db,\n tenantId: principal.tenantId,\n sourceExpenseId: source.id!,\n portionId: reservation.portionId,\n invoiceId: binding?.invoiceId ?? null,\n invoiceLineId: binding?.invoiceLineId ?? null,\n requestId,\n requestFingerprint: fingerprint,\n kind: 'release',\n relatedReservationId: reservationId,\n draftType: reservation.draftType,\n draftId: reservation.draftId,\n }),\n );\n if (binding?.invoiceLineId)\n await unbindInvoiceLineSource({\n db: source.db,\n tenantId: principal.tenantId,\n lineId: binding.invoiceLineId,\n reservationId,\n });\n return released;\n });\n });\n}\n\n// Static, trusted package registration; request strings can select only this closed capability.\nregisterInvoiceSourceBinding(\n EXPENSE_ALLOCATION_INVOICE_SOURCE,\n async ({ executor, invoice, line, reservationId, phase }) => {\n if (!invoice.tenantId || line.tenantId !== invoice.tenantId)\n invalid('binding tenant mismatch.');\n const reservation = await reservationFor(\n executor,\n reservationId,\n invoice.tenantId,\n );\n const source = await sourceFor(\n executor,\n reservation.sourceExpenseId,\n invoice.tenantId,\n );\n const binding = await bindingFor(source, reservationId);\n if (\n !binding ||\n binding.invoiceId !== invoice.id ||\n binding.invoiceLineId !== line.id ||\n line.sourceId !== reservation.portionId ||\n line.sourceType !== EXPENSE_ALLOCATION_INVOICE_SOURCE\n )\n invalid('binding does not identify this exact invoice line.');\n const active = (await activeReservations(source)).some(\n (item) => item.id === reservationId,\n );\n if (phase === 'release' ? active : !active)\n invalid('binding reservation state is invalid.');\n },\n);\n\n/** Bounded target-owned availability; historical/issued claims never become available implicitly. */\nexport interface ExpenseAllocationPortionPosition {\n identity: ExpenseAllocationIdentity;\n available: boolean;\n reservation: {\n reservationId: string;\n draftType: string;\n draftId: string;\n invoiceId: string | null;\n invoiceLineId: string | null;\n invoiceStatus: string | null;\n issued: boolean;\n } | null;\n}\n/** Read one portion's current claim without disclosing original receipts, source gross or sibling projects. */\nexport async function getExpenseAllocationPortionPosition(\n db: DatabaseInterface,\n portionId: string,\n authority: ExpenseAllocationAuthority,\n): Promise<ExpenseAllocationPortionPosition> {\n const identity = await resolveExpenseAllocationPortion(\n db,\n portionId,\n authority,\n );\n const principal = await authorizeExpenseAction(\n 'expenses',\n 'get',\n { db },\n { allowSuperAdminBypass: false },\n );\n return withActionPrincipal(principal, async () => {\n const source = await sourceFor(\n db,\n identity.sourceExpenseId,\n principal.tenantId,\n );\n identity.active = source.activeAllocationRevisionId === identity.revisionId;\n const active = (await activeReservations(source)).find(\n (row) => row.portionId === portionId,\n );\n if (!active)\n return { identity, available: identity.active, reservation: null };\n const reservation = await reservationFor(db, active.id, principal.tenantId);\n const binding = await bindingFor(source, active.id);\n const invoice = binding?.invoiceId\n ? await (await InvoiceCollection.create({ db })).get(\n { id: binding.invoiceId, tenantId: principal.tenantId },\n { cache: false },\n )\n : null;\n return {\n identity,\n available: false,\n reservation: {\n reservationId: reservation.id!,\n draftType: reservation.draftType,\n draftId: reservation.draftId,\n invoiceId: binding?.invoiceId ?? null,\n invoiceLineId: binding?.invoiceLineId ?? null,\n invoiceStatus: invoice?.status ?? null,\n issued: Boolean(binding && (!invoice || invoice.status !== 'draft')),\n },\n };\n });\n}\n","import {\n allocationTargetAmount,\n type ExpenseAllocationAuthority,\n type ExpenseAllocationResult,\n type ReviewExpenseAllocationInput,\n reviewExpenseAllocation,\n type WithdrawExpenseAllocationInput,\n type WithdrawExpenseAllocationResult,\n withdrawExpenseAllocation,\n} from '../expense-allocation.js';\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 type {\n CompleteSupplierPayableBasisInput,\n RecordSupplierPayableEventInput,\n RecordSupplierPayableInput,\n SupplierPayablePosition,\n} from '../supplier-payable.js';\nimport {\n type CommitmentPosition,\n type CurrencyTotals,\n ExpenseError,\n type ExpenseFinancialBreakdown,\n type ExpenseRefundPosition,\n type ExpenseReimbursementPosition,\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 /** Record immutable original supplier retention/payable evidence on its Expense. */\n async recordSupplierPayable(\n expenseId: string,\n input: RecordSupplierPayableInput,\n ): Promise<SupplierPayablePosition> {\n const expense = await this.requireSupplierPayableExpense(expenseId);\n return expense.recordSupplierPayable(input);\n }\n\n /** Append a dated supplier event; no external money movement is executed. */\n async recordSupplierPayableEvent(\n expenseId: string,\n input: RecordSupplierPayableEventInput,\n ): Promise<SupplierPayablePosition> {\n return (\n await this.requireSupplierPayableExpense(expenseId)\n ).recordSupplierPayableEvent(input);\n }\n\n /** Independently review an originally unknown payable basis exactly once. */\n async completeSupplierPayableBasis(\n expenseId: string,\n input: CompleteSupplierPayableBasisInput,\n ): Promise<SupplierPayablePosition> {\n return (\n await this.requireSupplierPayableExpense(expenseId)\n ).completeSupplierPayableBasis(input);\n }\n\n /** Dated supplier position is independent of incurred cost and reimbursement. */\n async supplierPayablePosition(\n expenseId: string,\n input: { asOfDate?: string } = {},\n ): Promise<SupplierPayablePosition | null> {\n return (\n await this.requireSupplierPayableExpense(expenseId)\n ).getSupplierPayablePosition(input);\n }\n\n private async requireSupplierPayableExpense(\n expenseId: string,\n ): Promise<Expense> {\n const expense = await this.get({ id: expenseId }, { cache: false });\n if (!expense)\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n 'Supplier payable source was not found.',\n );\n return expense;\n }\n\n /** Cash claim after explicit refund receipts and retained historical payments. */\n async reimbursementPosition(\n sourceId: string,\n ): Promise<ExpenseReimbursementPosition> {\n const source = await this.get({ id: sourceId }, { cache: false });\n if (!source)\n throw new ExpenseError(\n 'EXPENSE_INVALID',\n 'Reimbursement source was not found.',\n );\n return source.getReimbursementPosition();\n }\n\n /** All persisted linked refunds reserve source capacity, irrespective of review. */\n async refundPosition(sourceId: string): Promise<ExpenseRefundPosition> {\n const source = await this.get({ id: sourceId }, { cache: false });\n if (!source)\n throw new ExpenseError('EXPENSE_INVALID', 'Refund source was not found.');\n return source.getRefundPosition();\n }\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 where = { ...(options.where ?? {}) };\n const targetFilter: Record<string, unknown> = {};\n for (const key of Object.keys(where)) {\n if (/^cost(ObjectType|ObjectId|CodeRef)/.test(key)) {\n targetFilter[key] = where[key];\n delete where[key];\n }\n }\n const rows = await this.list({\n where: { ...where, reviewStatus: [...statuses], duplicateOfId: null },\n });\n const totals: CurrencyTotals = {};\n const seen = new Set<string>();\n for (const row of rows) {\n if (!row.id || seen.has(row.id)) continue;\n seen.add(row.id);\n const amount = Object.keys(targetFilter).length\n ? await allocationTargetAmount(row, targetFilter)\n : toMinorUnits(row.amount);\n if (amount !== null) addTo(totals, row.currency, amount);\n }\n return totals;\n }\n\n /** Review a complete allocation through ambient reviewer and mandatory host authority. */\n async reviewAllocation(\n input: ReviewExpenseAllocationInput,\n authority: ExpenseAllocationAuthority,\n ): Promise<ExpenseAllocationResult> {\n return reviewExpenseAllocation(this.db, input, authority);\n }\n\n /** Audit withdrawal of entirely unreserved portions before correcting the original source. */\n async withdrawAllocation(\n input: WithdrawExpenseAllocationInput,\n authority: ExpenseAllocationAuthority,\n ): Promise<WithdrawExpenseAllocationResult> {\n return withdrawExpenseAllocation(this.db, input, authority);\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 activeAllocationRevisionId: { visibility: 'hidden' },\n financialBreakdown: { visibility: 'hidden' },\n supplierPayableJson: { visibility: 'hidden' },\n refundRecipient: { visibility: 'hidden' },\n reimbursedAmount: {\n help: 'The recorded amount paid back to the person who paid.',\n },\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 upload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