@happyvertical/smrt-commerce 0.61.3 → 0.61.5

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 (44) hide show
  1. package/README.md +9 -7
  2. package/dist/chunks/{ContractLineItemCollection-B2ildsVf.js → ContractLineItemCollection-BKHy-nR8.js} +4 -4
  3. package/dist/chunks/{ContractLineItemCollection-B2ildsVf.js.map → ContractLineItemCollection-BKHy-nR8.js.map} +1 -1
  4. package/dist/chunks/{DocumentTaxCollection-eionhU1Y.js → DocumentTaxCollection-BRebznXF.js} +26 -20
  5. package/dist/chunks/DocumentTaxCollection-BRebznXF.js.map +1 -0
  6. package/dist/chunks/{InvoiceCollection-rexZLpLi.js → InvoiceCollection-Cc-fJrHy.js} +9 -9
  7. package/dist/chunks/{InvoiceCollection-rexZLpLi.js.map → InvoiceCollection-Cc-fJrHy.js.map} +1 -1
  8. package/dist/chunks/{TaxCodeCollection-DEXGRUB8.js → TaxCodeCollection-BBqCugs5.js} +2 -2
  9. package/dist/chunks/{TaxCodeCollection-DEXGRUB8.js.map → TaxCodeCollection-BBqCugs5.js.map} +1 -1
  10. package/dist/chunks/{TaxComponentCollection-BoiKGyxq.js → TaxComponentCollection-BHJjbQxq.js} +3 -3
  11. package/dist/chunks/{TaxComponentCollection-BoiKGyxq.js.map → TaxComponentCollection-BHJjbQxq.js.map} +1 -1
  12. package/dist/chunks/{allocation-integrity-CMHOpzs6.js → allocation-integrity-CvXQm3wK.js} +6 -6
  13. package/dist/chunks/{allocation-integrity-CMHOpzs6.js.map → allocation-integrity-CvXQm3wK.js.map} +1 -1
  14. package/dist/chunks/{contract-money-BwOM9bGi.js → contract-money-BoKHNfV6.js} +6 -6
  15. package/dist/chunks/{contract-money-BwOM9bGi.js.map → contract-money-BoKHNfV6.js.map} +1 -1
  16. package/dist/chunks/{invoice-posting-CvvfhP2R.js → invoice-posting-DlR_-TG1.js} +3 -3
  17. package/dist/chunks/{invoice-posting-CvvfhP2R.js.map → invoice-posting-DlR_-TG1.js.map} +1 -1
  18. package/dist/chunks/{retention-accounting-e9SlPXuQ.js → retention-accounting-D0KzSw3f.js} +8 -8
  19. package/dist/chunks/{retention-accounting-e9SlPXuQ.js.map → retention-accounting-D0KzSw3f.js.map} +1 -1
  20. package/dist/chunks/{tenant-money-barrier-Dlfgm-v1.js → tenant-money-barrier-Bmu4YiID.js} +3 -3
  21. package/dist/chunks/{tenant-money-barrier-Dlfgm-v1.js.map → tenant-money-barrier-Bmu4YiID.js.map} +1 -1
  22. package/dist/collections/PayoutCollection.d.ts.map +1 -1
  23. package/dist/commerce-money-tools.d.ts.map +1 -1
  24. package/dist/customer-funds.d.ts.map +1 -1
  25. package/dist/document-money.d.ts.map +1 -1
  26. package/dist/historical-customer-funds.d.ts.map +1 -1
  27. package/dist/historical-sales-money.d.ts.map +1 -1
  28. package/dist/index.js +81 -38
  29. package/dist/index.js.map +1 -1
  30. package/dist/invoices.js +1 -1
  31. package/dist/manifest.json +16672 -13065
  32. package/dist/migrations/partyLinks.d.ts +10 -0
  33. package/dist/migrations/partyLinks.d.ts.map +1 -1
  34. package/dist/models/Contract.d.ts +1 -2
  35. package/dist/models/Contract.d.ts.map +1 -1
  36. package/dist/models/TenantPaymentWebhookEvent.d.ts +1 -1
  37. package/dist/models/TenantPaymentWebhookEvent.d.ts.map +1 -1
  38. package/dist/models/billing.d.ts +1 -1
  39. package/dist/models/billing.d.ts.map +1 -1
  40. package/dist/observed-purchase-price.d.ts.map +1 -1
  41. package/dist/smrt-knowledge.json +10801 -10794
  42. package/dist/smrt-knowledge.okf.md +2 -2
  43. package/package.json +17 -17
  44. package/dist/chunks/DocumentTaxCollection-eionhU1Y.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import { t as __exportAll } from "./chunks/rolldown-runtime-D7D4PA-g.js";
2
- import { $ as CustomerCollection, A as issueContractMilestoneInvoice, B as Order, C as refreshIssuedCreditBalance, D as allocateContractMilestones, E as unbindInvoiceLineSource, F as Cart, G as SupplierQuote, H as PurchaseContract, I as Contract, J as Vendor, K as WholesaleOrder, L as Estimate, M as SalesContractCollection, N as PurchaseContractCollection, O as approveContractBillingSchedule, P as Agreement, Q as InvoiceLineItem, R as Lease, S as previewInvoiceMoney, T as registerInvoiceSourceBinding, U as PurchaseOrder, V as ProductionOrder, W as SalesContract, X as HistoricalSalesLine, Y as HistoricalSalesLineCollection, Z as InvoiceLineItemCollection, _ as historicalText, a as getReceivedSalesContractMoney, at as PartyContactValidationError, b as getInvoiceMoneyFacts, c as validateReceivedPurchaseMoneyFacts, ct as readPartyContactRows, d as HistoricalSalesTaxClassificationRequired, et as Customer, f as listHistoricalSalesHeaderFacts, g as historicalCalendarDate, h as recordHistoricalSalesMoney, i as getReceivedPurchaseMoney, it as PartyContactPayloadError, j as ContractCollection, k as getContractBillingSchedule, l as VendorCollection, lt as savePartyContacts, m as readHistoricalSalesLines, nt as PARTY_CONTACT_MAX_LENGTHS, o as recordReceivedPurchaseMoney, ot as applyPartyContactIntent, p as getHistoricalSalesMoney, r as ReceivedPurchaseTaxClassificationRequired, rt as PartyContactPartyNotFoundError, s as recordReceivedSalesContractMoney, st as normalizePartyContacts, t as DocumentTaxCollection, tt as DEFAULT_PARTY_CONTACT_FIELD_NAMES, u as DocumentTax, ut as validatePartyContactRows, v as validateHistoricalSalesMoneyFacts, w as bindInvoiceLineSource, x as lockAndReloadInvoice, z as LicenseSale } from "./chunks/DocumentTaxCollection-eionhU1Y.js";
2
+ import { $ as CustomerCollection, A as issueContractMilestoneInvoice, B as Order, C as refreshIssuedCreditBalance, D as allocateContractMilestones, E as unbindInvoiceLineSource, F as Cart, G as SupplierQuote, H as PurchaseContract, I as Contract, J as Vendor, K as WholesaleOrder, L as Estimate, M as SalesContractCollection, N as PurchaseContractCollection, O as approveContractBillingSchedule, P as Agreement, Q as InvoiceLineItem, R as Lease, S as previewInvoiceMoney, T as registerInvoiceSourceBinding, U as PurchaseOrder, V as ProductionOrder, W as SalesContract, X as HistoricalSalesLine, Y as HistoricalSalesLineCollection, Z as InvoiceLineItemCollection, _ as historicalText, a as getReceivedSalesContractMoney, at as PartyContactValidationError, b as getInvoiceMoneyFacts, c as validateReceivedPurchaseMoneyFacts, ct as readPartyContactRows, d as HistoricalSalesTaxClassificationRequired, et as Customer, f as listHistoricalSalesHeaderFacts, g as historicalCalendarDate, h as recordHistoricalSalesMoney, i as getReceivedPurchaseMoney, it as PartyContactPayloadError, j as ContractCollection, k as getContractBillingSchedule, l as VendorCollection, lt as savePartyContacts, m as readHistoricalSalesLines, nt as PARTY_CONTACT_MAX_LENGTHS, o as recordReceivedPurchaseMoney, ot as applyPartyContactIntent, p as getHistoricalSalesMoney, r as ReceivedPurchaseTaxClassificationRequired, rt as PartyContactPartyNotFoundError, s as recordReceivedSalesContractMoney, st as normalizePartyContacts, t as DocumentTaxCollection, tt as DEFAULT_PARTY_CONTACT_FIELD_NAMES, u as DocumentTax, ut as validatePartyContactRows, v as validateHistoricalSalesMoneyFacts, w as bindInvoiceLineSource, x as lockAndReloadInvoice, z as LicenseSale } from "./chunks/DocumentTaxCollection-BRebznXF.js";
3
3
  import { a as FulfillmentStatus, c as PaymentInstrumentStatus, d as PaymentStatus, f as PayoutStatus, i as CustomerType, l as PaymentIntentStatus, n as ContractType, o as FulfillmentType, p as VendorStatus, r as CustomerStatus, s as InvoiceStatus, t as ContractStatus, u as PaymentMethod } from "./chunks/types-Bbm0Xflc.js";
4
4
  import { a as majorToMinorUnits, c as currencyMinorUnitExponent, i as isUuid, l as normalizeCurrency, n as deterministicId, o as minorToMajorUnits, r as isTenantId, s as tenantKey, t as canonicalTenantId } from "./chunks/units-8ElbjVZK.js";
5
- import { A as quickBooksPilotInvoiceId, D as runQuickBooksPilot, E as reconcileFrozenInvoiceAccountingSync, F as PaymentCollection, L as Payment, N as PaymentAllocation, O as syncFrozenInvoiceToAccounting, P as historicalCreditRefundCommittedTotal, R as hasConnectedPaymentAuthority, S as calculateInvoiceMinorLine, T as readFrozenAccountingSyncState, _ as reconcileOrdinaryCreditAccounting, a as reconcileRetainedBaseInvoice, b as syncOrdinaryRefundToAccounting, c as syncRetainedCreditToAccounting, d as toRetainedCreditAccountingInput, f as toRetainedInvoiceAccountingInput, g as reconcileOrdinaryBaseInvoice, h as reconcileOrdinaryAccountingStep, i as reconcileRetainedAccountingStep, j as PaymentAllocationCollection, k as toFrozenInvoiceAccountingInput, l as syncRetainedInvoiceToAccounting, m as readOrdinaryInvoiceAccountingState, n as loadRetainedInvoiceAccountingSnapshot, o as reconcileRetainedCreditAccounting, p as loadOrdinaryCreditAccountingSnapshot, r as readRetainedInvoiceAccountingState, s as releaseRetainedInvoiceToAccounting, t as loadRetainedCreditAccountingSnapshot, u as syncRetainedRefundToAccounting, v as syncOrdinaryCreditToAccounting, w as loadFrozenInvoiceAccountingSnapshot, x as toOrdinaryCreditAccountingInput, y as syncOrdinaryInvoiceToAccounting, z as withConnectedPaymentAuthority } from "./chunks/retention-accounting-e9SlPXuQ.js";
5
+ import { A as quickBooksPilotInvoiceId, D as runQuickBooksPilot, E as reconcileFrozenInvoiceAccountingSync, F as PaymentCollection, L as Payment, N as PaymentAllocation, O as syncFrozenInvoiceToAccounting, P as historicalCreditRefundCommittedTotal, R as hasConnectedPaymentAuthority, S as calculateInvoiceMinorLine, T as readFrozenAccountingSyncState, _ as reconcileOrdinaryCreditAccounting, a as reconcileRetainedBaseInvoice, b as syncOrdinaryRefundToAccounting, c as syncRetainedCreditToAccounting, d as toRetainedCreditAccountingInput, f as toRetainedInvoiceAccountingInput, g as reconcileOrdinaryBaseInvoice, h as reconcileOrdinaryAccountingStep, i as reconcileRetainedAccountingStep, j as PaymentAllocationCollection, k as toFrozenInvoiceAccountingInput, l as syncRetainedInvoiceToAccounting, m as readOrdinaryInvoiceAccountingState, n as loadRetainedInvoiceAccountingSnapshot, o as reconcileRetainedCreditAccounting, p as loadOrdinaryCreditAccountingSnapshot, r as readRetainedInvoiceAccountingState, s as releaseRetainedInvoiceToAccounting, t as loadRetainedCreditAccountingSnapshot, u as syncRetainedRefundToAccounting, v as syncOrdinaryCreditToAccounting, w as loadFrozenInvoiceAccountingSnapshot, x as toOrdinaryCreditAccountingInput, y as syncOrdinaryInvoiceToAccounting, z as withConnectedPaymentAuthority } from "./chunks/retention-accounting-D0KzSw3f.js";
6
6
  import { n as customerFundsState, r as withCustomerFundsWrite } from "./chunks/customer-funds-internal-BQzoJXK5.js";
7
7
  import { MoneyValidationError, assertIntegerMinorUnits, calculateMoneyDocument, resolveLineTaxCode } from "./money.js";
8
8
  import { n as withHistoricalCommerceWrite } from "./chunks/historical-commerce-internal-C9ButfuH.js";
9
9
  import { a as HistoricalCustomerFunds, i as HistoricalCustomerFundsAllocation, n as HistoricalCustomerFundsCollection, t as HistoricalCustomerFundsAllocationCollection } from "./chunks/HistoricalCustomerFundsCollections-B5x8gTW3.js";
10
10
  import { n as calculateAvailableRefund, t as allocateFrozenCredit } from "./chunks/credit-allocation-yspz0Lab.js";
11
11
  import { _ as withDocumentMoneyTransaction, a as assertCommerceMoneySchemaCurrent, d as withCommerceMoneyUpgradeExecutor, h as lockDocumentMoneyParents, i as OLD_MONEY_TABLES, l as findCommerceMoneyUpgradeNeeds, n as CommerceDataNeedsUpgradeError, o as assertTenantMoneyCurrent, p as DOCUMENT_MONEY_WRITE, r as OLD_MONEY_COLUMNS, s as commerceMoneyUpgradeCommand, t as COMMERCE_DATA_NEEDS_UPGRADE, u as findOldMoneySchema } from "./chunks/detect-DAE-_NAk.js";
12
- import { a as assertRetentionMinor, c as validateRetentionEvidence, i as Invoice, o as calculateInvoicePayable, r as UNPAID_STATUSES, s as parseInvoiceRetention, t as InvoiceCollection } from "./chunks/InvoiceCollection-rexZLpLi.js";
13
- import { a as materializeTenantTaxSettings, c as TaxSettings, i as TaxSettingsCollection, o as createOrLoadTaxSeed, r as withTenantMoneyRuntime, s as deterministicTaxId, t as lockTenantMoneyRuntime } from "./chunks/tenant-money-barrier-Dlfgm-v1.js";
14
- import { r as TaxCode, t as TaxCodeCollection } from "./chunks/TaxCodeCollection-DEXGRUB8.js";
15
- import { r as ContractLineItem, t as ContractLineItemCollection } from "./chunks/ContractLineItemCollection-B2ildsVf.js";
16
- import { r as TaxComponent, t as TaxComponentCollection } from "./chunks/TaxComponentCollection-BoiKGyxq.js";
17
- import { t as allowConversionLineageWrite } from "./chunks/contract-money-BwOM9bGi.js";
12
+ import { a as assertRetentionMinor, c as validateRetentionEvidence, i as Invoice, o as calculateInvoicePayable, r as UNPAID_STATUSES, s as parseInvoiceRetention, t as InvoiceCollection } from "./chunks/InvoiceCollection-Cc-fJrHy.js";
13
+ import { a as materializeTenantTaxSettings, c as TaxSettings, i as TaxSettingsCollection, o as createOrLoadTaxSeed, r as withTenantMoneyRuntime, s as deterministicTaxId, t as lockTenantMoneyRuntime } from "./chunks/tenant-money-barrier-Bmu4YiID.js";
14
+ import { r as TaxCode, t as TaxCodeCollection } from "./chunks/TaxCodeCollection-BBqCugs5.js";
15
+ import { r as ContractLineItem, t as ContractLineItemCollection } from "./chunks/ContractLineItemCollection-BKHy-nR8.js";
16
+ import { r as TaxComponent, t as TaxComponentCollection } from "./chunks/TaxComponentCollection-BHJjbQxq.js";
17
+ import { t as allowConversionLineageWrite } from "./chunks/contract-money-BoKHNfV6.js";
18
18
  import { t as buildRevenueJournalEntries } from "./chunks/revenue-journal-LLA9Kh_i.js";
19
19
  import { COMMERCE_MODULE_META, COMMERCE_UI_SLOTS } from "./ui.js";
20
20
  import { ObjectRegistry, SmrtCollection, SmrtObject, SmrtRecipe, crossPackageRef, field, foreignKey, isPostgresDatabase, isUniqueViolationError, smrt } from "@happyvertical/smrt-core";
@@ -30,7 +30,7 @@ import { SmrtReport, SmrtReportCollection, assertMaterializedReportRead, buildRe
30
30
  import { StripeAdapter } from "@happyvertical/payments/stripe";
31
31
  import { planSqliteTableRebuilds, preflightMinorUnitsRescale, rescaleMoneyColumnsToMinorUnits, sqliteRebuildPlaceholderSql } from "@happyvertical/smrt-core/migrations";
32
32
  //#region src/__smrt-register__.ts
33
- ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-commerce","packageVersion":"0.61.3","objects":{"@happyvertical/smrt-commerce:ContractCollection":{"name":"contractcollection","className":"ContractCollection","qualifiedName":"@happyvertical/smrt-commerce:ContractCollection","collection":"contracts","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/ContractCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<Contract>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<Contract>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<Contract | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<Contract>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByVendor":{"name":"findByVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"listSnapshotReportContracts":{"name":"listSnapshotReportContracts","async":true,"parameters":[{"name":"options","type":"object","optional":false,"memberTypes":["string","Date"]}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByType":{"name":"findByType","async":true,"parameters":[{"name":"contractType","type":"ContractType","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"ContractStatus","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findDrafts":{"name":"findDrafts","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findAccepted":{"name":"findAccepted","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findOverdue":{"name":"findOverdue","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findExpired":{"name":"findExpired","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Contract","exportName":"ContractCollection","collectionExportName":"ContractCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Contract","inheritedExposure":["api","mcp"],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"ff08ed4f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:ContractLineItemCollection":{"name":"contractlineitemcollection","className":"ContractLineItemCollection","qualifiedName":"@happyvertical/smrt-commerce:ContractLineItemCollection","collection":"contractlineitems","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/ContractLineItemCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<ContractLineItem>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<ContractLineItem>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<ContractLineItem | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<ContractLineItem>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"ContractLineItem","exportName":"ContractLineItemCollection","collectionExportName":"ContractLineItemCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:ContractLineItem","inheritedExposure":["api","mcp"],"schema":{"tableName":"contract_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"contract_line_items\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"description\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"product_id\\" UUID,\\n \\"sku\\" TEXT DEFAULT '',\\n \\"start_date\\" TIMESTAMP,\\n \\"end_date\\" TIMESTAMP,\\n \\"billing_period\\" TEXT DEFAULT '',\\n \\"sort_order\\" INTEGER DEFAULT 0\\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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"description":{"type":"TEXT","notNull":false,"default":""},"quantity":{"type":"REAL","notNull":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false},"tax_rate":{"type":"REAL","notNull":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false},"tax_code_name":{"type":"TEXT","notNull":false},"tax_components_json":{"type":"TEXT","notNull":false},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false},"amount":{"type":"INTEGER","notNull":false,"default":0},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"sku":{"type":"TEXT","notNull":false,"default":""},"start_date":{"type":"TIMESTAMP","notNull":false},"end_date":{"type":"TIMESTAMP","notNull":false},"billing_period":{"type":"TEXT","notNull":false,"default":""},"sort_order":{"type":"INTEGER","notNull":false,"default":0}},"indexes":[{"name":"contract_line_items_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contract_line_items_meta_type_idx","columns":["_meta_type"]},{"name":"contract_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contract_line_items_contract_id_idx","columns":["contract_id"]},{"name":"contract_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"contract_line_items_product_id_idx","columns":["product_id"]}],"version":"89a3137e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:CustomerCollection":{"name":"customercollection","className":"CustomerCollection","qualifiedName":"@happyvertical/smrt-commerce:CustomerCollection","collection":"customers","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/CustomerCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"create":{"name":"create","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true},{"name":"context","type":"Partial<AuditContext>","optional":true}],"returnType":"Promise<Customer>","isStatic":false,"isPublic":true},"update":{"name":"update","async":true,"parameters":[{"name":"id","type":"string","optional":false},{"name":"values","type":"any","optional":false,"typeUnresolved":true},{"name":"context","type":"Partial<AuditContext>","optional":true}],"returnType":"Promise<Customer | null>","isStatic":false,"isPublic":true},"findByProfile":{"name":"findByProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findActive":{"name":"findActive","async":true,"parameters":[],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"CustomerStatus","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"getOrCreateForProfile":{"name":"getOrCreateForProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false},{"name":"defaults","type":"Partial<object>","optional":true,"memberTypes":["number","string"]}],"returnType":"Promise<Customer>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get","create","update"]}},"extends":"SmrtCollection","extendsTypeArg":"Customer","exportName":"CustomerCollection","collectionExportName":"CustomerCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Customer","inheritedExposure":["api","mcp"],"schema":{"tableName":"customers","ddl":"CREATE TABLE IF NOT EXISTS \\"customers\\" (\\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 \\"profile_id\\" UUID,\\n \\"credit_limit\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"tax_exempt\\" BOOLEAN DEFAULT FALSE,\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_shipping_address\\" JSON,\\n \\"default_billing_address\\" JSON,\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"customer_type\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"credit_limit":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tax_exempt":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_shipping_address":{"type":"JSON","notNull":false,"unique":false},"default_billing_address":{"type":"JSON","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"customer_type":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"customers_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"customers_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"customers_profile_id_idx","columns":["profile_id"]},{"name":"customers_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"617d1e93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:DocumentTaxCollection":{"name":"documenttaxcollection","className":"DocumentTaxCollection","qualifiedName":"@happyvertical/smrt-commerce:DocumentTaxCollection","collection":"documenttaxes","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/DocumentTaxCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"listReportFacts":{"name":"listReportFacts","async":true,"parameters":[{"name":"options","type":"DocumentTaxReportFactsOptions","optional":false}],"returnType":"Promise<DocumentTaxReportFact[]>","isStatic":false,"isPublic":true},"findByDocument":{"name":"findByDocument","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"documentType","type":"CommerceDocumentType","optional":false},{"name":"documentId","type":"string","optional":false}],"returnType":"Promise<DocumentTax[]>","isStatic":false,"isPublic":true},"replaceDerivedForDocument":{"name":"replaceDerivedForDocument","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"input","type":"object","optional":false,"typeUnresolved":true,"memberTypes":["string","CommerceDocumentType"]}],"returnType":"Promise<DocumentTax[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"document_taxes","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"DocumentTax","exportName":"DocumentTaxCollection","collectionExportName":"DocumentTaxCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:DocumentTax","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"document_taxes","ddl":"CREATE TABLE IF NOT EXISTS \\"document_taxes\\" (\\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 \\"document_type\\" TEXT NOT NULL DEFAULT 'invoice',\\n \\"document_id\\" TEXT NOT NULL,\\n \\"currency\\" TEXT NOT NULL,\\n \\"tax_code_id\\" TEXT,\\n \\"tax_code_code\\" TEXT,\\n \\"kind\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_component_name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"net_minor\\" INTEGER,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER NOT NULL DEFAULT 0\\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},"document_type":{"type":"TEXT","notNull":true,"unique":false,"default":"invoice"},"document_id":{"type":"TEXT","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":true,"unique":false},"tax_code_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_component_name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"net_minor":{"type":"INTEGER","notNull":false,"unique":false},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0}},"indexes":[{"name":"document_taxes_document_type_document_id_idx","columns":["document_type","document_id","tax_code_id","tax_component_id"],"unique":true,"nullsNotDistinct":true},{"name":"document_taxes_slug_context_idx","columns":["slug","context"]},{"name":"document_taxes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b35e53b9"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:FulfillmentCollection":{"name":"fulfillmentcollection","className":"FulfillmentCollection","qualifiedName":"@happyvertical/smrt-commerce:FulfillmentCollection","collection":"fulfillments","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/FulfillmentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"FulfillmentStatus","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByType":{"name":"findByType","async":true,"parameters":[{"name":"fulfillmentType","type":"FulfillmentType","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findPending":{"name":"findPending","async":true,"parameters":[],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findInTransit":{"name":"findInTransit","async":true,"parameters":[],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByTracking":{"name":"findByTracking","async":true,"parameters":[{"name":"trackingNumber","type":"string","optional":false}],"returnType":"Promise<Fulfillment | null>","isStatic":false,"isPublic":true},"findShippedInRange":{"name":"findShippedInRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Fulfillment","exportName":"FulfillmentCollection","collectionExportName":"FulfillmentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Fulfillment","inheritedExposure":["api","mcp"],"schema":{"tableName":"fulfillments","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillments\\" (\\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 \\"contract_id\\" UUID,\\n \\"fulfillment_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"tracking_number\\" TEXT DEFAULT '',\\n \\"carrier\\" TEXT DEFAULT '',\\n \\"shipping_address\\" JSON,\\n \\"shipped_at\\" TIMESTAMP,\\n \\"delivered_at\\" TIMESTAMP,\\n \\"estimated_delivery\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT ''\\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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"fulfillment_type":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"tracking_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"carrier":{"type":"TEXT","notNull":false,"unique":false,"default":""},"shipping_address":{"type":"JSON","notNull":false,"unique":false},"shipped_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"delivered_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"estimated_delivery":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillments_contract_id_idx","columns":["contract_id"]}],"version":"3970fcbd"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:FulfillmentLineItemCollection":{"name":"fulfillmentlineitemcollection","className":"FulfillmentLineItemCollection","qualifiedName":"@happyvertical/smrt-commerce:FulfillmentLineItemCollection","collection":"fulfillmentlineitems","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/FulfillmentLineItemCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByFulfillment":{"name":"findByFulfillment","async":true,"parameters":[{"name":"fulfillmentId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"findByContractLineItem":{"name":"findByContractLineItem","async":true,"parameters":[{"name":"contractLineItemId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"getTotalFulfilledForContractLine":{"name":"getTotalFulfilledForContractLine","async":true,"parameters":[{"name":"contractLineItemId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"FulfillmentLineItem","exportName":"FulfillmentLineItemCollection","collectionExportName":"FulfillmentLineItemCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:FulfillmentLineItem","inheritedExposure":["api","mcp"],"schema":{"tableName":"fulfillment_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillment_line_items\\" (\\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 \\"fulfillment_id\\" UUID,\\n \\"contract_line_item_id\\" UUID,\\n \\"quantity_fulfilled\\" REAL DEFAULT 1,\\n \\"notes\\" TEXT DEFAULT ''\\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},"fulfillment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"fulfillments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_line_item_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contract_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"quantity_fulfilled":{"type":"REAL","notNull":false,"unique":false,"default":1},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillment_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillment_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillment_line_items_fulfillment_id_idx","columns":["fulfillment_id"]},{"name":"fulfillment_line_items_contract_line_item_id_idx","columns":["contract_line_item_id"]}],"version":"acf1ca5f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFundsCollection":{"name":"historicalcustomerfundscollection","className":"HistoricalCustomerFundsCollection","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFundsCollection","collection":"historicalcustomerfundses","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/HistoricalCustomerFundsCollections.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"historical_customer_funds","api":{"include":["get","list"]},"mcp":{"include":["get","list"]},"cli":{"include":["get","list"]}},"extends":"SmrtCollection","extendsTypeArg":"HistoricalCustomerFunds","exportName":"HistoricalCustomerFundsCollection","collectionExportName":"HistoricalCustomerFundsCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:HistoricalCustomerFunds","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"historical_customer_funds","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds\\" (\\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 \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'receipt',\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"payment_id\\" UUID,\\n \\"currency\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"source_receipt_id\\" UUID,\\n \\"source_credit_note_id\\" UUID,\\n \\"snapshot_json\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"receipt"},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"currency":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"source_receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_customer_funds_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_customer_id_idx","columns":["customer_id"]},{"name":"historical_customer_funds_contract_id_idx","columns":["contract_id"]},{"name":"historical_customer_funds_payment_id_idx","columns":["payment_id"]},{"name":"historical_customer_funds_source_receipt_id_idx","columns":["source_receipt_id"]},{"name":"historical_customer_funds_source_credit_note_id_idx","columns":["source_credit_note_id"]}],"version":"96a8006b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocationCollection":{"name":"historicalcustomerfundsallocationcollection","className":"HistoricalCustomerFundsAllocationCollection","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocationCollection","collection":"historicalcustomerfundsallocations","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/HistoricalCustomerFundsCollections.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"historical_customer_funds_allocations","api":{"include":["get","list"]},"mcp":{"include":["get","list"]},"cli":{"include":["get","list"]}},"extends":"SmrtCollection","extendsTypeArg":"HistoricalCustomerFundsAllocation","exportName":"HistoricalCustomerFundsAllocationCollection","collectionExportName":"HistoricalCustomerFundsAllocationCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocation","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"historical_customer_funds_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds_allocations\\" (\\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 \\"receipt_id\\" UUID,\\n \\"credit_note_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"effect\\" TEXT DEFAULT 'payment',\\n \\"journal_id\\" UUID,\\n \\"snapshot_json\\" 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},"receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"effect":{"type":"TEXT","notNull":false,"unique":false,"default":"payment"},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_funds_allocation_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_allocations_receipt_id_idx","columns":["receipt_id"]},{"name":"historical_customer_funds_allocations_credit_note_id_idx","columns":["credit_note_id"]},{"name":"historical_customer_funds_allocations_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_customer_funds_allocations_journal_id_idx","columns":["journal_id"]}],"version":"6c92192c"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalSalesLineCollection":{"name":"historicalsaleslinecollection","className":"HistoricalSalesLineCollection","qualifiedName":"@happyvertical/smrt-commerce:HistoricalSalesLineCollection","collection":"historicalsaleslines","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/HistoricalSalesLineCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"historical_sales_lines","api":{"include":["get","list"]},"mcp":{"include":["get","list"]},"cli":{"include":["get","list"]}},"extends":"SmrtCollection","extendsTypeArg":"HistoricalSalesLine","exportName":"HistoricalSalesLineCollection","collectionExportName":"HistoricalSalesLineCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:HistoricalSalesLine","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"historical_sales_lines","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_sales_lines\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"source_key\\" TEXT,\\n \\"source_key_hash\\" TEXT,\\n \\"description\\" TEXT,\\n \\"net_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER,\\n \\"gross_minor\\" INTEGER,\\n \\"quantity_text\\" TEXT,\\n \\"unit_rate_text\\" TEXT,\\n \\"source_fields_json\\" TEXT,\\n \\"money_snapshot_id\\" 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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_sales_lines","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key":{"type":"TEXT","notNull":false,"unique":false},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false},"net_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"gross_minor":{"type":"INTEGER","notNull":false,"unique":false},"quantity_text":{"type":"TEXT","notNull":false,"unique":false},"unit_rate_text":{"type":"TEXT","notNull":false,"unique":false},"source_fields_json":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_sales_lines_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_sales_line_source_key","columns":["tenant_id","invoice_id","source_key_hash"],"unique":true},{"name":"historical_sales_lines_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_sales_lines_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_sales_lines_credited_line_id_idx","columns":["credited_line_id"]}],"version":"d5807042"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:InvoiceCollection":{"name":"invoicecollection","className":"InvoiceCollection","qualifiedName":"@happyvertical/smrt-commerce:InvoiceCollection","collection":"invoices","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/InvoiceCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<Invoice>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<Invoice>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<Invoice | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<Invoice>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"InvoiceStatus","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findDrafts":{"name":"findDrafts","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findSent":{"name":"findSent","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findPaid":{"name":"findPaid","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findPartial":{"name":"findPartial","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findOverdue":{"name":"findOverdue","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByExternalId":{"name":"findByExternalId","async":true,"parameters":[{"name":"externalId","type":"string","optional":false}],"returnType":"Promise<Invoice | null>","isStatic":false,"isPublic":true},"findNeedingSync":{"name":"findNeedingSync","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByNumber":{"name":"findByNumber","async":true,"parameters":[{"name":"invoiceNumber","type":"string","optional":false}],"returnType":"Promise<Invoice | null>","isStatic":false,"isPublic":true},"countForYear":{"name":"countForYear","async":true,"parameters":[{"name":"year","type":"number","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"generateInvoiceNumber":{"name":"generateInvoiceNumber","async":true,"parameters":[{"name":"options","type":"InvoiceNumberOptions","optional":true}],"returnType":"Promise<string>","isStatic":false,"isPublic":true},"getTotalOutstandingForCustomer":{"name":"getTotalOutstandingForCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Invoice","exportName":"InvoiceCollection","collectionExportName":"InvoiceCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Invoice","inheritedExposure":["api","mcp"],"schema":{"tableName":"invoices","ddl":"CREATE TABLE IF NOT EXISTS \\"invoices\\" (\\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 \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"historical_sales_money_json\\" TEXT,\\n \\"historical_source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'invoice',\\n \\"credited_invoice_id\\" UUID,\\n \\"credited_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"retention_state_json\\" TEXT,\\n \\"retention_accounting_state_json\\" TEXT,\\n \\"ordinary_accounting_state_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"invoice_number\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"paid_date\\" TIMESTAMP,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"provider_tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'CAD',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"discount_total\\" INTEGER NOT NULL DEFAULT 0,\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"status\\" TEXT,\\n \\"ar_journal_id\\" UUID,\\n \\"ar_reversal_journal_id\\" UUID,\\n \\"revenue_journal_id\\" UUID,\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"customer_external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"accounting_sync_state_json\\" TEXT,\\n \\"collection_method\\" TEXT DEFAULT '',\\n \\"sent_at\\" TIMESTAMP,\\n \\"viewed_at\\" TIMESTAMP,\\n \\"reminders_sent\\" INTEGER DEFAULT 0,\\n \\"last_reminder_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"customer_notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT ''\\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"},"money_authority":{"type":"TEXT","notNull":false,"unique":false,"default":"calculated"},"historical_sales_money_json":{"type":"TEXT","notNull":false,"unique":false},"historical_source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"invoice"},"credited_invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"retention_state_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"issue_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"due_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"paid_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"provider_tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"CAD"},"line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"discount_total":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"seller_tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false},"party_tax_id":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"ar_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"ar_reversal_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"revenue_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"accounting_sync_state_json":{"type":"TEXT","notNull":false,"unique":false},"collection_method":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"viewed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"reminders_sent":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_reminder_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"invoices_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_historical_source_identity","columns":["tenant_id","historical_source_key_hash"],"unique":true},{"name":"invoices_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoices_credited_invoice_id_idx","columns":["credited_invoice_id"]},{"name":"invoices_customer_id_idx","columns":["customer_id"]},{"name":"invoices_contract_id_idx","columns":["contract_id"]},{"name":"invoices_ar_journal_id_idx","columns":["ar_journal_id"]},{"name":"invoices_ar_reversal_journal_id_idx","columns":["ar_reversal_journal_id"]},{"name":"invoices_revenue_journal_id_idx","columns":["revenue_journal_id"]}],"version":"20ebe916"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:InvoiceLineItemCollection":{"name":"invoicelineitemcollection","className":"InvoiceLineItemCollection","qualifiedName":"@happyvertical/smrt-commerce:InvoiceLineItemCollection","collection":"invoicelineitems","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/InvoiceLineItemCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<InvoiceLineItem>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<InvoiceLineItem>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<InvoiceLineItem | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<InvoiceLineItem>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByInvoice":{"name":"findByInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findBySource":{"name":"findBySource","async":true,"parameters":[{"name":"sourceType","type":"string","optional":false},{"name":"sourceId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findBySourceType":{"name":"findBySourceType","async":true,"parameters":[{"name":"sourceType","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"getTotalForInvoice":{"name":"getTotalForInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getNextSortOrder":{"name":"getNextSortOrder","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"InvoiceLineItem","exportName":"InvoiceLineItemCollection","collectionExportName":"InvoiceLineItemCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:InvoiceLineItem","inheritedExposure":["api","mcp"],"schema":{"tableName":"invoice_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"invoice_line_items\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"credit_calculation_basis_json\\" TEXT,\\n \\"description\\" TEXT DEFAULT '',\\n \\"sku\\" TEXT DEFAULT '',\\n \\"product_id\\" UUID,\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"source_type\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"source_reservation_id\\" TEXT,\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"revenue_account_id\\" UUID,\\n \\"sort_order\\" INTEGER DEFAULT 0\\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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoice_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_calculation_basis_json":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sku":{"type":"TEXT","notNull":false,"unique":false,"default":""},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false,"unique":false},"tax_rate":{"type":"REAL","notNull":false,"unique":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"tax_code_name":{"type":"TEXT","notNull":false,"unique":false},"tax_components_json":{"type":"TEXT","notNull":false,"unique":false},"tax_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_reservation_id":{"type":"TEXT","notNull":false,"unique":false},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"revenue_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0}},"indexes":[{"name":"invoice_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoice_line_items_invoice_id_idx","columns":["invoice_id"]},{"name":"invoice_line_items_credited_line_id_idx","columns":["credited_line_id"]},{"name":"invoice_line_items_product_id_idx","columns":["product_id"]},{"name":"invoice_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"invoice_line_items_revenue_account_id_idx","columns":["revenue_account_id"]}],"version":"78dcf926"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentAllocationCollection":{"name":"paymentallocationcollection","className":"PaymentAllocationCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentAllocationCollection","collection":"paymentallocations","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/PaymentAllocationCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"allocatePayment":{"name":"allocatePayment","async":true,"parameters":[{"name":"input","type":"object","optional":false,"memberTypes":["string","object[]","number"]}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"removeAllocation":{"name":"removeAllocation","async":true,"parameters":[{"name":"id","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"findByPayment":{"name":"findByPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findByInvoice":{"name":"findByInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"getTotalAllocatedToInvoice":{"name":"getTotalAllocatedToInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getTotalAllocatedFromPayment":{"name":"getTotalAllocatedFromPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getUnallocatedFromPayment":{"name":"getUnallocatedFromPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false},{"name":"paymentAmount","type":"number","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByPaymentAndInvoice":{"name":"findByPaymentAndInvoice","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false},{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation | null>","isStatic":false,"isPublic":true},"findByAllocator":{"name":"findByAllocator","async":true,"parameters":[{"name":"allocatedBy","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"PaymentAllocation","exportName":"PaymentAllocationCollection","collectionExportName":"PaymentAllocationCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PaymentAllocation","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"payment_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_allocations\\" (\\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 \\"payment_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"allocated_at\\" TIMESTAMP,\\n \\"allocated_by\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"allocated_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"allocated_by":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_allocations_payment_id_idx","columns":["payment_id"]},{"name":"payment_allocations_invoice_id_idx","columns":["invoice_id"]}],"version":"72c493d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentCollection":{"name":"paymentcollection","className":"PaymentCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentCollection","collection":"payments","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/PaymentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"PaymentStatus","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByMethod":{"name":"findByMethod","async":true,"parameters":[{"name":"method","type":"PaymentMethod","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findPending":{"name":"findPending","async":true,"parameters":[],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findCompleted":{"name":"findCompleted","async":true,"parameters":[],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByTransactionId":{"name":"findByTransactionId","async":true,"parameters":[{"name":"transactionId","type":"string","optional":false}],"returnType":"Promise<Payment | null>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"getTotalForContract":{"name":"getTotalForContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByJournal":{"name":"findByJournal","async":true,"parameters":[{"name":"journalId","type":"string","optional":false}],"returnType":"Promise<Payment | null>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Payment","exportName":"PaymentCollection","collectionExportName":"PaymentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Payment","inheritedExposure":["api","mcp"],"schema":{"tableName":"payments","ddl":"CREATE TABLE IF NOT EXISTS \\"payments\\" (\\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 'payment',\\n \\"customer_funds_json\\" TEXT,\\n \\"retention_accounting_binding_json\\" TEXT,\\n \\"ordinary_accounting_binding_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"method\\" TEXT,\\n \\"status\\" TEXT,\\n \\"transaction_id\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"journal_id\\" UUID,\\n \\"paid_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"native_amount\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"usd_at_quote\\" INTEGER DEFAULT 0,\\n \\"usd_at_confirmation\\" INTEGER DEFAULT 0,\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"refund_of_payment_id\\" TEXT DEFAULT '',\\n \\"connected_refund_state\\" TEXT DEFAULT '',\\n \\"application_fee_refunded\\" BOOLEAN DEFAULT FALSE\\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":"payment"},"customer_funds_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"method":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"transaction_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"usd_at_quote":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"usd_at_confirmation":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refund_of_payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_refund_state":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_refunded":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"payments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payments_contract_id_idx","columns":["contract_id"]},{"name":"payments_customer_id_idx","columns":["customer_id"]},{"name":"payments_journal_id_idx","columns":["journal_id"]}],"version":"2f961b5b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentInstrumentCollection":{"name":"paymentinstrumentcollection","className":"PaymentInstrumentCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentInstrumentCollection","collection":"paymentinstruments","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/PaymentInstrumentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findActiveByCustomer":{"name":"findActiveByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findDefaultForCustomer":{"name":"findDefaultForCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument | null>","isStatic":false,"isPublic":true},"findByProviderPaymentMethodId":{"name":"findByProviderPaymentMethodId","async":true,"parameters":[{"name":"providerPaymentMethodId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument | null>","isStatic":false,"isPublic":true},"setDefaultForCustomer":{"name":"setDefaultForCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false},{"name":"instrumentId","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"PaymentInstrument","exportName":"PaymentInstrumentCollection","collectionExportName":"PaymentInstrumentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PaymentInstrument","inheritedExposure":["api","mcp"],"schema":{"tableName":"payment_instruments","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_instruments\\" (\\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 \\"customer_id\\" UUID,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"provider_payment_method_id\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'card',\\n \\"brand\\" TEXT DEFAULT '',\\n \\"last4\\" TEXT DEFAULT '',\\n \\"exp_month\\" INTEGER DEFAULT 0,\\n \\"exp_year\\" INTEGER DEFAULT 0,\\n \\"is_default\\" BOOLEAN DEFAULT FALSE,\\n \\"status\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_payment_method_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"card"},"brand":{"type":"TEXT","notNull":false,"unique":false,"default":""},"last4":{"type":"TEXT","notNull":false,"unique":false,"default":""},"exp_month":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"exp_year":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"is_default":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"status":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"payment_instruments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_instruments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_instruments_customer_id_idx","columns":["customer_id"]}],"version":"fcbc59d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentIntentCollection":{"name":"paymentintentcollection","className":"PaymentIntentCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentIntentCollection","collection":"paymentintents","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/PaymentIntentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByIdempotencyKey":{"name":"findByIdempotencyKey","async":true,"parameters":[{"name":"args","type":"PaymentIntentIdempotencyArgs","optional":false}],"returnType":"Promise<PaymentIntent | null>","isStatic":false,"isPublic":true},"getOrCreateByIdempotencyKey":{"name":"getOrCreateByIdempotencyKey","async":true,"parameters":[{"name":"seed","type":"PaymentIntentSeed","optional":false}],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"findOpen":{"name":"findOpen","async":true,"parameters":[],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findStale":{"name":"findStale","async":true,"parameters":[],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByLicenseeEmail":{"name":"findByLicenseeEmail","async":true,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByOfferingRef":{"name":"findByOfferingRef","async":true,"parameters":[{"name":"offeringRef","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"PaymentIntentStatus","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"PaymentIntent","exportName":"PaymentIntentCollection","collectionExportName":"PaymentIntentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PaymentIntent","inheritedExposure":["api","mcp"],"schema":{"tableName":"payment_intents","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_intents\\" (\\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 \\"sku_id\\" TEXT DEFAULT '',\\n \\"offering_ref\\" TEXT DEFAULT '',\\n \\"licensee_email\\" TEXT DEFAULT '',\\n \\"customer_id\\" TEXT DEFAULT '',\\n \\"payment_options\\" JSON DEFAULT '[]',\\n \\"usd_price_locked\\" INTEGER DEFAULT 0,\\n \\"price_lock_window_ms\\" INTEGER,\\n \\"price_lock_expires_at\\" TIMESTAMP,\\n \\"status\\" TEXT,\\n \\"idempotency_key\\" TEXT DEFAULT '',\\n \\"paid_option_backend_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"paid_at\\" TIMESTAMP,\\n \\"issued_at\\" TIMESTAMP,\\n \\"expired_at\\" TIMESTAMP,\\n \\"cancelled_at\\" TIMESTAMP,\\n \\"retired_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"connected_environment\\" TEXT DEFAULT '',\\n \\"connected_amount\\" INTEGER DEFAULT 0,\\n \\"connected_currency\\" TEXT DEFAULT ''\\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},"sku_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"offering_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"licensee_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_options":{"type":"JSON","notNull":false,"unique":false,"default":[]},"usd_price_locked":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_lock_window_ms":{"type":"INTEGER","notNull":false,"unique":false},"price_lock_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"idempotency_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_option_backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"expired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancelled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"retired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_environment":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_intents_tenant_id_offering_ref_idx","columns":["tenant_id","offering_ref","licensee_email","idempotency_key"],"unique":true,"nullsNotDistinct":true},{"name":"payment_intents_slug_context_idx","columns":["slug","context"]},{"name":"payment_intents_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"92f80d93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PayoutCollection":{"name":"payoutcollection","className":"PayoutCollection","qualifiedName":"@happyvertical/smrt-commerce:PayoutCollection","collection":"payouts","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/PayoutCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"createFromPayment":{"name":"createFromPayment","async":true,"parameters":[{"name":"args","type":"CreatePayoutFromPaymentArgs","optional":false}],"returnType":"Promise<Payout>","isStatic":false,"isPublic":true},"findByPayment":{"name":"findByPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findByVendor":{"name":"findByVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"PayoutStatus","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findPending":{"name":"findPending","async":true,"parameters":[],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findFailed":{"name":"findFailed","async":true,"parameters":[],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findByBackendTxRef":{"name":"findByBackendTxRef","async":true,"parameters":[{"name":"backendTxRef","type":"string","optional":false}],"returnType":"Promise<Payout | null>","isStatic":false,"isPublic":true},"getConfirmedTotalForVendor":{"name":"getConfirmedTotalForVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Payout","exportName":"PayoutCollection","collectionExportName":"PayoutCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Payout","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"payouts","ddl":"CREATE TABLE IF NOT EXISTS \\"payouts\\" (\\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 \\"payment_id\\" TEXT DEFAULT '',\\n \\"vendor_id\\" UUID,\\n \\"gross_amount\\" INTEGER DEFAULT 0,\\n \\"operator_fee\\" INTEGER DEFAULT 0,\\n \\"supplier_net\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT '',\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"sent_at\\" TIMESTAMP,\\n \\"confirmed_at\\" TIMESTAMP,\\n \\"failed_at\\" TIMESTAMP,\\n \\"failure_reason\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"gross_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"operator_fee":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"supplier_net":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"confirmed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failure_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payouts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payouts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payouts_vendor_id_idx","columns":["vendor_id"]}],"version":"777cae02"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchaseContractCollection":{"name":"purchasecontractcollection","className":"PurchaseContractCollection","qualifiedName":"@happyvertical/smrt-commerce:PurchaseContractCollection","collection":"contracts","description":"Read supplier-side contracts across every purchase STI subtype.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/PurchaseContractCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByVendor":{"name":"findByVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<PurchaseContract[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"contracts","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","findByVendor"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","findByVendor"]},"cli":{"exclude":["create","update","delete","findByVendor"]}},"extends":"SmrtCollection","extendsTypeArg":"PurchaseContract","exportName":"PurchaseContractCollection","collectionExportName":"PurchaseContractCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PurchaseContract","inheritedExposure":["api","mcp"],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"fee54480"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchasePriceObservationCollection":{"name":"purchasepriceobservationcollection","className":"PurchasePriceObservationCollection","qualifiedName":"@happyvertical/smrt-commerce:PurchasePriceObservationCollection","collection":"purchasepriceobservations","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/PurchasePriceObservationCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"PurchasePriceObservation","exportName":"PurchasePriceObservationCollection","collectionExportName":"PurchasePriceObservationCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PurchasePriceObservation","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"purchase_price_observations","ddl":"CREATE TABLE IF NOT EXISTS \\"purchase_price_observations\\" (\\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_identity\\" TEXT,\\n \\"vendor_id\\" TEXT,\\n \\"snapshot_json\\" TEXT,\\n \\"completion_json\\" 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_identity":{"type":"TEXT","notNull":false,"unique":false},"vendor_id":{"type":"TEXT","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false},"completion_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"purchase_price_observations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"purchase_price_observations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"2a855c4b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:SalesContractCollection":{"name":"salescontractcollection","className":"SalesContractCollection","qualifiedName":"@happyvertical/smrt-commerce:SalesContractCollection","collection":"contracts","description":"Read customer-side contracts across every sales STI subtype.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/SalesContractCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<SalesContract[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"contracts","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","findByCustomer"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","findByCustomer"]},"cli":{"exclude":["create","update","delete","findByCustomer"]}},"extends":"SmrtCollection","extendsTypeArg":"SalesContract","exportName":"SalesContractCollection","collectionExportName":"SalesContractCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:SalesContract","inheritedExposure":["api","mcp"],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"c54df156"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxCodeCollection":{"name":"taxcodecollection","className":"TaxCodeCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxCodeCollection","collection":"taxcodes","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/TaxCodeCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByCode":{"name":"findByCode","async":true,"parameters":[{"name":"code","type":"string","optional":false},{"name":"tenantId","type":"string","optional":true}],"returnType":"Promise<TaxCode | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"TaxCode","exportName":"TaxCodeCollection","collectionExportName":"TaxCodeCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxCode","inheritedExposure":["api","mcp"],"schema":{"tableName":"tax_codes","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_codes\\" (\\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 \\"code\\" TEXT,\\n \\"name\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'taxable',\\n \\"applies_to\\" TEXT DEFAULT 'both',\\n \\"components_json\\" TEXT,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"code":{"type":"TEXT","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"taxable"},"applies_to":{"type":"TEXT","notNull":false,"unique":false,"default":"both"},"components_json":{"type":"TEXT","notNull":false,"unique":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_codes_tenant_id_code_idx","columns":["tenant_id","code"],"unique":true,"nullsNotDistinct":true},{"name":"tax_codes_slug_context_idx","columns":["slug","context"]},{"name":"tax_codes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"583dc2f0"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxComponentCollection":{"name":"taxcomponentcollection","className":"TaxComponentCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxComponentCollection","collection":"taxcomponents","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/TaxComponentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"TaxComponent","exportName":"TaxComponentCollection","collectionExportName":"TaxComponentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxComponent","inheritedExposure":["api","mcp"],"schema":{"tableName":"tax_components","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_components\\" (\\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 \\"name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" UUID,\\n \\"recoverable\\" BOOLEAN NOT NULL DEFAULT FALSE,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recoverable":{"type":"BOOLEAN","notNull":true,"unique":false,"default":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_components_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tax_components_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_components_liability_account_id_idx","columns":["liability_account_id"]}],"version":"79db2a87"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSettingsCollection":{"name":"taxsettingscollection","className":"TaxSettingsCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxSettingsCollection","collection":"taxsettingses","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/TaxSettingsCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"getOrCreateForTenant":{"name":"getOrCreateForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TaxSettings>","isStatic":false,"isPublic":true},"getForTenant":{"name":"getForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TaxSettings | null>","isStatic":false,"isPublic":true},"lockForTenant":{"name":"lockForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TaxSettings>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["get","create","update"]},"mcp":{"include":["get"]}},"extends":"SmrtCollection","extendsTypeArg":"TaxSettings","exportName":"TaxSettingsCollection","collectionExportName":"TaxSettingsCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxSettings","inheritedExposure":["api","mcp"],"schema":{"tableName":"tax_settings","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_settings\\" (\\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 \\"default_sales_tax_code_id\\" UUID,\\n \\"default_purchase_tax_code_id\\" UUID,\\n \\"default_line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"tax_registrations_json\\" 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},"default_sales_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_purchase_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_settings_tenant_id_idx","columns":["tenant_id"],"unique":true},{"name":"tax_settings_slug_context_idx","columns":["slug","context"]},{"name":"tax_settings_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_settings_default_sales_tax_code_id_idx","columns":["default_sales_tax_code_id"]},{"name":"tax_settings_default_purchase_tax_code_id_idx","columns":["default_purchase_tax_code_id"]}],"version":"e8ebb46e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSummaryReportCollection":{"name":"taxsummaryreportcollection","className":"TaxSummaryReportCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxSummaryReportCollection","collection":"taxsummaryreports","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/TaxSummaryReportCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"refresh":{"name":"refresh","async":true,"parameters":[{"name":"options","type":"Omit<ReportRefreshOptions, 'db'>","optional":true}],"returnType":"Promise<ReportRefreshResult>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<TaxSummaryReport>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"any","optional":false,"typeUnresolved":true},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<TaxSummaryReport | null>","isStatic":false,"isPublic":true},"count":{"name":"count","async":true,"parameters":[{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"refreshTaxSummary":{"name":"refreshTaxSummary","async":true,"parameters":[{"name":"options","type":"RefreshTaxSummaryReportOptions","optional":false}],"returnType":"Promise<TaxSummaryReportRefreshResult>","isStatic":false,"isPublic":true},"drilldownInvoiceFacts":{"name":"drilldownInvoiceFacts","async":true,"parameters":[{"name":"options","type":"TaxSummaryInvoiceDrilldownOptions","optional":false}],"returnType":"Promise<InvoiceTaxReportFact[]>","isStatic":false,"isPublic":true},"drilldownContributors":{"name":"drilldownContributors","async":true,"parameters":[{"name":"options","type":"TaxSummaryContributorDrilldownOptions","optional":false}],"returnType":"Promise<TaxSummaryContributorDrilldown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tax_summary_reports","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtReportCollection","extendsTypeArg":"TaxSummaryReport","exportName":"TaxSummaryReportCollection","collectionExportName":"TaxSummaryReportCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxSummaryReport","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"tax_summary_reports","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_summary_reports\\" (\\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 \\"refreshed_at\\" TIMESTAMP,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"period_from\\" TIMESTAMP,\\n \\"period_to\\" TIMESTAMP,\\n \\"currency\\" TEXT,\\n \\"row_kind\\" TEXT DEFAULT 'component',\\n \\"dimension_key\\" TEXT,\\n \\"direction\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_code_kind\\" TEXT,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER,\\n \\"ledger_movement_minor\\" INTEGER,\\n \\"net_tax_minor\\" INTEGER,\\n \\"difference_minor\\" INTEGER,\\n \\"document_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"source_scopes\\" TEXT,\\n \\"complete\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"warning_code\\" TEXT,\\n \\"warning_source_type\\" TEXT,\\n \\"warning_source_id\\" TEXT,\\n \\"warning_message\\" 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"},"refreshed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"period_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false},"row_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"component"},"dimension_key":{"type":"TEXT","notNull":false,"unique":false},"direction":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_kind":{"type":"TEXT","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":false,"unique":false},"ledger_movement_minor":{"type":"INTEGER","notNull":false,"unique":false},"net_tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"difference_minor":{"type":"INTEGER","notNull":false,"unique":false},"document_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"source_scopes":{"type":"TEXT","notNull":false,"unique":false},"complete":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"warning_code":{"type":"TEXT","notNull":false,"unique":false},"warning_source_type":{"type":"TEXT","notNull":false,"unique":false},"warning_source_id":{"type":"TEXT","notNull":false,"unique":false},"warning_message":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_summary_reports_tenant_id_period_from_idx","columns":["tenant_id","period_from","period_to","currency","row_kind","dimension_key"],"unique":true,"nullsNotDistinct":true},{"name":"tax_summary_reports_slug_context_idx","columns":["slug","context"]},{"name":"tax_summary_reports_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"d4d5ebbe"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentAccountCollection":{"name":"tenantpaymentaccountcollection","className":"TenantPaymentAccountCollection","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentAccountCollection","collection":"tenantpaymentaccounts","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/TenantPaymentAccountCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"build":{"name":"build","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<TenantPaymentAccount>","isStatic":false,"isPublic":true},"findForTenant":{"name":"findForTenant","async":true,"parameters":[{"name":"args","type":"object","optional":false,"memberTypes":["string","TenantPaymentEnvironment"]}],"returnType":"Promise<TenantPaymentAccount | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tenant_payment_accounts","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"],"skipApiCheck":true}},"extends":"SmrtCollection","extendsTypeArg":"TenantPaymentAccount","exportName":"TenantPaymentAccountCollection","collectionExportName":"TenantPaymentAccountCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TenantPaymentAccount","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"tenant_payment_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_accounts\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT 'stripe',\\n \\"environment\\" TEXT NOT NULL DEFAULT 'test',\\n \\"provider_account_id\\" TEXT NOT NULL DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'pending',\\n \\"charges_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"details_submitted\\" BOOLEAN DEFAULT FALSE,\\n \\"payouts_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"capabilities_json\\" TEXT,\\n \\"capabilities_observed_at\\" TIMESTAMP,\\n \\"fee_policy_ref\\" TEXT DEFAULT '',\\n \\"disabled_at\\" TIMESTAMP,\\n \\"disabled_reason\\" TEXT DEFAULT ''\\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},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":"stripe"},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"pending"},"charges_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"details_submitted":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"payouts_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"capabilities_json":{"type":"TEXT","notNull":false,"unique":false},"capabilities_observed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"disabled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"disabled_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"tenant_payment_accounts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_accounts_tenant_backend_environment","columns":["tenant_id","backend_id","environment"],"unique":true},{"name":"tenant_payment_accounts_provider_account","columns":["backend_id","environment","provider_account_id"],"unique":true},{"name":"tenant_payment_accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"ea6f5edc"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:VendorCollection":{"name":"vendorcollection","className":"VendorCollection","qualifiedName":"@happyvertical/smrt-commerce:VendorCollection","collection":"vendors","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/collections/VendorCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByProfile":{"name":"findByProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findActive":{"name":"findActive","async":true,"parameters":[],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"VendorStatus","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"getOrCreateForProfile":{"name":"getOrCreateForProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false},{"name":"defaults","type":"Partial<object>","optional":true,"memberTypes":["number","string"]}],"returnType":"Promise<Vendor>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Vendor","exportName":"VendorCollection","collectionExportName":"VendorCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Vendor","inheritedExposure":["api","mcp"],"schema":{"tableName":"vendors","ddl":"CREATE TABLE IF NOT EXISTS \\"vendors\\" (\\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 \\"profile_id\\" UUID,\\n \\"lead_time_days\\" INTEGER DEFAULT 0,\\n \\"minimum_order_amount\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_contact_email\\" TEXT DEFAULT '',\\n \\"default_contact_phone\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"payout_addresses\\" JSON DEFAULT '{}',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"lead_time_days":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"minimum_order_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_contact_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_contact_phone":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payout_addresses":{"type":"JSON","notNull":false,"unique":false,"default":{}},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"vendors_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"vendors_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"vendors_profile_id_idx","columns":["profile_id"]},{"name":"vendors_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"6cac701f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Contract":{"name":"contract","className":"Contract","qualifiedName":"@happyvertical/smrt-commerce:Contract","collection":"contracts","description":"Contract is the base class for all commercial agreements.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"label":"reference","list":["reference","customerId","vendorId","status","totalAmount","issueDate","dueDate"]},"tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context","_meta_type"]},"extends":"SmrtObject","exportName":"Contract","collectionExportName":"ContractCollection","displayLabelField":"reference","schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"ff08ed4f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:SalesContract":{"name":"salescontract","className":"SalesContract","qualifiedName":"@happyvertical/smrt-commerce:SalesContract","collection":"contracts","description":"Customer-side contracts, including orders, estimates, and licenses.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":false,"related":"Customer","_meta":{"description":"The customer a sales order or agreement is for."}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"abstract":true,"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"cli":{"skipApiCheck":true,"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]}},"extends":"Contract","exportName":"SalesContract","collectionExportName":"SalesContractCollection","abstractDeclaredApi":null,"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"c54df156"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchaseContract":{"name":"purchasecontract","className":"PurchaseContract","qualifiedName":"@happyvertical/smrt-commerce:PurchaseContract","collection":"contracts","description":"Supplier-side contracts, including supplier quotes, purchase and production orders.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"vendorId":{"type":"foreignKey","required":false,"related":"Vendor","_meta":{"description":"The vendor supplying this quote or purchase contract."}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"abstract":true,"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"cli":{"skipApiCheck":true,"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]}},"extends":"Contract","exportName":"PurchaseContract","collectionExportName":"PurchaseContractCollection","abstractDeclaredApi":null,"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"fee54480"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Estimate":{"name":"estimate","className":"Estimate","qualifiedName":"@happyvertical/smrt-commerce:Estimate","collection":"contracts","description":"Quote or proposal for a customer","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":true,"related":"Customer","_meta":{"required":true}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Estimate","collectionExportName":"EstimateCollection","validationRules":[{"field":"customerId","rule":"required","fieldType":"foreignKey"}],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"024e587f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Order":{"name":"order","className":"Order","qualifiedName":"@happyvertical/smrt-commerce:Order","collection":"contracts","description":"Customer purchase order","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":true,"related":"Customer","_meta":{"required":true}},"sourceEstimateId":{"type":"meta","required":false,"default":"","description":"The accepted estimate this order was converted from, if any.","_meta":{"description":"The accepted estimate this order was converted from, if any.","underlyingType":"text"}},"conversionRequestId":{"type":"meta","required":false,"default":"","description":"The request identity of the conversion that created this order.","_meta":{"description":"The request identity of the conversion that created this order.","underlyingType":"text"}},"acceptanceEvidenceRef":{"type":"meta","required":false,"default":"","description":"Where the proof of the customer accepting the estimate is kept.","_meta":{"description":"Where the proof of the customer accepting the estimate is kept.","underlyingType":"text"}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Order","collectionExportName":"OrderCollection","validationRules":[{"field":"customerId","rule":"required","fieldType":"foreignKey"}],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"e87e7d82"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Lease":{"name":"lease","className":"Lease","qualifiedName":"@happyvertical/smrt-commerce:Lease","collection":"contracts","description":"Rental or lease agreement","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":true,"related":"Customer","_meta":{"required":true}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Lease","collectionExportName":"LeaseCollection","validationRules":[{"field":"customerId","rule":"required","fieldType":"foreignKey"}],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"bdf1e524"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Agreement":{"name":"agreement","className":"Agreement","qualifiedName":"@happyvertical/smrt-commerce:Agreement","collection":"contracts","description":"Service or maintenance agreement","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":true,"related":"Customer","_meta":{"required":true}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"label":"reference","list":["reference","customerId","status","totalAmount","createdAt"]},"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Agreement","collectionExportName":"AgreementCollection","displayLabelField":"reference","validationRules":[{"field":"customerId","rule":"required","fieldType":"foreignKey"}],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"4dee0abb"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:SupplierQuote":{"name":"supplierquote","className":"SupplierQuote","qualifiedName":"@happyvertical/smrt-commerce:SupplierQuote","collection":"contracts","description":"Supplier quotation received from a vendor; acceptance does not create an order.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"vendorId":{"type":"foreignKey","required":true,"related":"Vendor","_meta":{"required":true}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"PurchaseContract","exportName":"SupplierQuote","collectionExportName":"SupplierQuoteCollection","validationRules":[{"field":"vendorId","rule":"required","fieldType":"foreignKey"}],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"d7b900cd"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchaseOrder":{"name":"purchaseorder","className":"PurchaseOrder","qualifiedName":"@happyvertical/smrt-commerce:PurchaseOrder","collection":"contracts","description":"Order sent to vendor/supplier","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"vendorId":{"type":"foreignKey","required":true,"related":"Vendor","_meta":{"required":true}},"expectedDate":{"type":"meta","required":false,"default":"","description":"The date you expect the delivery, as YYYY-MM-DD. Leave blank if it is not known.","_meta":{"description":"The date you expect the delivery, as YYYY-MM-DD. Leave blank if it is not known.","underlyingType":"text"}},"shipTo":{"type":"meta","required":false,"default":"","description":"Where this order should be delivered, including any delivery instructions.","_meta":{"description":"Where this order should be delivered, including any delivery instructions.","underlyingType":"text"}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"PurchaseContract","exportName":"PurchaseOrder","collectionExportName":"PurchaseOrderCollection","validationRules":[{"field":"vendorId","rule":"required","fieldType":"foreignKey"}],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"a4e35ea7"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:WholesaleOrder":{"name":"wholesaleorder","className":"WholesaleOrder","qualifiedName":"@happyvertical/smrt-commerce:WholesaleOrder","collection":"contracts","description":"B2B order placed by a wholesale customer.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":true,"related":"Customer","_meta":{"required":true}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"WholesaleOrder","collectionExportName":"WholesaleOrderCollection","validationRules":[{"field":"customerId","rule":"required","fieldType":"foreignKey"}],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"ad0e890c"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:ProductionOrder":{"name":"productionorder","className":"ProductionOrder","qualifiedName":"@happyvertical/smrt-commerce:ProductionOrder","collection":"contracts","description":"Instruction to commission goods from an internal or external factory.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"vendorId":{"type":"foreignKey","required":false,"related":"Vendor","_meta":{"description":"The vendor supplying this quote or purchase contract."}},"productId":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"bomId":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"PurchaseContract","exportName":"ProductionOrder","collectionExportName":"ProductionOrderCollection","schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"8a4deffc"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Cart":{"name":"cart","className":"Cart","qualifiedName":"@happyvertical/smrt-commerce:Cart","collection":"contracts","description":"Transient order-in-progress for a shopper.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":false,"related":"Customer","_meta":{"description":"The customer a sales order or agreement is for."}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Cart","collectionExportName":"CartCollection","schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"c96e872a"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:LicenseSale":{"name":"licensesale","className":"LicenseSale","qualifiedName":"@happyvertical/smrt-commerce:LicenseSale","collection":"contracts","description":"Industry-neutral licensing primitive.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractType":{"type":"text","required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","_meta":{"description":"The kind of contract: order, estimate, lease, agreement and so on."},"enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","_meta":{"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"discountTotal":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"The full amount, tax included.","_meta":{"description":"The full amount, tax included.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the amounts.","_meta":{"description":"The currency of the amounts.","ui":{"widget":"currency"}}},"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","_meta":{"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","required":false},"billingScheduleJson":{"type":"text","required":false,"default":"","_meta":{"default":""}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"issueDate":{"type":"datetime","required":false,"description":"The date it was issued or placed.","_meta":{"description":"The date it was issued or placed.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment or delivery is due.","_meta":{"description":"The date payment or delivery is due."}},"expiryDate":{"type":"datetime","required":false,"description":"The last day the price or offer is good for.","_meta":{"description":"The last day the price or offer is good for."}},"reference":{"type":"text","required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number.","_meta":{"description":"Your own number or note for finding this later, such as a purchase order or quote number."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this.","_meta":{"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions.","_meta":{"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}}},"channelId":{"type":"text","required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call.","_meta":{"description":"Where it came from, for example your shop, a marketplace or a phone call."}},"customerId":{"type":"foreignKey","required":false,"related":"Customer","_meta":{"description":"The customer a sales order or agreement is for."}},"skuId":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"paymentId":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"licenseeEmail":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"licenseeLegalEntity":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"licenseeJurisdiction":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"rightsMedium":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"rightsDistributionScope":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"rightsExclusivity":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"rightsDuration":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"rightsTerritory":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"rightsSublicensing":{"type":"meta","required":false,"default":false,"_meta":{"underlyingType":"boolean"}},"rightsDerivatives":{"type":"meta","required":false,"default":false,"_meta":{"underlyingType":"boolean"}},"pdfUrl":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"pdfHash":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}},"onChainHashRegistryRef":{"type":"meta","required":false,"default":"","_meta":{"underlyingType":"text"}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"getRightsSnapshot":{"name":"getRightsSnapshot","async":false,"parameters":[],"returnType":"LicenseRightsSnapshot","isStatic":false,"isPublic":true},"revoke":{"name":"revoke","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"LicenseSale","collectionExportName":"LicenseSaleCollection","schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"05161a85"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:ContractLineItem":{"name":"contractlineitem","className":"ContractLineItem","qualifiedName":"@happyvertical/smrt-commerce:ContractLineItem","collection":"contractlineitems","description":"ContractLineItem represents a single line item on a contract.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/ContractLineItem.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","required":false},"updated_at":{"type":"datetime","required":false},"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}}},"contractId":{"type":"foreignKey","required":false,"related":"Contract","description":"The order, quote or agreement this line belongs to.","_meta":{"description":"The order, quote or agreement this line belongs to.","role":"items"}},"description":{"type":"text","required":false,"default":"","description":"What is being sold or bought on this line.","_meta":{"description":"What is being sold or bought on this line."}},"quantity":{"type":"decimal","required":false,"default":1,"description":"How many.","_meta":{"description":"How many."}},"unitPrice":{"type":"integer","required":false,"default":0,"description":"The price of one, before discount; includes tax when the document's prices include tax.","_meta":{"description":"The price of one, before discount; includes tax when the document's prices include tax.","ui":{"format":"money"}}},"discount":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"discountType":{"type":"text","required":false,"default":"none","enum":["none","percent","amount"]},"discountRate":{"type":"decimal","required":false,"_meta":{}},"taxRate":{"type":"decimal","required":false,"default":0,"description":"The stored fractional tax rate for this line (0.05 means 5%).","_meta":{"description":"The stored fractional tax rate for this line (0.05 means 5%)."}},"taxMode":{"type":"text","required":false,"default":"inherit","enum":["inherit","override"]},"taxCodeId":{"type":"foreignKey","required":false,"related":"TaxCode","_meta":{"nullable":true}},"taxCodeCode":{"type":"text","required":false},"taxCodeName":{"type":"text","required":false},"taxComponentsJson":{"type":"text","required":false},"taxAmount":{"type":"integer","required":true,"default":0,"_meta":{"ui":{"format":"money"}}},"moneySnapshotId":{"type":"text","required":false},"amount":{"type":"integer","required":false,"default":0,"description":"The line amount: net of discount, and including tax only when the document's prices include tax.","_meta":{"description":"The line amount: net of discount, and including tax only when the document's prices include tax.","ui":{"format":"money"}}},"productId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-products:Product","description":"The product this line is for, if it is one you list.","_meta":{"description":"The product this line is for, if it is one you list."}},"sku":{"type":"text","required":false,"default":""},"startDate":{"type":"datetime","required":false},"endDate":{"type":"datetime","required":false},"billingPeriod":{"type":"text","required":false,"default":""},"sortOrder":{"type":"integer","required":false,"default":0}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isRecurring":{"name":"isRecurring","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSubscriptionActive":{"name":"isSubscriptionActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context","_meta_type"]},"extends":"SmrtObject","exportName":"ContractLineItem","collectionExportName":"ContractLineItemCollection","validationRules":[{"field":"taxAmount","rule":"required","fieldType":"integer"}],"schema":{"tableName":"contract_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"contract_line_items\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"description\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"product_id\\" UUID,\\n \\"sku\\" TEXT DEFAULT '',\\n \\"start_date\\" TIMESTAMP,\\n \\"end_date\\" TIMESTAMP,\\n \\"billing_period\\" TEXT DEFAULT '',\\n \\"sort_order\\" INTEGER DEFAULT 0\\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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"description":{"type":"TEXT","notNull":false,"default":""},"quantity":{"type":"REAL","notNull":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false},"tax_rate":{"type":"REAL","notNull":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false},"tax_code_name":{"type":"TEXT","notNull":false},"tax_components_json":{"type":"TEXT","notNull":false},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false},"amount":{"type":"INTEGER","notNull":false,"default":0},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"sku":{"type":"TEXT","notNull":false,"default":""},"start_date":{"type":"TIMESTAMP","notNull":false},"end_date":{"type":"TIMESTAMP","notNull":false},"billing_period":{"type":"TEXT","notNull":false,"default":""},"sort_order":{"type":"INTEGER","notNull":false,"default":0}},"indexes":[{"name":"contract_line_items_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contract_line_items_meta_type_idx","columns":["_meta_type"]},{"name":"contract_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contract_line_items_contract_id_idx","columns":["contract_id"]},{"name":"contract_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"contract_line_items_product_id_idx","columns":["product_id"]}],"version":"89a3137e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Customer":{"name":"customer","className":"Customer","qualifiedName":"@happyvertical/smrt-commerce:Customer","collection":"customers","description":"Customer represents the customer role for a Profile.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Customer.ts","packageName":"@happyvertical/smrt-commerce","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}}},"profileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile","_meta":{"description":"Choose an existing contact, or enter a new name above."}},"creditLimit":{"type":"integer","required":false,"default":0,"description":"The most this customer may owe you at one time. Leave it at zero if you do not set limits.","_meta":{"description":"The most this customer may owe you at one time. Leave it at zero if you do not set limits.","ui":{"format":"money"}}},"paymentTerms":{"type":"text","required":false,"default":"","description":"How long the customer has to pay, written the way you would say it, for example \\"Net 30\\".","_meta":{"description":"How long the customer has to pay, written the way you would say it, for example \\"Net 30\\"."}},"taxExempt":{"type":"boolean","required":false,"default":false,"description":"Turn this on if you do not charge this customer sales tax.","_meta":{"description":"Turn this on if you do not charge this customer sales tax."}},"taxId":{"type":"text","required":false,"default":"","description":"The tax or VAT number of the customer, kept on file for tax-exempt sales.","_meta":{"sensitive":true,"description":"The tax or VAT number of the customer, kept on file for tax-exempt sales."},"sensitive":true},"defaultTaxCodeId":{"type":"foreignKey","required":false,"related":"TaxCode","_meta":{"description":"The tax code normally used when selling to this customer."}},"defaultShippingAddress":{"type":"json","required":false,"description":"Where you usually send goods to this customer, so you do not retype it on every order.","_meta":{"description":"Where you usually send goods to this customer, so you do not retype it on every order."}},"defaultBillingAddress":{"type":"json","required":false,"description":"Where you send invoices to this customer.","_meta":{"description":"Where you send invoices to this customer."}},"status":{"type":"text","required":false,"default":"active","description":"Whether you are still dealing with this customer: active, inactive or suspended.","_meta":{"default":"active","description":"Whether you are still dealing with this customer: active, inactive or suspended."},"enum":["active","inactive","suspended"]},"customerType":{"type":"text","required":false,"description":"The kind of customer: a direct shopper, a wholesale buyer or a retail customer.","_meta":{"description":"The kind of customer: a direct shopper, a wholesale buyer or a retail customer."},"enum":["dtc","wholesale","retail"]},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this customer.","_meta":{"description":"Anything worth remembering about this customer.","ui":{"widget":"textarea"}}},"contacts":{"type":"json","required":false,"default":[],"description":"The people you deal with at this customer, with their role and how to reach them.","_meta":{"description":"The people you deal with at this customer, with their role and how to reach them."}}},"methods":{"resolveWriteThroughVirtualProjection":{"name":"resolveWriteThroughVirtualProjection","async":true,"parameters":[{"name":"via","type":"string","optional":false},{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<Record<string, object>>","isStatic":true,"isPublic":true,"decoratorConfig":{"expose":false}},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isWholesale":{"name":"isWholesale","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"hasAvailableCredit":{"name":"hasAvailableCredit","async":false,"parameters":[{"name":"amount","type":"number","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true},"getProfileId":{"name":"getProfileId","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true}},"decoratorConfig":{"writeThrough":{"profileId":{"fields":["name","email"],"virtualFields":{"phone":{"type":"text","description":"A phone number for reaching this person.","ui":{"widget":"phone"}}}}},"display":{"list":["status","email","phone"],"label":{"via":"profileId","field":"name","fallback":"Unnamed customer"}},"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get","create","update"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Customer","collectionExportName":"CustomerCollection","writeThroughFields":{"name":{"type":"text","required":false,"default":"","_meta":{"required":true,"ui":{"basic":true,"order":-100}}},"email":{"type":"text","required":false,"_meta":{"ui":{"basic":true,"order":-99}}},"phone":{"type":"text","description":"A phone number for reaching this person.","ui":{"widget":"phone"},"required":false,"_meta":{"ui":{"widget":"phone","basic":true,"order":-98}}}},"displayLabelProjection":{"via":"profileId","field":"name","fallback":"Unnamed customer"},"displayLabelField":"displayLabel","schema":{"tableName":"customers","ddl":"CREATE TABLE IF NOT EXISTS \\"customers\\" (\\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 \\"profile_id\\" UUID,\\n \\"credit_limit\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"tax_exempt\\" BOOLEAN DEFAULT FALSE,\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_shipping_address\\" JSON,\\n \\"default_billing_address\\" JSON,\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"customer_type\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"credit_limit":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tax_exempt":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_shipping_address":{"type":"JSON","notNull":false,"unique":false},"default_billing_address":{"type":"JSON","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"customer_type":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"customers_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"customers_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"customers_profile_id_idx","columns":["profile_id"]},{"name":"customers_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"617d1e93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:DocumentTax":{"name":"documenttax","className":"DocumentTax","qualifiedName":"@happyvertical/smrt-commerce:DocumentTax","collection":"documenttaxes","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/DocumentTax.ts","packageName":"@happyvertical/smrt-commerce","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}}},"documentType":{"type":"text","required":true,"default":"invoice","_meta":{"required":true},"enum":["invoice","contract","credit_note"]},"documentId":{"type":"text","required":true,"_meta":{"required":true}},"currency":{"type":"text","required":true,"_meta":{"required":true}},"taxCodeId":{"type":"text","required":false,"_meta":{"nullable":true}},"taxCodeCode":{"type":"text","required":false,"_meta":{"nullable":true}},"kind":{"type":"text","required":false,"_meta":{"nullable":true},"enum":["taxable","zero-rated","exempt","out-of-scope"]},"taxComponentId":{"type":"text","required":false,"_meta":{"nullable":true}},"taxComponentName":{"type":"text","required":false,"_meta":{"nullable":true}},"percent":{"type":"decimal","required":false,"_meta":{"nullable":true}},"liabilityAccountId":{"type":"text","required":false,"_meta":{"nullable":true}},"taxableMinor":{"type":"integer","required":true,"default":0,"description":"Actual component taxable basis, including prior compound taxes.","_meta":{"description":"Actual component taxable basis, including prior compound taxes.","ui":{"format":"money"}}},"netMinor":{"type":"integer","required":false,"description":"Net basis when different from the component taxable basis.","_meta":{"nullable":true,"description":"Net basis when different from the component taxable basis.","ui":{"format":"money"}}},"taxMinor":{"type":"integer","required":true,"default":0,"description":"Tax total in integer minor units.","_meta":{"description":"Tax total in integer minor units.","ui":{"format":"money"}}},"recoverableMinor":{"type":"integer","required":true,"default":0,"description":"Recoverable purchase tax in integer minor units.","_meta":{"description":"Recoverable purchase tax in integer minor units.","ui":{"format":"money"}}}},"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},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"document_taxes","conflictColumns":["document_type","document_id","tax_code_id","tax_component_id"],"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"DocumentTax","collectionExportName":"DocumentTaxCollection","validationRules":[{"field":"documentType","rule":"required","fieldType":"text"},{"field":"documentId","rule":"required","fieldType":"text"},{"field":"currency","rule":"required","fieldType":"text"},{"field":"taxableMinor","rule":"required","fieldType":"integer"},{"field":"taxMinor","rule":"required","fieldType":"integer"},{"field":"recoverableMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"document_taxes","ddl":"CREATE TABLE IF NOT EXISTS \\"document_taxes\\" (\\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 \\"document_type\\" TEXT NOT NULL DEFAULT 'invoice',\\n \\"document_id\\" TEXT NOT NULL,\\n \\"currency\\" TEXT NOT NULL,\\n \\"tax_code_id\\" TEXT,\\n \\"tax_code_code\\" TEXT,\\n \\"kind\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_component_name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"net_minor\\" INTEGER,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER NOT NULL DEFAULT 0\\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},"document_type":{"type":"TEXT","notNull":true,"unique":false,"default":"invoice"},"document_id":{"type":"TEXT","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":true,"unique":false},"tax_code_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_component_name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"net_minor":{"type":"INTEGER","notNull":false,"unique":false},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0}},"indexes":[{"name":"document_taxes_document_type_document_id_idx","columns":["document_type","document_id","tax_code_id","tax_component_id"],"unique":true,"nullsNotDistinct":true},{"name":"document_taxes_slug_context_idx","columns":["slug","context"]},{"name":"document_taxes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b35e53b9"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Fulfillment":{"name":"fulfillment","className":"Fulfillment","qualifiedName":"@happyvertical/smrt-commerce:Fulfillment","collection":"fulfillments","description":"Fulfillment tracks the delivery or completion of contract items.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Fulfillment.ts","packageName":"@happyvertical/smrt-commerce","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}}},"contractId":{"type":"foreignKey","required":false,"related":"SalesContract","description":"The order being fulfilled.","_meta":{"description":"The order being fulfilled.","validateSubtype":true}},"fulfillmentType":{"type":"text","required":false,"description":"How it gets to the customer: shipment, delivery, pickup, digital or service.","_meta":{"description":"How it gets to the customer: shipment, delivery, pickup, digital or service."},"enum":["shipment","delivery","pickup","digital","service"]},"status":{"type":"text","required":false,"description":"Where it stands: pending, processing, shipped, delivered or cancelled.","_meta":{"description":"Where it stands: pending, processing, shipped, delivered or cancelled."},"enum":["pending","processing","shipped","delivered","cancelled"]},"trackingNumber":{"type":"text","required":false,"default":"","description":"The carrier's tracking number.","_meta":{"description":"The carrier's tracking number."}},"carrier":{"type":"text","required":false,"default":"","description":"The company carrying it.","_meta":{"description":"The company carrying it."}},"shippingAddress":{"type":"json","required":false},"shippedAt":{"type":"datetime","required":false,"description":"When it was dispatched.","_meta":{"description":"When it was dispatched."}},"deliveredAt":{"type":"datetime","required":false,"description":"When it arrived.","_meta":{"description":"When it arrived."}},"estimatedDelivery":{"type":"datetime","required":false},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this shipment.","_meta":{"description":"Anything worth remembering about this shipment."}}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isDelivered":{"name":"isDelivered","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isInTransit":{"name":"isInTransit","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPending":{"name":"isPending","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markShipped":{"name":"markShipped","async":false,"parameters":[{"name":"trackingNumber","type":"string","optional":true},{"name":"carrier","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"markDelivered":{"name":"markDelivered","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Fulfillment","collectionExportName":"FulfillmentCollection","schema":{"tableName":"fulfillments","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillments\\" (\\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 \\"contract_id\\" UUID,\\n \\"fulfillment_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"tracking_number\\" TEXT DEFAULT '',\\n \\"carrier\\" TEXT DEFAULT '',\\n \\"shipping_address\\" JSON,\\n \\"shipped_at\\" TIMESTAMP,\\n \\"delivered_at\\" TIMESTAMP,\\n \\"estimated_delivery\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT ''\\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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"fulfillment_type":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"tracking_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"carrier":{"type":"TEXT","notNull":false,"unique":false,"default":""},"shipping_address":{"type":"JSON","notNull":false,"unique":false},"shipped_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"delivered_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"estimated_delivery":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillments_contract_id_idx","columns":["contract_id"]}],"version":"3970fcbd"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:FulfillmentLineItem":{"name":"fulfillmentlineitem","className":"FulfillmentLineItem","qualifiedName":"@happyvertical/smrt-commerce:FulfillmentLineItem","collection":"fulfillmentlineitems","description":"FulfillmentLineItem tracks which contract line items are included in a specific fulfillment and how much was fulfilled.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/FulfillmentLineItem.ts","packageName":"@happyvertical/smrt-commerce","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}}},"fulfillmentId":{"type":"foreignKey","required":false,"related":"Fulfillment","description":"The shipment this line belongs to.","_meta":{"description":"The shipment this line belongs to.","role":"items"}},"contractLineItemId":{"type":"foreignKey","required":false,"related":"ContractLineItem","description":"The order line being sent.","_meta":{"description":"The order line being sent."}},"quantityFulfilled":{"type":"decimal","required":false,"default":1,"description":"How many of that line are in this shipment.","_meta":{"description":"How many of that line are in this shipment."}},"notes":{"type":"text","required":false,"default":""}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]},"cli":true,"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"FulfillmentLineItem","collectionExportName":"FulfillmentLineItemCollection","schema":{"tableName":"fulfillment_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillment_line_items\\" (\\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 \\"fulfillment_id\\" UUID,\\n \\"contract_line_item_id\\" UUID,\\n \\"quantity_fulfilled\\" REAL DEFAULT 1,\\n \\"notes\\" TEXT DEFAULT ''\\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},"fulfillment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"fulfillments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_line_item_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contract_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"quantity_fulfilled":{"type":"REAL","notNull":false,"unique":false,"default":1},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillment_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillment_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillment_line_items_fulfillment_id_idx","columns":["fulfillment_id"]},{"name":"fulfillment_line_items_contract_line_item_id_idx","columns":["contract_line_item_id"]}],"version":"acf1ca5f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFunds":{"name":"historicalcustomerfunds","className":"HistoricalCustomerFunds","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFunds","collection":"historicalcustomerfundses","description":"Retained original cash evidence. It is deliberately not a completed ledger-backed Payment.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/HistoricalCustomerFunds.ts","packageName":"@happyvertical/smrt-commerce","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}}},"customerId":{"type":"foreignKey","required":false,"related":"Customer"},"contractId":{"type":"foreignKey","required":false,"related":"Contract","_meta":{"nullable":true}},"sourceKeyHash":{"type":"text","required":false},"kind":{"type":"text","required":false,"default":"receipt","enum":["receipt","refund"]},"origin":{"type":"text","required":false,"default":"historical","enum":["historical","live"]},"paymentId":{"type":"foreignKey","required":false,"related":"Payment","_meta":{"nullable":true}},"currency":{"type":"text","required":false},"amountMinor":{"type":"integer","required":true,"default":0,"_meta":{"ui":{"format":"money"}}},"effectiveOn":{"type":"text","required":false},"sourceReceiptId":{"type":"foreignKey","required":false,"related":"HistoricalCustomerFunds","_meta":{"nullable":true}},"sourceCreditNoteId":{"type":"foreignKey","required":false,"related":"Invoice","_meta":{"nullable":true}},"snapshotJson":{"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":"historical_customer_funds","indexes":[{"name":"historical_customer_funds_source","columns":["tenantId","sourceKeyHash"],"unique":true}],"api":{"include":["get","list"]},"cli":{"include":["get","list"]},"mcp":{"include":["get","list"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"HistoricalCustomerFunds","collectionExportName":"HistoricalCustomerFundsCollection","validationRules":[{"field":"amountMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"historical_customer_funds","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds\\" (\\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 \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'receipt',\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"payment_id\\" UUID,\\n \\"currency\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"source_receipt_id\\" UUID,\\n \\"source_credit_note_id\\" UUID,\\n \\"snapshot_json\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"receipt"},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"currency":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"source_receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_customer_funds_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_customer_id_idx","columns":["customer_id"]},{"name":"historical_customer_funds_contract_id_idx","columns":["contract_id"]},{"name":"historical_customer_funds_payment_id_idx","columns":["payment_id"]},{"name":"historical_customer_funds_source_receipt_id_idx","columns":["source_receipt_id"]},{"name":"historical_customer_funds_source_credit_note_id_idx","columns":["source_credit_note_id"]}],"version":"96a8006b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocation":{"name":"historicalcustomerfundsallocation","className":"HistoricalCustomerFundsAllocation","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocation","collection":"historicalcustomerfundsallocations","description":"Original applications have concrete identities; credit-audit records never count twice.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/HistoricalCustomerFundsAllocation.ts","packageName":"@happyvertical/smrt-commerce","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}}},"receiptId":{"type":"foreignKey","required":false,"related":"HistoricalCustomerFunds","_meta":{"nullable":true}},"creditNoteId":{"type":"foreignKey","required":false,"related":"Invoice","_meta":{"nullable":true}},"invoiceId":{"type":"foreignKey","required":false,"related":"Invoice"},"sourceKeyHash":{"type":"text","required":false},"amountMinor":{"type":"integer","required":true,"default":0,"_meta":{"ui":{"format":"money"}}},"effectiveOn":{"type":"text","required":false},"origin":{"type":"text","required":false,"default":"historical","enum":["historical","live"]},"effect":{"type":"text","required":false,"default":"payment","enum":["payment","credit-audit","refund-audit"]},"journalId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-ledgers:Journal","_meta":{"nullable":true}},"snapshotJson":{"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":"historical_customer_funds_allocations","indexes":[{"name":"historical_funds_allocation_source","columns":["tenantId","sourceKeyHash"],"unique":true}],"api":{"include":["get","list"]},"cli":{"include":["get","list"]},"mcp":{"include":["get","list"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"HistoricalCustomerFundsAllocation","collectionExportName":"HistoricalCustomerFundsAllocationCollection","validationRules":[{"field":"amountMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"historical_customer_funds_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds_allocations\\" (\\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 \\"receipt_id\\" UUID,\\n \\"credit_note_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"effect\\" TEXT DEFAULT 'payment',\\n \\"journal_id\\" UUID,\\n \\"snapshot_json\\" 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},"receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"effect":{"type":"TEXT","notNull":false,"unique":false,"default":"payment"},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_funds_allocation_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_allocations_receipt_id_idx","columns":["receipt_id"]},{"name":"historical_customer_funds_allocations_credit_note_id_idx","columns":["credit_note_id"]},{"name":"historical_customer_funds_allocations_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_customer_funds_allocations_journal_id_idx","columns":["journal_id"]}],"version":"6c92192c"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalSalesLine":{"name":"historicalsalesline","className":"HistoricalSalesLine","qualifiedName":"@happyvertical/smrt-commerce:HistoricalSalesLine","collection":"historicalsaleslines","description":"An immutable source line with explicit unknowns, never a calculated InvoiceLineItem.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/HistoricalSalesLine.ts","packageName":"@happyvertical/smrt-commerce","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}}},"invoiceId":{"type":"foreignKey","required":false,"related":"Invoice"},"creditedLineId":{"type":"foreignKey","required":false,"related":"HistoricalSalesLine","_meta":{"nullable":true}},"sourceKey":{"type":"text","required":false},"sourceKeyHash":{"type":"text","required":false},"description":{"type":"text","required":false},"netMinor":{"type":"integer","required":true,"default":0,"_meta":{"ui":{"format":"money"}}},"taxMinor":{"type":"integer","required":false,"_meta":{"nullable":true,"ui":{"format":"money"}}},"grossMinor":{"type":"integer","required":false,"_meta":{"nullable":true,"ui":{"format":"money"}}},"quantityText":{"type":"text","required":false,"_meta":{"nullable":true}},"unitRateText":{"type":"text","required":false,"_meta":{"nullable":true}},"sourceFieldsJson":{"type":"text","required":false},"moneySnapshotId":{"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":"historical_sales_lines","indexes":[{"name":"historical_sales_line_source_key","columns":["tenantId","invoiceId","sourceKeyHash"],"unique":true}],"api":{"include":["get","list"]},"cli":{"include":["get","list"]},"mcp":{"include":["get","list"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"HistoricalSalesLine","collectionExportName":"HistoricalSalesLineCollection","validationRules":[{"field":"netMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"historical_sales_lines","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_sales_lines\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"source_key\\" TEXT,\\n \\"source_key_hash\\" TEXT,\\n \\"description\\" TEXT,\\n \\"net_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER,\\n \\"gross_minor\\" INTEGER,\\n \\"quantity_text\\" TEXT,\\n \\"unit_rate_text\\" TEXT,\\n \\"source_fields_json\\" TEXT,\\n \\"money_snapshot_id\\" 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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_sales_lines","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key":{"type":"TEXT","notNull":false,"unique":false},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false},"net_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"gross_minor":{"type":"INTEGER","notNull":false,"unique":false},"quantity_text":{"type":"TEXT","notNull":false,"unique":false},"unit_rate_text":{"type":"TEXT","notNull":false,"unique":false},"source_fields_json":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_sales_lines_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_sales_line_source_key","columns":["tenant_id","invoice_id","source_key_hash"],"unique":true},{"name":"historical_sales_lines_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_sales_lines_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_sales_lines_credited_line_id_idx","columns":["credited_line_id"]}],"version":"d5807042"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Invoice":{"name":"invoice","className":"Invoice","qualifiedName":"@happyvertical/smrt-commerce:Invoice","collection":"invoices","description":"Invoice represents a bill sent to a customer for goods or services.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Invoice.ts","packageName":"@happyvertical/smrt-commerce","fields":{"moneyAuthority":{"type":"text","required":false,"default":"calculated","description":"Whether amounts were calculated or retained from an original issued invoice.","_meta":{"description":"Whether amounts were calculated or retained from an original issued invoice."},"enum":["calculated","historical"]},"historicalSalesMoneyJson":{"type":"text","required":false},"historicalSourceKeyHash":{"type":"text","required":false,"_meta":{"nullable":true}},"kind":{"type":"text","required":false,"default":"invoice","description":"Invoice or customer credit note.","_meta":{"description":"Invoice or customer credit note."},"enum":["invoice","credit_note"]},"creditedInvoiceId":{"type":"foreignKey","required":false,"related":"Invoice","_meta":{"nullable":true}},"creditedAmount":{"type":"integer","required":true,"default":0,"_meta":{"ui":{"format":"money"}}},"retentionStateJson":{"type":"text","required":false},"retentionAccountingStateJson":{"type":"text","required":false,"_meta":{"sensitive":true},"sensitive":true},"ordinaryAccountingStateJson":{"type":"text","required":false,"_meta":{"sensitive":true},"sensitive":true},"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"customerId":{"type":"foreignKey","required":false,"related":"Customer","description":"The customer being billed.","_meta":{"description":"The customer being billed."}},"contractId":{"type":"foreignKey","required":false,"related":"SalesContract","description":"The order or agreement this invoice bills for, if any.","_meta":{"description":"The order or agreement this invoice bills for, if any.","validateSubtype":true}},"invoiceNumber":{"type":"text","required":false,"default":"","description":"The number printed on the invoice.","_meta":{"description":"The number printed on the invoice."}},"reference":{"type":"text","required":false,"default":""},"issueDate":{"type":"datetime","required":false,"description":"The date the invoice was issued.","_meta":{"description":"The date the invoice was issued.","ui":{"format":"date"}}},"dueDate":{"type":"datetime","required":false,"description":"The date payment is expected; null when the original source did not establish it.","_meta":{"nullable":true,"description":"The date payment is expected; null when the original source did not establish it."}},"paidDate":{"type":"datetime","required":false,"description":"The date it was paid in full.","_meta":{"description":"The date it was paid in full."}},"subtotal":{"type":"integer","required":false,"default":0,"description":"The amount before tax.","_meta":{"description":"The amount before tax.","ui":{"format":"money"}}},"taxAmount":{"type":"integer","required":false,"default":0,"description":"The tax charged.","_meta":{"description":"The tax charged.","ui":{"format":"money"}}},"providerTaxAmount":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"totalAmount":{"type":"integer","required":false,"default":0,"description":"What the customer owes in all, tax included.","_meta":{"description":"What the customer owes in all, tax included.","ui":{"format":"money"}}},"amountPaid":{"type":"integer","required":false,"default":0,"description":"How much of the total has been paid so far.","_meta":{"description":"How much of the total has been paid so far.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"CAD","description":"The currency of the invoice.","_meta":{"description":"The currency of the invoice.","ui":{"widget":"currency"}}},"lineAmountType":{"type":"text","required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","enum":["line","document"]},"discountTotal":{"type":"integer","required":true,"default":0,"_meta":{"ui":{"format":"money"}}},"sellerTaxRegistrationsJson":{"type":"text","required":false},"partyTaxId":{"type":"text","required":false},"moneySnapshotId":{"type":"text","required":false},"status":{"type":"text","required":false,"description":"Where the invoice stands: draft, sent, viewed, paid, overdue or cancelled.","_meta":{"description":"Where the invoice stands: draft, sent, viewed, paid, overdue or cancelled."},"enum":["draft","sent","viewed","partial","paid","overdue","cancelled","written_off"]},"arJournalId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"arReversalJournalId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-ledgers:Journal","_meta":{"nullable":true}},"revenueJournalId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"externalId":{"type":"text","required":false,"default":""},"customerExternalId":{"type":"text","required":false,"default":""},"externalProvider":{"type":"text","required":false,"default":""},"syncedAt":{"type":"datetime","required":false},"accountingSyncStateJson":{"type":"text","required":false,"_meta":{"sensitive":true},"sensitive":true},"collectionMethod":{"type":"text","required":false,"default":"","enum":["","send_invoice","charge_automatically"]},"sentAt":{"type":"datetime","required":false},"viewedAt":{"type":"datetime","required":false},"remindersSent":{"type":"integer","required":false,"default":0},"lastReminderAt":{"type":"datetime","required":false},"notes":{"type":"text","required":false,"default":"","description":"Private notes, not shown to the customer.","_meta":{"description":"Private notes, not shown to the customer.","ui":{"widget":"textarea"}}},"customerNotes":{"type":"text","required":false,"default":"","description":"A message shown to the customer on the invoice.","_meta":{"description":"A message shown to the customer on the invoice.","ui":{"widget":"textarea"}}},"terms":{"type":"text","required":false,"default":"","description":"The payment conditions, such as Net 30.","_meta":{"description":"The payment conditions, such as Net 30.","ui":{"widget":"textarea"}}}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"getPayableFacts":{"name":"getPayableFacts","async":false,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSent":{"name":"isSent","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPaid":{"name":"isPaid","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPartial":{"name":"isPartial","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getAmountDue":{"name":"getAmountDue","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true},"getBalance":{"name":"getBalance","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true},"markSent":{"name":"markSent","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"markViewed":{"name":"markViewed","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"updatePaymentStatus":{"name":"updatePaymentStatus","async":false,"parameters":[{"name":"amountPaid","type":"number","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"cancelWithRevenueReversal":{"name":"cancelWithRevenueReversal","async":true,"parameters":[{"name":"options","type":"CancelRevenueOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"writeOff":{"name":"writeOff","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"recognizeRevenue":{"name":"recognizeRevenue","async":true,"parameters":[{"name":"options","type":"RecognizeRevenueOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"getArJournal":{"name":"getArJournal","async":true,"parameters":[],"returnType":"Promise<Journal | null>","isStatic":false,"isPublic":true},"toAccountingInput":{"name":"toAccountingInput","async":true,"parameters":[{"name":"options","type":"FrozenInvoiceAccountingOptions","optional":true}],"returnType":"Promise<AccountingInvoiceInput>","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"list":["invoiceNumber","customerId","status","totalAmount","issueDate","dueDate"],"label":"invoiceNumber"},"api":{"include":["list","get","create","update"],"writable":["customerId","contractId","invoiceNumber","reference","issueDate","dueDate","currency","lineAmountType","taxRoundingScope","notes","customerNotes","terms","externalId","customerExternalId","externalProvider"]},"mcp":{"include":["list","get"],"serializers":{"get":{"importPath":"@happyvertical/smrt-commerce","exportName":"serializeInvoiceMcpGet"}}},"cli":{"skipApiCheck":true},"indexes":[{"name":"invoice_historical_source_identity","columns":["tenantId","historicalSourceKeyHash"],"unique":true}],"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Invoice","collectionExportName":"InvoiceCollection","displayLabelField":"invoiceNumber","validationRules":[{"field":"creditedAmount","rule":"required","fieldType":"integer"},{"field":"discountTotal","rule":"required","fieldType":"integer"}],"schema":{"tableName":"invoices","ddl":"CREATE TABLE IF NOT EXISTS \\"invoices\\" (\\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 \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"historical_sales_money_json\\" TEXT,\\n \\"historical_source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'invoice',\\n \\"credited_invoice_id\\" UUID,\\n \\"credited_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"retention_state_json\\" TEXT,\\n \\"retention_accounting_state_json\\" TEXT,\\n \\"ordinary_accounting_state_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"invoice_number\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"paid_date\\" TIMESTAMP,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"provider_tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'CAD',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"discount_total\\" INTEGER NOT NULL DEFAULT 0,\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"status\\" TEXT,\\n \\"ar_journal_id\\" UUID,\\n \\"ar_reversal_journal_id\\" UUID,\\n \\"revenue_journal_id\\" UUID,\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"customer_external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"accounting_sync_state_json\\" TEXT,\\n \\"collection_method\\" TEXT DEFAULT '',\\n \\"sent_at\\" TIMESTAMP,\\n \\"viewed_at\\" TIMESTAMP,\\n \\"reminders_sent\\" INTEGER DEFAULT 0,\\n \\"last_reminder_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"customer_notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT ''\\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"},"money_authority":{"type":"TEXT","notNull":false,"unique":false,"default":"calculated"},"historical_sales_money_json":{"type":"TEXT","notNull":false,"unique":false},"historical_source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"invoice"},"credited_invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"retention_state_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"issue_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"due_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"paid_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"provider_tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"CAD"},"line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"discount_total":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"seller_tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false},"party_tax_id":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"ar_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"ar_reversal_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"revenue_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"accounting_sync_state_json":{"type":"TEXT","notNull":false,"unique":false},"collection_method":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"viewed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"reminders_sent":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_reminder_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"invoices_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_historical_source_identity","columns":["tenant_id","historical_source_key_hash"],"unique":true},{"name":"invoices_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoices_credited_invoice_id_idx","columns":["credited_invoice_id"]},{"name":"invoices_customer_id_idx","columns":["customer_id"]},{"name":"invoices_contract_id_idx","columns":["contract_id"]},{"name":"invoices_ar_journal_id_idx","columns":["ar_journal_id"]},{"name":"invoices_ar_reversal_journal_id_idx","columns":["ar_reversal_journal_id"]},{"name":"invoices_revenue_journal_id_idx","columns":["revenue_journal_id"]}],"version":"20ebe916"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:InvoiceLineItem":{"name":"invoicelineitem","className":"InvoiceLineItem","qualifiedName":"@happyvertical/smrt-commerce:InvoiceLineItem","collection":"invoicelineitems","description":"InvoiceLineItem represents a single line item on an invoice.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/InvoiceLineItem.ts","packageName":"@happyvertical/smrt-commerce","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}}},"invoiceId":{"type":"foreignKey","required":false,"related":"Invoice","description":"The invoice this line belongs to.","_meta":{"description":"The invoice this line belongs to.","role":"items"}},"creditedLineId":{"type":"foreignKey","required":false,"related":"InvoiceLineItem","_meta":{"nullable":true}},"creditCalculationBasisJson":{"type":"text","required":false,"description":"Frozen source basis used to cap and reproduce an issued credit line.","_meta":{"description":"Frozen source basis used to cap and reproduce an issued credit line."}},"description":{"type":"text","required":false,"default":"","description":"What is being billed on this line.","_meta":{"description":"What is being billed on this line."}},"sku":{"type":"text","required":false,"default":""},"productId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-products:Product","_meta":{"nullable":true}},"quantity":{"type":"decimal","required":false,"default":1,"description":"How many.","_meta":{"description":"How many."}},"unitPrice":{"type":"integer","required":false,"default":0,"description":"The price of one, before discount; includes tax when the document's prices include tax.","_meta":{"description":"The price of one, before discount; includes tax when the document's prices include tax.","ui":{"format":"money"}}},"discount":{"type":"integer","required":false,"default":0,"_meta":{"ui":{"format":"money"}}},"discountType":{"type":"text","required":false,"default":"none","enum":["none","percent","amount"]},"discountRate":{"type":"decimal","required":false,"_meta":{}},"taxRate":{"type":"decimal","required":false,"default":0,"description":"The stored fractional tax rate for this line (0.05 means 5%).","_meta":{"description":"The stored fractional tax rate for this line (0.05 means 5%)."}},"taxMode":{"type":"text","required":false,"default":"inherit","enum":["inherit","override"]},"taxCodeId":{"type":"foreignKey","required":false,"related":"TaxCode","_meta":{"nullable":true}},"taxCodeCode":{"type":"text","required":false},"taxCodeName":{"type":"text","required":false},"taxComponentsJson":{"type":"text","required":false},"taxAmount":{"type":"integer","required":true,"default":0,"_meta":{"ui":{"format":"money"}}},"moneySnapshotId":{"type":"text","required":false},"amount":{"type":"integer","required":false,"default":0,"description":"The line amount: net of discount, and including tax only when the document's prices include tax.","_meta":{"description":"The line amount: net of discount, and including tax only when the document's prices include tax.","ui":{"format":"money"}}},"sourceType":{"type":"text","required":false,"default":""},"sourceId":{"type":"text","required":false,"default":""},"sourceReservationId":{"type":"text","required":false,"_meta":{"nullable":true,"readonly":true},"readonly":true},"periodStart":{"type":"datetime","required":false},"periodEnd":{"type":"datetime","required":false},"revenueAccountId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-ledgers:Account","_meta":{"nullable":true}},"sortOrder":{"type":"integer","required":false,"default":0}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"hasSource":{"name":"hasSource","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"hasPeriod":{"name":"hasPeriod","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"],"writable":["invoiceId","description","sku","productId","quantity","unitPrice","discount","discountType","discountRate","taxRate","taxMode","taxCodeId","sourceType","sourceId","periodStart","periodEnd","revenueAccountId","sortOrder"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"InvoiceLineItem","collectionExportName":"InvoiceLineItemCollection","validationRules":[{"field":"taxAmount","rule":"required","fieldType":"integer"}],"schema":{"tableName":"invoice_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"invoice_line_items\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"credit_calculation_basis_json\\" TEXT,\\n \\"description\\" TEXT DEFAULT '',\\n \\"sku\\" TEXT DEFAULT '',\\n \\"product_id\\" UUID,\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"source_type\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"source_reservation_id\\" TEXT,\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"revenue_account_id\\" UUID,\\n \\"sort_order\\" INTEGER DEFAULT 0\\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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoice_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_calculation_basis_json":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sku":{"type":"TEXT","notNull":false,"unique":false,"default":""},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false,"unique":false},"tax_rate":{"type":"REAL","notNull":false,"unique":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"tax_code_name":{"type":"TEXT","notNull":false,"unique":false},"tax_components_json":{"type":"TEXT","notNull":false,"unique":false},"tax_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_reservation_id":{"type":"TEXT","notNull":false,"unique":false},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"revenue_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0}},"indexes":[{"name":"invoice_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoice_line_items_invoice_id_idx","columns":["invoice_id"]},{"name":"invoice_line_items_credited_line_id_idx","columns":["credited_line_id"]},{"name":"invoice_line_items_product_id_idx","columns":["product_id"]},{"name":"invoice_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"invoice_line_items_revenue_account_id_idx","columns":["revenue_account_id"]}],"version":"78dcf926"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Payment":{"name":"payment","className":"Payment","qualifiedName":"@happyvertical/smrt-commerce:Payment","collection":"payments","description":"Payment represents a financial transaction against a contract.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Payment.ts","packageName":"@happyvertical/smrt-commerce","fields":{"kind":{"type":"text","required":false,"default":"payment","enum":["payment","refund"]},"customerFundsJson":{"type":"text","required":false,"_meta":{}},"retentionAccountingBindingJson":{"type":"text","required":false,"_meta":{"sensitive":true},"sensitive":true},"ordinaryAccountingBindingJson":{"type":"text","required":false,"_meta":{"sensitive":true},"sensitive":true},"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"contractId":{"type":"foreignKey","required":false,"related":"SalesContract","description":"The order or agreement this payment is for, if any.","_meta":{"description":"The order or agreement this payment is for, if any.","validateSubtype":true}},"customerId":{"type":"foreignKey","required":false,"related":"Customer","description":"The customer who paid.","_meta":{"description":"The customer who paid."}},"amount":{"type":"integer","required":false,"default":0,"description":"How much was paid.","_meta":{"description":"How much was paid.","ui":{"format":"money"}}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency of the payment.","_meta":{"description":"The currency of the payment.","ui":{"widget":"currency"}}},"method":{"type":"text","required":false,"description":"How it was paid: cash, check, card, bank transfer or other.","_meta":{"description":"How it was paid: cash, check, card, bank transfer or other."},"enum":["cash","check","credit_card","bank_transfer","crypto","other"]},"status":{"type":"text","required":false,"description":"Whether the payment is pending, completed, failed or refunded.","_meta":{"description":"Whether the payment is pending, completed, failed or refunded."},"enum":["pending","completed","failed","refunded","cancelled"]},"transactionId":{"type":"text","required":false,"default":""},"reference":{"type":"text","required":false,"default":"","description":"A reference note, such as a check number.","_meta":{"description":"A reference note, such as a check number."}},"journalId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"paidAt":{"type":"datetime","required":false,"description":"When the money was received.","_meta":{"description":"When the money was received."}},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this payment.","_meta":{"description":"Anything worth remembering about this payment.","ui":{"widget":"textarea"}}},"externalId":{"type":"text","required":false,"default":""},"externalProvider":{"type":"text","required":false,"default":""},"syncedAt":{"type":"datetime","required":false},"backendId":{"type":"text","required":false,"default":""},"backendTxRef":{"type":"text","required":false,"default":""},"nativeAmount":{"type":"integer","required":false,"default":0},"nativeCurrency":{"type":"text","required":false,"default":""},"usdAtQuote":{"type":"integer","required":false,"default":0},"usdAtConfirmation":{"type":"integer","required":false,"default":0},"connectedAccountId":{"type":"text","required":false,"default":""},"connectedFeePolicyRef":{"type":"text","required":false,"default":""},"applicationFeeCents":{"type":"integer","required":false,"default":0},"refundOfPaymentId":{"type":"text","required":false,"default":""},"connectedRefundState":{"type":"text","required":false,"default":"","enum":["","requested","pending","succeeded","failed"]},"applicationFeeRefunded":{"type":"boolean","required":false,"default":false}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"usdDrift":{"name":"usdDrift","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true},"isPending":{"name":"isPending","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isRefunded":{"name":"isRefunded","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recordPayment":{"name":"recordPayment","async":true,"parameters":[{"name":"options","type":"RecordPaymentOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"recordRefund":{"name":"recordRefund","async":true,"parameters":[{"name":"options","type":"RecordPaymentOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"getJournal":{"name":"getJournal","async":true,"parameters":[],"returnType":"Promise<Journal | null>","isStatic":false,"isPublic":true},"markFailed":{"name":"markFailed","async":false,"parameters":[{"name":"reason","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"list":["reference","customerId","status","amount","paidAt"],"label":"reference"},"api":{"include":["list","get","create","update"],"writable":["kind","contractId","customerId","amount","currency","method","transactionId","reference","notes","externalId","externalProvider","backendId","backendTxRef","nativeAmount","nativeCurrency","usdAtQuote","usdAtConfirmation"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Payment","collectionExportName":"PaymentCollection","displayLabelField":"reference","schema":{"tableName":"payments","ddl":"CREATE TABLE IF NOT EXISTS \\"payments\\" (\\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 'payment',\\n \\"customer_funds_json\\" TEXT,\\n \\"retention_accounting_binding_json\\" TEXT,\\n \\"ordinary_accounting_binding_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"method\\" TEXT,\\n \\"status\\" TEXT,\\n \\"transaction_id\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"journal_id\\" UUID,\\n \\"paid_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"native_amount\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"usd_at_quote\\" INTEGER DEFAULT 0,\\n \\"usd_at_confirmation\\" INTEGER DEFAULT 0,\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"refund_of_payment_id\\" TEXT DEFAULT '',\\n \\"connected_refund_state\\" TEXT DEFAULT '',\\n \\"application_fee_refunded\\" BOOLEAN DEFAULT FALSE\\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":"payment"},"customer_funds_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"method":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"transaction_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"usd_at_quote":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"usd_at_confirmation":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refund_of_payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_refund_state":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_refunded":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"payments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payments_contract_id_idx","columns":["contract_id"]},{"name":"payments_customer_id_idx","columns":["customer_id"]},{"name":"payments_journal_id_idx","columns":["journal_id"]}],"version":"2f961b5b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentAllocation":{"name":"paymentallocation","className":"PaymentAllocation","qualifiedName":"@happyvertical/smrt-commerce:PaymentAllocation","collection":"paymentallocations","description":"PaymentAllocation tracks how payments are applied to invoices.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/PaymentAllocation.ts","packageName":"@happyvertical/smrt-commerce","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}}},"paymentId":{"type":"foreignKey","required":false,"related":"Payment","description":"The payment being applied.","_meta":{"description":"The payment being applied."}},"invoiceId":{"type":"foreignKey","required":false,"related":"Invoice","description":"The invoice it settles.","_meta":{"description":"The invoice it settles."}},"amount":{"type":"integer","required":false,"default":0,"description":"How much of the payment goes to this invoice.","_meta":{"description":"How much of the payment goes to this invoice.","ui":{"format":"money"}}},"allocatedAt":{"type":"datetime","required":false,"description":"When it was applied.","_meta":{"description":"When it was applied."}},"allocatedBy":{"type":"text","required":false,"default":""},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this allocation.","_meta":{"description":"Anything worth remembering about this allocation."}}},"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":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PaymentAllocation","collectionExportName":"PaymentAllocationCollection","schema":{"tableName":"payment_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_allocations\\" (\\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 \\"payment_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"allocated_at\\" TIMESTAMP,\\n \\"allocated_by\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"allocated_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"allocated_by":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_allocations_payment_id_idx","columns":["payment_id"]},{"name":"payment_allocations_invoice_id_idx","columns":["invoice_id"]}],"version":"72c493d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentInstrument":{"name":"paymentinstrument","className":"PaymentInstrument","qualifiedName":"@happyvertical/smrt-commerce:PaymentInstrument","collection":"paymentinstruments","description":"PaymentInstrument stores a reusable payment method a customer has saved with a payment backend (e.g. a card vaulted by Stripe), so it can be charged later without the customer present.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/PaymentInstrument.ts","packageName":"@happyvertical/smrt-commerce","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}}},"customerId":{"type":"foreignKey","required":false,"related":"Customer"},"backendId":{"type":"text","required":false,"default":""},"providerCustomerId":{"type":"text","required":false,"default":""},"providerPaymentMethodId":{"type":"text","required":false,"default":""},"type":{"type":"text","required":false,"default":"card"},"brand":{"type":"text","required":false,"default":""},"last4":{"type":"text","required":false,"default":""},"expMonth":{"type":"integer","required":false,"default":0},"expYear":{"type":"integer","required":false,"default":0},"isDefault":{"type":"boolean","required":false,"default":false},"status":{"type":"text","required":false,"enum":["active","expired","removed"]}},"methods":{"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isRemoved":{"name":"isRemoved","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markExpired":{"name":"markExpired","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"markRemoved":{"name":"markRemoved","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"],"writable":["customerId","backendId","providerCustomerId","providerPaymentMethodId","type","brand","last4","expMonth","expYear","status"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PaymentInstrument","collectionExportName":"PaymentInstrumentCollection","schema":{"tableName":"payment_instruments","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_instruments\\" (\\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 \\"customer_id\\" UUID,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"provider_payment_method_id\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'card',\\n \\"brand\\" TEXT DEFAULT '',\\n \\"last4\\" TEXT DEFAULT '',\\n \\"exp_month\\" INTEGER DEFAULT 0,\\n \\"exp_year\\" INTEGER DEFAULT 0,\\n \\"is_default\\" BOOLEAN DEFAULT FALSE,\\n \\"status\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_payment_method_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"card"},"brand":{"type":"TEXT","notNull":false,"unique":false,"default":""},"last4":{"type":"TEXT","notNull":false,"unique":false,"default":""},"exp_month":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"exp_year":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"is_default":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"status":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"payment_instruments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_instruments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_instruments_customer_id_idx","columns":["customer_id"]}],"version":"fcbc59d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentIntent":{"name":"paymentintent","className":"PaymentIntent","qualifiedName":"@happyvertical/smrt-commerce:PaymentIntent","collection":"paymentintents","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/PaymentIntent.ts","packageName":"@happyvertical/smrt-commerce","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}}},"skuId":{"type":"text","required":false,"default":""},"offeringRef":{"type":"text","required":false,"default":""},"licenseeEmail":{"type":"text","required":false,"default":""},"customerId":{"type":"text","required":false,"default":""},"paymentOptions":{"type":"json","required":false,"default":[]},"usdPriceLocked":{"type":"integer","required":false,"default":0},"priceLockWindowMs":{"type":"integer","required":false},"priceLockExpiresAt":{"type":"datetime","required":false},"status":{"type":"text","required":false,"enum":["awaiting_payment","paid","issued","retired","expired","cancelled"]},"idempotencyKey":{"type":"text","required":false,"default":""},"paidOptionBackendId":{"type":"text","required":false,"default":""},"paymentId":{"type":"text","required":false,"default":""},"paidAt":{"type":"datetime","required":false},"issuedAt":{"type":"datetime","required":false},"expiredAt":{"type":"datetime","required":false},"cancelledAt":{"type":"datetime","required":false},"retiredAt":{"type":"datetime","required":false},"notes":{"type":"text","required":false,"default":""},"connectedAccountId":{"type":"text","required":false,"default":""},"connectedFeePolicyRef":{"type":"text","required":false,"default":""},"applicationFeeCents":{"type":"integer","required":false,"default":0},"connectedEnvironment":{"type":"text","required":false,"default":""},"connectedAmount":{"type":"integer","required":false,"default":0},"connectedCurrency":{"type":"text","required":false,"default":""}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isAwaitingPayment":{"name":"isAwaitingPayment","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPaid":{"name":"isPaid","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isIssued":{"name":"isIssued","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCancelled":{"name":"isCancelled","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isRetired":{"name":"isRetired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isTerminal":{"name":"isTerminal","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markPaid":{"name":"markPaid","async":false,"parameters":[{"name":"args","type":"object","optional":false,"memberTypes":["string"]}],"returnType":"void","isStatic":false,"isPublic":true},"verifyAndMarkPaid":{"name":"verifyAndMarkPaid","async":true,"parameters":[{"name":"args","type":"object","optional":false,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markIssued":{"name":"markIssued","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"expire":{"name":"expire","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[{"name":"reason","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"retire":{"name":"retire","async":false,"parameters":[{"name":"reason","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"getOption":{"name":"getOption","async":false,"parameters":[{"name":"backendId","type":"string","optional":false}],"returnType":"PaymentOption | undefined","isStatic":false,"isPublic":true},"isOptionRetired":{"name":"isOptionRetired","async":false,"parameters":[{"name":"backendId","type":"string","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true},"getRetiredOptions":{"name":"getRetiredOptions","async":false,"parameters":[],"returnType":"PaymentOption[]","isStatic":false,"isPublic":true}},"decoratorConfig":{"conflictColumns":["tenant_id","offering_ref","licensee_email","idempotency_key"],"api":{"include":["list","get","create","update"],"writable":["skuId","offeringRef","licenseeEmail","customerId","paymentOptions","usdPriceLocked","priceLockWindowMs","idempotencyKey","notes"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"}},"extends":"SmrtObject","exportName":"PaymentIntent","collectionExportName":"PaymentIntentCollection","schema":{"tableName":"payment_intents","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_intents\\" (\\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 \\"sku_id\\" TEXT DEFAULT '',\\n \\"offering_ref\\" TEXT DEFAULT '',\\n \\"licensee_email\\" TEXT DEFAULT '',\\n \\"customer_id\\" TEXT DEFAULT '',\\n \\"payment_options\\" JSON DEFAULT '[]',\\n \\"usd_price_locked\\" INTEGER DEFAULT 0,\\n \\"price_lock_window_ms\\" INTEGER,\\n \\"price_lock_expires_at\\" TIMESTAMP,\\n \\"status\\" TEXT,\\n \\"idempotency_key\\" TEXT DEFAULT '',\\n \\"paid_option_backend_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"paid_at\\" TIMESTAMP,\\n \\"issued_at\\" TIMESTAMP,\\n \\"expired_at\\" TIMESTAMP,\\n \\"cancelled_at\\" TIMESTAMP,\\n \\"retired_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"connected_environment\\" TEXT DEFAULT '',\\n \\"connected_amount\\" INTEGER DEFAULT 0,\\n \\"connected_currency\\" TEXT DEFAULT ''\\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},"sku_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"offering_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"licensee_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_options":{"type":"JSON","notNull":false,"unique":false,"default":[]},"usd_price_locked":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_lock_window_ms":{"type":"INTEGER","notNull":false,"unique":false},"price_lock_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"idempotency_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_option_backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"expired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancelled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"retired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_environment":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_intents_tenant_id_offering_ref_idx","columns":["tenant_id","offering_ref","licensee_email","idempotency_key"],"unique":true,"nullsNotDistinct":true},{"name":"payment_intents_slug_context_idx","columns":["slug","context"]},{"name":"payment_intents_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"92f80d93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Payout":{"name":"payout","className":"Payout","qualifiedName":"@happyvertical/smrt-commerce:Payout","collection":"payouts","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Payout.ts","packageName":"@happyvertical/smrt-commerce","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}}},"paymentId":{"type":"text","required":false,"default":""},"vendorId":{"type":"foreignKey","required":false,"related":"Vendor"},"grossAmount":{"type":"integer","required":false,"default":0},"operatorFee":{"type":"integer","required":false,"default":0},"supplierNet":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":""},"backendId":{"type":"text","required":false,"default":""},"backendTxRef":{"type":"text","required":false,"default":""},"status":{"type":"text","required":false,"enum":["pending","sent","confirmed","failed"]},"sentAt":{"type":"datetime","required":false},"confirmedAt":{"type":"datetime","required":false},"failedAt":{"type":"datetime","required":false},"failureReason":{"type":"text","required":false,"default":""},"notes":{"type":"text","required":false,"default":""}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isPending":{"name":"isPending","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSent":{"name":"isSent","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isConfirmed":{"name":"isConfirmed","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isFailed":{"name":"isFailed","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markSent":{"name":"markSent","async":false,"parameters":[{"name":"backendTxRef","type":"string","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markConfirmed":{"name":"markConfirmed","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"markFailed":{"name":"markFailed","async":false,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"resetFromFailed":{"name":"resetFromFailed","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"validateAmounts":{"name":"validateAmounts","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Payout","collectionExportName":"PayoutCollection","schema":{"tableName":"payouts","ddl":"CREATE TABLE IF NOT EXISTS \\"payouts\\" (\\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 \\"payment_id\\" TEXT DEFAULT '',\\n \\"vendor_id\\" UUID,\\n \\"gross_amount\\" INTEGER DEFAULT 0,\\n \\"operator_fee\\" INTEGER DEFAULT 0,\\n \\"supplier_net\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT '',\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"sent_at\\" TIMESTAMP,\\n \\"confirmed_at\\" TIMESTAMP,\\n \\"failed_at\\" TIMESTAMP,\\n \\"failure_reason\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"gross_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"operator_fee":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"supplier_net":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"confirmed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failure_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payouts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payouts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payouts_vendor_id_idx","columns":["vendor_id"]}],"version":"777cae02"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchasePriceObservation":{"name":"purchasepriceobservation","className":"PurchasePriceObservation","qualifiedName":"@happyvertical/smrt-commerce:PurchasePriceObservation","collection":"purchasepriceobservations","description":"Original purchase evidence with explicitly unavailable monetary aggregates.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/PurchasePriceObservation.ts","packageName":"@happyvertical/smrt-commerce","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}}},"sourceIdentity":{"type":"text","required":false,"_meta":{}},"vendorId":{"type":"text","required":false,"_meta":{}},"snapshotJson":{"type":"text","required":false,"_meta":{}},"completionJson":{"type":"text","required":false,"_meta":{}}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"_options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveObserved":{"name":"saveObserved","async":true,"parameters":[{"name":"capability","type":"any","optional":false,"typeUnresolved":true},{"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":{"api":false,"cli":false,"mcp":false,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PurchasePriceObservation","collectionExportName":"PurchasePriceObservationCollection","validationRules":[],"schema":{"tableName":"purchase_price_observations","ddl":"CREATE TABLE IF NOT EXISTS \\"purchase_price_observations\\" (\\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_identity\\" TEXT,\\n \\"vendor_id\\" TEXT,\\n \\"snapshot_json\\" TEXT,\\n \\"completion_json\\" 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_identity":{"type":"TEXT","notNull":false,"unique":false},"vendor_id":{"type":"TEXT","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false},"completion_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"purchase_price_observations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"purchase_price_observations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"2a855c4b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxCode":{"name":"taxcode","className":"TaxCode","qualifiedName":"@happyvertical/smrt-commerce:TaxCode","collection":"taxcodes","description":"A reusable tax code whose ordered component list is safe to edit.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TaxCode.ts","packageName":"@happyvertical/smrt-commerce","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}}},"code":{"type":"text","required":false,"description":"A stable short code, for example gst-pst-bc.","_meta":{"description":"A stable short code, for example gst-pst-bc."}},"name":{"type":"text","required":false,"description":"The name people see for this tax code.","_meta":{"description":"The name people see for this tax code."}},"kind":{"type":"text","required":false,"default":"taxable","description":"How the tax code is reported.","_meta":{"description":"How the tax code is reported."},"enum":["taxable","zero-rated","exempt","out-of-scope"]},"appliesTo":{"type":"text","required":false,"default":"both","description":"Whether the code applies to sales, purchases or both.","_meta":{"description":"Whether the code applies to sales, purchases or both."},"enum":["sales","purchases","both"]},"componentsJson":{"type":"text","required":false},"active":{"type":"boolean","required":true,"default":true,"description":"Whether users may select this code for new documents.","_meta":{"description":"Whether users may select this code for new documents."}}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"conflictColumns":["tenant_id","code"],"api":{"include":["list","get","create","update"],"writable":["code","name","kind","appliesTo","components","active"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"TaxCode","collectionExportName":"TaxCodeCollection","displayLabelField":"name","validationRules":[{"field":"active","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"tax_codes","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_codes\\" (\\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 \\"code\\" TEXT,\\n \\"name\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'taxable',\\n \\"applies_to\\" TEXT DEFAULT 'both',\\n \\"components_json\\" TEXT,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"code":{"type":"TEXT","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"taxable"},"applies_to":{"type":"TEXT","notNull":false,"unique":false,"default":"both"},"components_json":{"type":"TEXT","notNull":false,"unique":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_codes_tenant_id_code_idx","columns":["tenant_id","code"],"unique":true,"nullsNotDistinct":true},{"name":"tax_codes_slug_context_idx","columns":["slug","context"]},{"name":"tax_codes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"583dc2f0"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxComponent":{"name":"taxcomponent","className":"TaxComponent","qualifiedName":"@happyvertical/smrt-commerce:TaxComponent","collection":"taxcomponents","description":"One reusable tax rate component.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TaxComponent.ts","packageName":"@happyvertical/smrt-commerce","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}}},"name":{"type":"text","required":false,"description":"The name of this tax component, for example GST.","_meta":{"description":"The name of this tax component, for example GST."}},"percent":{"type":"decimal","required":false,"description":"The tax percentage, for example 7.125 for 7.125 percent.","_meta":{"description":"The tax percentage, for example 7.125 for 7.125 percent."}},"liabilityAccountId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-ledgers:Account","_meta":{"description":"The liability account that receives this tax component."}},"recoverable":{"type":"boolean","required":true,"default":false,"description":"Whether purchases using this component may recover the full input tax. Partial recovery is not supported.","_meta":{"description":"Whether purchases using this component may recover the full input tax. Partial recovery is not supported."}},"active":{"type":"boolean","required":true,"default":true,"description":"Whether new tax codes and overrides may select it.","_meta":{"description":"Whether new tax codes and overrides may select it."}}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"],"writable":["name","percent","liabilityAccountId","recoverable","active"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TaxComponent","collectionExportName":"TaxComponentCollection","displayLabelField":"name","validationRules":[{"field":"recoverable","rule":"required","fieldType":"boolean"},{"field":"active","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"tax_components","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_components\\" (\\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 \\"name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" UUID,\\n \\"recoverable\\" BOOLEAN NOT NULL DEFAULT FALSE,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recoverable":{"type":"BOOLEAN","notNull":true,"unique":false,"default":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_components_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tax_components_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_components_liability_account_id_idx","columns":["liability_account_id"]}],"version":"79db2a87"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSettings":{"name":"taxsettings","className":"TaxSettings","qualifiedName":"@happyvertical/smrt-commerce:TaxSettings","collection":"taxsettingses","description":"Tenant-level defaults and registration numbers for tax determination.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TaxSettings.ts","packageName":"@happyvertical/smrt-commerce","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}}},"defaultSalesTaxCodeId":{"type":"foreignKey","required":false,"related":"TaxCode","_meta":{"description":"The default tax code for sales documents."}},"defaultPurchaseTaxCodeId":{"type":"foreignKey","required":false,"related":"TaxCode","_meta":{"description":"The default tax code for purchase documents."}},"defaultLineAmountType":{"type":"text","required":false,"default":"exclusive","description":"Whether new document amounts are exclusive, inclusive or out of scope.","_meta":{"description":"Whether new document amounts are exclusive, inclusive or out of scope."},"enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","required":false,"default":"line","description":"Whether components round per line or per document.","_meta":{"description":"Whether components round per line or per document."},"enum":["line","document"]},"taxRegistrationsJson":{"type":"text","required":false}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"conflictColumns":["tenant_id"],"api":{"include":["get","create","update"],"writable":["defaultSalesTaxCodeId","defaultPurchaseTaxCodeId","defaultLineAmountType","taxRoundingScope","taxRegistrations"]},"mcp":{"include":["get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"TaxSettings","collectionExportName":"TaxSettingsCollection","validationRules":[],"schema":{"tableName":"tax_settings","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_settings\\" (\\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 \\"default_sales_tax_code_id\\" UUID,\\n \\"default_purchase_tax_code_id\\" UUID,\\n \\"default_line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"tax_registrations_json\\" 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},"default_sales_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_purchase_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_settings_tenant_id_idx","columns":["tenant_id"],"unique":true},{"name":"tax_settings_slug_context_idx","columns":["slug","context"]},{"name":"tax_settings_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_settings_default_sales_tax_code_id_idx","columns":["default_sales_tax_code_id"]},{"name":"tax_settings_default_purchase_tax_code_id_idx","columns":["default_purchase_tax_code_id"]}],"version":"e8ebb46e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSummaryReport":{"name":"taxsummaryreport","className":"TaxSummaryReport","qualifiedName":"@happyvertical/smrt-commerce:TaxSummaryReport","collection":"taxsummaryreports","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TaxSummaryReport.ts","packageName":"@happyvertical/smrt-commerce","fields":{"refreshedAt":{"type":"datetime","required":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}}},"periodFrom":{"type":"datetime","required":false,"description":"The inclusive start of this report period.","_meta":{"description":"The inclusive start of this report period.","__report":{"kind":"group","sourceColumn":"issueDate"}}},"periodTo":{"type":"datetime","required":false,"description":"The inclusive end of this report period.","_meta":{"description":"The inclusive end of this report period.","__report":{"kind":"group","sourceColumn":"issueDate"}}},"currency":{"type":"text","required":false,"description":"The currency group; report rows never mix currencies.","_meta":{"description":"The currency group; report rows never mix currencies.","__report":{"kind":"group","sourceColumn":"currency"}}},"rowKind":{"type":"text","required":false,"default":"component","description":"The materialized tax-summary row category.","_meta":{"description":"The materialized tax-summary row category.","__report":{"kind":"group","sourceColumn":"kind"}},"enum":["component","kind","reconciliation","warning"]},"dimensionKey":{"type":"text","required":false,"description":"The stable dimension identity inside this report row.","_meta":{"description":"The stable dimension identity inside this report row.","__report":{"kind":"group","sourceColumn":"taxCodeId"}}},"direction":{"type":"text","required":false,"description":"Sales, purchase, expense or reconciliation direction.","_meta":{"description":"Sales, purchase, expense or reconciliation direction.","__report":{"kind":"group","sourceColumn":"documentType"}}},"taxComponentId":{"type":"text","required":false,"description":"Tenant tax component snapshot identity.","_meta":{"nullable":true,"description":"Tenant tax component snapshot identity.","__report":{"kind":"group","sourceColumn":"taxComponentId"}}},"taxCodeKind":{"type":"text","required":false,"description":"Stored tax-code kind snapshot.","_meta":{"nullable":true,"description":"Stored tax-code kind snapshot.","__report":{"kind":"group","sourceColumn":"kind"}}},"liabilityAccountId":{"type":"text","required":false,"description":"Liability account used for reconciliation.","_meta":{"nullable":true,"description":"Liability account used for reconciliation.","__report":{"kind":"group","sourceColumn":"liabilityAccountId"}}},"taxableMinor":{"type":"integer","required":true,"default":0,"description":"Stored taxable base in integer minor units.","_meta":{"description":"Stored taxable base in integer minor units.","__report":{"kind":"group","sourceColumn":"taxableMinor"}}},"taxMinor":{"type":"integer","required":true,"default":0,"description":"Collected tax or reconciliation tax amount in integer minor units.","_meta":{"description":"Collected tax or reconciliation tax amount in integer minor units.","__report":{"kind":"group","sourceColumn":"taxMinor"}}},"recoverableMinor":{"type":"integer","required":false,"description":"Recoverable tax in integer minor units, or null when incomplete.","_meta":{"nullable":true,"description":"Recoverable tax in integer minor units, or null when incomplete.","__report":{"kind":"group","sourceColumn":"recoverableMinor"}}},"ledgerMovementMinor":{"type":"integer","required":false,"description":"Posted ledger movement in raw commerce minor units.","_meta":{"nullable":true,"description":"Posted ledger movement in raw commerce minor units.","__report":{"kind":"group","sourceColumn":"ledgerMovementMinor"}}},"netTaxMinor":{"type":"integer","required":false,"description":"Collected less recoverable tax in integer minor units.","_meta":{"nullable":true,"description":"Collected less recoverable tax in integer minor units.","__report":{"kind":"group","sourceColumn":"taxMinor"}}},"differenceMinor":{"type":"integer","required":false,"description":"Ledger movement minus collected tax.","_meta":{"nullable":true,"description":"Ledger movement minus collected tax.","__report":{"kind":"group","sourceColumn":"differenceMinor"}}},"documentCount":{"type":"integer","required":true,"default":0,"description":"Distinct stored document count.","_meta":{"description":"Distinct stored document count.","__report":{"kind":"group","sourceColumn":"documentCount"}}},"sourceScopes":{"type":"text","required":false,"description":"Comma-separated source classes used to reproduce this row drilldown.","_meta":{"description":"Comma-separated source classes used to reproduce this row drilldown.","__report":{"kind":"group","sourceColumn":"sourceScopes"}}},"complete":{"type":"boolean","required":true,"default":true,"description":"Whether this row belongs to a complete tax-summary result.","_meta":{"description":"Whether this row belongs to a complete tax-summary result.","__report":{"kind":"group","sourceColumn":"complete"}}},"warningCode":{"type":"text","required":false,"description":"Incomplete-source warning code.","_meta":{"nullable":true,"description":"Incomplete-source warning code.","__report":{"kind":"group","sourceColumn":"taxCodeCode"}}},"warningSourceType":{"type":"text","required":false,"description":"Warning source category.","_meta":{"nullable":true,"description":"Warning source category.","__report":{"kind":"group","sourceColumn":"warningSourceType"}}},"warningSourceId":{"type":"text","required":false,"description":"Warning source identity.","_meta":{"nullable":true,"description":"Warning source identity.","__report":{"kind":"group","sourceColumn":"warningSourceId"}}},"warningMessage":{"type":"text","required":false,"description":"Operator-facing incomplete-source warning.","_meta":{"nullable":true,"description":"Operator-facing incomplete-source warning.","__report":{"kind":"group","sourceColumn":"taxComponentName"}}}},"methods":{"isStale":{"name":"isStale","async":false,"parameters":[{"name":"ttlMs","type":"number","optional":true}],"returnType":"boolean","isStatic":false,"isPublic":true},"refresh":{"name":"refresh","async":true,"parameters":[{"name":"options","type":"Omit<ReportRefreshOptions, 'db'>","optional":true}],"returnType":"Promise<ReportRefreshResult>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tax_summary_reports","conflictColumns":["tenant_id","period_from","period_to","currency","row_kind","dimension_key"],"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"report":{"source":"DocumentTax","refresh":{"manual":true,"mode":"rebuild"}},"tenantScoped":{"mode":"required"}},"extends":"SmrtReport","exportName":"TaxSummaryReport","collectionExportName":"TaxSummaryReportCollection","validationRules":[{"field":"taxableMinor","rule":"required","fieldType":"integer"},{"field":"taxMinor","rule":"required","fieldType":"integer"},{"field":"documentCount","rule":"required","fieldType":"integer"},{"field":"complete","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"tax_summary_reports","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_summary_reports\\" (\\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 \\"refreshed_at\\" TIMESTAMP,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"period_from\\" TIMESTAMP,\\n \\"period_to\\" TIMESTAMP,\\n \\"currency\\" TEXT,\\n \\"row_kind\\" TEXT DEFAULT 'component',\\n \\"dimension_key\\" TEXT,\\n \\"direction\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_code_kind\\" TEXT,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER,\\n \\"ledger_movement_minor\\" INTEGER,\\n \\"net_tax_minor\\" INTEGER,\\n \\"difference_minor\\" INTEGER,\\n \\"document_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"source_scopes\\" TEXT,\\n \\"complete\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"warning_code\\" TEXT,\\n \\"warning_source_type\\" TEXT,\\n \\"warning_source_id\\" TEXT,\\n \\"warning_message\\" 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"},"refreshed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"period_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false},"row_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"component"},"dimension_key":{"type":"TEXT","notNull":false,"unique":false},"direction":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_kind":{"type":"TEXT","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":false,"unique":false},"ledger_movement_minor":{"type":"INTEGER","notNull":false,"unique":false},"net_tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"difference_minor":{"type":"INTEGER","notNull":false,"unique":false},"document_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"source_scopes":{"type":"TEXT","notNull":false,"unique":false},"complete":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"warning_code":{"type":"TEXT","notNull":false,"unique":false},"warning_source_type":{"type":"TEXT","notNull":false,"unique":false},"warning_source_id":{"type":"TEXT","notNull":false,"unique":false},"warning_message":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_summary_reports_tenant_id_period_from_idx","columns":["tenant_id","period_from","period_to","currency","row_kind","dimension_key"],"unique":true,"nullsNotDistinct":true},{"name":"tax_summary_reports_slug_context_idx","columns":["slug","context"]},{"name":"tax_summary_reports_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"d4d5ebbe"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentAccount":{"name":"tenantpaymentaccount","className":"TenantPaymentAccount","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentAccount","collection":"tenantpaymentaccounts","description":"A tenant's connected payment account for one backend and environment.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TenantPaymentAccount.ts","packageName":"@happyvertical/smrt-commerce","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}}},"backendId":{"type":"text","required":true,"default":"stripe","_meta":{"required":true}},"environment":{"type":"text","required":true,"default":"test","_meta":{"required":true},"enum":["test","live"]},"providerAccountId":{"type":"text","required":true,"default":"","_meta":{"required":true}},"status":{"type":"text","required":false,"default":"pending","enum":["pending","restricted","enabled","disabled"]},"chargesEnabled":{"type":"boolean","required":false,"default":false},"detailsSubmitted":{"type":"boolean","required":false,"default":false},"payoutsEnabled":{"type":"boolean","required":false,"default":false},"capabilitiesJson":{"type":"text","required":false,"_meta":{}},"capabilitiesObservedAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"feePolicyRef":{"type":"text","required":false,"default":""},"disabledAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"disabledReason":{"type":"text","required":false,"default":""}},"methods":{"isEnabled":{"name":"isEnabled","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getCapabilities":{"name":"getCapabilities","async":false,"parameters":[],"returnType":"TenantPaymentCapabilitySnapshot | null","isStatic":false,"isPublic":true},"setCapabilities":{"name":"setCapabilities","async":false,"parameters":[{"name":"snapshot","type":"TenantPaymentCapabilitySnapshot","optional":false},{"name":"observedAt","type":"Date","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"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":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tenant_payment_accounts","indexes":[{"name":"tenant_payment_accounts_tenant_backend_environment","columns":["tenantId","backendId","environment"],"unique":true},{"name":"tenant_payment_accounts_provider_account","columns":["backendId","environment","providerAccountId"],"unique":true}],"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get","isEnabled","getCapabilities"],"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantPaymentAccount","collectionExportName":"TenantPaymentAccountCollection","validationRules":[{"field":"backendId","rule":"required","fieldType":"text"},{"field":"environment","rule":"required","fieldType":"text"},{"field":"providerAccountId","rule":"required","fieldType":"text"}],"schema":{"tableName":"tenant_payment_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_accounts\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT 'stripe',\\n \\"environment\\" TEXT NOT NULL DEFAULT 'test',\\n \\"provider_account_id\\" TEXT NOT NULL DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'pending',\\n \\"charges_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"details_submitted\\" BOOLEAN DEFAULT FALSE,\\n \\"payouts_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"capabilities_json\\" TEXT,\\n \\"capabilities_observed_at\\" TIMESTAMP,\\n \\"fee_policy_ref\\" TEXT DEFAULT '',\\n \\"disabled_at\\" TIMESTAMP,\\n \\"disabled_reason\\" TEXT DEFAULT ''\\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},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":"stripe"},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"pending"},"charges_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"details_submitted":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"payouts_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"capabilities_json":{"type":"TEXT","notNull":false,"unique":false},"capabilities_observed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"disabled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"disabled_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"tenant_payment_accounts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_accounts_tenant_backend_environment","columns":["tenant_id","backend_id","environment"],"unique":true},{"name":"tenant_payment_accounts_provider_account","columns":["backend_id","environment","provider_account_id"],"unique":true},{"name":"tenant_payment_accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"ea6f5edc"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentDispute":{"name":"tenantpaymentdispute","className":"TenantPaymentDispute","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentDispute","collection":"tenantpaymentdisputes","description":"One authoritative dispute snapshot and its immutable balance evidence.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TenantPaymentDispute.ts","packageName":"@happyvertical/smrt-commerce","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}}},"backendId":{"type":"text","required":false,"default":""},"environment":{"type":"text","required":false,"default":"test","enum":["test","live"]},"providerAccountId":{"type":"text","required":false,"default":""},"disputeId":{"type":"text","required":false,"default":""},"paymentId":{"type":"foreignKey","required":false,"related":"Payment"},"status":{"type":"text","required":false,"default":"unknown"},"snapshotJson":{"type":"text","required":false,"_meta":{}}},"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":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tenant_payment_disputes","api":false,"cli":false,"mcp":false,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantPaymentDispute","collectionExportName":"TenantPaymentDisputeCollection","validationRules":[],"schema":{"tableName":"tenant_payment_disputes","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_disputes\\" (\\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 \\"backend_id\\" TEXT DEFAULT '',\\n \\"environment\\" TEXT DEFAULT 'test',\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"dispute_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'unknown',\\n \\"snapshot_json\\" 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},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":false,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dispute_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"unknown"},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tenant_payment_disputes_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_disputes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tenant_payment_disputes_payment_id_idx","columns":["payment_id"]}],"version":"fd77af5e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentDisputeCollection":{"name":"tenantpaymentdisputecollection","className":"TenantPaymentDisputeCollection","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentDisputeCollection","collection":"tenantpaymentdisputes","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TenantPaymentDispute.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"tenant_payment_disputes","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"TenantPaymentDispute","exportName":"TenantPaymentDisputeCollection","collectionExportName":"TenantPaymentDisputeCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TenantPaymentDispute","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"tenant_payment_disputes","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_disputes\\" (\\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 \\"backend_id\\" TEXT DEFAULT '',\\n \\"environment\\" TEXT DEFAULT 'test',\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"dispute_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'unknown',\\n \\"snapshot_json\\" 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},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":false,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dispute_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"unknown"},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tenant_payment_disputes_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_disputes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tenant_payment_disputes_payment_id_idx","columns":["payment_id"]}],"version":"fd77af5e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentWebhookEvent":{"name":"tenantpaymentwebhookevent","className":"TenantPaymentWebhookEvent","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentWebhookEvent","collection":"tenantpaymentwebhookevents","description":"One processed provider webhook event.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TenantPaymentWebhookEvent.ts","packageName":"@happyvertical/smrt-commerce","fields":{"backendId":{"type":"text","required":true,"default":"","_meta":{"required":true}},"environment":{"type":"text","required":true,"default":"","_meta":{"required":true}},"eventId":{"type":"text","required":true,"default":"","_meta":{"required":true}},"eventType":{"type":"text","required":false,"default":""},"endpoint":{"type":"text","required":false,"default":""},"tenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"providerAccountId":{"type":"text","required":false,"default":""},"outcome":{"type":"text","required":false,"default":"ignored","enum":["settled","already_settled","pending","account_updated","stale_account_update","application_fee","refund_reported","refund_updated","dispute_updated","dispute_reported","late_payment","ignored"]},"paymentIntentId":{"type":"text","required":false,"default":""},"paymentId":{"type":"text","required":false,"default":""},"applicationFeeJson":{"type":"text","required":false,"_meta":{}},"processedAt":{"type":"datetime","required":false,"_meta":{"nullable":true}}},"methods":{},"decoratorConfig":{"tableName":"_smrt_tenant_payment_webhook_events","indexes":[{"name":"_smrt_tenant_payment_webhook_events_event","columns":["backendId","environment","eventId"],"unique":true}],"api":false,"cli":false,"mcp":false,"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantPaymentWebhookEvent","collectionExportName":"TenantPaymentWebhookEventCollection","validationRules":[{"field":"backendId","rule":"required","fieldType":"text"},{"field":"environment","rule":"required","fieldType":"text"},{"field":"eventId","rule":"required","fieldType":"text"},{"field":"tenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_tenant_payment_webhook_events","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_payment_webhook_events\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT '',\\n \\"environment\\" TEXT NOT NULL DEFAULT '',\\n \\"event_id\\" TEXT NOT NULL DEFAULT '',\\n \\"event_type\\" TEXT DEFAULT '',\\n \\"endpoint\\" TEXT DEFAULT '',\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"outcome\\" TEXT DEFAULT 'ignored',\\n \\"payment_intent_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"application_fee_json\\" TEXT,\\n \\"processed_at\\" TIMESTAMP\\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"},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"endpoint":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"outcome":{"type":"TEXT","notNull":false,"unique":false,"default":"ignored"},"payment_intent_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_json":{"type":"TEXT","notNull":false,"unique":false},"processed_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_tenant_payment_webhook_events_tenant_id_slug_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_tenant_payment_webhook_events_event","columns":["backend_id","environment","event_id"],"unique":true},{"name":"_smrt_tenant_payment_webhook_events_created_at_idx","columns":["created_at"]}],"version":"be527ce0"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentWebhookEventCollection":{"name":"tenantpaymentwebhookeventcollection","className":"TenantPaymentWebhookEventCollection","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentWebhookEventCollection","collection":"tenantpaymentwebhookevents","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/TenantPaymentWebhookEvent.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"build":{"name":"build","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<TenantPaymentWebhookEvent>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_payment_webhook_events","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"TenantPaymentWebhookEvent","exportName":"TenantPaymentWebhookEventCollection","collectionExportName":"TenantPaymentWebhookEventCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TenantPaymentWebhookEvent","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_tenant_payment_webhook_events","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_payment_webhook_events\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT '',\\n \\"environment\\" TEXT NOT NULL DEFAULT '',\\n \\"event_id\\" TEXT NOT NULL DEFAULT '',\\n \\"event_type\\" TEXT DEFAULT '',\\n \\"endpoint\\" TEXT DEFAULT '',\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"outcome\\" TEXT DEFAULT 'ignored',\\n \\"payment_intent_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"application_fee_json\\" TEXT,\\n \\"processed_at\\" TIMESTAMP\\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"},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"endpoint":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"outcome":{"type":"TEXT","notNull":false,"unique":false,"default":"ignored"},"payment_intent_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_json":{"type":"TEXT","notNull":false,"unique":false},"processed_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_tenant_payment_webhook_events_tenant_id_slug_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_tenant_payment_webhook_events_event","columns":["backend_id","environment","event_id"],"unique":true},{"name":"_smrt_tenant_payment_webhook_events_created_at_idx","columns":["created_at"]}],"version":"be527ce0"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Vendor":{"name":"vendor","className":"Vendor","qualifiedName":"@happyvertical/smrt-commerce:Vendor","collection":"vendors","description":"Vendor represents the vendor/supplier role for a Profile.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/Vendor.ts","packageName":"@happyvertical/smrt-commerce","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}}},"profileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile","_meta":{"description":"Links this vendor to their profile record, where their name and contact details are kept."}},"leadTimeDays":{"type":"integer","required":false,"default":0,"description":"How many days the vendor usually takes between your order and delivery.","_meta":{"description":"How many days the vendor usually takes between your order and delivery."}},"minimumOrderAmount":{"type":"integer","required":false,"default":0,"description":"The smallest order the vendor will accept.","_meta":{"description":"The smallest order the vendor will accept.","ui":{"format":"money"}}},"paymentTerms":{"type":"text","required":false,"default":"","description":"How long you have to pay this vendor, written the way you would say it, for example \\"Net 30\\".","_meta":{"description":"How long you have to pay this vendor, written the way you would say it, for example \\"Net 30\\"."}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency this vendor bills you in.","_meta":{"description":"The currency this vendor bills you in.","ui":{"widget":"currency"}}},"taxId":{"type":"text","required":false,"default":"","description":"The vendor tax or VAT registration number kept on file.","_meta":{"sensitive":true,"description":"The vendor tax or VAT registration number kept on file."},"sensitive":true},"defaultTaxCodeId":{"type":"foreignKey","required":false,"related":"TaxCode","_meta":{"description":"The tax code normally used when buying from this vendor."}},"defaultContactEmail":{"type":"text","required":false,"default":"","description":"The email address you normally use to reach this vendor.","_meta":{"description":"The email address you normally use to reach this vendor.","ui":{"widget":"email"}}},"defaultContactPhone":{"type":"text","required":false,"default":"","description":"The phone number you normally use to reach this vendor.","_meta":{"description":"The phone number you normally use to reach this vendor.","ui":{"widget":"phone"}}},"status":{"type":"text","required":false,"description":"Whether you still buy from this vendor: active, inactive or suspended.","_meta":{"description":"Whether you still buy from this vendor: active, inactive or suspended."},"enum":["active","inactive","suspended"]},"notes":{"type":"text","required":false,"default":"","description":"Anything worth remembering about this vendor.","_meta":{"description":"Anything worth remembering about this vendor.","ui":{"widget":"textarea"}}},"payoutAddresses":{"type":"json","required":false,"default":{},"description":"Where payments to this vendor should be sent.","_meta":{"sensitive":true,"description":"Where payments to this vendor should be sent."},"sensitive":true},"contacts":{"type":"json","required":false,"default":[],"description":"The people you deal with at this vendor, with their role and how to reach them.","_meta":{"description":"The people you deal with at this vendor, with their role and how to reach them."}}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"meetsMinimumOrder":{"name":"meetsMinimumOrder","async":false,"parameters":[{"name":"amount","type":"number","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true},"getProfileId":{"name":"getProfileId","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true},"getPayoutAddress":{"name":"getPayoutAddress","async":false,"parameters":[{"name":"currency","type":"string","optional":false}],"returnType":"string | undefined","isStatic":false,"isPublic":true},"setPayoutAddress":{"name":"setPayoutAddress","async":false,"parameters":[{"name":"currency","type":"string","optional":false},{"name":"destination","type":"string","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"clearPayoutAddress":{"name":"clearPayoutAddress","async":false,"parameters":[{"name":"currency","type":"string","optional":false}],"returnType":"this","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Vendor","collectionExportName":"VendorCollection","schema":{"tableName":"vendors","ddl":"CREATE TABLE IF NOT EXISTS \\"vendors\\" (\\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 \\"profile_id\\" UUID,\\n \\"lead_time_days\\" INTEGER DEFAULT 0,\\n \\"minimum_order_amount\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_contact_email\\" TEXT DEFAULT '',\\n \\"default_contact_phone\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"payout_addresses\\" JSON DEFAULT '{}',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"lead_time_days":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"minimum_order_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_contact_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_contact_phone":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payout_addresses":{"type":"JSON","notNull":false,"unique":false,"default":{}},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"vendors_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"vendors_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"vendors_profile_id_idx","columns":["profile_id"]},{"name":"vendors_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"6cac701f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingAccount":{"name":"billingaccount","className":"BillingAccount","qualifiedName":"@happyvertical/smrt-commerce:BillingAccount","collection":"billingaccounts","description":"One payer's account with one seller: the commerce Customer invoices are issued to, the provider customer they are pushed to, and the payer's billing terms.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"payerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"customerId":{"type":"foreignKey","required":false,"related":"Customer"},"name":{"type":"text","required":false,"default":""},"email":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":""},"providerCustomerId":{"type":"text","required":false,"default":""},"automaticTax":{"type":"boolean","required":false,"default":true},"flatDiscountBasisPoints":{"type":"integer","required":false,"default":0},"paymentTermsDays":{"type":"integer","required":false,"default":30},"standing":{"type":"text","required":false,"default":"current","enum":["current","past_due","uncollectible"]},"billingAnchorAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"prorateFlatPlans":{"type":"boolean","required":false,"default":false}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_accounts","conflictColumns":["seller_tenant_id","payer_tenant_id"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingAccount","collectionExportName":"BillingAccountCollection","displayLabelField":"name","validationRules":[{"field":"sellerTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"payerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_billing_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_accounts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"customer_id\\" UUID,\\n \\"name\\" TEXT DEFAULT '',\\n \\"email\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"automatic_tax\\" BOOLEAN DEFAULT TRUE,\\n \\"flat_discount_basis_points\\" INTEGER DEFAULT 0,\\n \\"payment_terms_days\\" INTEGER DEFAULT 30,\\n \\"standing\\" TEXT DEFAULT 'current',\\n \\"billing_anchor_at\\" TIMESTAMP,\\n \\"prorate_flat_plans\\" BOOLEAN DEFAULT FALSE\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"automatic_tax":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"flat_discount_basis_points":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms_days":{"type":"INTEGER","notNull":false,"unique":false,"default":30},"standing":{"type":"TEXT","notNull":false,"unique":false,"default":"current"},"billing_anchor_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"prorate_flat_plans":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"_smrt_billing_accounts_seller_tenant_id_payer_tenant_id_idx","columns":["seller_tenant_id","payer_tenant_id"],"unique":true},{"name":"_smrt_billing_accounts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_accounts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_accounts_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_accounts_customer_id_idx","columns":["customer_id"]}],"version":"01922629"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPeriodClose":{"name":"billingperiodclose","className":"BillingPeriodClose","qualifiedName":"@happyvertical/smrt-commerce:BillingPeriodClose","collection":"billingperiodcloses","description":"The idempotency anchor for one payer's invoice in one currency for one period. Its id is derived from that identity, so a retried close always resumes the same row, invoice, and provider invoice.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"kind":{"type":"text","required":false,"default":"provider","enum":["provider","reseller"]},"payerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"currency":{"type":"text","required":false,"default":"USD"},"periodStart":{"type":"datetime","required":false},"periodEnd":{"type":"datetime","required":false},"billingAccountId":{"type":"foreignKey","required":false,"related":"BillingAccount"},"status":{"type":"text","required":false,"default":"collecting","enum":["collecting","invoiced","pushed","sent","completed","carried_forward"]},"invoiceId":{"type":"foreignKey","required":false,"related":"Invoice"},"providerInvoiceId":{"type":"text","required":false,"default":""},"subtotal":{"type":"integer","required":false,"default":0},"lineCount":{"type":"integer","required":false,"default":0},"issuedAt":{"type":"datetime","required":false},"leaseToken":{"type":"text","required":false,"_meta":{"nullable":true}},"leaseExpiresAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"attempts":{"type":"integer","required":false,"default":0},"lastError":{"type":"text","required":false,"default":""}},"methods":{"runPeriodClose":{"name":"runPeriodClose","async":true,"parameters":[{"name":"args","type":"Record<string, unknown>","optional":true},{"name":"_context","type":"JobExecutionContext","optional":true}],"returnType":"Promise<unknown>","isStatic":false,"isPublic":true},"processBillingEvents":{"name":"processBillingEvents","async":true,"parameters":[{"name":"args","type":"Record<string, unknown>","optional":true},{"name":"_context","type":"JobExecutionContext","optional":true}],"returnType":"Promise<unknown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_billing_period_closes","conflictColumns":["seller_tenant_id","kind","payer_tenant_id","currency","period_start","period_end"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingPeriodClose","collectionExportName":"BillingPeriodCloseCollection","validationRules":[{"field":"sellerTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"payerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_billing_period_closes","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_period_closes\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT DEFAULT 'provider',\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"billing_account_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'collecting',\\n \\"invoice_id\\" UUID,\\n \\"provider_invoice_id\\" TEXT DEFAULT '',\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"line_count\\" INTEGER DEFAULT 0,\\n \\"issued_at\\" TIMESTAMP,\\n \\"lease_token\\" TEXT,\\n \\"lease_expires_at\\" TIMESTAMP,\\n \\"attempts\\" INTEGER DEFAULT 0,\\n \\"last_error\\" TEXT DEFAULT ''\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"provider"},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"billing_account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"collecting"},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"provider_invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"line_count":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"lease_token":{"type":"TEXT","notNull":false,"unique":false},"lease_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"attempts":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_error":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_period_closes_seller_tenant_id_kind_idx","columns":["seller_tenant_id","kind","payer_tenant_id","currency","period_start","period_end"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_period_closes_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_period_closes_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_period_closes_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_period_closes_billing_account_id_idx","columns":["billing_account_id"]},{"name":"_smrt_billing_period_closes_invoice_id_idx","columns":["invoice_id"]}],"version":"5b8a7e8f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingLineSource":{"name":"billinglinesource","className":"BillingLineSource","qualifiedName":"@happyvertical/smrt-commerce:BillingLineSource","collection":"billinglinesources","description":"A claim that one billable source \u2014 a charge, an adjustment, or a window of a flat plan \u2014 is billed on exactly one period close.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"periodCloseId":{"type":"foreignKey","required":false,"related":"BillingPeriodClose"},"sourceType":{"type":"text","required":false,"default":"client_charge","enum":["client_charge","billing_adjustment","retail_charge","subscription_period","credit_carry_forward"]},"sourceId":{"type":"text","required":false,"default":""},"lineKey":{"type":"text","required":false,"default":""},"lineDescription":{"type":"text","required":false,"default":""},"amount":{"type":"integer","required":false,"default":0},"discount":{"type":"integer","required":false,"default":0},"quantity":{"type":"decimal","required":false,"default":0},"chainSequence":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"periodStart":{"type":"datetime","required":false},"periodEnd":{"type":"datetime","required":false}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_line_sources","conflictColumns":["source_type","source_id"],"indexes":[{"name":"_smrt_billing_line_sources_line_key_chain_sequence_idx","columns":["lineKey","chainSequence"]}],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingLineSource","collectionExportName":"BillingLineSourceCollection","validationRules":[{"field":"sellerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_billing_line_sources","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_line_sources\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"period_close_id\\" UUID,\\n \\"source_type\\" TEXT DEFAULT 'client_charge',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"line_key\\" TEXT DEFAULT '',\\n \\"line_description\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"chain_sequence\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"period_close_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_period_closes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":"client_charge"},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"chain_sequence":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_billing_line_sources_source_type_source_id_idx","columns":["source_type","source_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_line_sources_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_line_sources_line_key_chain_sequence_idx","columns":["line_key","chain_sequence"]},{"name":"_smrt_billing_line_sources_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_line_sources_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_line_sources_period_close_id_idx","columns":["period_close_id"]}],"version":"618b2817"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPaymentAttempt":{"name":"billingpaymentattempt","className":"BillingPaymentAttempt","qualifiedName":"@happyvertical/smrt-commerce:BillingPaymentAttempt","collection":"billingpaymentattempts","description":"One payment attempt on a payment rail (#3138): a short-lived provider checkout (for example a BTCPay invoice) paying a credit purchase or an issued invoice.","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"payerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"billingAccountId":{"type":"text","required":false,"default":""},"purpose":{"type":"text","required":false,"default":"credit_purchase","enum":["credit_purchase","invoice_payment"]},"invoiceId":{"type":"text","required":false,"default":""},"spendingPolicyId":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":""},"orderId":{"type":"text","required":false,"default":""},"checkoutId":{"type":"text","required":false,"default":""},"status":{"type":"text","required":false,"default":"open"},"exception":{"type":"text","required":false,"default":"none"},"flag":{"type":"text","required":false,"default":"","enum":["","overpaid","underpaid","paid_late","manually_marked","invalidated_after_settlement","invoice_already_paid","amount_mismatch","out_of_band_without_settlement"]},"amount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"amountPaid":{"type":"integer","required":false,"default":0},"nativeCurrency":{"type":"text","required":false,"default":""},"nativeAmountDue":{"type":"integer","required":false,"default":0},"nativeAmountPaid":{"type":"integer","required":false,"default":0},"rate":{"type":"text","required":false,"default":""},"rateSource":{"type":"text","required":false,"default":""},"checkoutUrl":{"type":"text","required":false,"default":""},"expiresAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"payments":{"type":"json","required":false,"default":[]},"timeline":{"type":"json","required":false,"default":[]},"settledAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"paymentId":{"type":"text","required":false,"default":""},"creditGrantId":{"type":"text","required":false,"default":""},"resolution":{"type":"text","required":false,"default":""},"resolvedAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"outOfBandRequestedAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"pausedStanding":{"type":"text","required":false,"default":""},"excessAmount":{"type":"integer","required":false,"default":0},"excessRevision":{"type":"integer","required":false,"default":0},"settlementOutcome":{"type":"text","required":false,"default":""},"refundedAmount":{"type":"integer","required":false,"default":0},"refundedPrincipal":{"type":"integer","required":false,"default":0},"refunds":{"type":"json","required":false,"default":[]}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_payment_attempts","conflictColumns":["provider","checkout_id"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingPaymentAttempt","collectionExportName":"BillingPaymentAttemptCollection","validationRules":[{"field":"sellerTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"payerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_billing_payment_attempts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_payment_attempts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"billing_account_id\\" TEXT DEFAULT '',\\n \\"purpose\\" TEXT DEFAULT 'credit_purchase',\\n \\"invoice_id\\" TEXT DEFAULT '',\\n \\"spending_policy_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"order_id\\" TEXT DEFAULT '',\\n \\"checkout_id\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'open',\\n \\"exception\\" TEXT DEFAULT 'none',\\n \\"flag\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"native_amount_due\\" INTEGER DEFAULT 0,\\n \\"native_amount_paid\\" INTEGER DEFAULT 0,\\n \\"rate\\" TEXT DEFAULT '',\\n \\"rate_source\\" TEXT DEFAULT '',\\n \\"checkout_url\\" TEXT DEFAULT '',\\n \\"expires_at\\" TIMESTAMP,\\n \\"payments\\" JSON DEFAULT '[]',\\n \\"timeline\\" JSON DEFAULT '[]',\\n \\"settled_at\\" TIMESTAMP,\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"credit_grant_id\\" TEXT DEFAULT '',\\n \\"resolution\\" TEXT DEFAULT '',\\n \\"resolved_at\\" TIMESTAMP,\\n \\"out_of_band_requested_at\\" TIMESTAMP,\\n \\"paused_standing\\" TEXT DEFAULT '',\\n \\"excess_amount\\" INTEGER DEFAULT 0,\\n \\"excess_revision\\" INTEGER DEFAULT 0,\\n \\"settlement_outcome\\" TEXT DEFAULT '',\\n \\"refunded_amount\\" INTEGER DEFAULT 0,\\n \\"refunded_principal\\" INTEGER DEFAULT 0,\\n \\"refunds\\" JSON DEFAULT '[]'\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"billing_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"purpose":{"type":"TEXT","notNull":false,"unique":false,"default":"credit_purchase"},"invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"spending_policy_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"order_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"open"},"exception":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"flag":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount_due":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"rate":{"type":"TEXT","notNull":false,"unique":false,"default":""},"rate_source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_url":{"type":"TEXT","notNull":false,"unique":false,"default":""},"expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payments":{"type":"JSON","notNull":false,"unique":false,"default":[]},"timeline":{"type":"JSON","notNull":false,"unique":false,"default":[]},"settled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"credit_grant_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolution":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolved_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"out_of_band_requested_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"paused_standing":{"type":"TEXT","notNull":false,"unique":false,"default":""},"excess_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"excess_revision":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"settlement_outcome":{"type":"TEXT","notNull":false,"unique":false,"default":""},"refunded_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunded_principal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunds":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"_smrt_billing_payment_attempts_provider_checkout_id_idx","columns":["provider","checkout_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_payment_attempts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_payment_attempts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_payment_attempts_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_payment_attempts_payer_tenant_id_idx","columns":["payer_tenant_id"]}],"version":"eff3952d"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingAccountCollection":{"name":"billingaccountcollection","className":"BillingAccountCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingAccountCollection","collection":"billingaccounts","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_accounts","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingAccount","exportName":"BillingAccountCollection","collectionExportName":"BillingAccountCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingAccount","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_accounts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"customer_id\\" UUID,\\n \\"name\\" TEXT DEFAULT '',\\n \\"email\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"automatic_tax\\" BOOLEAN DEFAULT TRUE,\\n \\"flat_discount_basis_points\\" INTEGER DEFAULT 0,\\n \\"payment_terms_days\\" INTEGER DEFAULT 30,\\n \\"standing\\" TEXT DEFAULT 'current',\\n \\"billing_anchor_at\\" TIMESTAMP,\\n \\"prorate_flat_plans\\" BOOLEAN DEFAULT FALSE\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"automatic_tax":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"flat_discount_basis_points":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms_days":{"type":"INTEGER","notNull":false,"unique":false,"default":30},"standing":{"type":"TEXT","notNull":false,"unique":false,"default":"current"},"billing_anchor_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"prorate_flat_plans":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"_smrt_billing_accounts_seller_tenant_id_payer_tenant_id_idx","columns":["seller_tenant_id","payer_tenant_id"],"unique":true},{"name":"_smrt_billing_accounts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_accounts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_accounts_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_accounts_customer_id_idx","columns":["customer_id"]}],"version":"01922629"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPeriodCloseCollection":{"name":"billingperiodclosecollection","className":"BillingPeriodCloseCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingPeriodCloseCollection","collection":"billingperiodcloses","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_period_closes","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingPeriodClose","exportName":"BillingPeriodCloseCollection","collectionExportName":"BillingPeriodCloseCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingPeriodClose","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_period_closes","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_period_closes\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT DEFAULT 'provider',\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"billing_account_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'collecting',\\n \\"invoice_id\\" UUID,\\n \\"provider_invoice_id\\" TEXT DEFAULT '',\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"line_count\\" INTEGER DEFAULT 0,\\n \\"issued_at\\" TIMESTAMP,\\n \\"lease_token\\" TEXT,\\n \\"lease_expires_at\\" TIMESTAMP,\\n \\"attempts\\" INTEGER DEFAULT 0,\\n \\"last_error\\" TEXT DEFAULT ''\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"provider"},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"billing_account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"collecting"},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"provider_invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"line_count":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"lease_token":{"type":"TEXT","notNull":false,"unique":false},"lease_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"attempts":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_error":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_period_closes_seller_tenant_id_kind_idx","columns":["seller_tenant_id","kind","payer_tenant_id","currency","period_start","period_end"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_period_closes_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_period_closes_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_period_closes_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_period_closes_billing_account_id_idx","columns":["billing_account_id"]},{"name":"_smrt_billing_period_closes_invoice_id_idx","columns":["invoice_id"]}],"version":"5b8a7e8f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingLineSourceCollection":{"name":"billinglinesourcecollection","className":"BillingLineSourceCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingLineSourceCollection","collection":"billinglinesources","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_line_sources","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingLineSource","exportName":"BillingLineSourceCollection","collectionExportName":"BillingLineSourceCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingLineSource","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_line_sources","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_line_sources\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"period_close_id\\" UUID,\\n \\"source_type\\" TEXT DEFAULT 'client_charge',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"line_key\\" TEXT DEFAULT '',\\n \\"line_description\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"chain_sequence\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"period_close_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_period_closes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":"client_charge"},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"chain_sequence":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_billing_line_sources_source_type_source_id_idx","columns":["source_type","source_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_line_sources_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_line_sources_line_key_chain_sequence_idx","columns":["line_key","chain_sequence"]},{"name":"_smrt_billing_line_sources_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_line_sources_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_line_sources_period_close_id_idx","columns":["period_close_id"]}],"version":"618b2817"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPaymentAttemptCollection":{"name":"billingpaymentattemptcollection","className":"BillingPaymentAttemptCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingPaymentAttemptCollection","collection":"billingpaymentattempts","filePath":"/home/runner/work/smrt/smrt/packages/commerce/src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_payment_attempts","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingPaymentAttempt","exportName":"BillingPaymentAttemptCollection","collectionExportName":"BillingPaymentAttemptCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingPaymentAttempt","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_payment_attempts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_payment_attempts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"billing_account_id\\" TEXT DEFAULT '',\\n \\"purpose\\" TEXT DEFAULT 'credit_purchase',\\n \\"invoice_id\\" TEXT DEFAULT '',\\n \\"spending_policy_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"order_id\\" TEXT DEFAULT '',\\n \\"checkout_id\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'open',\\n \\"exception\\" TEXT DEFAULT 'none',\\n \\"flag\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"native_amount_due\\" INTEGER DEFAULT 0,\\n \\"native_amount_paid\\" INTEGER DEFAULT 0,\\n \\"rate\\" TEXT DEFAULT '',\\n \\"rate_source\\" TEXT DEFAULT '',\\n \\"checkout_url\\" TEXT DEFAULT '',\\n \\"expires_at\\" TIMESTAMP,\\n \\"payments\\" JSON DEFAULT '[]',\\n \\"timeline\\" JSON DEFAULT '[]',\\n \\"settled_at\\" TIMESTAMP,\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"credit_grant_id\\" TEXT DEFAULT '',\\n \\"resolution\\" TEXT DEFAULT '',\\n \\"resolved_at\\" TIMESTAMP,\\n \\"out_of_band_requested_at\\" TIMESTAMP,\\n \\"paused_standing\\" TEXT DEFAULT '',\\n \\"excess_amount\\" INTEGER DEFAULT 0,\\n \\"excess_revision\\" INTEGER DEFAULT 0,\\n \\"settlement_outcome\\" TEXT DEFAULT '',\\n \\"refunded_amount\\" INTEGER DEFAULT 0,\\n \\"refunded_principal\\" INTEGER DEFAULT 0,\\n \\"refunds\\" JSON DEFAULT '[]'\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"billing_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"purpose":{"type":"TEXT","notNull":false,"unique":false,"default":"credit_purchase"},"invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"spending_policy_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"order_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"open"},"exception":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"flag":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount_due":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"rate":{"type":"TEXT","notNull":false,"unique":false,"default":""},"rate_source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_url":{"type":"TEXT","notNull":false,"unique":false,"default":""},"expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payments":{"type":"JSON","notNull":false,"unique":false,"default":[]},"timeline":{"type":"JSON","notNull":false,"unique":false,"default":[]},"settled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"credit_grant_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolution":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolved_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"out_of_band_requested_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"paused_standing":{"type":"TEXT","notNull":false,"unique":false,"default":""},"excess_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"excess_revision":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"settlement_outcome":{"type":"TEXT","notNull":false,"unique":false,"default":""},"refunded_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunded_principal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunds":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"_smrt_billing_payment_attempts_provider_checkout_id_idx","columns":["provider","checkout_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_payment_attempts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_payment_attempts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_payment_attempts_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_payment_attempts_payer_tenant_id_idx","columns":["payer_tenant_id"]}],"version":"eff3952d"},"importPath":"@happyvertical/smrt-commerce"}},"moduleType":"smrt","recipes":[{"id":"commerce.agreements","className":"AgreementsRecipe","label":"General agreements","summary":"Keep signed agreements with customers, and see every contract in one list.","synonyms":["contracts","terms","deals"],"models":["@happyvertical/smrt-commerce:Agreement","@happyvertical/smrt-commerce:Contract","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"General agreements","model":"@happyvertical/smrt-commerce:Agreement","icon":"fileText","description":"Signed deals and terms with your customers, in one place."},{"label":"All contracts","model":"@happyvertical/smrt-commerce:Contract","icon":"fileText","description":"Every contract you hold, whoever it is with."}],"requires":["commerce.customers"],"group":{"id":"agreements","label":"Agreements","summary":"Contracts with customers: general agreements, leases and licence sales."},"section":{"id":"agreements","label":"Agreements","icon":"fileText","description":"Contracts, leases and licenses with customers."},"options":{"@happyvertical/smrt-commerce:Agreement":{"fields":{"contractType":{"default":"agreement","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"subtotal":{"visibility":"hidden"},"taxAmount":{"visibility":"hidden"},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:Contract":{"fields":{"channelId":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nAgreements are contracts you keep with customers. General agreements live here;\\nleases and licence sales are separate recipes in the same group.\\n**All contracts** lists every kind together, including orders and quotes.\\n\\n## Tasks\\n\\n### Record an agreement\\n\\n1. Create a new agreement.\\n2. Pick the **{field:customerId}**.\\n3. Set the **{field:issueDate}** and **{field:expiryDate}**.\\n4. Put the conditions in **{field:terms}** and save.\\n\\n### Follow it\\n\\n1. Update **{field:status}** from draft to accepted to completed.\\n2. Check **{field:expiryDate}** to spot agreements about to lapse.\\n","fieldRefs":["customerId","expiryDate","issueDate","status","terms"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.customers","className":"CustomersRecipe","label":"Customers","summary":"Keep a list of the people and companies you sell to.","synonyms":["clients","buyers","accounts"],"models":["@happyvertical/smrt-commerce:Customer"],"nav":[{"label":"Customers","model":"@happyvertical/smrt-commerce:Customer","icon":"users","description":"The people and companies you sell to, with how to reach them."}],"requires":["profiles.identity"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:Customer":{"fields":{"profileId":{"label":"Name","order":-1}}}},"help":{"markdown":"## Overview\\n\\nCustomers is your address book for the people and businesses you sell to. Keep\\none record for each customer so you can see who they are, how they like to pay\\nand what you have agreed with them, then refer back to them whenever you take an\\norder.\\n\\n## Tasks\\n\\n### Add a new customer\\n\\n1. Choose the **New** button above the list.\\n2. Describe the customer with **{field:customerType}**: a direct shopper, a\\n wholesale buyer or a retail customer. Note in **{field:status}** whether you\\n are still dealing with them.\\n3. Fill in the **{field:defaultShippingAddress}** and\\n **{field:defaultBillingAddress}** so you do not have to type them again on\\n every order.\\n4. Add **{field:paymentTerms}**, for example \\"Net 30\\", if you give this\\n customer time to pay.\\n5. Save. The customer is now on your list and ready to use on a sales order.\\n\\n### Keep track of what a customer can owe\\n\\n1. Open the customer from the list and choose Edit.\\n2. Set **{field:creditLimit}** to the most you are comfortable letting them owe\\n you at one time.\\n3. If you do not charge them sales tax, turn on **{field:taxExempt}**, and keep\\n their tax number on file.\\n4. Use **{field:notes}** for anything the next person who deals with this\\n customer should know.\\n\\n### Find a customer\\n\\nScan the list for the customer you want, or open a record to see everything you\\nhave on file. To stop dealing with someone without losing their history, change\\ntheir **{field:status}** to inactive instead of deleting them.\\n","fieldRefs":["creditLimit","customerType","defaultBillingAddress","defaultShippingAddress","notes","paymentTerms","status","taxExempt"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.estimates","className":"EstimatesRecipe","label":"Estimates","summary":"Send customers a price quote before they commit.","synonyms":["quotes","quotations","proposals","bids"],"models":["@happyvertical/smrt-commerce:Estimate","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Estimates","model":"@happyvertical/smrt-commerce:Estimate","icon":"fileText","description":"Price quotes you have sent to customers."}],"requires":["commerce.customers"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:Estimate":{"fields":{"contractType":{"default":"estimate","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nEstimates are price quotes you send before a customer commits. Each one belongs\\nto a customer, lists its line items and shows how long the price is good for.\\n\\n## Tasks\\n\\n### Write an estimate\\n\\n1. Create a new estimate.\\n2. Pick the **{field:customerId}** the quote is for.\\n3. Add the line items, then check the **{field:totalAmount}**.\\n4. Set **{field:expiryDate}** to the last day the price is good for.\\n5. Put your conditions in **{field:terms}** and save.\\n\\n### Follow it up\\n\\n1. Set **{field:status}** to sent once it goes out.\\n2. Move it to accepted or declined when the customer answers.\\n3. Once accepted, convert it to an order so the work can be billed; the order keeps the estimate's lines and totals and a link back to the quote.\\n","fieldRefs":["customerId","expiryDate","status","terms","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.fulfillment","className":"FulfillmentRecipe","label":"Shipping","summary":"Pack, ship and deliver orders, with tracking.","synonyms":["fulfillment","delivery","shipments","tracking"],"models":["@happyvertical/smrt-commerce:Fulfillment","@happyvertical/smrt-commerce:FulfillmentLineItem"],"nav":[{"label":"Shipments","model":"@happyvertical/smrt-commerce:Fulfillment","icon":"truck","description":"What has gone out the door and where it is now."}],"requires":[],"requiresAny":[["commerce.sales","commerce.wholesale"]],"group":{"id":"billing","label":"Billing & shipping","summary":"Invoice your customers, record what they pay and ship what they ordered."},"section":{"id":"operations","label":"Operations","icon":"wrench","description":"Fulfillment and the day-to-day work behind an order."},"options":{"@happyvertical/smrt-commerce:Fulfillment":{"fields":{"estimatedDelivery":{"visibility":"hidden"},"shippingAddress":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:FulfillmentLineItem":{"fields":{"notes":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nShipping tracks how an order gets to the customer. Each shipment belongs to an\\norder and lists which line items are in it, so an order can go out in parts.\\n\\n## Tasks\\n\\n### Ship an order\\n\\n1. Create a new shipment.\\n2. Pick the order in **{field:contractId}** and choose the\\n **{field:fulfillmentType}**.\\n3. Enter the **{field:carrier}** and **{field:trackingNumber}**.\\n4. List the items and quantities in the shipment.\\n5. Set **{field:status}** to shipped and record **{field:shippedAt}**.\\n\\n### Confirm delivery\\n\\n1. Open the shipment and set **{field:status}** to delivered.\\n2. Record **{field:deliveredAt}**.\\n","fieldRefs":["carrier","contractId","deliveredAt","fulfillmentType","shippedAt","status","trackingNumber"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.invoicing","className":"InvoicingRecipe","label":"Invoicing","summary":"Bill customers and record the payments that come in.","synonyms":["invoices","billing","payments","receivables"],"models":["@happyvertical/smrt-commerce:Invoice","@happyvertical/smrt-commerce:InvoiceLineItem","@happyvertical/smrt-commerce:Payment","@happyvertical/smrt-commerce:PaymentAllocation"],"nav":[{"label":"Invoices","model":"@happyvertical/smrt-commerce:Invoice","icon":"receipt","description":"Bills you have sent and which ones are still waiting to be paid."},{"label":"Payments","model":"@happyvertical/smrt-commerce:Payment","icon":"creditCard","description":"Money received, matched to the invoices it paid."}],"requires":["commerce.customers"],"group":{"id":"billing","label":"Billing & shipping","summary":"Invoice your customers, record what they pay and ship what they ordered."},"section":{"id":"billing","label":"Billing","icon":"receipt","description":"Invoices and the payments against them."},"options":{"@happyvertical/smrt-commerce:Invoice":{"fields":{"historicalSourceKeyHash":{"visibility":"hidden"},"providerTaxAmount":{"visibility":"hidden"},"arJournalId":{"visibility":"hidden"},"revenueJournalId":{"visibility":"hidden"},"externalId":{"visibility":"hidden"},"customerExternalId":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"syncedAt":{"visibility":"hidden"},"collectionMethod":{"visibility":"hidden"},"sentAt":{"visibility":"hidden"},"viewedAt":{"visibility":"hidden"},"remindersSent":{"visibility":"hidden"},"lastReminderAt":{"visibility":"hidden"},"reference":{"visibility":"hidden"},"customerId":{"required":true}}},"@happyvertical/smrt-commerce:InvoiceLineItem":{"fields":{"sourceType":{"visibility":"hidden"},"sourceId":{"visibility":"hidden"},"sourceReservationId":{"visibility":"hidden"},"periodStart":{"visibility":"hidden"},"periodEnd":{"visibility":"hidden"},"revenueAccountId":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"sku":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:Payment":{"fields":{"journalId":{"visibility":"hidden"},"externalId":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"syncedAt":{"visibility":"hidden"},"backendId":{"visibility":"hidden"},"backendTxRef":{"visibility":"hidden"},"nativeAmount":{"visibility":"hidden"},"nativeCurrency":{"visibility":"hidden"},"usdAtQuote":{"visibility":"hidden"},"usdAtConfirmation":{"visibility":"hidden"},"transactionId":{"visibility":"hidden"},"connectedAccountId":{"visibility":"hidden"},"connectedFeePolicyRef":{"visibility":"hidden"},"applicationFeeCents":{"visibility":"hidden"},"refundOfPaymentId":{"visibility":"hidden"},"connectedRefundState":{"visibility":"hidden"},"applicationFeeRefunded":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:PaymentAllocation":{"fields":{"allocatedBy":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nInvoicing bills your customers and records what they pay. An invoice lists its\\nline items; a payment can be spread across one or more invoices.\\n\\n## Tasks\\n\\n### Send an invoice\\n\\n1. Create a new invoice.\\n2. Pick the **{field:customerId}** and add the line items.\\n3. Check the **{field:totalAmount}** and set the **{field:dueDate}**.\\n4. Set **{field:status}** to sent once it goes out.\\n\\n### Record a payment\\n\\n1. Create a new payment.\\n2. Pick the **{field:customerId}**, then enter the **{field:Payment.amount}** and the\\n **{field:method}** used.\\n3. Set **{field:Payment.status}** to completed once the money has arrived.\\n4. Apply it to the invoices it settles; each one shows what is still owed.\\n","fieldRefs":["Payment.amount","Payment.status","customerId","dueDate","method","status","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.leases","className":"LeasesRecipe","label":"Leases","summary":"Rent things out and track the term and the payments due.","synonyms":["rentals","renting","hire"],"models":["@happyvertical/smrt-commerce:Lease","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Leases","model":"@happyvertical/smrt-commerce:Lease","icon":"home","description":"Rentals you give or take, with terms and dates."}],"requires":["commerce.customers"],"group":{"id":"agreements","label":"Agreements","summary":"Contracts with customers: general agreements, leases and licence sales."},"section":{"id":"agreements","label":"Agreements","icon":"fileText","description":"Contracts, leases and licenses with customers."},"options":{"@happyvertical/smrt-commerce:Lease":{"fields":{"contractType":{"default":"lease","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"subtotal":{"visibility":"hidden"},"taxAmount":{"visibility":"hidden"},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nLeases are agreements where a customer rents something from you for a period.\\nEach lease keeps its own line items and dates.\\n\\n## Tasks\\n\\n### Record a lease\\n\\n1. Create a new lease.\\n2. Pick the **{field:customerId}** renting from you.\\n3. Set the **{field:issueDate}** it starts and the **{field:expiryDate}** it ends.\\n4. Add a line item for each thing rented, then save.\\n\\n### Keep an eye on it\\n\\n1. Update **{field:status}** as the lease goes from draft to accepted to\\n completed.\\n2. Check **{field:expiryDate}** to see which leases end soon.\\n","fieldRefs":["customerId","expiryDate","issueDate","status"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.licenses","className":"LicensesRecipe","label":"Licence sales","summary":"Sell licences to software, content or other rights.","synonyms":["licenses","licensing","subscriptions"],"models":["@happyvertical/smrt-commerce:LicenseSale","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Licence sales","model":"@happyvertical/smrt-commerce:LicenseSale","icon":"shoppingBag","description":"Licences you have sold and who holds them."}],"requires":["commerce.customers"],"group":{"id":"agreements","label":"Agreements","summary":"Contracts with customers: general agreements, leases and licence sales."},"section":{"id":"agreements","label":"Agreements","icon":"fileText","description":"Contracts, leases and licenses with customers."},"options":{"@happyvertical/smrt-commerce:LicenseSale":{"fields":{"contractType":{"default":"license_sale","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"subtotal":{"visibility":"hidden"},"taxAmount":{"visibility":"hidden"},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nLicence sales record selling the right to use something, such as software or\\ncontent, rather than a physical item.\\n\\n## Tasks\\n\\n### Record a licence sale\\n\\n1. Create a new licence sale.\\n2. Pick the **{field:customerId}** who bought the licence.\\n3. Add a line item for what is licensed and check the **{field:totalAmount}**.\\n4. Set the **{field:expiryDate}** if the licence runs out, then save.\\n\\n### Follow it\\n\\n1. Update **{field:status}** when the customer accepts or the sale completes.\\n","fieldRefs":["customerId","expiryDate","status","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.purchases","className":"PurchasesRecipe","label":"Purchases","summary":"Order from your vendors and track what you have bought.","synonyms":["purchase orders","buying","procurement"],"models":["@happyvertical/smrt-commerce:PurchaseOrder","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Purchase orders","model":"@happyvertical/smrt-commerce:PurchaseOrder","icon":"truck","description":"What you have ordered from your suppliers and when it arrives."}],"requires":["commerce.vendors"],"section":{"id":"purchasing","label":"Purchasing","icon":"truck","description":"Vendors and purchase orders: everything you buy."},"options":{"@happyvertical/smrt-commerce:PurchaseOrder":{"fields":{"contractType":{"default":"purchase_order","visibility":"hidden","locked":true},"vendorId":{"label":"Vendor","order":1},"channelId":{"visibility":"hidden"},"expiryDate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nPurchases is where you order from your vendors and keep track of what you have\\nbought. Every purchase order belongs to one of your vendors and records the\\namounts, the dates and where the order stands.\\n\\n## Tasks\\n\\n### Place a purchase order\\n\\n1. Choose the **New** button above the list.\\n2. Enter the **{field:vendorId}** you are buying from. Add them under Vendors\\n first so they are on your list.\\n3. Enter the **{field:subtotal}** and **{field:taxAmount}**, then the\\n **{field:totalAmount}** you expect to pay.\\n4. Set the **{field:issueDate}**, and the **{field:dueDate}** for when the\\n goods or the payment are due.\\n5. Add your own **{field:reference}**, such as the vendor's quote number, so\\n you can match it to their paperwork.\\n6. Enter **{field:expectedDate}** as YYYY-MM-DD if you know when the delivery\\n should arrive. Leave it blank until a date is agreed.\\n7. Use **{field:shipTo}** for the delivery address and instructions, such as\\n which entrance or loading dock to use.\\n8. Save.\\n\\n### Follow an order until it arrives\\n\\n1. Open the purchase order from the list and choose Edit.\\n2. Update **{field:status}** as the order moves along, for example from draft to\\n sent, accepted and completed.\\n3. Use **{field:notes}** to record what the vendor told you, such as delays or\\n partial shipments.\\n\\n### Record the agreement\\n\\n1. Open the purchase order and choose Edit.\\n2. Write down the **{field:terms}** you agreed with the vendor, such as payment\\n or delivery conditions.\\n3. Set **{field:expiryDate}** if the vendor's offer is only good until a certain\\n day.\\n","fieldRefs":["dueDate","expectedDate","expiryDate","issueDate","notes","reference","shipTo","status","subtotal","taxAmount","terms","totalAmount","vendorId"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.sales","className":"SalesRecipe","label":"Sales","summary":"Take customer orders and track them.","synonyms":["sales orders","orders","customer orders"],"models":["@happyvertical/smrt-commerce:Order","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Sales orders","model":"@happyvertical/smrt-commerce:Order","icon":"shoppingBag","description":"Orders from your customers, from placed to delivered."}],"requires":["commerce.customers"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:Order":{"fields":{"contractType":{"default":"order","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"channelId":{"visibility":"hidden"},"expiryDate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nSales is where you take orders from your customers and see where each one\\nstands. Every order belongs to one of your customers, carries its amounts and\\ndates, and keeps a status so you always know what is still open.\\n\\n## Tasks\\n\\n### Take an order\\n\\n1. Choose the **New** button above the list.\\n2. Enter the **{field:customerId}** the order is for. Add them under Customers\\n first so they are on your list.\\n3. Enter the **{field:subtotal}** and **{field:taxAmount}**, then the\\n **{field:totalAmount}** the customer will pay.\\n4. Set the **{field:issueDate}**, and the **{field:dueDate}** if you expect\\n payment by a certain day.\\n5. Add your own **{field:reference}**, such as a purchase order number the\\n customer gave you, so you can find the order later.\\n6. Save.\\n\\n### Follow an order through to the end\\n\\n1. Open the order from the list and choose Edit.\\n2. Update **{field:status}** as the order moves along, for example from draft to\\n sent, accepted and completed.\\n3. Check the **{field:dueDate}** against today to spot orders that are overdue.\\n4. Use **{field:notes}** to record calls, changes and anything promised.\\n\\n### Make a quote with an expiry\\n\\n1. Create the order as usual and set its **{field:status}** to show it is still\\n a draft.\\n2. Set **{field:expiryDate}** to the last day the price is good for.\\n3. Put your conditions, such as deposits or delivery, in **{field:terms}**.\\n","fieldRefs":["customerId","dueDate","expiryDate","issueDate","notes","reference","status","subtotal","taxAmount","terms","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.vendors","className":"VendorsRecipe","label":"Vendors","summary":"Keep a list of the suppliers you buy from.","synonyms":["suppliers","sellers"],"models":["@happyvertical/smrt-commerce:Vendor"],"nav":[{"label":"Vendors","model":"@happyvertical/smrt-commerce:Vendor","icon":"briefcase","description":"The suppliers you buy from, with terms and contacts."}],"requires":["profiles.identity"],"section":{"id":"purchasing","label":"Purchasing","icon":"truck","description":"Vendors and purchase orders: everything you buy."},"options":{"@happyvertical/smrt-commerce:Vendor":{"fields":{"profileId":{"label":"Name","order":-1}}}},"help":{"markdown":"## Overview\\n\\nVendors is your list of the suppliers you buy from. Each record holds who they\\nare, how to reach them and the terms you have agreed, so you can order from them\\nquickly and keep track of what you have bought.\\n\\n## Tasks\\n\\n### Add a vendor\\n\\n1. Choose the **New** button above the list.\\n2. Enter **{field:defaultContactEmail}** and **{field:defaultContactPhone}** for\\n the person you normally deal with.\\n3. Set the **{field:currency}** they bill you in and your **{field:paymentTerms}**,\\n for example \\"Net 30\\".\\n4. Save. The vendor is now on your list and ready to use on a purchase order.\\n\\n### Note how a vendor likes to work\\n\\n1. Open the vendor from the list and choose Edit.\\n2. Enter **{field:leadTimeDays}**, the number of days they usually need between\\n your order and delivery, so you can plan ahead.\\n3. Enter **{field:minimumOrderAmount}** if they will not accept small orders.\\n4. Use **{field:notes}** for anything else worth remembering, such as the best\\n time to call.\\n\\n### Keep payment details in one place\\n\\n1. Open the vendor and choose Edit.\\n2. Record where payments to this vendor should be sent, so it is all in one\\n place.\\n3. Set **{field:status}** to show whether you still buy from them: active,\\n inactive or suspended.\\n","fieldRefs":["currency","defaultContactEmail","defaultContactPhone","leadTimeDays","minimumOrderAmount","notes","paymentTerms","status"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.wholesale","className":"WholesaleRecipe","label":"Wholesale orders","summary":"Take bulk orders from trade customers.","synonyms":["bulk orders","trade orders","b2b"],"models":["@happyvertical/smrt-commerce:WholesaleOrder","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Wholesale orders","model":"@happyvertical/smrt-commerce:WholesaleOrder","icon":"shoppingBag","description":"Bulk orders from cafes, shops and other businesses."}],"requires":["commerce.customers"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:WholesaleOrder":{"fields":{"contractType":{"default":"wholesale_order","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"channelId":{"visibility":"hidden"},"expiryDate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nWholesale orders are bulk orders from trade customers. They work like sales\\norders, with a list of line items, but are kept in their own list so trade and\\nretail sales stay apart.\\n\\n## Tasks\\n\\n### Take a wholesale order\\n\\n1. Create a new wholesale order.\\n2. Pick the **{field:customerId}** placing the order.\\n3. Add the line items and check the **{field:totalAmount}**.\\n4. Set the **{field:dueDate}** for payment and save.\\n\\n### Track it\\n\\n1. Update **{field:status}** as the order moves from draft to completed.\\n2. Use **{field:reference}** for the buyer's own order number.\\n","fieldRefs":["customerId","dueDate","reference","status","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}}],"uiSelectors":{"customer-select":{"slotId":"customer-select","selects":"@happyvertical/smrt-commerce:Customer","label":"Customer Select","description":"Searchable customer picker for relation fields; the caller supplies the lookup"},"vendor-select":{"slotId":"vendor-select","selects":"@happyvertical/smrt-commerce:Vendor","label":"Vendor Select","description":"Searchable vendor picker for relation fields; the caller supplies the lookup"}},"smrtDependencies":["@happyvertical/smrt-agents","@happyvertical/smrt-core","@happyvertical/smrt-jobs","@happyvertical/smrt-ledgers","@happyvertical/smrt-products","@happyvertical/smrt-profiles","@happyvertical/smrt-reports","@happyvertical/smrt-subscriptions","@happyvertical/smrt-tenancy"],"browser":{"status":"server-only","issues":["#3615","#3616","#3617","#3624","#3625","#3626","#3627"],"reason":"@happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs","via":["@happyvertical/smrt-agents","@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}`));
33
+ ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-commerce","packageVersion":"0.61.5","objects":{"@happyvertical/smrt-commerce:Payout":{"name":"payout","className":"Payout","qualifiedName":"@happyvertical/smrt-commerce:Payout","collection":"payouts","filePath":"src/models/Payout.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"paymentId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"vendorId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Vendor"},"grossAmount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"operatorFee":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"supplierNet":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"currency":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"backendId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"backendTxRef":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"status":{"type":"text","_meta":{"__statedOptions":["enum"]},"required":false,"enum":["pending","sent","confirmed","failed"]},"sentAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"confirmedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"failedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"failureReason":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"notes":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isPending":{"name":"isPending","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSent":{"name":"isSent","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isConfirmed":{"name":"isConfirmed","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isFailed":{"name":"isFailed","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markSent":{"name":"markSent","async":false,"parameters":[{"name":"backendTxRef","type":"string","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markConfirmed":{"name":"markConfirmed","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"markFailed":{"name":"markFailed","async":false,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"resetFromFailed":{"name":"resetFromFailed","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"validateAmounts":{"name":"validateAmounts","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Payout","collectionExportName":"PayoutCollection","schema":{"tableName":"payouts","ddl":"CREATE TABLE IF NOT EXISTS \\"payouts\\" (\\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 \\"payment_id\\" TEXT DEFAULT '',\\n \\"vendor_id\\" UUID,\\n \\"gross_amount\\" INTEGER DEFAULT 0,\\n \\"operator_fee\\" INTEGER DEFAULT 0,\\n \\"supplier_net\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT '',\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"sent_at\\" TIMESTAMP,\\n \\"confirmed_at\\" TIMESTAMP,\\n \\"failed_at\\" TIMESTAMP,\\n \\"failure_reason\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"gross_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"operator_fee":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"supplier_net":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"confirmed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failure_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payouts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payouts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payouts_vendor_id_idx","columns":["vendor_id"]}],"version":"777cae02"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:InvoiceLineItem":{"name":"invoicelineitem","className":"InvoiceLineItem","qualifiedName":"@happyvertical/smrt-commerce:InvoiceLineItem","collection":"invoicelineitems","description":"InvoiceLineItem represents a single line item on an invoice.","filePath":"src/models/InvoiceLineItem.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"invoiceId":{"type":"foreignKey","_meta":{"__statedOptions":["description","role","related"],"description":"The invoice this line belongs to.","role":"items"},"required":false,"related":"Invoice","description":"The invoice this line belongs to."},"creditedLineId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"InvoiceLineItem"},"creditCalculationBasisJson":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Frozen source basis used to cap and reproduce an issued credit line."},"required":false,"description":"Frozen source basis used to cap and reproduce an issued credit line."},"description":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"What is being billed on this line."},"required":false,"default":"","description":"What is being billed on this line."},"sku":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"productId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-products:Product"},"quantity":{"type":"decimal","_meta":{"__statedOptions":["description","default"],"description":"How many."},"required":false,"default":1,"description":"How many."},"unitPrice":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The price of one, before discount; includes tax when the document's prices include tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The price of one, before discount; includes tax when the document's prices include tax."},"discount":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"discountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"none","enum":["none","percent","amount"]},"discountRate":{"type":"decimal","_meta":{"__statedOptions":[]},"required":false},"taxRate":{"type":"decimal","_meta":{"__statedOptions":["description","default"],"description":"The stored fractional tax rate for this line (0.05 means 5%)."},"required":false,"default":0,"description":"The stored fractional tax rate for this line (0.05 means 5%)."},"taxMode":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"inherit","enum":["inherit","override"]},"taxCodeId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"TaxCode"},"taxCodeCode":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"taxCodeName":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"taxComponentsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":true,"default":0},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"amount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The line amount: net of discount, and including tax only when the document's prices include tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The line amount: net of discount, and including tax only when the document's prices include tax."},"sourceType":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"sourceId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"sourceReservationId":{"type":"text","_meta":{"__statedOptions":["nullable","readonly","required"],"readonly":true,"nullable":true,"required":false},"required":false,"readonly":true},"periodStart":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"periodEnd":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"revenueAccountId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-ledgers:Account"},"sortOrder":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"hasSource":{"name":"hasSource","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"hasPeriod":{"name":"hasPeriod","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"],"writable":["invoiceId","description","sku","productId","quantity","unitPrice","discount","discountType","discountRate","taxRate","taxMode","taxCodeId","sourceType","sourceId","periodStart","periodEnd","revenueAccountId","sortOrder"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"InvoiceLineItem","collectionExportName":"InvoiceLineItemCollection","validationRules":[{"field":"taxAmount","rule":"required","fieldType":"integer"}],"schema":{"tableName":"invoice_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"invoice_line_items\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"credit_calculation_basis_json\\" TEXT,\\n \\"description\\" TEXT DEFAULT '',\\n \\"sku\\" TEXT DEFAULT '',\\n \\"product_id\\" UUID,\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"source_type\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"source_reservation_id\\" TEXT,\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"revenue_account_id\\" UUID,\\n \\"sort_order\\" INTEGER DEFAULT 0\\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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoice_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_calculation_basis_json":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sku":{"type":"TEXT","notNull":false,"unique":false,"default":""},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false,"unique":false},"tax_rate":{"type":"REAL","notNull":false,"unique":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"tax_code_name":{"type":"TEXT","notNull":false,"unique":false},"tax_components_json":{"type":"TEXT","notNull":false,"unique":false},"tax_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_reservation_id":{"type":"TEXT","notNull":false,"unique":false},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"revenue_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0}},"indexes":[{"name":"invoice_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoice_line_items_invoice_id_idx","columns":["invoice_id"]},{"name":"invoice_line_items_credited_line_id_idx","columns":["credited_line_id"]},{"name":"invoice_line_items_product_id_idx","columns":["product_id"]},{"name":"invoice_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"invoice_line_items_revenue_account_id_idx","columns":["revenue_account_id"]}],"version":"78dcf926"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Payment":{"name":"payment","className":"Payment","qualifiedName":"@happyvertical/smrt-commerce:Payment","collection":"payments","description":"Payment represents a financial transaction against a contract.","filePath":"src/models/Payment.ts","packageName":"@happyvertical/smrt-commerce","fields":{"kind":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"payment","enum":["payment","refund"]},"customerFundsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"retentionAccountingBindingJson":{"type":"text","_meta":{"__statedOptions":["sensitive"],"sensitive":true},"required":false,"sensitive":true},"ordinaryAccountingBindingJson":{"type":"text","_meta":{"__statedOptions":["sensitive"],"sensitive":true},"required":false,"sensitive":true},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"contractId":{"type":"foreignKey","_meta":{"__statedOptions":["description","validateSubtype","related"],"description":"The order or agreement this payment is for, if any.","validateSubtype":true},"required":false,"related":"SalesContract","description":"The order or agreement this payment is for, if any."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer who paid."},"required":false,"related":"Customer","description":"The customer who paid."},"amount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"How much was paid.","ui":{"format":"money"}},"required":false,"default":0,"description":"How much was paid."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the payment.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the payment."},"method":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"How it was paid: cash, check, card, bank transfer or other."},"required":false,"description":"How it was paid: cash, check, card, bank transfer or other.","enum":["cash","check","credit_card","bank_transfer","crypto","other"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Whether the payment is pending, completed, failed or refunded."},"required":false,"description":"Whether the payment is pending, completed, failed or refunded.","enum":["pending","completed","failed","refunded","cancelled"]},"transactionId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"A reference note, such as a check number."},"required":false,"default":"","description":"A reference note, such as a check number."},"journalId":{"type":"crossPackageRef","_meta":{"__statedOptions":["related"]},"required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"paidAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the money was received."},"required":false,"description":"When the money was received."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this payment.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this payment."},"externalId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"externalProvider":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"syncedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"backendId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"backendTxRef":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"nativeAmount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"nativeCurrency":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"usdAtQuote":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"usdAtConfirmation":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"connectedAccountId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"connectedFeePolicyRef":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"applicationFeeCents":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"refundOfPaymentId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"connectedRefundState":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"","enum":["","requested","pending","succeeded","failed"]},"applicationFeeRefunded":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":false}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"usdDrift":{"name":"usdDrift","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true},"isPending":{"name":"isPending","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isRefunded":{"name":"isRefunded","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recordPayment":{"name":"recordPayment","async":true,"parameters":[{"name":"options","type":"RecordPaymentOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"recordRefund":{"name":"recordRefund","async":true,"parameters":[{"name":"options","type":"RecordPaymentOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"getJournal":{"name":"getJournal","async":true,"parameters":[],"returnType":"Promise<Journal | null>","isStatic":false,"isPublic":true},"markFailed":{"name":"markFailed","async":false,"parameters":[{"name":"reason","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"list":["reference","customerId","status","amount","paidAt"],"label":"reference"},"api":{"include":["list","get","create","update"],"writable":["kind","contractId","customerId","amount","currency","method","transactionId","reference","notes","externalId","externalProvider","backendId","backendTxRef","nativeAmount","nativeCurrency","usdAtQuote","usdAtConfirmation"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Payment","collectionExportName":"PaymentCollection","displayLabelField":"reference","schema":{"tableName":"payments","ddl":"CREATE TABLE IF NOT EXISTS \\"payments\\" (\\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 'payment',\\n \\"customer_funds_json\\" TEXT,\\n \\"retention_accounting_binding_json\\" TEXT,\\n \\"ordinary_accounting_binding_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"method\\" TEXT,\\n \\"status\\" TEXT,\\n \\"transaction_id\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"journal_id\\" UUID,\\n \\"paid_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"native_amount\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"usd_at_quote\\" INTEGER DEFAULT 0,\\n \\"usd_at_confirmation\\" INTEGER DEFAULT 0,\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"refund_of_payment_id\\" TEXT DEFAULT '',\\n \\"connected_refund_state\\" TEXT DEFAULT '',\\n \\"application_fee_refunded\\" BOOLEAN DEFAULT FALSE\\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":"payment"},"customer_funds_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"method":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"transaction_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"usd_at_quote":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"usd_at_confirmation":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refund_of_payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_refund_state":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_refunded":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"payments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payments_contract_id_idx","columns":["contract_id"]},{"name":"payments_customer_id_idx","columns":["customer_id"]},{"name":"payments_journal_id_idx","columns":["journal_id"]}],"version":"2f961b5b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentAllocation":{"name":"paymentallocation","className":"PaymentAllocation","qualifiedName":"@happyvertical/smrt-commerce:PaymentAllocation","collection":"paymentallocations","description":"PaymentAllocation tracks how payments are applied to invoices.","filePath":"src/models/PaymentAllocation.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"paymentId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The payment being applied."},"required":false,"related":"Payment","description":"The payment being applied."},"invoiceId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The invoice it settles."},"required":false,"related":"Invoice","description":"The invoice it settles."},"amount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"How much of the payment goes to this invoice.","ui":{"format":"money"}},"required":false,"default":0,"description":"How much of the payment goes to this invoice."},"allocatedAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When it was applied."},"required":false,"description":"When it was applied."},"allocatedBy":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"notes":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Anything worth remembering about this allocation."},"required":false,"default":"","description":"Anything worth remembering about this allocation."}},"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":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PaymentAllocation","collectionExportName":"PaymentAllocationCollection","schema":{"tableName":"payment_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_allocations\\" (\\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 \\"payment_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"allocated_at\\" TIMESTAMP,\\n \\"allocated_by\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"allocated_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"allocated_by":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_allocations_payment_id_idx","columns":["payment_id"]},{"name":"payment_allocations_invoice_id_idx","columns":["invoice_id"]}],"version":"72c493d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFunds":{"name":"historicalcustomerfunds","className":"HistoricalCustomerFunds","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFunds","collection":"historicalcustomerfundses","description":"Retained original cash evidence. It is deliberately not a completed ledger-backed Payment.","filePath":"src/models/HistoricalCustomerFunds.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Customer"},"contractId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"Contract"},"sourceKeyHash":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"kind":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"receipt","enum":["receipt","refund"]},"origin":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"historical","enum":["historical","live"]},"paymentId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"Payment"},"currency":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"amountMinor":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":true,"default":0},"effectiveOn":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"sourceReceiptId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"HistoricalCustomerFunds"},"sourceCreditNoteId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"Invoice"},"snapshotJson":{"type":"text","_meta":{"__statedOptions":[]},"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":"historical_customer_funds","indexes":[{"name":"historical_customer_funds_source","columns":["tenantId","sourceKeyHash"],"unique":true}],"api":{"include":["get","list"]},"cli":{"include":["get","list"]},"mcp":{"include":["get","list"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"HistoricalCustomerFunds","collectionExportName":"HistoricalCustomerFundsCollection","validationRules":[{"field":"amountMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"historical_customer_funds","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds\\" (\\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 \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'receipt',\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"payment_id\\" UUID,\\n \\"currency\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"source_receipt_id\\" UUID,\\n \\"source_credit_note_id\\" UUID,\\n \\"snapshot_json\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"receipt"},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"currency":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"source_receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_customer_funds_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_customer_id_idx","columns":["customer_id"]},{"name":"historical_customer_funds_contract_id_idx","columns":["contract_id"]},{"name":"historical_customer_funds_payment_id_idx","columns":["payment_id"]},{"name":"historical_customer_funds_source_receipt_id_idx","columns":["source_receipt_id"]},{"name":"historical_customer_funds_source_credit_note_id_idx","columns":["source_credit_note_id"]}],"version":"96a8006b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocation":{"name":"historicalcustomerfundsallocation","className":"HistoricalCustomerFundsAllocation","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocation","collection":"historicalcustomerfundsallocations","description":"Original applications have concrete identities; credit-audit records never count twice.","filePath":"src/models/HistoricalCustomerFundsAllocation.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"receiptId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"HistoricalCustomerFunds"},"creditNoteId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"Invoice"},"invoiceId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Invoice"},"sourceKeyHash":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"amountMinor":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":true,"default":0},"effectiveOn":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"origin":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"historical","enum":["historical","live"]},"effect":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"payment","enum":["payment","credit-audit","refund-audit"]},"journalId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"snapshotJson":{"type":"text","_meta":{"__statedOptions":[]},"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":"historical_customer_funds_allocations","indexes":[{"name":"historical_funds_allocation_source","columns":["tenantId","sourceKeyHash"],"unique":true}],"api":{"include":["get","list"]},"cli":{"include":["get","list"]},"mcp":{"include":["get","list"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"HistoricalCustomerFundsAllocation","collectionExportName":"HistoricalCustomerFundsAllocationCollection","validationRules":[{"field":"amountMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"historical_customer_funds_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds_allocations\\" (\\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 \\"receipt_id\\" UUID,\\n \\"credit_note_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"effect\\" TEXT DEFAULT 'payment',\\n \\"journal_id\\" UUID,\\n \\"snapshot_json\\" 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},"receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"effect":{"type":"TEXT","notNull":false,"unique":false,"default":"payment"},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_funds_allocation_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_allocations_receipt_id_idx","columns":["receipt_id"]},{"name":"historical_customer_funds_allocations_credit_note_id_idx","columns":["credit_note_id"]},{"name":"historical_customer_funds_allocations_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_customer_funds_allocations_journal_id_idx","columns":["journal_id"]}],"version":"6c92192c"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalSalesLine":{"name":"historicalsalesline","className":"HistoricalSalesLine","qualifiedName":"@happyvertical/smrt-commerce:HistoricalSalesLine","collection":"historicalsaleslines","description":"An immutable source line with explicit unknowns, never a calculated InvoiceLineItem.","filePath":"src/models/HistoricalSalesLine.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"invoiceId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Invoice"},"creditedLineId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"HistoricalSalesLine"},"sourceKey":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"sourceKeyHash":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"description":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"netMinor":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":true,"default":0},"taxMinor":{"type":"integer","_meta":{"__statedOptions":["nullable","ui","required"],"nullable":true,"ui":{"format":"money"},"required":false},"required":false},"grossMinor":{"type":"integer","_meta":{"__statedOptions":["nullable","ui","required"],"nullable":true,"ui":{"format":"money"},"required":false},"required":false},"quantityText":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"unitRateText":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"sourceFieldsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"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":"historical_sales_lines","indexes":[{"name":"historical_sales_line_source_key","columns":["tenantId","invoiceId","sourceKeyHash"],"unique":true}],"api":{"include":["get","list"]},"cli":{"include":["get","list"]},"mcp":{"include":["get","list"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"HistoricalSalesLine","collectionExportName":"HistoricalSalesLineCollection","validationRules":[{"field":"netMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"historical_sales_lines","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_sales_lines\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"source_key\\" TEXT,\\n \\"source_key_hash\\" TEXT,\\n \\"description\\" TEXT,\\n \\"net_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER,\\n \\"gross_minor\\" INTEGER,\\n \\"quantity_text\\" TEXT,\\n \\"unit_rate_text\\" TEXT,\\n \\"source_fields_json\\" TEXT,\\n \\"money_snapshot_id\\" 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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_sales_lines","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key":{"type":"TEXT","notNull":false,"unique":false},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false},"net_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"gross_minor":{"type":"INTEGER","notNull":false,"unique":false},"quantity_text":{"type":"TEXT","notNull":false,"unique":false},"unit_rate_text":{"type":"TEXT","notNull":false,"unique":false},"source_fields_json":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_sales_lines_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_sales_line_source_key","columns":["tenant_id","invoice_id","source_key_hash"],"unique":true},{"name":"historical_sales_lines_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_sales_lines_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_sales_lines_credited_line_id_idx","columns":["credited_line_id"]}],"version":"d5807042"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchasePriceObservation":{"name":"purchasepriceobservation","className":"PurchasePriceObservation","qualifiedName":"@happyvertical/smrt-commerce:PurchasePriceObservation","collection":"purchasepriceobservations","description":"Original purchase evidence with explicitly unavailable monetary aggregates.","filePath":"src/models/PurchasePriceObservation.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"sourceIdentity":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"vendorId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"snapshotJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"completionJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"_options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveObserved":{"name":"saveObserved","async":true,"parameters":[{"name":"capability","type":"any","optional":false,"typeUnresolved":true},{"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":{"api":false,"cli":false,"mcp":false,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PurchasePriceObservation","collectionExportName":"PurchasePriceObservationCollection","validationRules":[],"schema":{"tableName":"purchase_price_observations","ddl":"CREATE TABLE IF NOT EXISTS \\"purchase_price_observations\\" (\\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_identity\\" TEXT,\\n \\"vendor_id\\" TEXT,\\n \\"snapshot_json\\" TEXT,\\n \\"completion_json\\" 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_identity":{"type":"TEXT","notNull":false,"unique":false},"vendor_id":{"type":"TEXT","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false},"completion_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"purchase_price_observations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"purchase_price_observations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"2a855c4b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:ContractCollection":{"name":"contractcollection","className":"ContractCollection","qualifiedName":"@happyvertical/smrt-commerce:ContractCollection","collection":"contracts","filePath":"src/collections/ContractCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<Contract>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<Contract>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<Contract | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<Contract>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByVendor":{"name":"findByVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"listSnapshotReportContracts":{"name":"listSnapshotReportContracts","async":true,"parameters":[{"name":"options","type":"object","optional":false,"memberTypes":["string","Date"]}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByType":{"name":"findByType","async":true,"parameters":[{"name":"contractType","type":"ContractType","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"ContractStatus","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findDrafts":{"name":"findDrafts","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findAccepted":{"name":"findAccepted","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findOverdue":{"name":"findOverdue","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findExpired":{"name":"findExpired","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Contract[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Contract","exportName":"ContractCollection","collectionExportName":"ContractCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Contract","inheritedExposure":["api","mcp"],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"ff08ed4f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:ContractLineItemCollection":{"name":"contractlineitemcollection","className":"ContractLineItemCollection","qualifiedName":"@happyvertical/smrt-commerce:ContractLineItemCollection","collection":"contractlineitems","filePath":"src/collections/ContractLineItemCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<ContractLineItem>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<ContractLineItem>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<ContractLineItem | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<ContractLineItem>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<ContractLineItem[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"ContractLineItem","exportName":"ContractLineItemCollection","collectionExportName":"ContractLineItemCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:ContractLineItem","inheritedExposure":["api","mcp"],"schema":{"tableName":"contract_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"contract_line_items\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"description\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"product_id\\" UUID,\\n \\"sku\\" TEXT DEFAULT '',\\n \\"start_date\\" TIMESTAMP,\\n \\"end_date\\" TIMESTAMP,\\n \\"billing_period\\" TEXT DEFAULT '',\\n \\"sort_order\\" INTEGER DEFAULT 0\\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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"description":{"type":"TEXT","notNull":false,"default":""},"quantity":{"type":"REAL","notNull":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false},"tax_rate":{"type":"REAL","notNull":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false},"tax_code_name":{"type":"TEXT","notNull":false},"tax_components_json":{"type":"TEXT","notNull":false},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false},"amount":{"type":"INTEGER","notNull":false,"default":0},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"sku":{"type":"TEXT","notNull":false,"default":""},"start_date":{"type":"TIMESTAMP","notNull":false},"end_date":{"type":"TIMESTAMP","notNull":false},"billing_period":{"type":"TEXT","notNull":false,"default":""},"sort_order":{"type":"INTEGER","notNull":false,"default":0}},"indexes":[{"name":"contract_line_items_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contract_line_items_meta_type_idx","columns":["_meta_type"]},{"name":"contract_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contract_line_items_contract_id_idx","columns":["contract_id"]},{"name":"contract_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"contract_line_items_product_id_idx","columns":["product_id"]}],"version":"89a3137e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:CustomerCollection":{"name":"customercollection","className":"CustomerCollection","qualifiedName":"@happyvertical/smrt-commerce:CustomerCollection","collection":"customers","filePath":"src/collections/CustomerCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"create":{"name":"create","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true},{"name":"context","type":"Partial<AuditContext>","optional":true}],"returnType":"Promise<Customer>","isStatic":false,"isPublic":true},"update":{"name":"update","async":true,"parameters":[{"name":"id","type":"string","optional":false},{"name":"values","type":"any","optional":false,"typeUnresolved":true},{"name":"context","type":"Partial<AuditContext>","optional":true}],"returnType":"Promise<Customer | null>","isStatic":false,"isPublic":true},"findByProfile":{"name":"findByProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findActive":{"name":"findActive","async":true,"parameters":[],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"CustomerStatus","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"getOrCreateForProfile":{"name":"getOrCreateForProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false},{"name":"defaults","type":"Partial<object>","optional":true,"memberTypes":["number","string"]}],"returnType":"Promise<Customer>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Customer[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get","create","update"]}},"extends":"SmrtCollection","extendsTypeArg":"Customer","exportName":"CustomerCollection","collectionExportName":"CustomerCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Customer","inheritedExposure":["api","mcp"],"schema":{"tableName":"customers","ddl":"CREATE TABLE IF NOT EXISTS \\"customers\\" (\\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 \\"profile_id\\" UUID,\\n \\"credit_limit\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"tax_exempt\\" BOOLEAN DEFAULT FALSE,\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_shipping_address\\" JSON,\\n \\"default_billing_address\\" JSON,\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"customer_type\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"credit_limit":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tax_exempt":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_shipping_address":{"type":"JSON","notNull":false,"unique":false},"default_billing_address":{"type":"JSON","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"customer_type":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"customers_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"customers_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"customers_profile_id_idx","columns":["profile_id"]},{"name":"customers_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"617d1e93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:DocumentTaxCollection":{"name":"documenttaxcollection","className":"DocumentTaxCollection","qualifiedName":"@happyvertical/smrt-commerce:DocumentTaxCollection","collection":"documenttaxes","filePath":"src/collections/DocumentTaxCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"listReportFacts":{"name":"listReportFacts","async":true,"parameters":[{"name":"options","type":"DocumentTaxReportFactsOptions","optional":false}],"returnType":"Promise<DocumentTaxReportFact[]>","isStatic":false,"isPublic":true},"findByDocument":{"name":"findByDocument","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"documentType","type":"CommerceDocumentType","optional":false},{"name":"documentId","type":"string","optional":false}],"returnType":"Promise<DocumentTax[]>","isStatic":false,"isPublic":true},"replaceDerivedForDocument":{"name":"replaceDerivedForDocument","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"input","type":"object","optional":false,"typeUnresolved":true,"memberTypes":["string","CommerceDocumentType"]}],"returnType":"Promise<DocumentTax[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"document_taxes","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"DocumentTax","exportName":"DocumentTaxCollection","collectionExportName":"DocumentTaxCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:DocumentTax","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"document_taxes","ddl":"CREATE TABLE IF NOT EXISTS \\"document_taxes\\" (\\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 \\"document_type\\" TEXT NOT NULL DEFAULT 'invoice',\\n \\"document_id\\" TEXT NOT NULL,\\n \\"currency\\" TEXT NOT NULL,\\n \\"tax_code_id\\" TEXT,\\n \\"tax_code_code\\" TEXT,\\n \\"kind\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_component_name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"net_minor\\" INTEGER,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER NOT NULL DEFAULT 0\\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},"document_type":{"type":"TEXT","notNull":true,"unique":false,"default":"invoice"},"document_id":{"type":"TEXT","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":true,"unique":false},"tax_code_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_component_name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"net_minor":{"type":"INTEGER","notNull":false,"unique":false},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0}},"indexes":[{"name":"document_taxes_document_type_document_id_idx","columns":["document_type","document_id","tax_code_id","tax_component_id"],"unique":true,"nullsNotDistinct":true},{"name":"document_taxes_slug_context_idx","columns":["slug","context"]},{"name":"document_taxes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b35e53b9"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:FulfillmentCollection":{"name":"fulfillmentcollection","className":"FulfillmentCollection","qualifiedName":"@happyvertical/smrt-commerce:FulfillmentCollection","collection":"fulfillments","filePath":"src/collections/FulfillmentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"FulfillmentStatus","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByType":{"name":"findByType","async":true,"parameters":[{"name":"fulfillmentType","type":"FulfillmentType","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findPending":{"name":"findPending","async":true,"parameters":[],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findInTransit":{"name":"findInTransit","async":true,"parameters":[],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByTracking":{"name":"findByTracking","async":true,"parameters":[{"name":"trackingNumber","type":"string","optional":false}],"returnType":"Promise<Fulfillment | null>","isStatic":false,"isPublic":true},"findShippedInRange":{"name":"findShippedInRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Fulfillment[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Fulfillment","exportName":"FulfillmentCollection","collectionExportName":"FulfillmentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Fulfillment","inheritedExposure":["api","mcp"],"schema":{"tableName":"fulfillments","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillments\\" (\\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 \\"contract_id\\" UUID,\\n \\"fulfillment_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"tracking_number\\" TEXT DEFAULT '',\\n \\"carrier\\" TEXT DEFAULT '',\\n \\"shipping_address\\" JSON,\\n \\"shipped_at\\" TIMESTAMP,\\n \\"delivered_at\\" TIMESTAMP,\\n \\"estimated_delivery\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT ''\\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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"fulfillment_type":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"tracking_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"carrier":{"type":"TEXT","notNull":false,"unique":false,"default":""},"shipping_address":{"type":"JSON","notNull":false,"unique":false},"shipped_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"delivered_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"estimated_delivery":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillments_contract_id_idx","columns":["contract_id"]}],"version":"3970fcbd"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:FulfillmentLineItemCollection":{"name":"fulfillmentlineitemcollection","className":"FulfillmentLineItemCollection","qualifiedName":"@happyvertical/smrt-commerce:FulfillmentLineItemCollection","collection":"fulfillmentlineitems","filePath":"src/collections/FulfillmentLineItemCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByFulfillment":{"name":"findByFulfillment","async":true,"parameters":[{"name":"fulfillmentId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"findByContractLineItem":{"name":"findByContractLineItem","async":true,"parameters":[{"name":"contractLineItemId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"getTotalFulfilledForContractLine":{"name":"getTotalFulfilledForContractLine","async":true,"parameters":[{"name":"contractLineItemId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<FulfillmentLineItem[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"FulfillmentLineItem","exportName":"FulfillmentLineItemCollection","collectionExportName":"FulfillmentLineItemCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:FulfillmentLineItem","inheritedExposure":["api","mcp"],"schema":{"tableName":"fulfillment_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillment_line_items\\" (\\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 \\"fulfillment_id\\" UUID,\\n \\"contract_line_item_id\\" UUID,\\n \\"quantity_fulfilled\\" REAL DEFAULT 1,\\n \\"notes\\" TEXT DEFAULT ''\\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},"fulfillment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"fulfillments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_line_item_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contract_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"quantity_fulfilled":{"type":"REAL","notNull":false,"unique":false,"default":1},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillment_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillment_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillment_line_items_fulfillment_id_idx","columns":["fulfillment_id"]},{"name":"fulfillment_line_items_contract_line_item_id_idx","columns":["contract_line_item_id"]}],"version":"acf1ca5f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFundsCollection":{"name":"historicalcustomerfundscollection","className":"HistoricalCustomerFundsCollection","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFundsCollection","collection":"historicalcustomerfundses","filePath":"src/collections/HistoricalCustomerFundsCollections.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"historical_customer_funds","api":{"include":["get","list"]},"mcp":{"include":["get","list"]},"cli":{"include":["get","list"]}},"extends":"SmrtCollection","extendsTypeArg":"HistoricalCustomerFunds","exportName":"HistoricalCustomerFundsCollection","collectionExportName":"HistoricalCustomerFundsCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:HistoricalCustomerFunds","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"historical_customer_funds","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds\\" (\\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 \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'receipt',\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"payment_id\\" UUID,\\n \\"currency\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"source_receipt_id\\" UUID,\\n \\"source_credit_note_id\\" UUID,\\n \\"snapshot_json\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"receipt"},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"currency":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"source_receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_customer_funds_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_customer_id_idx","columns":["customer_id"]},{"name":"historical_customer_funds_contract_id_idx","columns":["contract_id"]},{"name":"historical_customer_funds_payment_id_idx","columns":["payment_id"]},{"name":"historical_customer_funds_source_receipt_id_idx","columns":["source_receipt_id"]},{"name":"historical_customer_funds_source_credit_note_id_idx","columns":["source_credit_note_id"]}],"version":"96a8006b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocationCollection":{"name":"historicalcustomerfundsallocationcollection","className":"HistoricalCustomerFundsAllocationCollection","qualifiedName":"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocationCollection","collection":"historicalcustomerfundsallocations","filePath":"src/collections/HistoricalCustomerFundsCollections.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"historical_customer_funds_allocations","api":{"include":["get","list"]},"mcp":{"include":["get","list"]},"cli":{"include":["get","list"]}},"extends":"SmrtCollection","extendsTypeArg":"HistoricalCustomerFundsAllocation","exportName":"HistoricalCustomerFundsAllocationCollection","collectionExportName":"HistoricalCustomerFundsAllocationCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:HistoricalCustomerFundsAllocation","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"historical_customer_funds_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_customer_funds_allocations\\" (\\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 \\"receipt_id\\" UUID,\\n \\"credit_note_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"source_key_hash\\" TEXT,\\n \\"amount_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"effective_on\\" TEXT,\\n \\"origin\\" TEXT DEFAULT 'historical',\\n \\"effect\\" TEXT DEFAULT 'payment',\\n \\"journal_id\\" UUID,\\n \\"snapshot_json\\" 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},"receipt_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_customer_funds","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_note_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"amount_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"effective_on":{"type":"TEXT","notNull":false,"unique":false},"origin":{"type":"TEXT","notNull":false,"unique":false,"default":"historical"},"effect":{"type":"TEXT","notNull":false,"unique":false,"default":"payment"},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_customer_funds_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_funds_allocation_source","columns":["tenant_id","source_key_hash"],"unique":true},{"name":"historical_customer_funds_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_customer_funds_allocations_receipt_id_idx","columns":["receipt_id"]},{"name":"historical_customer_funds_allocations_credit_note_id_idx","columns":["credit_note_id"]},{"name":"historical_customer_funds_allocations_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_customer_funds_allocations_journal_id_idx","columns":["journal_id"]}],"version":"6c92192c"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:HistoricalSalesLineCollection":{"name":"historicalsaleslinecollection","className":"HistoricalSalesLineCollection","qualifiedName":"@happyvertical/smrt-commerce:HistoricalSalesLineCollection","collection":"historicalsaleslines","filePath":"src/collections/HistoricalSalesLineCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"historical_sales_lines","api":{"include":["get","list"]},"mcp":{"include":["get","list"]},"cli":{"include":["get","list"]}},"extends":"SmrtCollection","extendsTypeArg":"HistoricalSalesLine","exportName":"HistoricalSalesLineCollection","collectionExportName":"HistoricalSalesLineCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:HistoricalSalesLine","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"historical_sales_lines","ddl":"CREATE TABLE IF NOT EXISTS \\"historical_sales_lines\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"source_key\\" TEXT,\\n \\"source_key_hash\\" TEXT,\\n \\"description\\" TEXT,\\n \\"net_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER,\\n \\"gross_minor\\" INTEGER,\\n \\"quantity_text\\" TEXT,\\n \\"unit_rate_text\\" TEXT,\\n \\"source_fields_json\\" TEXT,\\n \\"money_snapshot_id\\" 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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"historical_sales_lines","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_key":{"type":"TEXT","notNull":false,"unique":false},"source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false},"net_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"gross_minor":{"type":"INTEGER","notNull":false,"unique":false},"quantity_text":{"type":"TEXT","notNull":false,"unique":false},"unit_rate_text":{"type":"TEXT","notNull":false,"unique":false},"source_fields_json":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"historical_sales_lines_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"historical_sales_line_source_key","columns":["tenant_id","invoice_id","source_key_hash"],"unique":true},{"name":"historical_sales_lines_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"historical_sales_lines_invoice_id_idx","columns":["invoice_id"]},{"name":"historical_sales_lines_credited_line_id_idx","columns":["credited_line_id"]}],"version":"d5807042"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:InvoiceCollection":{"name":"invoicecollection","className":"InvoiceCollection","qualifiedName":"@happyvertical/smrt-commerce:InvoiceCollection","collection":"invoices","filePath":"src/collections/InvoiceCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<Invoice>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<Invoice>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<Invoice | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<Invoice>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"InvoiceStatus","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findDrafts":{"name":"findDrafts","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findSent":{"name":"findSent","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findPaid":{"name":"findPaid","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findPartial":{"name":"findPartial","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findOverdue":{"name":"findOverdue","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByExternalId":{"name":"findByExternalId","async":true,"parameters":[{"name":"externalId","type":"string","optional":false}],"returnType":"Promise<Invoice | null>","isStatic":false,"isPublic":true},"findNeedingSync":{"name":"findNeedingSync","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findByNumber":{"name":"findByNumber","async":true,"parameters":[{"name":"invoiceNumber","type":"string","optional":false}],"returnType":"Promise<Invoice | null>","isStatic":false,"isPublic":true},"countForYear":{"name":"countForYear","async":true,"parameters":[{"name":"year","type":"number","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"generateInvoiceNumber":{"name":"generateInvoiceNumber","async":true,"parameters":[{"name":"options","type":"InvoiceNumberOptions","optional":true}],"returnType":"Promise<string>","isStatic":false,"isPublic":true},"getTotalOutstandingForCustomer":{"name":"getTotalOutstandingForCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Invoice[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Invoice","exportName":"InvoiceCollection","collectionExportName":"InvoiceCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Invoice","inheritedExposure":["api","mcp"],"schema":{"tableName":"invoices","ddl":"CREATE TABLE IF NOT EXISTS \\"invoices\\" (\\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 \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"historical_sales_money_json\\" TEXT,\\n \\"historical_source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'invoice',\\n \\"credited_invoice_id\\" UUID,\\n \\"credited_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"retention_state_json\\" TEXT,\\n \\"retention_accounting_state_json\\" TEXT,\\n \\"ordinary_accounting_state_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"invoice_number\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"paid_date\\" TIMESTAMP,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"provider_tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'CAD',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"discount_total\\" INTEGER NOT NULL DEFAULT 0,\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"status\\" TEXT,\\n \\"ar_journal_id\\" UUID,\\n \\"ar_reversal_journal_id\\" UUID,\\n \\"revenue_journal_id\\" UUID,\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"customer_external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"accounting_sync_state_json\\" TEXT,\\n \\"collection_method\\" TEXT DEFAULT '',\\n \\"sent_at\\" TIMESTAMP,\\n \\"viewed_at\\" TIMESTAMP,\\n \\"reminders_sent\\" INTEGER DEFAULT 0,\\n \\"last_reminder_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"customer_notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT ''\\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"},"money_authority":{"type":"TEXT","notNull":false,"unique":false,"default":"calculated"},"historical_sales_money_json":{"type":"TEXT","notNull":false,"unique":false},"historical_source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"invoice"},"credited_invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"retention_state_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"issue_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"due_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"paid_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"provider_tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"CAD"},"line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"discount_total":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"seller_tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false},"party_tax_id":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"ar_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"ar_reversal_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"revenue_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"accounting_sync_state_json":{"type":"TEXT","notNull":false,"unique":false},"collection_method":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"viewed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"reminders_sent":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_reminder_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"invoices_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_historical_source_identity","columns":["tenant_id","historical_source_key_hash"],"unique":true},{"name":"invoices_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoices_credited_invoice_id_idx","columns":["credited_invoice_id"]},{"name":"invoices_customer_id_idx","columns":["customer_id"]},{"name":"invoices_contract_id_idx","columns":["contract_id"]},{"name":"invoices_ar_journal_id_idx","columns":["ar_journal_id"]},{"name":"invoices_ar_reversal_journal_id_idx","columns":["ar_reversal_journal_id"]},{"name":"invoices_revenue_journal_id_idx","columns":["revenue_journal_id"]}],"version":"20ebe916"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:InvoiceLineItemCollection":{"name":"invoicelineitemcollection","className":"InvoiceLineItemCollection","qualifiedName":"@happyvertical/smrt-commerce:InvoiceLineItemCollection","collection":"invoicelineitems","filePath":"src/collections/InvoiceLineItemCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"string | SmrtWhereClause<InvoiceLineItem>","optional":false,"unionBranches":[{"type":"string"},{"type":"SmrtWhereClause<InvoiceLineItem>"}]},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<InvoiceLineItem | null>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<InvoiceLineItem>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"findByInvoice":{"name":"findByInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findBySource":{"name":"findBySource","async":true,"parameters":[{"name":"sourceType","type":"string","optional":false},{"name":"sourceId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findBySourceType":{"name":"findBySourceType","async":true,"parameters":[{"name":"sourceType","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"getTotalForInvoice":{"name":"getTotalForInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getNextSortOrder":{"name":"getNextSortOrder","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<InvoiceLineItem[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"InvoiceLineItem","exportName":"InvoiceLineItemCollection","collectionExportName":"InvoiceLineItemCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:InvoiceLineItem","inheritedExposure":["api","mcp"],"schema":{"tableName":"invoice_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"invoice_line_items\\" (\\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 \\"invoice_id\\" UUID,\\n \\"credited_line_id\\" UUID,\\n \\"credit_calculation_basis_json\\" TEXT,\\n \\"description\\" TEXT DEFAULT '',\\n \\"sku\\" TEXT DEFAULT '',\\n \\"product_id\\" UUID,\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"source_type\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"source_reservation_id\\" TEXT,\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"revenue_account_id\\" UUID,\\n \\"sort_order\\" INTEGER DEFAULT 0\\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},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_line_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoice_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credit_calculation_basis_json":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sku":{"type":"TEXT","notNull":false,"unique":false,"default":""},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false,"unique":false},"tax_rate":{"type":"REAL","notNull":false,"unique":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"tax_code_name":{"type":"TEXT","notNull":false,"unique":false},"tax_components_json":{"type":"TEXT","notNull":false,"unique":false},"tax_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_reservation_id":{"type":"TEXT","notNull":false,"unique":false},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"revenue_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0}},"indexes":[{"name":"invoice_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoice_line_items_invoice_id_idx","columns":["invoice_id"]},{"name":"invoice_line_items_credited_line_id_idx","columns":["credited_line_id"]},{"name":"invoice_line_items_product_id_idx","columns":["product_id"]},{"name":"invoice_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"invoice_line_items_revenue_account_id_idx","columns":["revenue_account_id"]}],"version":"78dcf926"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentAllocationCollection":{"name":"paymentallocationcollection","className":"PaymentAllocationCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentAllocationCollection","collection":"paymentallocations","filePath":"src/collections/PaymentAllocationCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"allocatePayment":{"name":"allocatePayment","async":true,"parameters":[{"name":"input","type":"object","optional":false,"memberTypes":["string","object[]","number"]}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"removeAllocation":{"name":"removeAllocation","async":true,"parameters":[{"name":"id","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"findByPayment":{"name":"findByPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findByInvoice":{"name":"findByInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"getTotalAllocatedToInvoice":{"name":"getTotalAllocatedToInvoice","async":true,"parameters":[{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getTotalAllocatedFromPayment":{"name":"getTotalAllocatedFromPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getUnallocatedFromPayment":{"name":"getUnallocatedFromPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false},{"name":"paymentAmount","type":"number","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByPaymentAndInvoice":{"name":"findByPaymentAndInvoice","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false},{"name":"invoiceId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation | null>","isStatic":false,"isPublic":true},"findByAllocator":{"name":"findByAllocator","async":true,"parameters":[{"name":"allocatedBy","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentAllocation[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"PaymentAllocation","exportName":"PaymentAllocationCollection","collectionExportName":"PaymentAllocationCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PaymentAllocation","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"payment_allocations","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_allocations\\" (\\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 \\"payment_id\\" UUID,\\n \\"invoice_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"allocated_at\\" TIMESTAMP,\\n \\"allocated_by\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"allocated_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"allocated_by":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_allocations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_allocations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_allocations_payment_id_idx","columns":["payment_id"]},{"name":"payment_allocations_invoice_id_idx","columns":["invoice_id"]}],"version":"72c493d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentCollection":{"name":"paymentcollection","className":"PaymentCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentCollection","collection":"payments","filePath":"src/collections/PaymentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByContract":{"name":"findByContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"PaymentStatus","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByMethod":{"name":"findByMethod","async":true,"parameters":[{"name":"method","type":"PaymentMethod","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findPending":{"name":"findPending","async":true,"parameters":[],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findCompleted":{"name":"findCompleted","async":true,"parameters":[],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findByTransactionId":{"name":"findByTransactionId","async":true,"parameters":[{"name":"transactionId","type":"string","optional":false}],"returnType":"Promise<Payment | null>","isStatic":false,"isPublic":true},"findByDateRange":{"name":"findByDateRange","async":true,"parameters":[{"name":"startDate","type":"Date","optional":false},{"name":"endDate","type":"Date","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"getTotalForContract":{"name":"getTotalForContract","async":true,"parameters":[{"name":"contractId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByJournal":{"name":"findByJournal","async":true,"parameters":[{"name":"journalId","type":"string","optional":false}],"returnType":"Promise<Payment | null>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payment[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Payment","exportName":"PaymentCollection","collectionExportName":"PaymentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Payment","inheritedExposure":["api","mcp"],"schema":{"tableName":"payments","ddl":"CREATE TABLE IF NOT EXISTS \\"payments\\" (\\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 'payment',\\n \\"customer_funds_json\\" TEXT,\\n \\"retention_accounting_binding_json\\" TEXT,\\n \\"ordinary_accounting_binding_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"method\\" TEXT,\\n \\"status\\" TEXT,\\n \\"transaction_id\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"journal_id\\" UUID,\\n \\"paid_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"native_amount\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"usd_at_quote\\" INTEGER DEFAULT 0,\\n \\"usd_at_confirmation\\" INTEGER DEFAULT 0,\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"refund_of_payment_id\\" TEXT DEFAULT '',\\n \\"connected_refund_state\\" TEXT DEFAULT '',\\n \\"application_fee_refunded\\" BOOLEAN DEFAULT FALSE\\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":"payment"},"customer_funds_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_binding_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"method":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"transaction_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"usd_at_quote":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"usd_at_confirmation":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refund_of_payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_refund_state":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_refunded":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"payments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payments_contract_id_idx","columns":["contract_id"]},{"name":"payments_customer_id_idx","columns":["customer_id"]},{"name":"payments_journal_id_idx","columns":["journal_id"]}],"version":"2f961b5b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentInstrumentCollection":{"name":"paymentinstrumentcollection","className":"PaymentInstrumentCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentInstrumentCollection","collection":"paymentinstruments","filePath":"src/collections/PaymentInstrumentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findActiveByCustomer":{"name":"findActiveByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findDefaultForCustomer":{"name":"findDefaultForCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument | null>","isStatic":false,"isPublic":true},"findByProviderPaymentMethodId":{"name":"findByProviderPaymentMethodId","async":true,"parameters":[{"name":"providerPaymentMethodId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument | null>","isStatic":false,"isPublic":true},"setDefaultForCustomer":{"name":"setDefaultForCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false},{"name":"instrumentId","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentInstrument[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"PaymentInstrument","exportName":"PaymentInstrumentCollection","collectionExportName":"PaymentInstrumentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PaymentInstrument","inheritedExposure":["api","mcp"],"schema":{"tableName":"payment_instruments","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_instruments\\" (\\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 \\"customer_id\\" UUID,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"provider_payment_method_id\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'card',\\n \\"brand\\" TEXT DEFAULT '',\\n \\"last4\\" TEXT DEFAULT '',\\n \\"exp_month\\" INTEGER DEFAULT 0,\\n \\"exp_year\\" INTEGER DEFAULT 0,\\n \\"is_default\\" BOOLEAN DEFAULT FALSE,\\n \\"status\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_payment_method_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"card"},"brand":{"type":"TEXT","notNull":false,"unique":false,"default":""},"last4":{"type":"TEXT","notNull":false,"unique":false,"default":""},"exp_month":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"exp_year":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"is_default":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"status":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"payment_instruments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_instruments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_instruments_customer_id_idx","columns":["customer_id"]}],"version":"fcbc59d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentIntentCollection":{"name":"paymentintentcollection","className":"PaymentIntentCollection","qualifiedName":"@happyvertical/smrt-commerce:PaymentIntentCollection","collection":"paymentintents","filePath":"src/collections/PaymentIntentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByIdempotencyKey":{"name":"findByIdempotencyKey","async":true,"parameters":[{"name":"args","type":"PaymentIntentIdempotencyArgs","optional":false}],"returnType":"Promise<PaymentIntent | null>","isStatic":false,"isPublic":true},"getOrCreateByIdempotencyKey":{"name":"getOrCreateByIdempotencyKey","async":true,"parameters":[{"name":"seed","type":"PaymentIntentSeed","optional":false}],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"findOpen":{"name":"findOpen","async":true,"parameters":[],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findStale":{"name":"findStale","async":true,"parameters":[],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByLicenseeEmail":{"name":"findByLicenseeEmail","async":true,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByOfferingRef":{"name":"findByOfferingRef","async":true,"parameters":[{"name":"offeringRef","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"PaymentIntentStatus","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<PaymentIntent[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"PaymentIntent","exportName":"PaymentIntentCollection","collectionExportName":"PaymentIntentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PaymentIntent","inheritedExposure":["api","mcp"],"schema":{"tableName":"payment_intents","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_intents\\" (\\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 \\"sku_id\\" TEXT DEFAULT '',\\n \\"offering_ref\\" TEXT DEFAULT '',\\n \\"licensee_email\\" TEXT DEFAULT '',\\n \\"customer_id\\" TEXT DEFAULT '',\\n \\"payment_options\\" JSON DEFAULT '[]',\\n \\"usd_price_locked\\" INTEGER DEFAULT 0,\\n \\"price_lock_window_ms\\" INTEGER,\\n \\"price_lock_expires_at\\" TIMESTAMP,\\n \\"status\\" TEXT,\\n \\"idempotency_key\\" TEXT DEFAULT '',\\n \\"paid_option_backend_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"paid_at\\" TIMESTAMP,\\n \\"issued_at\\" TIMESTAMP,\\n \\"expired_at\\" TIMESTAMP,\\n \\"cancelled_at\\" TIMESTAMP,\\n \\"retired_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"connected_environment\\" TEXT DEFAULT '',\\n \\"connected_amount\\" INTEGER DEFAULT 0,\\n \\"connected_currency\\" TEXT DEFAULT ''\\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},"sku_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"offering_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"licensee_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_options":{"type":"JSON","notNull":false,"unique":false,"default":[]},"usd_price_locked":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_lock_window_ms":{"type":"INTEGER","notNull":false,"unique":false},"price_lock_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"idempotency_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_option_backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"expired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancelled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"retired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_environment":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_intents_tenant_id_offering_ref_idx","columns":["tenant_id","offering_ref","licensee_email","idempotency_key"],"unique":true,"nullsNotDistinct":true},{"name":"payment_intents_slug_context_idx","columns":["slug","context"]},{"name":"payment_intents_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"92f80d93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PayoutCollection":{"name":"payoutcollection","className":"PayoutCollection","qualifiedName":"@happyvertical/smrt-commerce:PayoutCollection","collection":"payouts","filePath":"src/collections/PayoutCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"createFromPayment":{"name":"createFromPayment","async":true,"parameters":[{"name":"args","type":"CreatePayoutFromPaymentArgs","optional":false}],"returnType":"Promise<Payout>","isStatic":false,"isPublic":true},"findByPayment":{"name":"findByPayment","async":true,"parameters":[{"name":"paymentId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findByVendor":{"name":"findByVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"PayoutStatus","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findPending":{"name":"findPending","async":true,"parameters":[],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findFailed":{"name":"findFailed","async":true,"parameters":[],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findByBackendTxRef":{"name":"findByBackendTxRef","async":true,"parameters":[{"name":"backendTxRef","type":"string","optional":false}],"returnType":"Promise<Payout | null>","isStatic":false,"isPublic":true},"getConfirmedTotalForVendor":{"name":"getConfirmedTotalForVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Payout[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Payout","exportName":"PayoutCollection","collectionExportName":"PayoutCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Payout","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"payouts","ddl":"CREATE TABLE IF NOT EXISTS \\"payouts\\" (\\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 \\"payment_id\\" TEXT DEFAULT '',\\n \\"vendor_id\\" UUID,\\n \\"gross_amount\\" INTEGER DEFAULT 0,\\n \\"operator_fee\\" INTEGER DEFAULT 0,\\n \\"supplier_net\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT '',\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"backend_tx_ref\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"sent_at\\" TIMESTAMP,\\n \\"confirmed_at\\" TIMESTAMP,\\n \\"failed_at\\" TIMESTAMP,\\n \\"failure_reason\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT ''\\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},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"gross_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"operator_fee":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"supplier_net":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"backend_tx_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"confirmed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"failure_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payouts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payouts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payouts_vendor_id_idx","columns":["vendor_id"]}],"version":"777cae02"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchaseContractCollection":{"name":"purchasecontractcollection","className":"PurchaseContractCollection","qualifiedName":"@happyvertical/smrt-commerce:PurchaseContractCollection","collection":"contracts","description":"Read supplier-side contracts across every purchase STI subtype.","filePath":"src/collections/PurchaseContractCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByVendor":{"name":"findByVendor","async":true,"parameters":[{"name":"vendorId","type":"string","optional":false}],"returnType":"Promise<PurchaseContract[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"contracts","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","findByVendor"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","findByVendor"]},"cli":{"exclude":["create","update","delete","findByVendor"]}},"extends":"SmrtCollection","extendsTypeArg":"PurchaseContract","exportName":"PurchaseContractCollection","collectionExportName":"PurchaseContractCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PurchaseContract","inheritedExposure":["api","mcp"],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"fee54480"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchasePriceObservationCollection":{"name":"purchasepriceobservationcollection","className":"PurchasePriceObservationCollection","qualifiedName":"@happyvertical/smrt-commerce:PurchasePriceObservationCollection","collection":"purchasepriceobservations","filePath":"src/collections/PurchasePriceObservationCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"PurchasePriceObservation","exportName":"PurchasePriceObservationCollection","collectionExportName":"PurchasePriceObservationCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:PurchasePriceObservation","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"purchase_price_observations","ddl":"CREATE TABLE IF NOT EXISTS \\"purchase_price_observations\\" (\\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_identity\\" TEXT,\\n \\"vendor_id\\" TEXT,\\n \\"snapshot_json\\" TEXT,\\n \\"completion_json\\" 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_identity":{"type":"TEXT","notNull":false,"unique":false},"vendor_id":{"type":"TEXT","notNull":false,"unique":false},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false},"completion_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"purchase_price_observations_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"purchase_price_observations_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"2a855c4b"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:SalesContractCollection":{"name":"salescontractcollection","className":"SalesContractCollection","qualifiedName":"@happyvertical/smrt-commerce:SalesContractCollection","collection":"contracts","description":"Read customer-side contracts across every sales STI subtype.","filePath":"src/collections/SalesContractCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByCustomer":{"name":"findByCustomer","async":true,"parameters":[{"name":"customerId","type":"string","optional":false}],"returnType":"Promise<SalesContract[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"contracts","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","findByCustomer"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","findByCustomer"]},"cli":{"exclude":["create","update","delete","findByCustomer"]}},"extends":"SmrtCollection","extendsTypeArg":"SalesContract","exportName":"SalesContractCollection","collectionExportName":"SalesContractCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:SalesContract","inheritedExposure":["api","mcp"],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"c54df156"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxCodeCollection":{"name":"taxcodecollection","className":"TaxCodeCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxCodeCollection","collection":"taxcodes","filePath":"src/collections/TaxCodeCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByCode":{"name":"findByCode","async":true,"parameters":[{"name":"code","type":"string","optional":false},{"name":"tenantId","type":"string","optional":true}],"returnType":"Promise<TaxCode | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"TaxCode","exportName":"TaxCodeCollection","collectionExportName":"TaxCodeCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxCode","inheritedExposure":["api","mcp"],"schema":{"tableName":"tax_codes","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_codes\\" (\\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 \\"code\\" TEXT,\\n \\"name\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'taxable',\\n \\"applies_to\\" TEXT DEFAULT 'both',\\n \\"components_json\\" TEXT,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"code":{"type":"TEXT","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"taxable"},"applies_to":{"type":"TEXT","notNull":false,"unique":false,"default":"both"},"components_json":{"type":"TEXT","notNull":false,"unique":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_codes_tenant_id_code_idx","columns":["tenant_id","code"],"unique":true,"nullsNotDistinct":true},{"name":"tax_codes_slug_context_idx","columns":["slug","context"]},{"name":"tax_codes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"583dc2f0"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxComponentCollection":{"name":"taxcomponentcollection","className":"TaxComponentCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxComponentCollection","collection":"taxcomponents","filePath":"src/collections/TaxComponentCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"TaxComponent","exportName":"TaxComponentCollection","collectionExportName":"TaxComponentCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxComponent","inheritedExposure":["api","mcp"],"schema":{"tableName":"tax_components","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_components\\" (\\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 \\"name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" UUID,\\n \\"recoverable\\" BOOLEAN NOT NULL DEFAULT FALSE,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recoverable":{"type":"BOOLEAN","notNull":true,"unique":false,"default":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_components_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tax_components_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_components_liability_account_id_idx","columns":["liability_account_id"]}],"version":"79db2a87"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSettingsCollection":{"name":"taxsettingscollection","className":"TaxSettingsCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxSettingsCollection","collection":"taxsettingses","filePath":"src/collections/TaxSettingsCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"getOrCreateForTenant":{"name":"getOrCreateForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TaxSettings>","isStatic":false,"isPublic":true},"getForTenant":{"name":"getForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TaxSettings | null>","isStatic":false,"isPublic":true},"lockForTenant":{"name":"lockForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TaxSettings>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["get","create","update"]},"mcp":{"include":["get"]}},"extends":"SmrtCollection","extendsTypeArg":"TaxSettings","exportName":"TaxSettingsCollection","collectionExportName":"TaxSettingsCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxSettings","inheritedExposure":["api","mcp"],"schema":{"tableName":"tax_settings","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_settings\\" (\\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 \\"default_sales_tax_code_id\\" UUID,\\n \\"default_purchase_tax_code_id\\" UUID,\\n \\"default_line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"tax_registrations_json\\" 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},"default_sales_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_purchase_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_settings_tenant_id_idx","columns":["tenant_id"],"unique":true},{"name":"tax_settings_slug_context_idx","columns":["slug","context"]},{"name":"tax_settings_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_settings_default_sales_tax_code_id_idx","columns":["default_sales_tax_code_id"]},{"name":"tax_settings_default_purchase_tax_code_id_idx","columns":["default_purchase_tax_code_id"]}],"version":"e8ebb46e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSummaryReportCollection":{"name":"taxsummaryreportcollection","className":"TaxSummaryReportCollection","qualifiedName":"@happyvertical/smrt-commerce:TaxSummaryReportCollection","collection":"taxsummaryreports","filePath":"src/collections/TaxSummaryReportCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"refresh":{"name":"refresh","async":true,"parameters":[{"name":"options","type":"Omit<ReportRefreshOptions, 'db'>","optional":true}],"returnType":"Promise<ReportRefreshResult>","isStatic":false,"isPublic":true},"list":{"name":"list","async":true,"parameters":[{"name":"options","type":"SmrtListOptions<TaxSummaryReport>","optional":true}],"returnType":"Promise<SmrtObject[] | Record<string, unknown>[]>","isStatic":false,"isPublic":true},"get":{"name":"get","async":true,"parameters":[{"name":"filter","type":"any","optional":false,"typeUnresolved":true},{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<TaxSummaryReport | null>","isStatic":false,"isPublic":true},"count":{"name":"count","async":true,"parameters":[{"name":"options","type":"any","optional":true,"typeUnresolved":true}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"refreshTaxSummary":{"name":"refreshTaxSummary","async":true,"parameters":[{"name":"options","type":"RefreshTaxSummaryReportOptions","optional":false}],"returnType":"Promise<TaxSummaryReportRefreshResult>","isStatic":false,"isPublic":true},"drilldownInvoiceFacts":{"name":"drilldownInvoiceFacts","async":true,"parameters":[{"name":"options","type":"TaxSummaryInvoiceDrilldownOptions","optional":false}],"returnType":"Promise<InvoiceTaxReportFact[]>","isStatic":false,"isPublic":true},"drilldownContributors":{"name":"drilldownContributors","async":true,"parameters":[{"name":"options","type":"TaxSummaryContributorDrilldownOptions","optional":false}],"returnType":"Promise<TaxSummaryContributorDrilldown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tax_summary_reports","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtReportCollection","extendsTypeArg":"TaxSummaryReport","exportName":"TaxSummaryReportCollection","collectionExportName":"TaxSummaryReportCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TaxSummaryReport","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"tax_summary_reports","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_summary_reports\\" (\\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 \\"refreshed_at\\" TIMESTAMP,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"period_from\\" TIMESTAMP,\\n \\"period_to\\" TIMESTAMP,\\n \\"currency\\" TEXT,\\n \\"row_kind\\" TEXT DEFAULT 'component',\\n \\"dimension_key\\" TEXT,\\n \\"direction\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_code_kind\\" TEXT,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER,\\n \\"ledger_movement_minor\\" INTEGER,\\n \\"net_tax_minor\\" INTEGER,\\n \\"difference_minor\\" INTEGER,\\n \\"document_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"source_scopes\\" TEXT,\\n \\"complete\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"warning_code\\" TEXT,\\n \\"warning_source_type\\" TEXT,\\n \\"warning_source_id\\" TEXT,\\n \\"warning_message\\" 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"},"refreshed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"period_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false},"row_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"component"},"dimension_key":{"type":"TEXT","notNull":false,"unique":false},"direction":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_kind":{"type":"TEXT","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":false,"unique":false},"ledger_movement_minor":{"type":"INTEGER","notNull":false,"unique":false},"net_tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"difference_minor":{"type":"INTEGER","notNull":false,"unique":false},"document_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"source_scopes":{"type":"TEXT","notNull":false,"unique":false},"complete":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"warning_code":{"type":"TEXT","notNull":false,"unique":false},"warning_source_type":{"type":"TEXT","notNull":false,"unique":false},"warning_source_id":{"type":"TEXT","notNull":false,"unique":false},"warning_message":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_summary_reports_tenant_id_period_from_idx","columns":["tenant_id","period_from","period_to","currency","row_kind","dimension_key"],"unique":true,"nullsNotDistinct":true},{"name":"tax_summary_reports_slug_context_idx","columns":["slug","context"]},{"name":"tax_summary_reports_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"d4d5ebbe"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentAccountCollection":{"name":"tenantpaymentaccountcollection","className":"TenantPaymentAccountCollection","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentAccountCollection","collection":"tenantpaymentaccounts","filePath":"src/collections/TenantPaymentAccountCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"build":{"name":"build","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<TenantPaymentAccount>","isStatic":false,"isPublic":true},"findForTenant":{"name":"findForTenant","async":true,"parameters":[{"name":"args","type":"object","optional":false,"memberTypes":["string","TenantPaymentEnvironment"]}],"returnType":"Promise<TenantPaymentAccount | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tenant_payment_accounts","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"],"skipApiCheck":true}},"extends":"SmrtCollection","extendsTypeArg":"TenantPaymentAccount","exportName":"TenantPaymentAccountCollection","collectionExportName":"TenantPaymentAccountCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TenantPaymentAccount","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"tenant_payment_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_accounts\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT 'stripe',\\n \\"environment\\" TEXT NOT NULL DEFAULT 'test',\\n \\"provider_account_id\\" TEXT NOT NULL DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'pending',\\n \\"charges_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"details_submitted\\" BOOLEAN DEFAULT FALSE,\\n \\"payouts_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"capabilities_json\\" TEXT,\\n \\"capabilities_observed_at\\" TIMESTAMP,\\n \\"fee_policy_ref\\" TEXT DEFAULT '',\\n \\"disabled_at\\" TIMESTAMP,\\n \\"disabled_reason\\" TEXT DEFAULT ''\\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},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":"stripe"},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"pending"},"charges_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"details_submitted":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"payouts_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"capabilities_json":{"type":"TEXT","notNull":false,"unique":false},"capabilities_observed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"disabled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"disabled_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"tenant_payment_accounts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_accounts_tenant_backend_environment","columns":["tenant_id","backend_id","environment"],"unique":true},{"name":"tenant_payment_accounts_provider_account","columns":["backend_id","environment","provider_account_id"],"unique":true},{"name":"tenant_payment_accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"ea6f5edc"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:VendorCollection":{"name":"vendorcollection","className":"VendorCollection","qualifiedName":"@happyvertical/smrt-commerce:VendorCollection","collection":"vendors","filePath":"src/collections/VendorCollection.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"findByProfile":{"name":"findByProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findActive":{"name":"findActive","async":true,"parameters":[],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findByStatus":{"name":"findByStatus","async":true,"parameters":[{"name":"status","type":"VendorStatus","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"getOrCreateForProfile":{"name":"getOrCreateForProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false},{"name":"defaults","type":"Partial<object>","optional":true,"memberTypes":["number","string"]}],"returnType":"Promise<Vendor>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Vendor[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Vendor","exportName":"VendorCollection","collectionExportName":"VendorCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:Vendor","inheritedExposure":["api","mcp"],"schema":{"tableName":"vendors","ddl":"CREATE TABLE IF NOT EXISTS \\"vendors\\" (\\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 \\"profile_id\\" UUID,\\n \\"lead_time_days\\" INTEGER DEFAULT 0,\\n \\"minimum_order_amount\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_contact_email\\" TEXT DEFAULT '',\\n \\"default_contact_phone\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"payout_addresses\\" JSON DEFAULT '{}',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"lead_time_days":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"minimum_order_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_contact_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_contact_phone":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payout_addresses":{"type":"JSON","notNull":false,"unique":false,"default":{}},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"vendors_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"vendors_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"vendors_profile_id_idx","columns":["profile_id"]},{"name":"vendors_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"6cac701f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Contract":{"name":"contract","className":"Contract","qualifiedName":"@happyvertical/smrt-commerce:Contract","collection":"contracts","description":"Contract is the base class for all commercial agreements.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"label":"reference","list":["reference","customerId","vendorId","status","totalAmount","issueDate","dueDate"]},"tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context","_meta_type"]},"extends":"SmrtObject","exportName":"Contract","collectionExportName":"ContractCollection","displayLabelField":"reference","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"ff08ed4f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:SalesContract":{"name":"salescontract","className":"SalesContract","qualifiedName":"@happyvertical/smrt-commerce:SalesContract","collection":"contracts","description":"Customer-side contracts, including orders, estimates, and licenses.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"abstract":true,"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"cli":{"skipApiCheck":true,"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]}},"extends":"Contract","exportName":"SalesContract","collectionExportName":"SalesContractCollection","abstractDeclaredApi":null,"validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"c54df156"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchaseContract":{"name":"purchasecontract","className":"PurchaseContract","qualifiedName":"@happyvertical/smrt-commerce:PurchaseContract","collection":"contracts","description":"Supplier-side contracts, including supplier quotes, purchase and production orders.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"vendorId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The vendor supplying this quote or purchase contract."},"required":false,"related":"Vendor","description":"The vendor supplying this quote or purchase contract."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"abstract":true,"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"mcp":{"include":["list","get"],"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]},"cli":{"skipApiCheck":true,"exclude":["create","update","delete","rebindMoneyRead","isDraft","isAccepted","isCompleted","isExpired","isOverdue","recalculateTotals","initialize","save","deleteDerived","saveDerived"]}},"extends":"Contract","exportName":"PurchaseContract","collectionExportName":"PurchaseContractCollection","abstractDeclaredApi":null,"validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"fee54480"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Estimate":{"name":"estimate","className":"Estimate","qualifiedName":"@happyvertical/smrt-commerce:Estimate","collection":"contracts","description":"Quote or proposal for a customer","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Estimate","collectionExportName":"EstimateCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"024e587f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Order":{"name":"order","className":"Order","qualifiedName":"@happyvertical/smrt-commerce:Order","collection":"contracts","description":"Customer purchase order","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."},"sourceEstimateId":{"type":"meta","_meta":{"__statedOptions":["description","default"],"description":"The accepted estimate this order was converted from, if any.","underlyingType":"text"},"required":false,"default":"","description":"The accepted estimate this order was converted from, if any."},"conversionRequestId":{"type":"meta","_meta":{"__statedOptions":["description","default"],"description":"The request identity of the conversion that created this order.","underlyingType":"text"},"required":false,"default":"","description":"The request identity of the conversion that created this order."},"acceptanceEvidenceRef":{"type":"meta","_meta":{"__statedOptions":["description","default"],"description":"Where the proof of the customer accepting the estimate is kept.","underlyingType":"text"},"required":false,"default":"","description":"Where the proof of the customer accepting the estimate is kept."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Order","collectionExportName":"OrderCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"e87e7d82"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Lease":{"name":"lease","className":"Lease","qualifiedName":"@happyvertical/smrt-commerce:Lease","collection":"contracts","description":"Rental or lease agreement","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Lease","collectionExportName":"LeaseCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"bdf1e524"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Agreement":{"name":"agreement","className":"Agreement","qualifiedName":"@happyvertical/smrt-commerce:Agreement","collection":"contracts","description":"Service or maintenance agreement","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"label":"reference","list":["reference","customerId","status","totalAmount","createdAt"]},"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Agreement","collectionExportName":"AgreementCollection","displayLabelField":"reference","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"4dee0abb"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:SupplierQuote":{"name":"supplierquote","className":"SupplierQuote","qualifiedName":"@happyvertical/smrt-commerce:SupplierQuote","collection":"contracts","description":"Supplier quotation received from a vendor; acceptance does not create an order.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"vendorId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The vendor supplying this quote or purchase contract."},"required":false,"related":"Vendor","description":"The vendor supplying this quote or purchase contract."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"PurchaseContract","exportName":"SupplierQuote","collectionExportName":"SupplierQuoteCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"d7b900cd"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PurchaseOrder":{"name":"purchaseorder","className":"PurchaseOrder","qualifiedName":"@happyvertical/smrt-commerce:PurchaseOrder","collection":"contracts","description":"Order sent to vendor/supplier","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"vendorId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The vendor supplying this quote or purchase contract."},"required":false,"related":"Vendor","description":"The vendor supplying this quote or purchase contract."},"expectedDate":{"type":"meta","_meta":{"__statedOptions":["description","default"],"description":"The date you expect the delivery, as YYYY-MM-DD. Leave blank if it is not known.","underlyingType":"text"},"required":false,"default":"","description":"The date you expect the delivery, as YYYY-MM-DD. Leave blank if it is not known."},"shipTo":{"type":"meta","_meta":{"__statedOptions":["description","default"],"description":"Where this order should be delivered, including any delivery instructions.","underlyingType":"text"},"required":false,"default":"","description":"Where this order should be delivered, including any delivery instructions."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"PurchaseContract","exportName":"PurchaseOrder","collectionExportName":"PurchaseOrderCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"a4e35ea7"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:WholesaleOrder":{"name":"wholesaleorder","className":"WholesaleOrder","qualifiedName":"@happyvertical/smrt-commerce:WholesaleOrder","collection":"contracts","description":"B2B order placed by a wholesale customer.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"WholesaleOrder","collectionExportName":"WholesaleOrderCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"ad0e890c"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:ProductionOrder":{"name":"productionorder","className":"ProductionOrder","qualifiedName":"@happyvertical/smrt-commerce:ProductionOrder","collection":"contracts","description":"Instruction to commission goods from an internal or external factory.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"vendorId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The vendor supplying this quote or purchase contract."},"required":false,"related":"Vendor","description":"The vendor supplying this quote or purchase contract."},"productId":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"bomId":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"PurchaseContract","exportName":"ProductionOrder","collectionExportName":"ProductionOrderCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"8a4deffc"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Cart":{"name":"cart","className":"Cart","qualifiedName":"@happyvertical/smrt-commerce:Cart","collection":"contracts","description":"Transient order-in-progress for a shopper.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"Cart","collectionExportName":"CartCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"c96e872a"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:LicenseSale":{"name":"licensesale","className":"LicenseSale","qualifiedName":"@happyvertical/smrt-commerce:LicenseSale","collection":"contracts","description":"Industry-neutral licensing primitive.","filePath":"src/models/Contract.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["required","requiredFor","sqlType","nullable","__tenancy"],"required":true,"requiredFor":"tenant-scope","sqlType":"UUID","nullable":false},"required":true},"contractType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of contract: order, estimate, lease, agreement and so on."},"required":false,"description":"The kind of contract: order, estimate, lease, agreement and so on.","enum":["estimate","order","lease","agreement","supplier_quote","purchase_order","wholesale_order","production_order","cart","license_sale"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the order or agreement stands, for example draft, sent, accepted or completed."},"required":false,"description":"Where the order or agreement stands, for example draft, sent, accepted or completed.","enum":["draft","sent","accepted","declined","completed","cancelled"]},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The full amount, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"The full amount, tax included."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the amounts.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency of the amounts."},"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or recorded from reviewed original paperwork."},"required":false,"default":"calculated","description":"Whether amounts were calculated or recorded from reviewed original paperwork.","enum":["calculated","received"]},"receivedPurchaseMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"billingScheduleJson":{"type":"text","_meta":{"__statedOptions":["default"],"default":""},"required":false,"default":""},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date it was issued or placed.","ui":{"format":"date"}},"required":false,"description":"The date it was issued or placed."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date payment or delivery is due."},"required":false,"description":"The date payment or delivery is due."},"expiryDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The last day the price or offer is good for."},"required":false,"description":"The last day the price or offer is good for."},"reference":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Your own number or note for finding this later, such as a purchase order or quote number."},"required":false,"default":"","description":"Your own number or note for finding this later, such as a purchase order or quote number."},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The conditions agreed, such as deposits, payment or delivery conditions.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The conditions agreed, such as deposits, payment or delivery conditions."},"channelId":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Where it came from, for example your shop, a marketplace or a phone call."},"required":false,"default":"","description":"Where it came from, for example your shop, a marketplace or a phone call."},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer a sales order or agreement is for."},"required":false,"related":"Customer","description":"The customer a sales order or agreement is for."},"skuId":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"paymentId":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"licenseeEmail":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"licenseeLegalEntity":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"licenseeJurisdiction":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"rightsMedium":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"rightsDistributionScope":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"rightsExclusivity":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"rightsDuration":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"rightsTerritory":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"rightsSublicensing":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"boolean"},"required":false,"default":false},"rightsDerivatives":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"boolean"},"required":false,"default":false},"pdfUrl":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"pdfHash":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""},"onChainHashRegistryRef":{"type":"meta","_meta":{"__statedOptions":["default"],"underlyingType":"text"},"required":false,"default":""}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isAccepted":{"name":"isAccepted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCompleted":{"name":"isCompleted","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"recalculateTotals":{"name":"recalculateTotals","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"getRightsSnapshot":{"name":"getRightsSnapshot","async":false,"parameters":[],"returnType":"LicenseRightsSnapshot","isStatic":false,"isPublic":true},"revoke":{"name":"revoke","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tenantScoped":{"mode":"optional"},"tableName":"contracts","tableStrategy":"sti","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true}},"extends":"SalesContract","exportName":"LicenseSale","collectionExportName":"LicenseSaleCollection","validationRules":[],"schema":{"tableName":"contracts","ddl":"CREATE TABLE IF NOT EXISTS \\"contracts\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"discount_total\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"received_purchase_money_json\\" TEXT,\\n \\"billing_schedule_json\\" TEXT DEFAULT '',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"expiry_date\\" TIMESTAMP,\\n \\"reference\\" TEXT DEFAULT '',\\n \\"notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT '',\\n \\"channel_id\\" TEXT DEFAULT '',\\n \\"customer_id\\" UUID,\\n \\"vendor_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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_type":{"type":"TEXT","notNull":false},"status":{"type":"TEXT","notNull":false},"subtotal":{"type":"INTEGER","notNull":false,"default":0},"discount_total":{"type":"INTEGER","notNull":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"default":0},"currency":{"type":"TEXT","notNull":false,"default":"USD"},"money_authority":{"type":"TEXT","notNull":false,"default":"calculated"},"received_purchase_money_json":{"type":"TEXT","notNull":false},"billing_schedule_json":{"type":"TEXT","notNull":false,"default":""},"line_amount_type":{"type":"TEXT","notNull":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"default":"line"},"seller_tax_registrations_json":{"type":"TEXT","notNull":false},"party_tax_id":{"type":"TEXT","notNull":false},"money_snapshot_id":{"type":"TEXT","notNull":false},"issue_date":{"type":"TIMESTAMP","notNull":false},"due_date":{"type":"TIMESTAMP","notNull":false},"expiry_date":{"type":"TIMESTAMP","notNull":false},"reference":{"type":"TEXT","notNull":false,"default":""},"notes":{"type":"TEXT","notNull":false,"default":""},"terms":{"type":"TEXT","notNull":false,"default":""},"channel_id":{"type":"TEXT","notNull":false,"default":""},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"vendor_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"vendors","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"contracts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contracts_meta_type_idx","columns":["_meta_type"]},{"name":"contracts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contracts_customer_id_idx","columns":["customer_id"]},{"name":"contracts_vendor_id_idx","columns":["vendor_id"]}],"version":"05161a85"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:ContractLineItem":{"name":"contractlineitem","className":"ContractLineItem","qualifiedName":"@happyvertical/smrt-commerce:ContractLineItem","collection":"contractlineitems","description":"ContractLineItem represents a single line item on a contract.","filePath":"src/models/ContractLineItem.ts","packageName":"@happyvertical/smrt-commerce","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"contractId":{"type":"foreignKey","_meta":{"__statedOptions":["description","role","related"],"description":"The order, quote or agreement this line belongs to.","role":"items"},"required":false,"related":"Contract","description":"The order, quote or agreement this line belongs to."},"description":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"What is being sold or bought on this line."},"required":false,"default":"","description":"What is being sold or bought on this line."},"quantity":{"type":"decimal","_meta":{"__statedOptions":["description","default"],"description":"How many."},"required":false,"default":1,"description":"How many."},"unitPrice":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The price of one, before discount; includes tax when the document's prices include tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The price of one, before discount; includes tax when the document's prices include tax."},"discount":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"discountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"none","enum":["none","percent","amount"]},"discountRate":{"type":"decimal","_meta":{"__statedOptions":[]},"required":false},"taxRate":{"type":"decimal","_meta":{"__statedOptions":["description","default"],"description":"The stored fractional tax rate for this line (0.05 means 5%)."},"required":false,"default":0,"description":"The stored fractional tax rate for this line (0.05 means 5%)."},"taxMode":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"inherit","enum":["inherit","override"]},"taxCodeId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"TaxCode"},"taxCodeCode":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"taxCodeName":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"taxComponentsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":true,"default":0},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"amount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The line amount: net of discount, and including tax only when the document's prices include tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The line amount: net of discount, and including tax only when the document's prices include tax."},"productId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The product this line is for, if it is one you list."},"required":false,"related":"@happyvertical/smrt-products:Product","description":"The product this line is for, if it is one you list."},"sku":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"startDate":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"endDate":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"billingPeriod":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"sortOrder":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isRecurring":{"name":"isRecurring","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSubscriptionActive":{"name":"isSubscriptionActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context","_meta_type"]},"extends":"SmrtObject","exportName":"ContractLineItem","collectionExportName":"ContractLineItemCollection","validationRules":[{"field":"taxAmount","rule":"required","fieldType":"integer"}],"schema":{"tableName":"contract_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"contract_line_items\\" (\\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 \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"description\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 1,\\n \\"unit_price\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"discount_type\\" TEXT DEFAULT 'none',\\n \\"discount_rate\\" REAL,\\n \\"tax_rate\\" REAL DEFAULT 0,\\n \\"tax_mode\\" TEXT DEFAULT 'inherit',\\n \\"tax_code_id\\" UUID,\\n \\"tax_code_code\\" TEXT,\\n \\"tax_code_name\\" TEXT,\\n \\"tax_components_json\\" TEXT,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"money_snapshot_id\\" TEXT,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"product_id\\" UUID,\\n \\"sku\\" TEXT DEFAULT '',\\n \\"start_date\\" TIMESTAMP,\\n \\"end_date\\" TIMESTAMP,\\n \\"billing_period\\" TEXT DEFAULT '',\\n \\"sort_order\\" INTEGER DEFAULT 0\\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":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"description":{"type":"TEXT","notNull":false,"default":""},"quantity":{"type":"REAL","notNull":false,"default":1},"unit_price":{"type":"INTEGER","notNull":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"default":0},"discount_type":{"type":"TEXT","notNull":false,"default":"none"},"discount_rate":{"type":"REAL","notNull":false},"tax_rate":{"type":"REAL","notNull":false,"default":0},"tax_mode":{"type":"TEXT","notNull":false,"default":"inherit"},"tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"tax_code_code":{"type":"TEXT","notNull":false},"tax_code_name":{"type":"TEXT","notNull":false},"tax_components_json":{"type":"TEXT","notNull":false},"tax_amount":{"type":"INTEGER","notNull":false,"default":0},"money_snapshot_id":{"type":"TEXT","notNull":false},"amount":{"type":"INTEGER","notNull":false,"default":0},"product_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"sku":{"type":"TEXT","notNull":false,"default":""},"start_date":{"type":"TIMESTAMP","notNull":false},"end_date":{"type":"TIMESTAMP","notNull":false},"billing_period":{"type":"TEXT","notNull":false,"default":""},"sort_order":{"type":"INTEGER","notNull":false,"default":0}},"indexes":[{"name":"contract_line_items_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"contract_line_items_meta_type_idx","columns":["_meta_type"]},{"name":"contract_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"contract_line_items_contract_id_idx","columns":["contract_id"]},{"name":"contract_line_items_tax_code_id_idx","columns":["tax_code_id"]},{"name":"contract_line_items_product_id_idx","columns":["product_id"]}],"version":"89a3137e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Customer":{"name":"customer","className":"Customer","qualifiedName":"@happyvertical/smrt-commerce:Customer","collection":"customers","description":"Customer represents the customer role for a Profile.","filePath":"src/models/Customer.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"profileId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"Choose an existing contact, or enter a new name above."},"required":false,"related":"@happyvertical/smrt-profiles:Profile","description":"Choose an existing contact, or enter a new name above."},"creditLimit":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The most this customer may owe you at one time. Leave it at zero if you do not set limits.","ui":{"format":"money"}},"required":false,"default":0,"description":"The most this customer may owe you at one time. Leave it at zero if you do not set limits."},"paymentTerms":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"How long the customer has to pay, written the way you would say it, for example \\"Net 30\\"."},"required":false,"default":"","description":"How long the customer has to pay, written the way you would say it, for example \\"Net 30\\"."},"taxExempt":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Turn this on if you do not charge this customer sales tax."},"required":false,"default":false,"description":"Turn this on if you do not charge this customer sales tax."},"taxId":{"type":"text","_meta":{"__statedOptions":["sensitive","description","default"],"description":"The tax or VAT number of the customer, kept on file for tax-exempt sales.","sensitive":true},"required":false,"default":"","description":"The tax or VAT number of the customer, kept on file for tax-exempt sales.","sensitive":true},"defaultTaxCodeId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The tax code normally used when selling to this customer."},"required":false,"related":"TaxCode","description":"The tax code normally used when selling to this customer."},"defaultShippingAddress":{"type":"json","_meta":{"__typeUnresolved":true,"__statedOptions":["description"],"description":"Where you usually send goods to this customer, so you do not retype it on every order."},"required":false,"description":"Where you usually send goods to this customer, so you do not retype it on every order."},"defaultBillingAddress":{"type":"json","_meta":{"__typeUnresolved":true,"__statedOptions":["description"],"description":"Where you send invoices to this customer."},"required":false,"description":"Where you send invoices to this customer."},"status":{"type":"text","_meta":{"__statedOptions":["default","description","enum"],"default":"active","description":"Whether you are still dealing with this customer: active, inactive or suspended."},"required":false,"default":"active","description":"Whether you are still dealing with this customer: active, inactive or suspended.","enum":["active","inactive","suspended"]},"customerType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"The kind of customer: a direct shopper, a wholesale buyer or a retail customer."},"required":false,"description":"The kind of customer: a direct shopper, a wholesale buyer or a retail customer.","enum":["dtc","wholesale","retail"]},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this customer.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this customer."},"contacts":{"type":"json","_meta":{"__statedOptions":["description","default"],"description":"The people you deal with at this customer, with their role and how to reach them."},"required":false,"default":[],"description":"The people you deal with at this customer, with their role and how to reach them."}},"methods":{"resolveWriteThroughVirtualProjection":{"name":"resolveWriteThroughVirtualProjection","async":true,"parameters":[{"name":"via","type":"string","optional":false},{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<Record<string, object>>","isStatic":true,"isPublic":true,"decoratorConfig":{"expose":false}},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isWholesale":{"name":"isWholesale","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"hasAvailableCredit":{"name":"hasAvailableCredit","async":false,"parameters":[{"name":"amount","type":"number","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true},"getProfileId":{"name":"getProfileId","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true}},"decoratorConfig":{"writeThrough":{"profileId":{"fields":["name","email"],"virtualFields":{"phone":{"type":"text","description":"A phone number for reaching this person.","ui":{"widget":"phone"}}}}},"display":{"list":["status","email","phone"],"label":{"via":"profileId","field":"name","fallback":"Unnamed customer"}},"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get","create","update"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Customer","collectionExportName":"CustomerCollection","writeThroughFields":{"name":{"type":"text","_meta":{"__statedOptions":["default"],"ui":{"basic":true,"order":-100}},"required":false,"default":""},"email":{"type":"text","_meta":{"__statedOptions":[],"ui":{"basic":true,"order":-99}},"required":false},"phone":{"type":"text","description":"A phone number for reaching this person.","ui":{"widget":"phone"},"required":false,"_meta":{"ui":{"widget":"phone","basic":true,"order":-98}}}},"displayLabelProjection":{"via":"profileId","field":"name","fallback":"Unnamed customer"},"displayLabelField":"displayLabel","schema":{"tableName":"customers","ddl":"CREATE TABLE IF NOT EXISTS \\"customers\\" (\\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 \\"profile_id\\" UUID,\\n \\"credit_limit\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"tax_exempt\\" BOOLEAN DEFAULT FALSE,\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_shipping_address\\" JSON,\\n \\"default_billing_address\\" JSON,\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"customer_type\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"credit_limit":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tax_exempt":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_shipping_address":{"type":"JSON","notNull":false,"unique":false},"default_billing_address":{"type":"JSON","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"customer_type":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"customers_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"customers_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"customers_profile_id_idx","columns":["profile_id"]},{"name":"customers_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"617d1e93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:DocumentTax":{"name":"documenttax","className":"DocumentTax","qualifiedName":"@happyvertical/smrt-commerce:DocumentTax","collection":"documenttaxes","filePath":"src/models/DocumentTax.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"documentType":{"type":"text","_meta":{"__statedOptions":["required","default","enum"],"required":true},"required":true,"default":"invoice","enum":["invoice","contract","credit_note"]},"documentId":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"identity"},"required":true},"currency":{"type":"text","_meta":{"__statedOptions":["required"],"required":true},"required":true},"taxCodeId":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"taxCodeCode":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"kind":{"type":"text","_meta":{"__statedOptions":["nullable","enum","required"],"nullable":true,"required":false},"required":false,"enum":["taxable","zero-rated","exempt","out-of-scope"]},"taxComponentId":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"taxComponentName":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"percent":{"type":"decimal","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"liabilityAccountId":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"taxableMinor":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"Actual component taxable basis, including prior compound taxes.","ui":{"format":"money"}},"required":true,"default":0,"description":"Actual component taxable basis, including prior compound taxes."},"netMinor":{"type":"integer","_meta":{"__statedOptions":["nullable","description","ui","required"],"description":"Net basis when different from the component taxable basis.","nullable":true,"ui":{"format":"money"},"required":false},"required":false,"description":"Net basis when different from the component taxable basis."},"taxMinor":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"Tax total in integer minor units.","ui":{"format":"money"}},"required":true,"default":0,"description":"Tax total in integer minor units."},"recoverableMinor":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"Recoverable purchase tax in integer minor units.","ui":{"format":"money"}},"required":true,"default":0,"description":"Recoverable purchase tax in integer minor units."}},"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},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"document_taxes","conflictColumns":["document_type","document_id","tax_code_id","tax_component_id"],"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"DocumentTax","collectionExportName":"DocumentTaxCollection","validationRules":[{"field":"documentType","rule":"required","fieldType":"text"},{"field":"documentId","rule":"required","fieldType":"text"},{"field":"currency","rule":"required","fieldType":"text"},{"field":"taxableMinor","rule":"required","fieldType":"integer"},{"field":"taxMinor","rule":"required","fieldType":"integer"},{"field":"recoverableMinor","rule":"required","fieldType":"integer"}],"schema":{"tableName":"document_taxes","ddl":"CREATE TABLE IF NOT EXISTS \\"document_taxes\\" (\\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 \\"document_type\\" TEXT NOT NULL DEFAULT 'invoice',\\n \\"document_id\\" TEXT NOT NULL,\\n \\"currency\\" TEXT NOT NULL,\\n \\"tax_code_id\\" TEXT,\\n \\"tax_code_code\\" TEXT,\\n \\"kind\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_component_name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"net_minor\\" INTEGER,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER NOT NULL DEFAULT 0\\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},"document_type":{"type":"TEXT","notNull":true,"unique":false,"default":"invoice"},"document_id":{"type":"TEXT","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":true,"unique":false},"tax_code_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_code":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_component_name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"net_minor":{"type":"INTEGER","notNull":false,"unique":false},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0}},"indexes":[{"name":"document_taxes_document_type_document_id_idx","columns":["document_type","document_id","tax_code_id","tax_component_id"],"unique":true,"nullsNotDistinct":true},{"name":"document_taxes_slug_context_idx","columns":["slug","context"]},{"name":"document_taxes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b35e53b9"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Fulfillment":{"name":"fulfillment","className":"Fulfillment","qualifiedName":"@happyvertical/smrt-commerce:Fulfillment","collection":"fulfillments","description":"Fulfillment tracks the delivery or completion of contract items.","filePath":"src/models/Fulfillment.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"contractId":{"type":"foreignKey","_meta":{"__statedOptions":["description","validateSubtype","related"],"description":"The order being fulfilled.","validateSubtype":true},"required":false,"related":"SalesContract","description":"The order being fulfilled."},"fulfillmentType":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"How it gets to the customer: shipment, delivery, pickup, digital or service."},"required":false,"description":"How it gets to the customer: shipment, delivery, pickup, digital or service.","enum":["shipment","delivery","pickup","digital","service"]},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where it stands: pending, processing, shipped, delivered or cancelled."},"required":false,"description":"Where it stands: pending, processing, shipped, delivered or cancelled.","enum":["pending","processing","shipped","delivered","cancelled"]},"trackingNumber":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"The carrier's tracking number."},"required":false,"default":"","description":"The carrier's tracking number."},"carrier":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"The company carrying it."},"required":false,"default":"","description":"The company carrying it."},"shippingAddress":{"type":"json","_meta":{"__typeUnresolved":true,"__statedOptions":[]},"required":false},"shippedAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When it was dispatched."},"required":false,"description":"When it was dispatched."},"deliveredAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When it arrived."},"required":false,"description":"When it arrived."},"estimatedDelivery":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"notes":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"Anything worth remembering about this shipment."},"required":false,"default":"","description":"Anything worth remembering about this shipment."}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isDelivered":{"name":"isDelivered","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isInTransit":{"name":"isInTransit","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPending":{"name":"isPending","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markShipped":{"name":"markShipped","async":false,"parameters":[{"name":"trackingNumber","type":"string","optional":true},{"name":"carrier","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"markDelivered":{"name":"markDelivered","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Fulfillment","collectionExportName":"FulfillmentCollection","schema":{"tableName":"fulfillments","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillments\\" (\\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 \\"contract_id\\" UUID,\\n \\"fulfillment_type\\" TEXT,\\n \\"status\\" TEXT,\\n \\"tracking_number\\" TEXT DEFAULT '',\\n \\"carrier\\" TEXT DEFAULT '',\\n \\"shipping_address\\" JSON,\\n \\"shipped_at\\" TIMESTAMP,\\n \\"delivered_at\\" TIMESTAMP,\\n \\"estimated_delivery\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT ''\\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},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"fulfillment_type":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"tracking_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"carrier":{"type":"TEXT","notNull":false,"unique":false,"default":""},"shipping_address":{"type":"JSON","notNull":false,"unique":false},"shipped_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"delivered_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"estimated_delivery":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillments_contract_id_idx","columns":["contract_id"]}],"version":"3970fcbd"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:FulfillmentLineItem":{"name":"fulfillmentlineitem","className":"FulfillmentLineItem","qualifiedName":"@happyvertical/smrt-commerce:FulfillmentLineItem","collection":"fulfillmentlineitems","description":"FulfillmentLineItem tracks which contract line items are included in a specific fulfillment and how much was fulfilled.","filePath":"src/models/FulfillmentLineItem.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"fulfillmentId":{"type":"foreignKey","_meta":{"__statedOptions":["description","role","related"],"description":"The shipment this line belongs to.","role":"items"},"required":false,"related":"Fulfillment","description":"The shipment this line belongs to."},"contractLineItemId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The order line being sent."},"required":false,"related":"ContractLineItem","description":"The order line being sent."},"quantityFulfilled":{"type":"decimal","_meta":{"__statedOptions":["description","default"],"description":"How many of that line are in this shipment."},"required":false,"default":1,"description":"How many of that line are in this shipment."},"notes":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]},"cli":true,"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"FulfillmentLineItem","collectionExportName":"FulfillmentLineItemCollection","schema":{"tableName":"fulfillment_line_items","ddl":"CREATE TABLE IF NOT EXISTS \\"fulfillment_line_items\\" (\\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 \\"fulfillment_id\\" UUID,\\n \\"contract_line_item_id\\" UUID,\\n \\"quantity_fulfilled\\" REAL DEFAULT 1,\\n \\"notes\\" TEXT DEFAULT ''\\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},"fulfillment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"fulfillments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_line_item_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contract_line_items","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"quantity_fulfilled":{"type":"REAL","notNull":false,"unique":false,"default":1},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"fulfillment_line_items_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"fulfillment_line_items_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"fulfillment_line_items_fulfillment_id_idx","columns":["fulfillment_id"]},{"name":"fulfillment_line_items_contract_line_item_id_idx","columns":["contract_line_item_id"]}],"version":"acf1ca5f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Invoice":{"name":"invoice","className":"Invoice","qualifiedName":"@happyvertical/smrt-commerce:Invoice","collection":"invoices","description":"Invoice represents a bill sent to a customer for goods or services.","filePath":"src/models/Invoice.ts","packageName":"@happyvertical/smrt-commerce","fields":{"moneyAuthority":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether amounts were calculated or retained from an original issued invoice."},"required":false,"default":"calculated","description":"Whether amounts were calculated or retained from an original issued invoice.","enum":["calculated","historical"]},"historicalSalesMoneyJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"historicalSourceKeyHash":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"kind":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Invoice or customer credit note."},"required":false,"default":"invoice","description":"Invoice or customer credit note.","enum":["invoice","credit_note"]},"creditedInvoiceId":{"type":"foreignKey","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"Invoice"},"creditedAmount":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":true,"default":0},"retentionStateJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"retentionAccountingStateJson":{"type":"text","_meta":{"__statedOptions":["sensitive"],"sensitive":true},"required":false,"sensitive":true},"ordinaryAccountingStateJson":{"type":"text","_meta":{"__statedOptions":["sensitive"],"sensitive":true},"required":false,"sensitive":true},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The customer being billed."},"required":false,"related":"Customer","description":"The customer being billed."},"contractId":{"type":"foreignKey","_meta":{"__statedOptions":["description","validateSubtype","related"],"description":"The order or agreement this invoice bills for, if any.","validateSubtype":true},"required":false,"related":"SalesContract","description":"The order or agreement this invoice bills for, if any."},"invoiceNumber":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"The number printed on the invoice."},"required":false,"default":"","description":"The number printed on the invoice."},"reference":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"issueDate":{"type":"datetime","_meta":{"__statedOptions":["description","ui"],"description":"The date the invoice was issued.","ui":{"format":"date"}},"required":false,"description":"The date the invoice was issued."},"dueDate":{"type":"datetime","_meta":{"__statedOptions":["nullable","description","required"],"description":"The date payment is expected; null when the original source did not establish it.","nullable":true,"required":false},"required":false,"description":"The date payment is expected; null when the original source did not establish it."},"paidDate":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"The date it was paid in full."},"required":false,"description":"The date it was paid in full."},"subtotal":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The amount before tax.","ui":{"format":"money"}},"required":false,"default":0,"description":"The amount before tax."},"taxAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The tax charged.","ui":{"format":"money"}},"required":false,"default":0,"description":"The tax charged."},"providerTaxAmount":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":false,"default":0},"totalAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"What the customer owes in all, tax included.","ui":{"format":"money"}},"required":false,"default":0,"description":"What the customer owes in all, tax included."},"amountPaid":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"How much of the total has been paid so far.","ui":{"format":"money"}},"required":false,"default":0,"description":"How much of the total has been paid so far."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency of the invoice.","ui":{"widget":"currency"}},"required":false,"default":"CAD","description":"The currency of the invoice."},"lineAmountType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"exclusive","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"line","enum":["line","document"]},"discountTotal":{"type":"integer","_meta":{"__statedOptions":["ui","default"],"ui":{"format":"money"}},"required":true,"default":0},"sellerTaxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"partyTaxId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"moneySnapshotId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Where the invoice stands: draft, sent, viewed, paid, overdue or cancelled."},"required":false,"description":"Where the invoice stands: draft, sent, viewed, paid, overdue or cancelled.","enum":["draft","sent","viewed","partial","paid","overdue","cancelled","written_off"]},"arJournalId":{"type":"crossPackageRef","_meta":{"__statedOptions":["related"]},"required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"arReversalJournalId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"revenueJournalId":{"type":"crossPackageRef","_meta":{"__statedOptions":["related"]},"required":false,"related":"@happyvertical/smrt-ledgers:Journal"},"externalId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"customerExternalId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"externalProvider":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"syncedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"accountingSyncStateJson":{"type":"text","_meta":{"__statedOptions":["sensitive"],"sensitive":true},"required":false,"sensitive":true},"collectionMethod":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"","enum":["","send_invoice","charge_automatically"]},"sentAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"viewedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"remindersSent":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"lastReminderAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Private notes, not shown to the customer.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Private notes, not shown to the customer."},"customerNotes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"A message shown to the customer on the invoice.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"A message shown to the customer on the invoice."},"terms":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The payment conditions, such as Net 30.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"The payment conditions, such as Net 30."}},"methods":{"rebindMoneyRead":{"name":"rebindMoneyRead","async":false,"parameters":[{"name":"capability","type":"DocumentMoneyReadRebindCapability","optional":false},{"name":"db","type":"DatabaseInterface","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"getPayableFacts":{"name":"getPayableFacts","async":false,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"saveDerived":{"name":"saveDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"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},"deleteDerived":{"name":"deleteDerived","async":true,"parameters":[{"name":"capability","type":"DocumentMoneyWriteCapability","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isDraft":{"name":"isDraft","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSent":{"name":"isSent","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPaid":{"name":"isPaid","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPartial":{"name":"isPartial","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isOverdue":{"name":"isOverdue","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getAmountDue":{"name":"getAmountDue","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true},"getBalance":{"name":"getBalance","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true},"markSent":{"name":"markSent","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"markViewed":{"name":"markViewed","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"updatePaymentStatus":{"name":"updatePaymentStatus","async":false,"parameters":[{"name":"amountPaid","type":"number","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"cancelWithRevenueReversal":{"name":"cancelWithRevenueReversal","async":true,"parameters":[{"name":"options","type":"CancelRevenueOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"writeOff":{"name":"writeOff","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"recognizeRevenue":{"name":"recognizeRevenue","async":true,"parameters":[{"name":"options","type":"RecognizeRevenueOptions","optional":false}],"returnType":"Promise<Journal>","isStatic":false,"isPublic":true},"getArJournal":{"name":"getArJournal","async":true,"parameters":[],"returnType":"Promise<Journal | null>","isStatic":false,"isPublic":true},"toAccountingInput":{"name":"toAccountingInput","async":true,"parameters":[{"name":"options","type":"FrozenInvoiceAccountingOptions","optional":true}],"returnType":"Promise<AccountingInvoiceInput>","isStatic":false,"isPublic":true}},"decoratorConfig":{"display":{"list":["invoiceNumber","customerId","status","totalAmount","issueDate","dueDate"],"label":"invoiceNumber"},"api":{"include":["list","get","create","update"],"writable":["customerId","contractId","invoiceNumber","reference","issueDate","dueDate","currency","lineAmountType","taxRoundingScope","notes","customerNotes","terms","externalId","customerExternalId","externalProvider"]},"mcp":{"include":["list","get"],"serializers":{"get":{"importPath":"@happyvertical/smrt-commerce","exportName":"serializeInvoiceMcpGet"}}},"cli":{"skipApiCheck":true},"indexes":[{"name":"invoice_historical_source_identity","columns":["tenantId","historicalSourceKeyHash"],"unique":true}],"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Invoice","collectionExportName":"InvoiceCollection","displayLabelField":"invoiceNumber","validationRules":[{"field":"creditedAmount","rule":"required","fieldType":"integer"},{"field":"discountTotal","rule":"required","fieldType":"integer"}],"schema":{"tableName":"invoices","ddl":"CREATE TABLE IF NOT EXISTS \\"invoices\\" (\\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 \\"money_authority\\" TEXT DEFAULT 'calculated',\\n \\"historical_sales_money_json\\" TEXT,\\n \\"historical_source_key_hash\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'invoice',\\n \\"credited_invoice_id\\" UUID,\\n \\"credited_amount\\" INTEGER NOT NULL DEFAULT 0,\\n \\"retention_state_json\\" TEXT,\\n \\"retention_accounting_state_json\\" TEXT,\\n \\"ordinary_accounting_state_json\\" TEXT,\\n \\"tenant_id\\" UUID,\\n \\"customer_id\\" UUID,\\n \\"contract_id\\" UUID,\\n \\"invoice_number\\" TEXT DEFAULT '',\\n \\"reference\\" TEXT DEFAULT '',\\n \\"issue_date\\" TIMESTAMP,\\n \\"due_date\\" TIMESTAMP,\\n \\"paid_date\\" TIMESTAMP,\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"tax_amount\\" INTEGER DEFAULT 0,\\n \\"provider_tax_amount\\" INTEGER DEFAULT 0,\\n \\"total_amount\\" INTEGER DEFAULT 0,\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'CAD',\\n \\"line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"discount_total\\" INTEGER NOT NULL DEFAULT 0,\\n \\"seller_tax_registrations_json\\" TEXT,\\n \\"party_tax_id\\" TEXT,\\n \\"money_snapshot_id\\" TEXT,\\n \\"status\\" TEXT,\\n \\"ar_journal_id\\" UUID,\\n \\"ar_reversal_journal_id\\" UUID,\\n \\"revenue_journal_id\\" UUID,\\n \\"external_id\\" TEXT DEFAULT '',\\n \\"customer_external_id\\" TEXT DEFAULT '',\\n \\"external_provider\\" TEXT DEFAULT '',\\n \\"synced_at\\" TIMESTAMP,\\n \\"accounting_sync_state_json\\" TEXT,\\n \\"collection_method\\" TEXT DEFAULT '',\\n \\"sent_at\\" TIMESTAMP,\\n \\"viewed_at\\" TIMESTAMP,\\n \\"reminders_sent\\" INTEGER DEFAULT 0,\\n \\"last_reminder_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"customer_notes\\" TEXT DEFAULT '',\\n \\"terms\\" TEXT DEFAULT ''\\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"},"money_authority":{"type":"TEXT","notNull":false,"unique":false,"default":"calculated"},"historical_sales_money_json":{"type":"TEXT","notNull":false,"unique":false},"historical_source_key_hash":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"invoice"},"credited_invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"credited_amount":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"retention_state_json":{"type":"TEXT","notNull":false,"unique":false},"retention_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"ordinary_accounting_state_json":{"type":"TEXT","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"contract_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"contracts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"invoice_number":{"type":"TEXT","notNull":false,"unique":false,"default":""},"reference":{"type":"TEXT","notNull":false,"unique":false,"default":""},"issue_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"due_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"paid_date":{"type":"TIMESTAMP","notNull":false,"unique":false},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"provider_tax_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"total_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"CAD"},"line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"discount_total":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"seller_tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false},"party_tax_id":{"type":"TEXT","notNull":false,"unique":false},"money_snapshot_id":{"type":"TEXT","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"ar_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"ar_reversal_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"revenue_journal_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"external_provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"synced_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"accounting_sync_state_json":{"type":"TEXT","notNull":false,"unique":false},"collection_method":{"type":"TEXT","notNull":false,"unique":false,"default":""},"sent_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"viewed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"reminders_sent":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_reminder_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"invoices_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"invoice_historical_source_identity","columns":["tenant_id","historical_source_key_hash"],"unique":true},{"name":"invoices_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"invoices_credited_invoice_id_idx","columns":["credited_invoice_id"]},{"name":"invoices_customer_id_idx","columns":["customer_id"]},{"name":"invoices_contract_id_idx","columns":["contract_id"]},{"name":"invoices_ar_journal_id_idx","columns":["ar_journal_id"]},{"name":"invoices_ar_reversal_journal_id_idx","columns":["ar_reversal_journal_id"]},{"name":"invoices_revenue_journal_id_idx","columns":["revenue_journal_id"]}],"version":"20ebe916"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentInstrument":{"name":"paymentinstrument","className":"PaymentInstrument","qualifiedName":"@happyvertical/smrt-commerce:PaymentInstrument","collection":"paymentinstruments","description":"PaymentInstrument stores a reusable payment method a customer has saved with a payment backend (e.g. a card vaulted by Stripe), so it can be charged later without the customer present.","filePath":"src/models/PaymentInstrument.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Customer"},"backendId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"providerCustomerId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"providerPaymentMethodId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"type":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":"card"},"brand":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"last4":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"expMonth":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"expYear":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"isDefault":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":false},"status":{"type":"text","_meta":{"__statedOptions":["enum"]},"required":false,"enum":["active","expired","removed"]}},"methods":{"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isRemoved":{"name":"isRemoved","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markExpired":{"name":"markExpired","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"markRemoved":{"name":"markRemoved","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"],"writable":["customerId","backendId","providerCustomerId","providerPaymentMethodId","type","brand","last4","expMonth","expYear","status"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PaymentInstrument","collectionExportName":"PaymentInstrumentCollection","schema":{"tableName":"payment_instruments","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_instruments\\" (\\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 \\"customer_id\\" UUID,\\n \\"backend_id\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"provider_payment_method_id\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'card',\\n \\"brand\\" TEXT DEFAULT '',\\n \\"last4\\" TEXT DEFAULT '',\\n \\"exp_month\\" INTEGER DEFAULT 0,\\n \\"exp_year\\" INTEGER DEFAULT 0,\\n \\"is_default\\" BOOLEAN DEFAULT FALSE,\\n \\"status\\" 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},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_payment_method_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"card"},"brand":{"type":"TEXT","notNull":false,"unique":false,"default":""},"last4":{"type":"TEXT","notNull":false,"unique":false,"default":""},"exp_month":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"exp_year":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"is_default":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"status":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"payment_instruments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"payment_instruments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"payment_instruments_customer_id_idx","columns":["customer_id"]}],"version":"fcbc59d5"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:PaymentIntent":{"name":"paymentintent","className":"PaymentIntent","qualifiedName":"@happyvertical/smrt-commerce:PaymentIntent","collection":"paymentintents","filePath":"src/models/PaymentIntent.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"skuId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"offeringRef":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"licenseeEmail":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"customerId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"paymentOptions":{"type":"json","_meta":{"__statedOptions":["default"]},"required":false,"default":[]},"usdPriceLocked":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"priceLockWindowMs":{"type":"integer","_meta":{"__statedOptions":[]},"required":false},"priceLockExpiresAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"status":{"type":"text","_meta":{"__statedOptions":["enum"]},"required":false,"enum":["awaiting_payment","paid","issued","retired","expired","cancelled"]},"idempotencyKey":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"paidOptionBackendId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"paymentId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"paidAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"issuedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"expiredAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"cancelledAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"retiredAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"notes":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"connectedAccountId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"connectedFeePolicyRef":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"applicationFeeCents":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"connectedEnvironment":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"connectedAmount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"connectedCurrency":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isAwaitingPayment":{"name":"isAwaitingPayment","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPaid":{"name":"isPaid","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isIssued":{"name":"isIssued","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isCancelled":{"name":"isCancelled","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isRetired":{"name":"isRetired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isTerminal":{"name":"isTerminal","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isExpired":{"name":"isExpired","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"markPaid":{"name":"markPaid","async":false,"parameters":[{"name":"args","type":"object","optional":false,"memberTypes":["string"]}],"returnType":"void","isStatic":false,"isPublic":true},"verifyAndMarkPaid":{"name":"verifyAndMarkPaid","async":true,"parameters":[{"name":"args","type":"object","optional":false,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markIssued":{"name":"markIssued","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"expire":{"name":"expire","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true},"cancel":{"name":"cancel","async":false,"parameters":[{"name":"reason","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"retire":{"name":"retire","async":false,"parameters":[{"name":"reason","type":"string","optional":true}],"returnType":"void","isStatic":false,"isPublic":true},"getOption":{"name":"getOption","async":false,"parameters":[{"name":"backendId","type":"string","optional":false}],"returnType":"PaymentOption | undefined","isStatic":false,"isPublic":true},"isOptionRetired":{"name":"isOptionRetired","async":false,"parameters":[{"name":"backendId","type":"string","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true},"getRetiredOptions":{"name":"getRetiredOptions","async":false,"parameters":[],"returnType":"PaymentOption[]","isStatic":false,"isPublic":true}},"decoratorConfig":{"conflictColumns":["tenant_id","offering_ref","licensee_email","idempotency_key"],"api":{"include":["list","get","create","update"],"writable":["skuId","offeringRef","licenseeEmail","customerId","paymentOptions","usdPriceLocked","priceLockWindowMs","idempotencyKey","notes"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"}},"extends":"SmrtObject","exportName":"PaymentIntent","collectionExportName":"PaymentIntentCollection","schema":{"tableName":"payment_intents","ddl":"CREATE TABLE IF NOT EXISTS \\"payment_intents\\" (\\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 \\"sku_id\\" TEXT DEFAULT '',\\n \\"offering_ref\\" TEXT DEFAULT '',\\n \\"licensee_email\\" TEXT DEFAULT '',\\n \\"customer_id\\" TEXT DEFAULT '',\\n \\"payment_options\\" JSON DEFAULT '[]',\\n \\"usd_price_locked\\" INTEGER DEFAULT 0,\\n \\"price_lock_window_ms\\" INTEGER,\\n \\"price_lock_expires_at\\" TIMESTAMP,\\n \\"status\\" TEXT,\\n \\"idempotency_key\\" TEXT DEFAULT '',\\n \\"paid_option_backend_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"paid_at\\" TIMESTAMP,\\n \\"issued_at\\" TIMESTAMP,\\n \\"expired_at\\" TIMESTAMP,\\n \\"cancelled_at\\" TIMESTAMP,\\n \\"retired_at\\" TIMESTAMP,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"connected_account_id\\" TEXT DEFAULT '',\\n \\"connected_fee_policy_ref\\" TEXT DEFAULT '',\\n \\"application_fee_cents\\" INTEGER DEFAULT 0,\\n \\"connected_environment\\" TEXT DEFAULT '',\\n \\"connected_amount\\" INTEGER DEFAULT 0,\\n \\"connected_currency\\" TEXT DEFAULT ''\\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},"sku_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"offering_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"licensee_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_options":{"type":"JSON","notNull":false,"unique":false,"default":[]},"usd_price_locked":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_lock_window_ms":{"type":"INTEGER","notNull":false,"unique":false},"price_lock_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"status":{"type":"TEXT","notNull":false,"unique":false},"idempotency_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_option_backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"paid_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"expired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancelled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"retired_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_cents":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_environment":{"type":"TEXT","notNull":false,"unique":false,"default":""},"connected_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"connected_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"payment_intents_tenant_id_offering_ref_idx","columns":["tenant_id","offering_ref","licensee_email","idempotency_key"],"unique":true,"nullsNotDistinct":true},{"name":"payment_intents_slug_context_idx","columns":["slug","context"]},{"name":"payment_intents_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"92f80d93"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxCode":{"name":"taxcode","className":"TaxCode","qualifiedName":"@happyvertical/smrt-commerce:TaxCode","collection":"taxcodes","description":"A reusable tax code whose ordered component list is safe to edit.","filePath":"src/models/TaxCode.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"code":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A stable short code, for example gst-pst-bc."},"required":false,"description":"A stable short code, for example gst-pst-bc."},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The name people see for this tax code."},"required":false,"description":"The name people see for this tax code."},"kind":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"How the tax code is reported."},"required":false,"default":"taxable","description":"How the tax code is reported.","enum":["taxable","zero-rated","exempt","out-of-scope"]},"appliesTo":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether the code applies to sales, purchases or both."},"required":false,"default":"both","description":"Whether the code applies to sales, purchases or both.","enum":["sales","purchases","both"]},"componentsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"active":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether users may select this code for new documents."},"required":true,"default":true,"description":"Whether users may select this code for new documents."}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"conflictColumns":["tenant_id","code"],"api":{"include":["list","get","create","update"],"writable":["code","name","kind","appliesTo","components","active"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"TaxCode","collectionExportName":"TaxCodeCollection","displayLabelField":"name","validationRules":[{"field":"active","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"tax_codes","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_codes\\" (\\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 \\"code\\" TEXT,\\n \\"name\\" TEXT,\\n \\"kind\\" TEXT DEFAULT 'taxable',\\n \\"applies_to\\" TEXT DEFAULT 'both',\\n \\"components_json\\" TEXT,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"code":{"type":"TEXT","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"taxable"},"applies_to":{"type":"TEXT","notNull":false,"unique":false,"default":"both"},"components_json":{"type":"TEXT","notNull":false,"unique":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_codes_tenant_id_code_idx","columns":["tenant_id","code"],"unique":true,"nullsNotDistinct":true},{"name":"tax_codes_slug_context_idx","columns":["slug","context"]},{"name":"tax_codes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"583dc2f0"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxComponent":{"name":"taxcomponent","className":"TaxComponent","qualifiedName":"@happyvertical/smrt-commerce:TaxComponent","collection":"taxcomponents","description":"One reusable tax rate component.","filePath":"src/models/TaxComponent.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The name of this tax component, for example GST."},"required":false,"description":"The name of this tax component, for example GST."},"percent":{"type":"decimal","_meta":{"__statedOptions":["description"],"description":"The tax percentage, for example 7.125 for 7.125 percent."},"required":false,"description":"The tax percentage, for example 7.125 for 7.125 percent."},"liabilityAccountId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The liability account that receives this tax component."},"required":false,"related":"@happyvertical/smrt-ledgers:Account","description":"The liability account that receives this tax component."},"recoverable":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether purchases using this component may recover the full input tax. Partial recovery is not supported."},"required":true,"default":false,"description":"Whether purchases using this component may recover the full input tax. Partial recovery is not supported."},"active":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether new tax codes and overrides may select it."},"required":true,"default":true,"description":"Whether new tax codes and overrides may select it."}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"],"writable":["name","percent","liabilityAccountId","recoverable","active"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TaxComponent","collectionExportName":"TaxComponentCollection","displayLabelField":"name","validationRules":[{"field":"recoverable","rule":"required","fieldType":"boolean"},{"field":"active","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"tax_components","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_components\\" (\\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 \\"name\\" TEXT,\\n \\"percent\\" REAL,\\n \\"liability_account_id\\" UUID,\\n \\"recoverable\\" BOOLEAN NOT NULL DEFAULT FALSE,\\n \\"active\\" BOOLEAN NOT NULL DEFAULT TRUE\\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},"name":{"type":"TEXT","notNull":false,"unique":false},"percent":{"type":"REAL","notNull":false,"unique":false},"liability_account_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recoverable":{"type":"BOOLEAN","notNull":true,"unique":false,"default":false},"active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"tax_components_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tax_components_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_components_liability_account_id_idx","columns":["liability_account_id"]}],"version":"79db2a87"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSettings":{"name":"taxsettings","className":"TaxSettings","qualifiedName":"@happyvertical/smrt-commerce:TaxSettings","collection":"taxsettingses","description":"Tenant-level defaults and registration numbers for tax determination.","filePath":"src/models/TaxSettings.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"defaultSalesTaxCodeId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The default tax code for sales documents."},"required":false,"related":"TaxCode","description":"The default tax code for sales documents."},"defaultPurchaseTaxCodeId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The default tax code for purchase documents."},"required":false,"related":"TaxCode","description":"The default tax code for purchase documents."},"defaultLineAmountType":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether new document amounts are exclusive, inclusive or out of scope."},"required":false,"default":"exclusive","description":"Whether new document amounts are exclusive, inclusive or out of scope.","enum":["exclusive","inclusive","none"]},"taxRoundingScope":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"Whether components round per line or per document."},"required":false,"default":"line","description":"Whether components round per line or per document.","enum":["line","document"]},"taxRegistrationsJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true}},"decoratorConfig":{"conflictColumns":["tenant_id"],"api":{"include":["get","create","update"],"writable":["defaultSalesTaxCodeId","defaultPurchaseTaxCodeId","defaultLineAmountType","taxRoundingScope","taxRegistrations"]},"mcp":{"include":["get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"TaxSettings","collectionExportName":"TaxSettingsCollection","validationRules":[],"schema":{"tableName":"tax_settings","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_settings\\" (\\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 \\"default_sales_tax_code_id\\" UUID,\\n \\"default_purchase_tax_code_id\\" UUID,\\n \\"default_line_amount_type\\" TEXT DEFAULT 'exclusive',\\n \\"tax_rounding_scope\\" TEXT DEFAULT 'line',\\n \\"tax_registrations_json\\" 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},"default_sales_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_purchase_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_line_amount_type":{"type":"TEXT","notNull":false,"unique":false,"default":"exclusive"},"tax_rounding_scope":{"type":"TEXT","notNull":false,"unique":false,"default":"line"},"tax_registrations_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_settings_tenant_id_idx","columns":["tenant_id"],"unique":true},{"name":"tax_settings_slug_context_idx","columns":["slug","context"]},{"name":"tax_settings_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tax_settings_default_sales_tax_code_id_idx","columns":["default_sales_tax_code_id"]},{"name":"tax_settings_default_purchase_tax_code_id_idx","columns":["default_purchase_tax_code_id"]}],"version":"e8ebb46e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TaxSummaryReport":{"name":"taxsummaryreport","className":"TaxSummaryReport","qualifiedName":"@happyvertical/smrt-commerce:TaxSummaryReport","collection":"taxsummaryreports","filePath":"src/models/TaxSummaryReport.ts","packageName":"@happyvertical/smrt-commerce","fields":{"refreshedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"periodFrom":{"type":"datetime","_meta":{"__report":{"kind":"group","sourceColumn":"issueDate"},"__statedOptions":["description","__report"],"description":"The inclusive start of this report period."},"required":false,"description":"The inclusive start of this report period."},"periodTo":{"type":"datetime","_meta":{"__report":{"kind":"group","sourceColumn":"issueDate"},"__statedOptions":["description","__report"],"description":"The inclusive end of this report period."},"required":false,"description":"The inclusive end of this report period."},"currency":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"currency"},"__statedOptions":["description","__report"],"description":"The currency group; report rows never mix currencies."},"required":false,"description":"The currency group; report rows never mix currencies."},"rowKind":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"kind"},"__statedOptions":["description","__report","default","enum"],"description":"The materialized tax-summary row category."},"required":false,"default":"component","description":"The materialized tax-summary row category.","enum":["component","kind","reconciliation","warning"]},"dimensionKey":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"taxCodeId"},"__statedOptions":["description","__report"],"description":"The stable dimension identity inside this report row."},"required":false,"description":"The stable dimension identity inside this report row."},"direction":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"documentType"},"__statedOptions":["description","__report"],"description":"Sales, purchase, expense or reconciliation direction."},"required":false,"description":"Sales, purchase, expense or reconciliation direction."},"taxComponentId":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"taxComponentId"},"__statedOptions":["nullable","description","__report","required"],"description":"Tenant tax component snapshot identity.","nullable":true,"required":false},"required":false,"description":"Tenant tax component snapshot identity."},"taxCodeKind":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"kind"},"__statedOptions":["nullable","description","__report","required"],"description":"Stored tax-code kind snapshot.","nullable":true,"required":false},"required":false,"description":"Stored tax-code kind snapshot."},"liabilityAccountId":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"liabilityAccountId"},"__statedOptions":["nullable","description","__report","required"],"description":"Liability account used for reconciliation.","nullable":true,"required":false},"required":false,"description":"Liability account used for reconciliation."},"taxableMinor":{"type":"integer","_meta":{"__report":{"kind":"group","sourceColumn":"taxableMinor"},"__statedOptions":["description","__report","default"],"description":"Stored taxable base in integer minor units."},"required":true,"default":0,"description":"Stored taxable base in integer minor units."},"taxMinor":{"type":"integer","_meta":{"__report":{"kind":"group","sourceColumn":"taxMinor"},"__statedOptions":["description","__report","default"],"description":"Collected tax or reconciliation tax amount in integer minor units."},"required":true,"default":0,"description":"Collected tax or reconciliation tax amount in integer minor units."},"recoverableMinor":{"type":"integer","_meta":{"__report":{"kind":"group","sourceColumn":"recoverableMinor"},"__statedOptions":["nullable","description","__report","required"],"description":"Recoverable tax in integer minor units, or null when incomplete.","nullable":true,"required":false},"required":false,"description":"Recoverable tax in integer minor units, or null when incomplete."},"ledgerMovementMinor":{"type":"integer","_meta":{"__report":{"kind":"group","sourceColumn":"ledgerMovementMinor"},"__statedOptions":["nullable","description","__report","required"],"description":"Posted ledger movement in raw commerce minor units.","nullable":true,"required":false},"required":false,"description":"Posted ledger movement in raw commerce minor units."},"netTaxMinor":{"type":"integer","_meta":{"__report":{"kind":"group","sourceColumn":"taxMinor"},"__statedOptions":["nullable","description","__report","required"],"description":"Collected less recoverable tax in integer minor units.","nullable":true,"required":false},"required":false,"description":"Collected less recoverable tax in integer minor units."},"differenceMinor":{"type":"integer","_meta":{"__report":{"kind":"group","sourceColumn":"differenceMinor"},"__statedOptions":["nullable","description","__report","required"],"description":"Ledger movement minus collected tax.","nullable":true,"required":false},"required":false,"description":"Ledger movement minus collected tax."},"documentCount":{"type":"integer","_meta":{"__report":{"kind":"group","sourceColumn":"documentCount"},"__statedOptions":["description","__report","default"],"description":"Distinct stored document count."},"required":true,"default":0,"description":"Distinct stored document count."},"sourceScopes":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"sourceScopes"},"__statedOptions":["description","__report"],"description":"Comma-separated source classes used to reproduce this row drilldown."},"required":false,"description":"Comma-separated source classes used to reproduce this row drilldown."},"complete":{"type":"boolean","_meta":{"__report":{"kind":"group","sourceColumn":"complete"},"__statedOptions":["description","__report","default"],"description":"Whether this row belongs to a complete tax-summary result."},"required":true,"default":true,"description":"Whether this row belongs to a complete tax-summary result."},"warningCode":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"taxCodeCode"},"__statedOptions":["nullable","description","__report","required"],"description":"Incomplete-source warning code.","nullable":true,"required":false},"required":false,"description":"Incomplete-source warning code."},"warningSourceType":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"warningSourceType"},"__statedOptions":["nullable","description","__report","required"],"description":"Warning source category.","nullable":true,"required":false},"required":false,"description":"Warning source category."},"warningSourceId":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"warningSourceId"},"__statedOptions":["nullable","description","__report","required"],"description":"Warning source identity.","nullable":true,"required":false},"required":false,"description":"Warning source identity."},"warningMessage":{"type":"text","_meta":{"__report":{"kind":"group","sourceColumn":"taxComponentName"},"__statedOptions":["nullable","description","__report","required"],"description":"Operator-facing incomplete-source warning.","nullable":true,"required":false},"required":false,"description":"Operator-facing incomplete-source warning."}},"methods":{"isStale":{"name":"isStale","async":false,"parameters":[{"name":"ttlMs","type":"number","optional":true}],"returnType":"boolean","isStatic":false,"isPublic":true},"refresh":{"name":"refresh","async":true,"parameters":[{"name":"options","type":"Omit<ReportRefreshOptions, 'db'>","optional":true}],"returnType":"Promise<ReportRefreshResult>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tax_summary_reports","conflictColumns":["tenant_id","period_from","period_to","currency","row_kind","dimension_key"],"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"report":{"source":"DocumentTax","refresh":{"manual":true,"mode":"rebuild"}},"tenantScoped":{"mode":"required"}},"extends":"SmrtReport","exportName":"TaxSummaryReport","collectionExportName":"TaxSummaryReportCollection","validationRules":[{"field":"taxableMinor","rule":"required","fieldType":"integer"},{"field":"taxMinor","rule":"required","fieldType":"integer"},{"field":"documentCount","rule":"required","fieldType":"integer"},{"field":"complete","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"tax_summary_reports","ddl":"CREATE TABLE IF NOT EXISTS \\"tax_summary_reports\\" (\\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 \\"refreshed_at\\" TIMESTAMP,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"period_from\\" TIMESTAMP,\\n \\"period_to\\" TIMESTAMP,\\n \\"currency\\" TEXT,\\n \\"row_kind\\" TEXT DEFAULT 'component',\\n \\"dimension_key\\" TEXT,\\n \\"direction\\" TEXT,\\n \\"tax_component_id\\" TEXT,\\n \\"tax_code_kind\\" TEXT,\\n \\"liability_account_id\\" TEXT,\\n \\"taxable_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"tax_minor\\" INTEGER NOT NULL DEFAULT 0,\\n \\"recoverable_minor\\" INTEGER,\\n \\"ledger_movement_minor\\" INTEGER,\\n \\"net_tax_minor\\" INTEGER,\\n \\"difference_minor\\" INTEGER,\\n \\"document_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"source_scopes\\" TEXT,\\n \\"complete\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"warning_code\\" TEXT,\\n \\"warning_source_type\\" TEXT,\\n \\"warning_source_id\\" TEXT,\\n \\"warning_message\\" 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"},"refreshed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"period_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false},"row_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"component"},"dimension_key":{"type":"TEXT","notNull":false,"unique":false},"direction":{"type":"TEXT","notNull":false,"unique":false},"tax_component_id":{"type":"TEXT","notNull":false,"unique":false},"tax_code_kind":{"type":"TEXT","notNull":false,"unique":false},"liability_account_id":{"type":"TEXT","notNull":false,"unique":false},"taxable_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"tax_minor":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"recoverable_minor":{"type":"INTEGER","notNull":false,"unique":false},"ledger_movement_minor":{"type":"INTEGER","notNull":false,"unique":false},"net_tax_minor":{"type":"INTEGER","notNull":false,"unique":false},"difference_minor":{"type":"INTEGER","notNull":false,"unique":false},"document_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"source_scopes":{"type":"TEXT","notNull":false,"unique":false},"complete":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"warning_code":{"type":"TEXT","notNull":false,"unique":false},"warning_source_type":{"type":"TEXT","notNull":false,"unique":false},"warning_source_id":{"type":"TEXT","notNull":false,"unique":false},"warning_message":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tax_summary_reports_tenant_id_period_from_idx","columns":["tenant_id","period_from","period_to","currency","row_kind","dimension_key"],"unique":true,"nullsNotDistinct":true},{"name":"tax_summary_reports_slug_context_idx","columns":["slug","context"]},{"name":"tax_summary_reports_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"d4d5ebbe"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentAccount":{"name":"tenantpaymentaccount","className":"TenantPaymentAccount","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentAccount","collection":"tenantpaymentaccounts","description":"A tenant's connected payment account for one backend and environment.","filePath":"src/models/TenantPaymentAccount.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"backendId":{"type":"text","_meta":{"__statedOptions":["required","default"],"required":true},"required":true,"default":"stripe"},"environment":{"type":"text","_meta":{"__statedOptions":["required","default","enum"],"required":true},"required":true,"default":"test","enum":["test","live"]},"providerAccountId":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"identity"},"required":true,"default":""},"status":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"pending","enum":["pending","restricted","enabled","disabled"]},"chargesEnabled":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":false},"detailsSubmitted":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":false},"payoutsEnabled":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":false},"capabilitiesJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"capabilitiesObservedAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"feePolicyRef":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"disabledAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"disabledReason":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""}},"methods":{"isEnabled":{"name":"isEnabled","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getCapabilities":{"name":"getCapabilities","async":false,"parameters":[],"returnType":"TenantPaymentCapabilitySnapshot | null","isStatic":false,"isPublic":true},"setCapabilities":{"name":"setCapabilities","async":false,"parameters":[{"name":"snapshot","type":"TenantPaymentCapabilitySnapshot","optional":false},{"name":"observedAt","type":"Date","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"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":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tenant_payment_accounts","indexes":[{"name":"tenant_payment_accounts_tenant_backend_environment","columns":["tenantId","backendId","environment"],"unique":true},{"name":"tenant_payment_accounts_provider_account","columns":["backendId","environment","providerAccountId"],"unique":true}],"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get","isEnabled","getCapabilities"],"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantPaymentAccount","collectionExportName":"TenantPaymentAccountCollection","validationRules":[{"field":"backendId","rule":"required","fieldType":"text"},{"field":"environment","rule":"required","fieldType":"text"},{"field":"providerAccountId","rule":"required","fieldType":"text"}],"schema":{"tableName":"tenant_payment_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_accounts\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT 'stripe',\\n \\"environment\\" TEXT NOT NULL DEFAULT 'test',\\n \\"provider_account_id\\" TEXT NOT NULL DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'pending',\\n \\"charges_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"details_submitted\\" BOOLEAN DEFAULT FALSE,\\n \\"payouts_enabled\\" BOOLEAN DEFAULT FALSE,\\n \\"capabilities_json\\" TEXT,\\n \\"capabilities_observed_at\\" TIMESTAMP,\\n \\"fee_policy_ref\\" TEXT DEFAULT '',\\n \\"disabled_at\\" TIMESTAMP,\\n \\"disabled_reason\\" TEXT DEFAULT ''\\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},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":"stripe"},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"pending"},"charges_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"details_submitted":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"payouts_enabled":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"capabilities_json":{"type":"TEXT","notNull":false,"unique":false},"capabilities_observed_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"fee_policy_ref":{"type":"TEXT","notNull":false,"unique":false,"default":""},"disabled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"disabled_reason":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"tenant_payment_accounts_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_accounts_tenant_backend_environment","columns":["tenant_id","backend_id","environment"],"unique":true},{"name":"tenant_payment_accounts_provider_account","columns":["backend_id","environment","provider_account_id"],"unique":true},{"name":"tenant_payment_accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"ea6f5edc"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentDispute":{"name":"tenantpaymentdispute","className":"TenantPaymentDispute","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentDispute","collection":"tenantpaymentdisputes","description":"One authoritative dispute snapshot and its immutable balance evidence.","filePath":"src/models/TenantPaymentDispute.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"backendId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"environment":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"test","enum":["test","live"]},"providerAccountId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"disputeId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"paymentId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Payment"},"status":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":"unknown"},"snapshotJson":{"type":"text","_meta":{"__statedOptions":[]},"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":[{"name":"_options","type":"SmrtDeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"tenant_payment_disputes","api":false,"cli":false,"mcp":false,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantPaymentDispute","collectionExportName":"TenantPaymentDisputeCollection","validationRules":[],"schema":{"tableName":"tenant_payment_disputes","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_disputes\\" (\\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 \\"backend_id\\" TEXT DEFAULT '',\\n \\"environment\\" TEXT DEFAULT 'test',\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"dispute_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'unknown',\\n \\"snapshot_json\\" 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},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":false,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dispute_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"unknown"},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tenant_payment_disputes_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_disputes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tenant_payment_disputes_payment_id_idx","columns":["payment_id"]}],"version":"fd77af5e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentDisputeCollection":{"name":"tenantpaymentdisputecollection","className":"TenantPaymentDisputeCollection","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentDisputeCollection","collection":"tenantpaymentdisputes","filePath":"src/models/TenantPaymentDispute.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"tenant_payment_disputes","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"TenantPaymentDispute","exportName":"TenantPaymentDisputeCollection","collectionExportName":"TenantPaymentDisputeCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TenantPaymentDispute","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"tenant_payment_disputes","ddl":"CREATE TABLE IF NOT EXISTS \\"tenant_payment_disputes\\" (\\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 \\"backend_id\\" TEXT DEFAULT '',\\n \\"environment\\" TEXT DEFAULT 'test',\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"dispute_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'unknown',\\n \\"snapshot_json\\" 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},"backend_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":false,"unique":false,"default":"test"},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dispute_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"payments","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"unknown"},"snapshot_json":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"tenant_payment_disputes_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"tenant_payment_disputes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"tenant_payment_disputes_payment_id_idx","columns":["payment_id"]}],"version":"fd77af5e"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentWebhookEvent":{"name":"tenantpaymentwebhookevent","className":"TenantPaymentWebhookEvent","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentWebhookEvent","collection":"tenantpaymentwebhookevents","description":"One processed provider webhook event.","filePath":"src/models/TenantPaymentWebhookEvent.ts","packageName":"@happyvertical/smrt-commerce","fields":{"backendId":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"idempotency"},"required":true,"default":""},"environment":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"idempotency"},"required":true,"default":""},"eventId":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"idempotency"},"required":true,"default":""},"eventType":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"endpoint":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"tenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","required","related"],"required":false,"nullable":true},"required":false,"related":"@happyvertical/smrt-users:Tenant"},"providerAccountId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"outcome":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"ignored","enum":["settled","already_settled","pending","account_updated","stale_account_update","application_fee","refund_reported","refund_updated","dispute_updated","dispute_reported","late_payment","ignored"]},"paymentIntentId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"paymentId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"applicationFeeJson":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"processedAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false}},"methods":{},"decoratorConfig":{"tableName":"_smrt_tenant_payment_webhook_events","indexes":[{"name":"_smrt_tenant_payment_webhook_events_event","columns":["backendId","environment","eventId"],"unique":true}],"api":false,"cli":false,"mcp":false,"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantPaymentWebhookEvent","collectionExportName":"TenantPaymentWebhookEventCollection","validationRules":[{"field":"backendId","rule":"required","fieldType":"text"},{"field":"environment","rule":"required","fieldType":"text"},{"field":"eventId","rule":"required","fieldType":"text"}],"schema":{"tableName":"_smrt_tenant_payment_webhook_events","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_payment_webhook_events\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT '',\\n \\"environment\\" TEXT NOT NULL DEFAULT '',\\n \\"event_id\\" TEXT NOT NULL DEFAULT '',\\n \\"event_type\\" TEXT DEFAULT '',\\n \\"endpoint\\" TEXT DEFAULT '',\\n \\"tenant_id\\" UUID,\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"outcome\\" TEXT DEFAULT 'ignored',\\n \\"payment_intent_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"application_fee_json\\" TEXT,\\n \\"processed_at\\" TIMESTAMP\\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"},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"endpoint":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"outcome":{"type":"TEXT","notNull":false,"unique":false,"default":"ignored"},"payment_intent_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_json":{"type":"TEXT","notNull":false,"unique":false},"processed_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_tenant_payment_webhook_events_tenant_id_slug_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_tenant_payment_webhook_events_event","columns":["backend_id","environment","event_id"],"unique":true},{"name":"_smrt_tenant_payment_webhook_events_created_at_idx","columns":["created_at"]}],"version":"419c8625"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:TenantPaymentWebhookEventCollection":{"name":"tenantpaymentwebhookeventcollection","className":"TenantPaymentWebhookEventCollection","qualifiedName":"@happyvertical/smrt-commerce:TenantPaymentWebhookEventCollection","collection":"tenantpaymentwebhookevents","filePath":"src/models/TenantPaymentWebhookEvent.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{"build":{"name":"build","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<TenantPaymentWebhookEvent>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_payment_webhook_events","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"TenantPaymentWebhookEvent","exportName":"TenantPaymentWebhookEventCollection","collectionExportName":"TenantPaymentWebhookEventCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:TenantPaymentWebhookEvent","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_tenant_payment_webhook_events","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_payment_webhook_events\\" (\\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 \\"backend_id\\" TEXT NOT NULL DEFAULT '',\\n \\"environment\\" TEXT NOT NULL DEFAULT '',\\n \\"event_id\\" TEXT NOT NULL DEFAULT '',\\n \\"event_type\\" TEXT DEFAULT '',\\n \\"endpoint\\" TEXT DEFAULT '',\\n \\"tenant_id\\" UUID,\\n \\"provider_account_id\\" TEXT DEFAULT '',\\n \\"outcome\\" TEXT DEFAULT 'ignored',\\n \\"payment_intent_id\\" TEXT DEFAULT '',\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"application_fee_json\\" TEXT,\\n \\"processed_at\\" TIMESTAMP\\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"},"backend_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"environment":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"event_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"endpoint":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"provider_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"outcome":{"type":"TEXT","notNull":false,"unique":false,"default":"ignored"},"payment_intent_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"application_fee_json":{"type":"TEXT","notNull":false,"unique":false},"processed_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_tenant_payment_webhook_events_tenant_id_slug_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_tenant_payment_webhook_events_event","columns":["backend_id","environment","event_id"],"unique":true},{"name":"_smrt_tenant_payment_webhook_events_created_at_idx","columns":["created_at"]}],"version":"419c8625"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:Vendor":{"name":"vendor","className":"Vendor","qualifiedName":"@happyvertical/smrt-commerce:Vendor","collection":"vendors","description":"Vendor represents the vendor/supplier role for a Profile.","filePath":"src/models/Vendor.ts","packageName":"@happyvertical/smrt-commerce","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"profileId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"Links this vendor to their profile record, where their name and contact details are kept."},"required":false,"related":"@happyvertical/smrt-profiles:Profile","description":"Links this vendor to their profile record, where their name and contact details are kept."},"leadTimeDays":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"How many days the vendor usually takes between your order and delivery."},"required":false,"default":0,"description":"How many days the vendor usually takes between your order and delivery."},"minimumOrderAmount":{"type":"integer","_meta":{"__statedOptions":["description","ui","default"],"description":"The smallest order the vendor will accept.","ui":{"format":"money"}},"required":false,"default":0,"description":"The smallest order the vendor will accept."},"paymentTerms":{"type":"text","_meta":{"__statedOptions":["description","default"],"description":"How long you have to pay this vendor, written the way you would say it, for example \\"Net 30\\"."},"required":false,"default":"","description":"How long you have to pay this vendor, written the way you would say it, for example \\"Net 30\\"."},"currency":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The currency this vendor bills you in.","ui":{"widget":"currency"}},"required":false,"default":"USD","description":"The currency this vendor bills you in."},"taxId":{"type":"text","_meta":{"__statedOptions":["sensitive","description","default"],"description":"The vendor tax or VAT registration number kept on file.","sensitive":true},"required":false,"default":"","description":"The vendor tax or VAT registration number kept on file.","sensitive":true},"defaultTaxCodeId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The tax code normally used when buying from this vendor."},"required":false,"related":"TaxCode","description":"The tax code normally used when buying from this vendor."},"defaultContactEmail":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The email address you normally use to reach this vendor.","ui":{"widget":"email"}},"required":false,"default":"","description":"The email address you normally use to reach this vendor."},"defaultContactPhone":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"The phone number you normally use to reach this vendor.","ui":{"widget":"phone"}},"required":false,"default":"","description":"The phone number you normally use to reach this vendor."},"status":{"type":"text","_meta":{"__statedOptions":["description","enum"],"description":"Whether you still buy from this vendor: active, inactive or suspended."},"required":false,"description":"Whether you still buy from this vendor: active, inactive or suspended.","enum":["active","inactive","suspended"]},"notes":{"type":"text","_meta":{"__statedOptions":["description","ui","default"],"description":"Anything worth remembering about this vendor.","ui":{"widget":"textarea"}},"required":false,"default":"","description":"Anything worth remembering about this vendor."},"payoutAddresses":{"type":"json","_meta":{"__statedOptions":["sensitive","description","default"],"description":"Where payments to this vendor should be sent.","sensitive":true},"required":false,"default":{},"description":"Where payments to this vendor should be sent.","sensitive":true},"contacts":{"type":"json","_meta":{"__statedOptions":["description","default"],"description":"The people you deal with at this vendor, with their role and how to reach them."},"required":false,"default":[],"description":"The people you deal with at this vendor, with their role and how to reach them."}},"methods":{"initialize":{"name":"initialize","async":true,"parameters":[],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"meetsMinimumOrder":{"name":"meetsMinimumOrder","async":false,"parameters":[{"name":"amount","type":"number","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true},"getProfileId":{"name":"getProfileId","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true},"getPayoutAddress":{"name":"getPayoutAddress","async":false,"parameters":[{"name":"currency","type":"string","optional":false}],"returnType":"string | undefined","isStatic":false,"isPublic":true},"setPayoutAddress":{"name":"setPayoutAddress","async":false,"parameters":[{"name":"currency","type":"string","optional":false},{"name":"destination","type":"string","optional":false}],"returnType":"this","isStatic":false,"isPublic":true},"clearPayoutAddress":{"name":"clearPayoutAddress","async":false,"parameters":[{"name":"currency","type":"string","optional":false}],"returnType":"this","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Vendor","collectionExportName":"VendorCollection","schema":{"tableName":"vendors","ddl":"CREATE TABLE IF NOT EXISTS \\"vendors\\" (\\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 \\"profile_id\\" UUID,\\n \\"lead_time_days\\" INTEGER DEFAULT 0,\\n \\"minimum_order_amount\\" INTEGER DEFAULT 0,\\n \\"payment_terms\\" TEXT DEFAULT '',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"tax_id\\" TEXT DEFAULT '',\\n \\"default_tax_code_id\\" UUID,\\n \\"default_contact_email\\" TEXT DEFAULT '',\\n \\"default_contact_phone\\" TEXT DEFAULT '',\\n \\"status\\" TEXT,\\n \\"notes\\" TEXT DEFAULT '',\\n \\"payout_addresses\\" JSON DEFAULT '{}',\\n \\"contacts\\" JSON DEFAULT '[]'\\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},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"lead_time_days":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"minimum_order_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms":{"type":"TEXT","notNull":false,"unique":false,"default":""},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"tax_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_tax_code_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"tax_codes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"default_contact_email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"default_contact_phone":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false},"notes":{"type":"TEXT","notNull":false,"unique":false,"default":""},"payout_addresses":{"type":"JSON","notNull":false,"unique":false,"default":{}},"contacts":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"vendors_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"vendors_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"vendors_profile_id_idx","columns":["profile_id"]},{"name":"vendors_default_tax_code_id_idx","columns":["default_tax_code_id"]}],"version":"6cac701f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingAccount":{"name":"billingaccount","className":"BillingAccount","qualifiedName":"@happyvertical/smrt-commerce:BillingAccount","collection":"billingaccounts","description":"One payer's account with one seller: the commerce Customer invoices are issued to, the provider customer they are pushed to, and the payer's billing terms.","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"identity"},"required":true,"related":"@happyvertical/smrt-users:Tenant"},"payerTenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"identity"},"required":true,"related":"@happyvertical/smrt-users:Tenant"},"customerId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Customer"},"name":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"email":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"provider":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"providerCustomerId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"automaticTax":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":true},"flatDiscountBasisPoints":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"paymentTermsDays":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":30},"standing":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"current","enum":["current","past_due","uncollectible"]},"billingAnchorAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"prorateFlatPlans":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":false}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_accounts","conflictColumns":["seller_tenant_id","payer_tenant_id"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingAccount","collectionExportName":"BillingAccountCollection","displayLabelField":"name","validationRules":[{"field":"sellerTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"payerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_billing_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_accounts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"customer_id\\" UUID,\\n \\"name\\" TEXT DEFAULT '',\\n \\"email\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"automatic_tax\\" BOOLEAN DEFAULT TRUE,\\n \\"flat_discount_basis_points\\" INTEGER DEFAULT 0,\\n \\"payment_terms_days\\" INTEGER DEFAULT 30,\\n \\"standing\\" TEXT DEFAULT 'current',\\n \\"billing_anchor_at\\" TIMESTAMP,\\n \\"prorate_flat_plans\\" BOOLEAN DEFAULT FALSE\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"automatic_tax":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"flat_discount_basis_points":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms_days":{"type":"INTEGER","notNull":false,"unique":false,"default":30},"standing":{"type":"TEXT","notNull":false,"unique":false,"default":"current"},"billing_anchor_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"prorate_flat_plans":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"_smrt_billing_accounts_seller_tenant_id_payer_tenant_id_idx","columns":["seller_tenant_id","payer_tenant_id"],"unique":true},{"name":"_smrt_billing_accounts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_accounts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_accounts_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_accounts_customer_id_idx","columns":["customer_id"]}],"version":"01922629"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPeriodClose":{"name":"billingperiodclose","className":"BillingPeriodClose","qualifiedName":"@happyvertical/smrt-commerce:BillingPeriodClose","collection":"billingperiodcloses","description":"The idempotency anchor for one payer's invoice in one currency for one period. Its id is derived from that identity, so a retried close always resumes the same row, invoice, and provider invoice.","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"tenant-scope"},"required":true,"related":"@happyvertical/smrt-users:Tenant"},"kind":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"provider","enum":["provider","reseller"]},"payerTenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"tenant-scope"},"required":true,"related":"@happyvertical/smrt-users:Tenant"},"currency":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":"USD"},"periodStart":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"periodEnd":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"billingAccountId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"BillingAccount"},"status":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"collecting","enum":["collecting","invoiced","pushed","sent","completed","carried_forward"]},"invoiceId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Invoice"},"providerInvoiceId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"subtotal":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"lineCount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"issuedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"leaseToken":{"type":"text","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"leaseExpiresAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"attempts":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"lastError":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""}},"methods":{"runPeriodClose":{"name":"runPeriodClose","async":true,"parameters":[{"name":"args","type":"Record<string, unknown>","optional":true},{"name":"_context","type":"JobExecutionContext","optional":true}],"returnType":"Promise<unknown>","isStatic":false,"isPublic":true},"processBillingEvents":{"name":"processBillingEvents","async":true,"parameters":[{"name":"args","type":"Record<string, unknown>","optional":true},{"name":"_context","type":"JobExecutionContext","optional":true}],"returnType":"Promise<unknown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_billing_period_closes","conflictColumns":["seller_tenant_id","kind","payer_tenant_id","currency","period_start","period_end"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingPeriodClose","collectionExportName":"BillingPeriodCloseCollection","validationRules":[{"field":"sellerTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"payerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_billing_period_closes","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_period_closes\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT DEFAULT 'provider',\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"billing_account_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'collecting',\\n \\"invoice_id\\" UUID,\\n \\"provider_invoice_id\\" TEXT DEFAULT '',\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"line_count\\" INTEGER DEFAULT 0,\\n \\"issued_at\\" TIMESTAMP,\\n \\"lease_token\\" TEXT,\\n \\"lease_expires_at\\" TIMESTAMP,\\n \\"attempts\\" INTEGER DEFAULT 0,\\n \\"last_error\\" TEXT DEFAULT ''\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"provider"},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"billing_account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"collecting"},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"provider_invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"line_count":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"lease_token":{"type":"TEXT","notNull":false,"unique":false},"lease_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"attempts":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_error":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_period_closes_seller_tenant_id_kind_idx","columns":["seller_tenant_id","kind","payer_tenant_id","currency","period_start","period_end"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_period_closes_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_period_closes_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_period_closes_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_period_closes_billing_account_id_idx","columns":["billing_account_id"]},{"name":"_smrt_billing_period_closes_invoice_id_idx","columns":["invoice_id"]}],"version":"5b8a7e8f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingLineSource":{"name":"billinglinesource","className":"BillingLineSource","qualifiedName":"@happyvertical/smrt-commerce:BillingLineSource","collection":"billinglinesources","description":"A claim that one billable source \u2014 a charge, an adjustment, or a window of a flat plan \u2014 is billed on exactly one period close.","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","required","related"],"required":false,"nullable":true},"required":false,"related":"@happyvertical/smrt-users:Tenant"},"periodCloseId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"BillingPeriodClose"},"sourceType":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"client_charge","enum":["client_charge","billing_adjustment","retail_charge","subscription_period","credit_carry_forward"]},"sourceId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"lineKey":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"lineDescription":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"amount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"discount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"quantity":{"type":"decimal","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"chainSequence":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"currency":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":"USD"},"periodStart":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"periodEnd":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_line_sources","conflictColumns":["source_type","source_id"],"indexes":[{"name":"_smrt_billing_line_sources_line_key_chain_sequence_idx","columns":["lineKey","chainSequence"]}],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingLineSource","collectionExportName":"BillingLineSourceCollection","schema":{"tableName":"_smrt_billing_line_sources","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_line_sources\\" (\\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 \\"seller_tenant_id\\" UUID,\\n \\"period_close_id\\" UUID,\\n \\"source_type\\" TEXT DEFAULT 'client_charge',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"line_key\\" TEXT DEFAULT '',\\n \\"line_description\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"chain_sequence\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"period_close_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_period_closes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":"client_charge"},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"chain_sequence":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_billing_line_sources_source_type_source_id_idx","columns":["source_type","source_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_line_sources_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_line_sources_line_key_chain_sequence_idx","columns":["line_key","chain_sequence"]},{"name":"_smrt_billing_line_sources_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_line_sources_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_line_sources_period_close_id_idx","columns":["period_close_id"]}],"version":"22af7cff"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPaymentAttempt":{"name":"billingpaymentattempt","className":"BillingPaymentAttempt","qualifiedName":"@happyvertical/smrt-commerce:BillingPaymentAttempt","collection":"billingpaymentattempts","description":"One payment attempt on a payment rail (#3138): a short-lived provider checkout (for example a BTCPay invoice) paying a credit purchase or an issued invoice.","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{"sellerTenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"tenant-scope"},"required":true,"related":"@happyvertical/smrt-users:Tenant"},"payerTenantId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"tenant-scope"},"required":true,"related":"@happyvertical/smrt-users:Tenant"},"billingAccountId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"purpose":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"credit_purchase","enum":["credit_purchase","invoice_payment"]},"invoiceId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"spendingPolicyId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"provider":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"idempotency"},"required":true,"default":""},"orderId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"checkoutId":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"idempotency"},"required":true,"default":""},"status":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":"open"},"exception":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":"none"},"flag":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"","enum":["","overpaid","underpaid","paid_late","manually_marked","invalidated_after_settlement","invoice_already_paid","amount_mismatch","out_of_band_without_settlement"]},"amount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"currency":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":"USD"},"amountPaid":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"nativeCurrency":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"nativeAmountDue":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"nativeAmountPaid":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"rate":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"rateSource":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"checkoutUrl":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"expiresAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"payments":{"type":"json","_meta":{"__statedOptions":["default"]},"required":false,"default":[]},"timeline":{"type":"json","_meta":{"__statedOptions":["default"]},"required":false,"default":[]},"settledAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"paymentId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"creditGrantId":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"resolution":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"resolvedAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"outOfBandRequestedAt":{"type":"datetime","_meta":{"__statedOptions":["nullable","required"],"nullable":true,"required":false},"required":false},"pausedStanding":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"excessAmount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"excessRevision":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"settlementOutcome":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"refundedAmount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"refundedPrincipal":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":false,"default":0},"refunds":{"type":"json","_meta":{"__statedOptions":["default"]},"required":false,"default":[]}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_payment_attempts","conflictColumns":["provider","checkout_id"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"BillingPaymentAttempt","collectionExportName":"BillingPaymentAttemptCollection","validationRules":[{"field":"sellerTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"payerTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"provider","rule":"required","fieldType":"text"},{"field":"checkoutId","rule":"required","fieldType":"text"}],"schema":{"tableName":"_smrt_billing_payment_attempts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_payment_attempts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"billing_account_id\\" TEXT DEFAULT '',\\n \\"purpose\\" TEXT DEFAULT 'credit_purchase',\\n \\"invoice_id\\" TEXT DEFAULT '',\\n \\"spending_policy_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT NOT NULL DEFAULT '',\\n \\"order_id\\" TEXT DEFAULT '',\\n \\"checkout_id\\" TEXT NOT NULL DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'open',\\n \\"exception\\" TEXT DEFAULT 'none',\\n \\"flag\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"native_amount_due\\" INTEGER DEFAULT 0,\\n \\"native_amount_paid\\" INTEGER DEFAULT 0,\\n \\"rate\\" TEXT DEFAULT '',\\n \\"rate_source\\" TEXT DEFAULT '',\\n \\"checkout_url\\" TEXT DEFAULT '',\\n \\"expires_at\\" TIMESTAMP,\\n \\"payments\\" JSON DEFAULT '[]',\\n \\"timeline\\" JSON DEFAULT '[]',\\n \\"settled_at\\" TIMESTAMP,\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"credit_grant_id\\" TEXT DEFAULT '',\\n \\"resolution\\" TEXT DEFAULT '',\\n \\"resolved_at\\" TIMESTAMP,\\n \\"out_of_band_requested_at\\" TIMESTAMP,\\n \\"paused_standing\\" TEXT DEFAULT '',\\n \\"excess_amount\\" INTEGER DEFAULT 0,\\n \\"excess_revision\\" INTEGER DEFAULT 0,\\n \\"settlement_outcome\\" TEXT DEFAULT '',\\n \\"refunded_amount\\" INTEGER DEFAULT 0,\\n \\"refunded_principal\\" INTEGER DEFAULT 0,\\n \\"refunds\\" JSON DEFAULT '[]'\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"billing_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"purpose":{"type":"TEXT","notNull":false,"unique":false,"default":"credit_purchase"},"invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"spending_policy_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":true,"unique":false,"default":""},"order_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"open"},"exception":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"flag":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount_due":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"rate":{"type":"TEXT","notNull":false,"unique":false,"default":""},"rate_source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_url":{"type":"TEXT","notNull":false,"unique":false,"default":""},"expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payments":{"type":"JSON","notNull":false,"unique":false,"default":[]},"timeline":{"type":"JSON","notNull":false,"unique":false,"default":[]},"settled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"credit_grant_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolution":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolved_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"out_of_band_requested_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"paused_standing":{"type":"TEXT","notNull":false,"unique":false,"default":""},"excess_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"excess_revision":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"settlement_outcome":{"type":"TEXT","notNull":false,"unique":false,"default":""},"refunded_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunded_principal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunds":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"_smrt_billing_payment_attempts_provider_checkout_id_idx","columns":["provider","checkout_id"],"unique":true},{"name":"_smrt_billing_payment_attempts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_payment_attempts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_payment_attempts_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_payment_attempts_payer_tenant_id_idx","columns":["payer_tenant_id"]}],"version":"f791b1f6"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingAccountCollection":{"name":"billingaccountcollection","className":"BillingAccountCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingAccountCollection","collection":"billingaccounts","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_accounts","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingAccount","exportName":"BillingAccountCollection","collectionExportName":"BillingAccountCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingAccount","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_accounts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"customer_id\\" UUID,\\n \\"name\\" TEXT DEFAULT '',\\n \\"email\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"provider_customer_id\\" TEXT DEFAULT '',\\n \\"automatic_tax\\" BOOLEAN DEFAULT TRUE,\\n \\"flat_discount_basis_points\\" INTEGER DEFAULT 0,\\n \\"payment_terms_days\\" INTEGER DEFAULT 30,\\n \\"standing\\" TEXT DEFAULT 'current',\\n \\"billing_anchor_at\\" TIMESTAMP,\\n \\"prorate_flat_plans\\" BOOLEAN DEFAULT FALSE\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"customer_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"customers","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"email":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"automatic_tax":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"flat_discount_basis_points":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"payment_terms_days":{"type":"INTEGER","notNull":false,"unique":false,"default":30},"standing":{"type":"TEXT","notNull":false,"unique":false,"default":"current"},"billing_anchor_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"prorate_flat_plans":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false}},"indexes":[{"name":"_smrt_billing_accounts_seller_tenant_id_payer_tenant_id_idx","columns":["seller_tenant_id","payer_tenant_id"],"unique":true},{"name":"_smrt_billing_accounts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_accounts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_accounts_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_accounts_customer_id_idx","columns":["customer_id"]}],"version":"01922629"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPeriodCloseCollection":{"name":"billingperiodclosecollection","className":"BillingPeriodCloseCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingPeriodCloseCollection","collection":"billingperiodcloses","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_period_closes","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingPeriodClose","exportName":"BillingPeriodCloseCollection","collectionExportName":"BillingPeriodCloseCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingPeriodClose","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_period_closes","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_period_closes\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT DEFAULT 'provider',\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP,\\n \\"billing_account_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'collecting',\\n \\"invoice_id\\" UUID,\\n \\"provider_invoice_id\\" TEXT DEFAULT '',\\n \\"subtotal\\" INTEGER DEFAULT 0,\\n \\"line_count\\" INTEGER DEFAULT 0,\\n \\"issued_at\\" TIMESTAMP,\\n \\"lease_token\\" TEXT,\\n \\"lease_expires_at\\" TIMESTAMP,\\n \\"attempts\\" INTEGER DEFAULT 0,\\n \\"last_error\\" TEXT DEFAULT ''\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"provider"},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"billing_account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"collecting"},"invoice_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"invoices","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"provider_invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subtotal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"line_count":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"issued_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"lease_token":{"type":"TEXT","notNull":false,"unique":false},"lease_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"attempts":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"last_error":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_period_closes_seller_tenant_id_kind_idx","columns":["seller_tenant_id","kind","payer_tenant_id","currency","period_start","period_end"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_period_closes_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_period_closes_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_period_closes_payer_tenant_id_idx","columns":["payer_tenant_id"]},{"name":"_smrt_billing_period_closes_billing_account_id_idx","columns":["billing_account_id"]},{"name":"_smrt_billing_period_closes_invoice_id_idx","columns":["invoice_id"]}],"version":"5b8a7e8f"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingLineSourceCollection":{"name":"billinglinesourcecollection","className":"BillingLineSourceCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingLineSourceCollection","collection":"billinglinesources","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_line_sources","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingLineSource","exportName":"BillingLineSourceCollection","collectionExportName":"BillingLineSourceCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingLineSource","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_line_sources","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_line_sources\\" (\\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 \\"seller_tenant_id\\" UUID,\\n \\"period_close_id\\" UUID,\\n \\"source_type\\" TEXT DEFAULT 'client_charge',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"line_key\\" TEXT DEFAULT '',\\n \\"line_description\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"discount\\" INTEGER DEFAULT 0,\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"chain_sequence\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"period_start\\" TIMESTAMP,\\n \\"period_end\\" TIMESTAMP\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"period_close_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_billing_period_closes","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"source_type":{"type":"TEXT","notNull":false,"unique":false,"default":"client_charge"},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"line_description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"discount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"chain_sequence":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"period_end":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_billing_line_sources_source_type_source_id_idx","columns":["source_type","source_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_billing_line_sources_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_line_sources_line_key_chain_sequence_idx","columns":["line_key","chain_sequence"]},{"name":"_smrt_billing_line_sources_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_line_sources_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_line_sources_period_close_id_idx","columns":["period_close_id"]}],"version":"22af7cff"},"importPath":"@happyvertical/smrt-commerce"},"@happyvertical/smrt-commerce:BillingPaymentAttemptCollection":{"name":"billingpaymentattemptcollection","className":"BillingPaymentAttemptCollection","qualifiedName":"@happyvertical/smrt-commerce:BillingPaymentAttemptCollection","collection":"billingpaymentattempts","filePath":"src/models/billing.ts","packageName":"@happyvertical/smrt-commerce","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_payment_attempts","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"BillingPaymentAttempt","exportName":"BillingPaymentAttemptCollection","collectionExportName":"BillingPaymentAttemptCollectionCollection","collectionOf":"@happyvertical/smrt-commerce:BillingPaymentAttempt","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_payment_attempts","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_payment_attempts\\" (\\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 \\"seller_tenant_id\\" UUID NOT NULL,\\n \\"payer_tenant_id\\" UUID NOT NULL,\\n \\"billing_account_id\\" TEXT DEFAULT '',\\n \\"purpose\\" TEXT DEFAULT 'credit_purchase',\\n \\"invoice_id\\" TEXT DEFAULT '',\\n \\"spending_policy_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT NOT NULL DEFAULT '',\\n \\"order_id\\" TEXT DEFAULT '',\\n \\"checkout_id\\" TEXT NOT NULL DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'open',\\n \\"exception\\" TEXT DEFAULT 'none',\\n \\"flag\\" TEXT DEFAULT '',\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"amount_paid\\" INTEGER DEFAULT 0,\\n \\"native_currency\\" TEXT DEFAULT '',\\n \\"native_amount_due\\" INTEGER DEFAULT 0,\\n \\"native_amount_paid\\" INTEGER DEFAULT 0,\\n \\"rate\\" TEXT DEFAULT '',\\n \\"rate_source\\" TEXT DEFAULT '',\\n \\"checkout_url\\" TEXT DEFAULT '',\\n \\"expires_at\\" TIMESTAMP,\\n \\"payments\\" JSON DEFAULT '[]',\\n \\"timeline\\" JSON DEFAULT '[]',\\n \\"settled_at\\" TIMESTAMP,\\n \\"payment_id\\" TEXT DEFAULT '',\\n \\"credit_grant_id\\" TEXT DEFAULT '',\\n \\"resolution\\" TEXT DEFAULT '',\\n \\"resolved_at\\" TIMESTAMP,\\n \\"out_of_band_requested_at\\" TIMESTAMP,\\n \\"paused_standing\\" TEXT DEFAULT '',\\n \\"excess_amount\\" INTEGER DEFAULT 0,\\n \\"excess_revision\\" INTEGER DEFAULT 0,\\n \\"settlement_outcome\\" TEXT DEFAULT '',\\n \\"refunded_amount\\" INTEGER DEFAULT 0,\\n \\"refunded_principal\\" INTEGER DEFAULT 0,\\n \\"refunds\\" JSON DEFAULT '[]'\\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"},"seller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"payer_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"billing_account_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"purpose":{"type":"TEXT","notNull":false,"unique":false,"default":"credit_purchase"},"invoice_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"spending_policy_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":true,"unique":false,"default":""},"order_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"open"},"exception":{"type":"TEXT","notNull":false,"unique":false,"default":"none"},"flag":{"type":"TEXT","notNull":false,"unique":false,"default":""},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"native_amount_due":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"native_amount_paid":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"rate":{"type":"TEXT","notNull":false,"unique":false,"default":""},"rate_source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"checkout_url":{"type":"TEXT","notNull":false,"unique":false,"default":""},"expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payments":{"type":"JSON","notNull":false,"unique":false,"default":[]},"timeline":{"type":"JSON","notNull":false,"unique":false,"default":[]},"settled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"payment_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"credit_grant_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolution":{"type":"TEXT","notNull":false,"unique":false,"default":""},"resolved_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"out_of_band_requested_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"paused_standing":{"type":"TEXT","notNull":false,"unique":false,"default":""},"excess_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"excess_revision":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"settlement_outcome":{"type":"TEXT","notNull":false,"unique":false,"default":""},"refunded_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunded_principal":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"refunds":{"type":"JSON","notNull":false,"unique":false,"default":[]}},"indexes":[{"name":"_smrt_billing_payment_attempts_provider_checkout_id_idx","columns":["provider","checkout_id"],"unique":true},{"name":"_smrt_billing_payment_attempts_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_billing_payment_attempts_created_at_idx","columns":["created_at"]},{"name":"_smrt_billing_payment_attempts_seller_tenant_id_idx","columns":["seller_tenant_id"]},{"name":"_smrt_billing_payment_attempts_payer_tenant_id_idx","columns":["payer_tenant_id"]}],"version":"f791b1f6"},"importPath":"@happyvertical/smrt-commerce"}},"moduleType":"smrt","recipes":[{"id":"commerce.agreements","className":"AgreementsRecipe","label":"General agreements","summary":"Keep signed agreements with customers, and see every contract in one list.","synonyms":["contracts","terms","deals"],"models":["@happyvertical/smrt-commerce:Agreement","@happyvertical/smrt-commerce:Contract","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"General agreements","model":"@happyvertical/smrt-commerce:Agreement","icon":"fileText","description":"Signed deals and terms with your customers, in one place."},{"label":"All contracts","model":"@happyvertical/smrt-commerce:Contract","icon":"fileText","description":"Every contract you hold, whoever it is with."}],"requires":["commerce.customers"],"group":{"id":"agreements","label":"Agreements","summary":"Contracts with customers: general agreements, leases and licence sales."},"section":{"id":"agreements","label":"Agreements","icon":"fileText","description":"Contracts, leases and licenses with customers."},"options":{"@happyvertical/smrt-commerce:Agreement":{"fields":{"contractType":{"default":"agreement","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"subtotal":{"visibility":"hidden"},"taxAmount":{"visibility":"hidden"},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:Contract":{"fields":{"channelId":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nAgreements are contracts you keep with customers. General agreements live here;\\nleases and licence sales are separate recipes in the same group.\\n**All contracts** lists every kind together, including orders and quotes.\\n\\n## Tasks\\n\\n### Record an agreement\\n\\n1. Create a new agreement.\\n2. Pick the **{field:customerId}**.\\n3. Set the **{field:issueDate}** and **{field:expiryDate}**.\\n4. Put the conditions in **{field:terms}** and save.\\n\\n### Follow it\\n\\n1. Update **{field:status}** from draft to accepted to completed.\\n2. Check **{field:expiryDate}** to spot agreements about to lapse.\\n","fieldRefs":["customerId","expiryDate","issueDate","status","terms"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.customers","className":"CustomersRecipe","label":"Customers","summary":"Keep a list of the people and companies you sell to.","synonyms":["clients","buyers","accounts"],"models":["@happyvertical/smrt-commerce:Customer"],"nav":[{"label":"Customers","model":"@happyvertical/smrt-commerce:Customer","icon":"users","description":"The people and companies you sell to, with how to reach them."}],"requires":["profiles.identity"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:Customer":{"fields":{"profileId":{"label":"Name","order":-1}}}},"help":{"markdown":"## Overview\\n\\nCustomers is your address book for the people and businesses you sell to. Keep\\none record for each customer so you can see who they are, how they like to pay\\nand what you have agreed with them, then refer back to them whenever you take an\\norder.\\n\\n## Tasks\\n\\n### Add a new customer\\n\\n1. Choose the **New** button above the list.\\n2. Describe the customer with **{field:customerType}**: a direct shopper, a\\n wholesale buyer or a retail customer. Note in **{field:status}** whether you\\n are still dealing with them.\\n3. Fill in the **{field:defaultShippingAddress}** and\\n **{field:defaultBillingAddress}** so you do not have to type them again on\\n every order.\\n4. Add **{field:paymentTerms}**, for example \\"Net 30\\", if you give this\\n customer time to pay.\\n5. Save. The customer is now on your list and ready to use on a sales order.\\n\\n### Keep track of what a customer can owe\\n\\n1. Open the customer from the list and choose Edit.\\n2. Set **{field:creditLimit}** to the most you are comfortable letting them owe\\n you at one time.\\n3. If you do not charge them sales tax, turn on **{field:taxExempt}**, and keep\\n their tax number on file.\\n4. Use **{field:notes}** for anything the next person who deals with this\\n customer should know.\\n\\n### Find a customer\\n\\nScan the list for the customer you want, or open a record to see everything you\\nhave on file. To stop dealing with someone without losing their history, change\\ntheir **{field:status}** to inactive instead of deleting them.\\n","fieldRefs":["creditLimit","customerType","defaultBillingAddress","defaultShippingAddress","notes","paymentTerms","status","taxExempt"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.estimates","className":"EstimatesRecipe","label":"Estimates","summary":"Send customers a price quote before they commit.","synonyms":["quotes","quotations","proposals","bids"],"models":["@happyvertical/smrt-commerce:Estimate","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Estimates","model":"@happyvertical/smrt-commerce:Estimate","icon":"fileText","description":"Price quotes you have sent to customers."}],"requires":["commerce.customers"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:Estimate":{"fields":{"contractType":{"default":"estimate","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nEstimates are price quotes you send before a customer commits. Each one belongs\\nto a customer, lists its line items and shows how long the price is good for.\\n\\n## Tasks\\n\\n### Write an estimate\\n\\n1. Create a new estimate.\\n2. Pick the **{field:customerId}** the quote is for.\\n3. Add the line items, then check the **{field:totalAmount}**.\\n4. Set **{field:expiryDate}** to the last day the price is good for.\\n5. Put your conditions in **{field:terms}** and save.\\n\\n### Follow it up\\n\\n1. Set **{field:status}** to sent once it goes out.\\n2. Move it to accepted or declined when the customer answers.\\n3. Once accepted, convert it to an order so the work can be billed; the order keeps the estimate's lines and totals and a link back to the quote.\\n","fieldRefs":["customerId","expiryDate","status","terms","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.fulfillment","className":"FulfillmentRecipe","label":"Shipping","summary":"Pack, ship and deliver orders, with tracking.","synonyms":["fulfillment","delivery","shipments","tracking"],"models":["@happyvertical/smrt-commerce:Fulfillment","@happyvertical/smrt-commerce:FulfillmentLineItem"],"nav":[{"label":"Shipments","model":"@happyvertical/smrt-commerce:Fulfillment","icon":"truck","description":"What has gone out the door and where it is now."}],"requires":[],"requiresAny":[["commerce.sales","commerce.wholesale"]],"group":{"id":"billing","label":"Billing & shipping","summary":"Invoice your customers, record what they pay and ship what they ordered."},"section":{"id":"operations","label":"Operations","icon":"wrench","description":"Fulfillment and the day-to-day work behind an order."},"options":{"@happyvertical/smrt-commerce:Fulfillment":{"fields":{"estimatedDelivery":{"visibility":"hidden"},"shippingAddress":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:FulfillmentLineItem":{"fields":{"notes":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nShipping tracks how an order gets to the customer. Each shipment belongs to an\\norder and lists which line items are in it, so an order can go out in parts.\\n\\n## Tasks\\n\\n### Ship an order\\n\\n1. Create a new shipment.\\n2. Pick the order in **{field:contractId}** and choose the\\n **{field:fulfillmentType}**.\\n3. Enter the **{field:carrier}** and **{field:trackingNumber}**.\\n4. List the items and quantities in the shipment.\\n5. Set **{field:status}** to shipped and record **{field:shippedAt}**.\\n\\n### Confirm delivery\\n\\n1. Open the shipment and set **{field:status}** to delivered.\\n2. Record **{field:deliveredAt}**.\\n","fieldRefs":["carrier","contractId","deliveredAt","fulfillmentType","shippedAt","status","trackingNumber"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.invoicing","className":"InvoicingRecipe","label":"Invoicing","summary":"Bill customers and record the payments that come in.","synonyms":["invoices","billing","payments","receivables"],"models":["@happyvertical/smrt-commerce:Invoice","@happyvertical/smrt-commerce:InvoiceLineItem","@happyvertical/smrt-commerce:Payment","@happyvertical/smrt-commerce:PaymentAllocation"],"nav":[{"label":"Invoices","model":"@happyvertical/smrt-commerce:Invoice","icon":"receipt","description":"Bills you have sent and which ones are still waiting to be paid."},{"label":"Payments","model":"@happyvertical/smrt-commerce:Payment","icon":"creditCard","description":"Money received, matched to the invoices it paid."}],"requires":["commerce.customers"],"group":{"id":"billing","label":"Billing & shipping","summary":"Invoice your customers, record what they pay and ship what they ordered."},"section":{"id":"billing","label":"Billing","icon":"receipt","description":"Invoices and the payments against them."},"options":{"@happyvertical/smrt-commerce:Invoice":{"fields":{"historicalSourceKeyHash":{"visibility":"hidden"},"providerTaxAmount":{"visibility":"hidden"},"arJournalId":{"visibility":"hidden"},"revenueJournalId":{"visibility":"hidden"},"externalId":{"visibility":"hidden"},"customerExternalId":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"syncedAt":{"visibility":"hidden"},"collectionMethod":{"visibility":"hidden"},"sentAt":{"visibility":"hidden"},"viewedAt":{"visibility":"hidden"},"remindersSent":{"visibility":"hidden"},"lastReminderAt":{"visibility":"hidden"},"reference":{"visibility":"hidden"},"customerId":{"required":true}}},"@happyvertical/smrt-commerce:InvoiceLineItem":{"fields":{"sourceType":{"visibility":"hidden"},"sourceId":{"visibility":"hidden"},"sourceReservationId":{"visibility":"hidden"},"periodStart":{"visibility":"hidden"},"periodEnd":{"visibility":"hidden"},"revenueAccountId":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"sku":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:Payment":{"fields":{"journalId":{"visibility":"hidden"},"externalId":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"syncedAt":{"visibility":"hidden"},"backendId":{"visibility":"hidden"},"backendTxRef":{"visibility":"hidden"},"nativeAmount":{"visibility":"hidden"},"nativeCurrency":{"visibility":"hidden"},"usdAtQuote":{"visibility":"hidden"},"usdAtConfirmation":{"visibility":"hidden"},"transactionId":{"visibility":"hidden"},"connectedAccountId":{"visibility":"hidden"},"connectedFeePolicyRef":{"visibility":"hidden"},"applicationFeeCents":{"visibility":"hidden"},"refundOfPaymentId":{"visibility":"hidden"},"connectedRefundState":{"visibility":"hidden"},"applicationFeeRefunded":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:PaymentAllocation":{"fields":{"allocatedBy":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nInvoicing bills your customers and records what they pay. An invoice lists its\\nline items; a payment can be spread across one or more invoices.\\n\\n## Tasks\\n\\n### Send an invoice\\n\\n1. Create a new invoice.\\n2. Pick the **{field:customerId}** and add the line items.\\n3. Check the **{field:totalAmount}** and set the **{field:dueDate}**.\\n4. Set **{field:status}** to sent once it goes out.\\n\\n### Record a payment\\n\\n1. Create a new payment.\\n2. Pick the **{field:customerId}**, then enter the **{field:Payment.amount}** and the\\n **{field:method}** used.\\n3. Set **{field:Payment.status}** to completed once the money has arrived.\\n4. Apply it to the invoices it settles; each one shows what is still owed.\\n","fieldRefs":["Payment.amount","Payment.status","customerId","dueDate","method","status","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.leases","className":"LeasesRecipe","label":"Leases","summary":"Rent things out and track the term and the payments due.","synonyms":["rentals","renting","hire"],"models":["@happyvertical/smrt-commerce:Lease","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Leases","model":"@happyvertical/smrt-commerce:Lease","icon":"home","description":"Rentals you give or take, with terms and dates."}],"requires":["commerce.customers"],"group":{"id":"agreements","label":"Agreements","summary":"Contracts with customers: general agreements, leases and licence sales."},"section":{"id":"agreements","label":"Agreements","icon":"fileText","description":"Contracts, leases and licenses with customers."},"options":{"@happyvertical/smrt-commerce:Lease":{"fields":{"contractType":{"default":"lease","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"subtotal":{"visibility":"hidden"},"taxAmount":{"visibility":"hidden"},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nLeases are agreements where a customer rents something from you for a period.\\nEach lease keeps its own line items and dates.\\n\\n## Tasks\\n\\n### Record a lease\\n\\n1. Create a new lease.\\n2. Pick the **{field:customerId}** renting from you.\\n3. Set the **{field:issueDate}** it starts and the **{field:expiryDate}** it ends.\\n4. Add a line item for each thing rented, then save.\\n\\n### Keep an eye on it\\n\\n1. Update **{field:status}** as the lease goes from draft to accepted to\\n completed.\\n2. Check **{field:expiryDate}** to see which leases end soon.\\n","fieldRefs":["customerId","expiryDate","issueDate","status"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.licenses","className":"LicensesRecipe","label":"Licence sales","summary":"Sell licences to software, content or other rights.","synonyms":["licenses","licensing","subscriptions"],"models":["@happyvertical/smrt-commerce:LicenseSale","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Licence sales","model":"@happyvertical/smrt-commerce:LicenseSale","icon":"shoppingBag","description":"Licences you have sold and who holds them."}],"requires":["commerce.customers"],"group":{"id":"agreements","label":"Agreements","summary":"Contracts with customers: general agreements, leases and licence sales."},"section":{"id":"agreements","label":"Agreements","icon":"fileText","description":"Contracts, leases and licenses with customers."},"options":{"@happyvertical/smrt-commerce:LicenseSale":{"fields":{"contractType":{"default":"license_sale","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"subtotal":{"visibility":"hidden"},"taxAmount":{"visibility":"hidden"},"channelId":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nLicence sales record selling the right to use something, such as software or\\ncontent, rather than a physical item.\\n\\n## Tasks\\n\\n### Record a licence sale\\n\\n1. Create a new licence sale.\\n2. Pick the **{field:customerId}** who bought the licence.\\n3. Add a line item for what is licensed and check the **{field:totalAmount}**.\\n4. Set the **{field:expiryDate}** if the licence runs out, then save.\\n\\n### Follow it\\n\\n1. Update **{field:status}** when the customer accepts or the sale completes.\\n","fieldRefs":["customerId","expiryDate","status","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.purchases","className":"PurchasesRecipe","label":"Purchases","summary":"Order from your vendors and track what you have bought.","synonyms":["purchase orders","buying","procurement"],"models":["@happyvertical/smrt-commerce:PurchaseOrder","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Purchase orders","model":"@happyvertical/smrt-commerce:PurchaseOrder","icon":"truck","description":"What you have ordered from your suppliers and when it arrives."}],"requires":["commerce.vendors"],"section":{"id":"purchasing","label":"Purchasing","icon":"truck","description":"Vendors and purchase orders: everything you buy."},"options":{"@happyvertical/smrt-commerce:PurchaseOrder":{"fields":{"contractType":{"default":"purchase_order","visibility":"hidden","locked":true},"vendorId":{"label":"Vendor","order":1},"channelId":{"visibility":"hidden"},"expiryDate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nPurchases is where you order from your vendors and keep track of what you have\\nbought. Every purchase order belongs to one of your vendors and records the\\namounts, the dates and where the order stands.\\n\\n## Tasks\\n\\n### Place a purchase order\\n\\n1. Choose the **New** button above the list.\\n2. Enter the **{field:vendorId}** you are buying from. Add them under Vendors\\n first so they are on your list.\\n3. Enter the **{field:subtotal}** and **{field:taxAmount}**, then the\\n **{field:totalAmount}** you expect to pay.\\n4. Set the **{field:issueDate}**, and the **{field:dueDate}** for when the\\n goods or the payment are due.\\n5. Add your own **{field:reference}**, such as the vendor's quote number, so\\n you can match it to their paperwork.\\n6. Enter **{field:expectedDate}** as YYYY-MM-DD if you know when the delivery\\n should arrive. Leave it blank until a date is agreed.\\n7. Use **{field:shipTo}** for the delivery address and instructions, such as\\n which entrance or loading dock to use.\\n8. Save.\\n\\n### Follow an order until it arrives\\n\\n1. Open the purchase order from the list and choose Edit.\\n2. Update **{field:status}** as the order moves along, for example from draft to\\n sent, accepted and completed.\\n3. Use **{field:notes}** to record what the vendor told you, such as delays or\\n partial shipments.\\n\\n### Record the agreement\\n\\n1. Open the purchase order and choose Edit.\\n2. Write down the **{field:terms}** you agreed with the vendor, such as payment\\n or delivery conditions.\\n3. Set **{field:expiryDate}** if the vendor's offer is only good until a certain\\n day.\\n","fieldRefs":["dueDate","expectedDate","expiryDate","issueDate","notes","reference","shipTo","status","subtotal","taxAmount","terms","totalAmount","vendorId"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.sales","className":"SalesRecipe","label":"Sales","summary":"Take customer orders and track them.","synonyms":["sales orders","orders","customer orders"],"models":["@happyvertical/smrt-commerce:Order","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Sales orders","model":"@happyvertical/smrt-commerce:Order","icon":"shoppingBag","description":"Orders from your customers, from placed to delivered."}],"requires":["commerce.customers"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:Order":{"fields":{"contractType":{"default":"order","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"channelId":{"visibility":"hidden"},"expiryDate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nSales is where you take orders from your customers and see where each one\\nstands. Every order belongs to one of your customers, carries its amounts and\\ndates, and keeps a status so you always know what is still open.\\n\\n## Tasks\\n\\n### Take an order\\n\\n1. Choose the **New** button above the list.\\n2. Enter the **{field:customerId}** the order is for. Add them under Customers\\n first so they are on your list.\\n3. Enter the **{field:subtotal}** and **{field:taxAmount}**, then the\\n **{field:totalAmount}** the customer will pay.\\n4. Set the **{field:issueDate}**, and the **{field:dueDate}** if you expect\\n payment by a certain day.\\n5. Add your own **{field:reference}**, such as a purchase order number the\\n customer gave you, so you can find the order later.\\n6. Save.\\n\\n### Follow an order through to the end\\n\\n1. Open the order from the list and choose Edit.\\n2. Update **{field:status}** as the order moves along, for example from draft to\\n sent, accepted and completed.\\n3. Check the **{field:dueDate}** against today to spot orders that are overdue.\\n4. Use **{field:notes}** to record calls, changes and anything promised.\\n\\n### Make a quote with an expiry\\n\\n1. Create the order as usual and set its **{field:status}** to show it is still\\n a draft.\\n2. Set **{field:expiryDate}** to the last day the price is good for.\\n3. Put your conditions, such as deposits or delivery, in **{field:terms}**.\\n","fieldRefs":["customerId","dueDate","expiryDate","issueDate","notes","reference","status","subtotal","taxAmount","terms","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.vendors","className":"VendorsRecipe","label":"Vendors","summary":"Keep a list of the suppliers you buy from.","synonyms":["suppliers","sellers"],"models":["@happyvertical/smrt-commerce:Vendor"],"nav":[{"label":"Vendors","model":"@happyvertical/smrt-commerce:Vendor","icon":"briefcase","description":"The suppliers you buy from, with terms and contacts."}],"requires":["profiles.identity"],"section":{"id":"purchasing","label":"Purchasing","icon":"truck","description":"Vendors and purchase orders: everything you buy."},"options":{"@happyvertical/smrt-commerce:Vendor":{"fields":{"profileId":{"label":"Name","order":-1}}}},"help":{"markdown":"## Overview\\n\\nVendors is your list of the suppliers you buy from. Each record holds who they\\nare, how to reach them and the terms you have agreed, so you can order from them\\nquickly and keep track of what you have bought.\\n\\n## Tasks\\n\\n### Add a vendor\\n\\n1. Choose the **New** button above the list.\\n2. Enter **{field:defaultContactEmail}** and **{field:defaultContactPhone}** for\\n the person you normally deal with.\\n3. Set the **{field:currency}** they bill you in and your **{field:paymentTerms}**,\\n for example \\"Net 30\\".\\n4. Save. The vendor is now on your list and ready to use on a purchase order.\\n\\n### Note how a vendor likes to work\\n\\n1. Open the vendor from the list and choose Edit.\\n2. Enter **{field:leadTimeDays}**, the number of days they usually need between\\n your order and delivery, so you can plan ahead.\\n3. Enter **{field:minimumOrderAmount}** if they will not accept small orders.\\n4. Use **{field:notes}** for anything else worth remembering, such as the best\\n time to call.\\n\\n### Keep payment details in one place\\n\\n1. Open the vendor and choose Edit.\\n2. Record where payments to this vendor should be sent, so it is all in one\\n place.\\n3. Set **{field:status}** to show whether you still buy from them: active,\\n inactive or suspended.\\n","fieldRefs":["currency","defaultContactEmail","defaultContactPhone","leadTimeDays","minimumOrderAmount","notes","paymentTerms","status"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}},{"id":"commerce.wholesale","className":"WholesaleRecipe","label":"Wholesale orders","summary":"Take bulk orders from trade customers.","synonyms":["bulk orders","trade orders","b2b"],"models":["@happyvertical/smrt-commerce:WholesaleOrder","@happyvertical/smrt-commerce:ContractLineItem"],"nav":[{"label":"Wholesale orders","model":"@happyvertical/smrt-commerce:WholesaleOrder","icon":"shoppingBag","description":"Bulk orders from cafes, shops and other businesses."}],"requires":["commerce.customers"],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-commerce:WholesaleOrder":{"fields":{"contractType":{"default":"wholesale_order","visibility":"hidden","locked":true},"customerId":{"label":"Customer","order":1},"channelId":{"visibility":"hidden"},"expiryDate":{"visibility":"hidden"}}},"@happyvertical/smrt-commerce:ContractLineItem":{"fields":{"sku":{"visibility":"hidden"},"startDate":{"visibility":"hidden"},"endDate":{"visibility":"hidden"},"billingPeriod":{"visibility":"hidden"},"sortOrder":{"visibility":"hidden"},"discount":{"visibility":"hidden"},"taxRate":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nWholesale orders are bulk orders from trade customers. They work like sales\\norders, with a list of line items, but are kept in their own list so trade and\\nretail sales stay apart.\\n\\n## Tasks\\n\\n### Take a wholesale order\\n\\n1. Create a new wholesale order.\\n2. Pick the **{field:customerId}** placing the order.\\n3. Add the line items and check the **{field:totalAmount}**.\\n4. Set the **{field:dueDate}** for payment and save.\\n\\n### Track it\\n\\n1. Update **{field:status}** as the order moves from draft to completed.\\n2. Use **{field:reference}** for the buyer's own order number.\\n","fieldRefs":["customerId","dueDate","reference","status","totalAmount"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: @happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs; and its package depends on @happyvertical/smrt-agents, @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)."]}}],"uiSelectors":{"customer-select":{"slotId":"customer-select","selects":"@happyvertical/smrt-commerce:Customer","label":"Customer Select","description":"Searchable customer picker for relation fields; the caller supplies the lookup"},"vendor-select":{"slotId":"vendor-select","selects":"@happyvertical/smrt-commerce:Vendor","label":"Vendor Select","description":"Searchable vendor picker for relation fields; the caller supplies the lookup"}},"smrtDependencies":["@happyvertical/smrt-agents","@happyvertical/smrt-core","@happyvertical/smrt-jobs","@happyvertical/smrt-ledgers","@happyvertical/smrt-products","@happyvertical/smrt-profiles","@happyvertical/smrt-reports","@happyvertical/smrt-subscriptions","@happyvertical/smrt-tenancy"],"browser":{"status":"server-only","issues":["#3615","#3616","#3617","#3624","#3625","#3626","#3627"],"reason":"@happyvertical/payments btcpay (node:crypto); core migrations (node:os). The jobs runner edge (#3615) is reported on smrt-jobs","via":["@happyvertical/smrt-agents","@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}`));
34
34
  //#endregion
35
35
  //#region src/billing/provider.ts
36
36
  function providerCapabilities(provider) {
@@ -1622,8 +1622,14 @@ var BillingAccount = class extends SmrtObject {
1622
1622
  }
1623
1623
  };
1624
1624
  __publicField$9(BillingAccount, "__smrtPackage__", "@happyvertical/smrt-commerce");
1625
- __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingAccount.prototype, "sellerTenantId", 2);
1626
- __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingAccount.prototype, "payerTenantId", 2);
1625
+ __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({
1626
+ required: true,
1627
+ requiredFor: "identity"
1628
+ })], BillingAccount.prototype, "sellerTenantId", 2);
1629
+ __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({
1630
+ required: true,
1631
+ requiredFor: "identity"
1632
+ })], BillingAccount.prototype, "payerTenantId", 2);
1627
1633
  __decorateClass$9([foreignKey("Customer")], BillingAccount.prototype, "customerId", 2);
1628
1634
  __decorateClass$9([field({
1629
1635
  type: "datetime",
@@ -1674,8 +1680,14 @@ var BillingPeriodClose = class extends SmrtObject {
1674
1680
  }
1675
1681
  };
1676
1682
  __publicField$9(BillingPeriodClose, "__smrtPackage__", "@happyvertical/smrt-commerce");
1677
- __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingPeriodClose.prototype, "sellerTenantId", 2);
1678
- __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingPeriodClose.prototype, "payerTenantId", 2);
1683
+ __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({
1684
+ required: true,
1685
+ requiredFor: "tenant-scope"
1686
+ })], BillingPeriodClose.prototype, "sellerTenantId", 2);
1687
+ __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({
1688
+ required: true,
1689
+ requiredFor: "tenant-scope"
1690
+ })], BillingPeriodClose.prototype, "payerTenantId", 2);
1679
1691
  __decorateClass$9([foreignKey("BillingAccount")], BillingPeriodClose.prototype, "billingAccountId", 2);
1680
1692
  __decorateClass$9([foreignKey("Invoice")], BillingPeriodClose.prototype, "invoiceId", 2);
1681
1693
  __decorateClass$9([field({
@@ -1703,7 +1715,7 @@ BillingPeriodClose = __decorateClass$9([smrt({
1703
1715
  mcp: false
1704
1716
  })], BillingPeriodClose);
1705
1717
  var BillingLineSource = class extends SmrtObject {
1706
- sellerTenantId = "";
1718
+ sellerTenantId = null;
1707
1719
  periodCloseId = "";
1708
1720
  sourceType = "client_charge";
1709
1721
  sourceId = "";
@@ -1730,7 +1742,10 @@ var BillingLineSource = class extends SmrtObject {
1730
1742
  periodEnd = null;
1731
1743
  };
1732
1744
  __publicField$9(BillingLineSource, "__smrtPackage__", "@happyvertical/smrt-commerce");
1733
- __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingLineSource.prototype, "sellerTenantId", 2);
1745
+ __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant", { nullable: true }), field({
1746
+ required: false,
1747
+ nullable: true
1748
+ })], BillingLineSource.prototype, "sellerTenantId", 2);
1734
1749
  __decorateClass$9([foreignKey("BillingPeriodClose")], BillingLineSource.prototype, "periodCloseId", 2);
1735
1750
  BillingLineSource = __decorateClass$9([smrt({
1736
1751
  tableName: "_smrt_billing_line_sources",
@@ -1752,7 +1767,6 @@ var BillingPaymentAttempt = class extends SmrtObject {
1752
1767
  invoiceId = "";
1753
1768
  /** The balance credited (`credit_purchase`). */
1754
1769
  spendingPolicyId = "";
1755
- /** Provider (rail) name, for example `btcpay`. */
1756
1770
  provider = "";
1757
1771
  /** The rail order id (checkout idempotency key) the checkout was made for. */
1758
1772
  orderId = "";
@@ -1838,8 +1852,22 @@ var BillingPaymentAttempt = class extends SmrtObject {
1838
1852
  }
1839
1853
  };
1840
1854
  __publicField$9(BillingPaymentAttempt, "__smrtPackage__", "@happyvertical/smrt-commerce");
1841
- __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingPaymentAttempt.prototype, "sellerTenantId", 2);
1842
- __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingPaymentAttempt.prototype, "payerTenantId", 2);
1855
+ __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({
1856
+ required: true,
1857
+ requiredFor: "tenant-scope"
1858
+ })], BillingPaymentAttempt.prototype, "sellerTenantId", 2);
1859
+ __decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({
1860
+ required: true,
1861
+ requiredFor: "tenant-scope"
1862
+ })], BillingPaymentAttempt.prototype, "payerTenantId", 2);
1863
+ __decorateClass$9([field({
1864
+ required: true,
1865
+ requiredFor: "idempotency"
1866
+ })], BillingPaymentAttempt.prototype, "provider", 2);
1867
+ __decorateClass$9([field({
1868
+ required: true,
1869
+ requiredFor: "idempotency"
1870
+ })], BillingPaymentAttempt.prototype, "checkoutId", 2);
1843
1871
  __decorateClass$9([field({
1844
1872
  type: "datetime",
1845
1873
  nullable: true
@@ -4636,7 +4664,7 @@ var FulfillmentLineItem = class extends SmrtObject {
4636
4664
  async save(options) {
4637
4665
  if (!Number.isFinite(this.quantityFulfilled) || this.quantityFulfilled <= 0) throw new Error(`FulfillmentLineItem ${this.id ?? "<new>"}: quantityFulfilled must be a positive number (got ${this.quantityFulfilled}).`);
4638
4666
  if (this.contractLineItemId) {
4639
- const { ContractLineItemCollection } = await import("./chunks/ContractLineItemCollection-B2ildsVf.js").then((n) => n.n);
4667
+ const { ContractLineItemCollection } = await import("./chunks/ContractLineItemCollection-BKHy-nR8.js").then((n) => n.n);
4640
4668
  const orderedLineItem = await (await ContractLineItemCollection.create(this.options)).get(this.contractLineItemId);
4641
4669
  if (!orderedLineItem) throw new Error(`FulfillmentLineItem ${this.id ?? "<new>"}: referenced ContractLineItem '${this.contractLineItemId}' does not exist \u2014 refusing to fulfill against a missing line item (the over-fulfillment cap cannot be enforced otherwise).`);
4642
4670
  if (this.fulfillmentId) {
@@ -5113,7 +5141,7 @@ var PaymentIntent = class extends SmrtObject {
5113
5141
  if (!this.paymentId) throw new Error(`PaymentIntent ${this.id}: cannot persist PAID status without a paymentId`);
5114
5142
  const option = this.getOption(this.paidOptionBackendId);
5115
5143
  if (!option) throw new Error(`PaymentIntent ${this.id}: paidOptionBackendId '${this.paidOptionBackendId}' is not one of the listed options`);
5116
- const { PaymentCollection } = await import("./chunks/retention-accounting-e9SlPXuQ.js").then((n) => n.I);
5144
+ const { PaymentCollection } = await import("./chunks/retention-accounting-D0KzSw3f.js").then((n) => n.I);
5117
5145
  const payment = await (await PaymentCollection.create(this.options)).get({ id: this.paymentId });
5118
5146
  if (!payment) throw new Error(`PaymentIntent ${this.id}: referenced Payment '${this.paymentId}' does not exist`);
5119
5147
  if (payment.customerFundsJson) throw new Error("Managed customer funds cannot settle a payment intent; apply them to an issued invoice");
@@ -5225,7 +5253,7 @@ var PaymentIntent = class extends SmrtObject {
5225
5253
  if (!args.paymentId) throw new Error(`PaymentIntent ${this.id}: verifyAndMarkPaid requires a paymentId`);
5226
5254
  const option = this.paymentOptions.find((o) => o.backendId === args.backendId);
5227
5255
  if (!option) throw new Error(`PaymentIntent ${this.id}: backendId '${args.backendId}' is not one of the listed options`);
5228
- const { PaymentCollection } = await import("./chunks/retention-accounting-e9SlPXuQ.js").then((n) => n.I);
5256
+ const { PaymentCollection } = await import("./chunks/retention-accounting-D0KzSw3f.js").then((n) => n.I);
5229
5257
  const payment = await (await PaymentCollection.create(this.options)).get({ id: args.paymentId });
5230
5258
  if (!payment) throw new Error(`PaymentIntent ${this.id}: referenced Payment '${args.paymentId}' does not exist`);
5231
5259
  if (payment.customerFundsJson) throw new Error("Managed customer funds cannot settle a payment intent; apply them to an issued invoice");
@@ -5827,7 +5855,7 @@ var Payout = class extends SmrtObject {
5827
5855
  */
5828
5856
  async assertCappedBySourcePayment() {
5829
5857
  if (!this.paymentId) throw new Error(`Payout ${this.id ?? "<new>"}: a paymentId is required \u2014 a payout must reference the source Payment that funded it (use createFromPayment()).`);
5830
- const { PaymentCollection } = await import("./chunks/retention-accounting-e9SlPXuQ.js").then((n) => n.I);
5858
+ const { PaymentCollection } = await import("./chunks/retention-accounting-D0KzSw3f.js").then((n) => n.I);
5831
5859
  const payment = await (await PaymentCollection.create(this.options)).get({ id: this.paymentId });
5832
5860
  if (!payment) throw new Error(`Payout ${this.id ?? "<new>"}: referenced source Payment '${this.paymentId}' does not exist \u2014 refusing to remit against a missing payment (the gross-amount cap cannot be enforced otherwise).`);
5833
5861
  if (payment.customerFundsJson) throw new Error("Managed customer funds cannot fund supplier payouts; use customer-funds commands");
@@ -5873,7 +5901,7 @@ var PayoutCollection = class extends SmrtCollection {
5873
5901
  const grossAmount = payment.nativeAmount || payment.amount || 0;
5874
5902
  const currency = payment.nativeCurrency || payment.currency || "";
5875
5903
  const backendId = args.backendId ?? payment.backendId ?? "";
5876
- const payout = new Payout({
5904
+ const payout = new (ObjectRegistry.resolveEffectiveConstructor(Payout))({
5877
5905
  ai: this.options.ai,
5878
5906
  db: this.db,
5879
5907
  _skipLoad: true,
@@ -7068,7 +7096,10 @@ __publicField$2(TenantPaymentAccount, "__smrtPackage__", "@happyvertical/smrt-co
7068
7096
  __decorateClass$2([tenantId()], TenantPaymentAccount.prototype, "tenantId", 2);
7069
7097
  __decorateClass$2([field({ required: true })], TenantPaymentAccount.prototype, "backendId", 2);
7070
7098
  __decorateClass$2([field({ required: true })], TenantPaymentAccount.prototype, "environment", 2);
7071
- __decorateClass$2([field({ required: true })], TenantPaymentAccount.prototype, "providerAccountId", 2);
7099
+ __decorateClass$2([field({
7100
+ required: true,
7101
+ requiredFor: "identity"
7102
+ })], TenantPaymentAccount.prototype, "providerAccountId", 2);
7072
7103
  __decorateClass$2([field({ type: "text" })], TenantPaymentAccount.prototype, "capabilitiesJson", 2);
7073
7104
  __decorateClass$2([field({
7074
7105
  type: "datetime",
@@ -7306,7 +7337,7 @@ var TenantPaymentWebhookEvent = class extends SmrtObject {
7306
7337
  eventType = "";
7307
7338
  /** Endpoint the event arrived on: `connect` or `platform`. */
7308
7339
  endpoint = "";
7309
- tenantId = "";
7340
+ tenantId = null;
7310
7341
  /** Connected provider account the event was routed by. */
7311
7342
  providerAccountId = "";
7312
7343
  /** What the handler did. */
@@ -7319,10 +7350,22 @@ var TenantPaymentWebhookEvent = class extends SmrtObject {
7319
7350
  processedAt = null;
7320
7351
  };
7321
7352
  __publicField(TenantPaymentWebhookEvent, "__smrtPackage__", "@happyvertical/smrt-commerce");
7322
- __decorateClass([field({ required: true })], TenantPaymentWebhookEvent.prototype, "backendId", 2);
7323
- __decorateClass([field({ required: true })], TenantPaymentWebhookEvent.prototype, "environment", 2);
7324
- __decorateClass([field({ required: true })], TenantPaymentWebhookEvent.prototype, "eventId", 2);
7325
- __decorateClass([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], TenantPaymentWebhookEvent.prototype, "tenantId", 2);
7353
+ __decorateClass([field({
7354
+ required: true,
7355
+ requiredFor: "idempotency"
7356
+ })], TenantPaymentWebhookEvent.prototype, "backendId", 2);
7357
+ __decorateClass([field({
7358
+ required: true,
7359
+ requiredFor: "idempotency"
7360
+ })], TenantPaymentWebhookEvent.prototype, "environment", 2);
7361
+ __decorateClass([field({
7362
+ required: true,
7363
+ requiredFor: "idempotency"
7364
+ })], TenantPaymentWebhookEvent.prototype, "eventId", 2);
7365
+ __decorateClass([crossPackageRef("@happyvertical/smrt-users:Tenant", { nullable: true }), field({
7366
+ required: false,
7367
+ nullable: true
7368
+ })], TenantPaymentWebhookEvent.prototype, "tenantId", 2);
7326
7369
  __decorateClass([field({ type: "text" })], TenantPaymentWebhookEvent.prototype, "applicationFeeJson", 2);
7327
7370
  __decorateClass([field({
7328
7371
  type: "datetime",
@@ -7747,7 +7790,7 @@ function createCommerceMoneyTools() {
7747
7790
  await requireCurrentMoney(database, tenantId);
7748
7791
  const invoiceId = requireText(args, "invoiceId");
7749
7792
  await requireInvoice(database, tenantId, invoiceId);
7750
- const line = new InvoiceLineItem({
7793
+ const line = new (ObjectRegistry.resolveEffectiveConstructor(InvoiceLineItem))({
7751
7794
  db: database,
7752
7795
  invoiceId,
7753
7796
  tenantId
@@ -8782,7 +8825,7 @@ async function persist(db, paymentId, state) {
8782
8825
  }
8783
8826
  async function settle(db, input) {
8784
8827
  if (!Object.values(PaymentMethod).includes(input.method)) throw new Error("Explicit supported payment method required");
8785
- const payment = new Payment({
8828
+ const payment = new (ObjectRegistry.resolveEffectiveConstructor(Payment))({
8786
8829
  db,
8787
8830
  id: input.id,
8788
8831
  tenantId: input.tenantId,
@@ -8939,7 +8982,7 @@ async function allocateCustomerFunds(input) {
8939
8982
  "overdue"
8940
8983
  ].includes(invoice.status) || !invoice.moneySnapshotId || invoice.moneySnapshotId !== release.invoiceSnapshotId || payment.contractId && invoice.contractId !== payment.contractId) throw new Error("Issued invoice does not match the customer funds and approved snapshot");
8941
8984
  await validateCustomerFundsAccounts(db, input.tenantId, state.policy);
8942
- const allocation = new PaymentAllocation({
8985
+ const allocation = new (ObjectRegistry.resolveEffectiveConstructor(PaymentAllocation))({
8943
8986
  db,
8944
8987
  id: operation.allocationId,
8945
8988
  tenantId: input.tenantId,
@@ -9426,7 +9469,7 @@ async function recordHistoricalCustomerFunds(input) {
9426
9469
  const { invoice } = await lockAndReloadInvoice(db, snapshot.refundSource.creditNoteId, input.tenantId);
9427
9470
  if (invoice.customerId !== input.customerId || invoice.currency !== input.currency || snapshot.source.effectiveOn < invoice.issueDate.toISOString().slice(0, 10) || amountMinor > await creditRefundAvailable(db, invoice)) invalid$1("Historical cash refund exceeds matching issued-credit capacity");
9428
9471
  }
9429
- const row = await new HistoricalCustomerFunds({
9472
+ const row = await new (ObjectRegistry.resolveEffectiveConstructor(HistoricalCustomerFunds))({
9430
9473
  db,
9431
9474
  id: identity$1({
9432
9475
  tenantId: input.tenantId,
@@ -9663,7 +9706,7 @@ async function recordHistoricalCustomerAllocation(input) {
9663
9706
  effect,
9664
9707
  journalId: null
9665
9708
  };
9666
- const row = await new HistoricalCustomerFundsAllocation({
9709
+ const row = await new (ObjectRegistry.resolveEffectiveConstructor(HistoricalCustomerFundsAllocation))({
9667
9710
  db,
9668
9711
  id: identity$1({
9669
9712
  tenantId: input.tenantId,
@@ -9738,7 +9781,7 @@ async function applyHistoricalCustomerFunds(input) {
9738
9781
  effectiveOn,
9739
9782
  amountMinor
9740
9783
  }, false, "historical-receipt");
9741
- const row = await new HistoricalCustomerFundsAllocation({
9784
+ const row = await new (ObjectRegistry.resolveEffectiveConstructor(HistoricalCustomerFundsAllocation))({
9742
9785
  db,
9743
9786
  id: identity$1({
9744
9787
  tenantId: input.tenantId,
@@ -9822,7 +9865,7 @@ async function refundHistoricalCustomerFunds(input) {
9822
9865
  recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
9823
9866
  operations: []
9824
9867
  };
9825
- const payment = await new Payment({
9868
+ const payment = await new (ObjectRegistry.resolveEffectiveConstructor(Payment))({
9826
9869
  db,
9827
9870
  id: identity$1({
9828
9871
  tenantId: input.tenantId,
@@ -9887,7 +9930,7 @@ async function refundHistoricalCustomerFunds(input) {
9887
9930
  },
9888
9931
  currentRequest: request
9889
9932
  };
9890
- const row = await new HistoricalCustomerFunds({
9933
+ const row = await new (ObjectRegistry.resolveEffectiveConstructor(HistoricalCustomerFunds))({
9891
9934
  db,
9892
9935
  id: identity$1({
9893
9936
  tenantId: input.tenantId,
@@ -10497,7 +10540,7 @@ async function recordPurchasePriceObservation(input) {
10497
10540
  tenantId
10498
10541
  }, { cache: false });
10499
10542
  if (!vendor || vendor.tenantId !== tenantId) throw new Error("Observed supplier must belong to active tenant");
10500
- const row = new PurchasePriceObservation({
10543
+ const row = new (ObjectRegistry.resolveEffectiveConstructor(PurchasePriceObservation))({
10501
10544
  db,
10502
10545
  id,
10503
10546
  tenantId,