@happyvertical/smrt-commerce 0.51.29 → 0.51.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +34 -13
- package/README.md +75 -7
- package/dist/billing/cards.d.ts +64 -0
- package/dist/billing/cards.d.ts.map +1 -0
- package/dist/billing/credits.d.ts +12 -0
- package/dist/billing/credits.d.ts.map +1 -1
- package/dist/billing/events.d.ts +12 -1
- package/dist/billing/events.d.ts.map +1 -1
- package/dist/billing/index.d.ts +6 -4
- package/dist/billing/index.d.ts.map +1 -1
- package/dist/billing/period-close.d.ts.map +1 -1
- package/dist/billing/provider.d.ts +130 -4
- package/dist/billing/provider.d.ts.map +1 -1
- package/dist/billing/runtime.d.ts +63 -4
- package/dist/billing/runtime.d.ts.map +1 -1
- package/dist/billing/stripe.d.ts.map +1 -1
- package/dist/billing/top-up.d.ts +102 -0
- package/dist/billing/top-up.d.ts.map +1 -0
- package/dist/billing/units.d.ts +4 -1
- package/dist/billing/units.d.ts.map +1 -1
- package/dist/chunks/{units-Bk_o7kRV.js → units-ROB39hIC.js} +30 -7
- package/dist/chunks/units-ROB39hIC.js.map +1 -0
- package/dist/index.js +1228 -659
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +5 -5
- package/package.json +10 -10
- package/dist/chunks/units-Bk_o7kRV.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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-CRnln577.js";
|
|
2
|
-
import { a as majorToMinorUnits, c as tenantKey, i as isTenantId, n as currencyMinorUnitExponent, o as minorToMajorUnits, r as deterministicId, s as normalizeCurrency, t as canonicalTenantId } from "./chunks/units-
|
|
2
|
+
import { a as majorToMinorUnits, c as tenantKey, i as isTenantId, n as currencyMinorUnitExponent, o as minorToMajorUnits, r as deterministicId, s as normalizeCurrency, t as canonicalTenantId } from "./chunks/units-ROB39hIC.js";
|
|
3
3
|
import { t as assertIntegerMinorUnits } from "./chunks/money-WSMvSgWq.js";
|
|
4
4
|
import { COMMERCE_MODULE_META, COMMERCE_UI_SLOTS } from "./ui.js";
|
|
5
|
-
import { ObjectRegistry, SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
5
|
+
import { ObjectRegistry, SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, isUniqueViolationError, smrt } from "@happyvertical/smrt-core";
|
|
6
6
|
import { ForgeDeliveryCollection, ForgeProjectionRuntime, SmrtJobCollection, backgroundEligible } from "@happyvertical/smrt-jobs";
|
|
7
7
|
import { TenantIsolationError, TenantScoped, getTenantId, isSuperAdminBypass, isSystemContext, queryGlobal, queryWithGlobals, tenantId, withSystemContext, withTenant } from "@happyvertical/smrt-tenancy";
|
|
8
8
|
import { JournalCollection } from "@happyvertical/smrt-ledgers";
|
|
@@ -21,7 +21,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/__smrt-register__.ts
|
|
24
|
-
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-commerce\",\"packageVersion\":\"0.51.29\",\"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\":{\"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},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Contract\",\"exportName\":\"ContractCollection\",\"collectionExportName\":\"ContractCollectionCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"9c2e9c49\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ContractLineItem\",\"exportName\":\"ContractLineItemCollection\",\"collectionExportName\":\"ContractLineItemCollectionCollection\",\"schema\":{\"tableName\":\"contract_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contract_line_items\\\" (\\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 \\\"tax_rate\\\" REAL DEFAULT 0,\\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\":{\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"default\":0},\"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_product_id_idx\",\"columns\":[\"product_id\"]}],\"version\":\"be2b46cd\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Customer\",\"exportName\":\"CustomerCollection\",\"collectionExportName\":\"CustomerCollectionCollection\",\"schema\":{\"tableName\":\"customers\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"customers\\\" (\\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_shipping_address\\\" JSON,\\n \\\"default_billing_address\\\" JSON,\\n \\\"status\\\" TEXT,\\n \\\"customer_type\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT ''\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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_shipping_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"default_billing_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"customer_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"notes\":{\"type\":\"TEXT\",\"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\"]}],\"version\":\"ad1b9967\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Fulfillment\",\"exportName\":\"FulfillmentCollection\",\"collectionExportName\":\"FulfillmentCollectionCollection\",\"schema\":{\"tableName\":\"fulfillments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"fulfillments\\\" (\\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\":{\"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\":\"2f708fc5\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"FulfillmentLineItem\",\"exportName\":\"FulfillmentLineItemCollection\",\"collectionExportName\":\"FulfillmentLineItemCollectionCollection\",\"schema\":{\"tableName\":\"fulfillment_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"fulfillment_line_items\\\" (\\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\":{\"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\":\"14537dbe\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Invoice\",\"exportName\":\"InvoiceCollection\",\"collectionExportName\":\"InvoiceCollectionCollection\",\"schema\":{\"tableName\":\"invoices\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoices\\\" (\\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 \\\"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 \\\"status\\\" TEXT,\\n \\\"ar_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 \\\"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\":{\"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\"}},\"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\"},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"ar_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},\"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\":\"invoices_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"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_revenue_journal_id_idx\",\"columns\":[\"revenue_journal_id\"]}],\"version\":\"40c25b56\"},\"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\":{\"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},\"getSubtotalForInvoice\":{\"name\":\"getSubtotalForInvoice\",\"async\":true,\"parameters\":[{\"name\":\"invoiceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getTaxForInvoice\":{\"name\":\"getTaxForInvoice\",\"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},\"recalculateAmounts\":{\"name\":\"recalculateAmounts\",\"async\":true,\"parameters\":[{\"name\":\"invoiceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<InvoiceLineItem[]>\",\"isStatic\":false,\"isPublic\":true},\"toAccountingLineItems\":{\"name\":\"toAccountingLineItems\",\"async\":true,\"parameters\":[{\"name\":\"invoiceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AccountingLineItemInput[]>\",\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"InvoiceLineItem\",\"exportName\":\"InvoiceLineItemCollection\",\"collectionExportName\":\"InvoiceLineItemCollectionCollection\",\"schema\":{\"tableName\":\"invoice_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoice_line_items\\\" (\\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 \\\"description\\\" TEXT DEFAULT '',\\n \\\"sku\\\" TEXT DEFAULT '',\\n \\\"quantity\\\" INTEGER DEFAULT 1,\\n \\\"unit_price\\\" INTEGER DEFAULT 0,\\n \\\"discount\\\" INTEGER DEFAULT 0,\\n \\\"tax_rate\\\" REAL DEFAULT 0,\\n \\\"amount\\\" INTEGER DEFAULT 0,\\n \\\"source_type\\\" TEXT DEFAULT '',\\n \\\"source_id\\\" TEXT DEFAULT '',\\n \\\"period_start\\\" TIMESTAMP,\\n \\\"period_end\\\" TIMESTAMP,\\n \\\"revenue_account_id\\\" UUID,\\n \\\"sort_order\\\" INTEGER DEFAULT 0\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"invoice_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"invoices\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"sku\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"quantity\":{\"type\":\"INTEGER\",\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"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\":\"\"},\"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_revenue_account_id_idx\",\"columns\":[\"revenue_account_id\"]}],\"version\":\"f96d2656\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"PaymentAllocation\",\"exportName\":\"PaymentAllocationCollection\",\"collectionExportName\":\"PaymentAllocationCollectionCollection\",\"schema\":{\"tableName\":\"payment_allocations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_allocations\\\" (\\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\":{\"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\":\"102e6fbc\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Payment\",\"exportName\":\"PaymentCollection\",\"collectionExportName\":\"PaymentCollectionCollection\",\"schema\":{\"tableName\":\"payments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payments\\\" (\\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 \\\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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}},\"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\":\"33f80e50\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"PaymentInstrument\",\"exportName\":\"PaymentInstrumentCollection\",\"collectionExportName\":\"PaymentInstrumentCollectionCollection\",\"schema\":{\"tableName\":\"payment_instruments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_instruments\\\" (\\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\":{\"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\":\"722393fe\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"PaymentIntent\",\"exportName\":\"PaymentIntentCollection\",\"collectionExportName\":\"PaymentIntentCollectionCollection\",\"schema\":{\"tableName\":\"payment_intents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_intents\\\" (\\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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\":\"\"}},\"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\":\"c565aaef\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Payout\",\"exportName\":\"PayoutCollection\",\"collectionExportName\":\"PayoutCollectionCollection\",\"schema\":{\"tableName\":\"payouts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payouts\\\" (\\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\":{\"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\":\"98fa81d5\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Vendor\",\"exportName\":\"VendorCollection\",\"collectionExportName\":\"VendorCollectionCollection\",\"schema\":{\"tableName\":\"vendors\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"vendors\\\" (\\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 \\\"default_contact_email\\\" TEXT DEFAULT '',\\n \\\"default_contact_phone\\\" TEXT DEFAULT '',\\n \\\"status\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT '',\\n \\\"payout_addresses\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\"},\"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\":{}}},\"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\"]}],\"version\":\"1dc2b65e\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Contract\":{\"name\":\"contract\",\"className\":\"Contract\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Contract\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"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\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"9c2e9c49\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Estimate\":{\"name\":\"estimate\",\"className\":\"Estimate\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Estimate\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Estimate\",\"collectionExportName\":\"EstimateCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"2f1624b2\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Order\":{\"name\":\"order\",\"className\":\"Order\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Order\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Order\",\"collectionExportName\":\"OrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"b7667cf3\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Lease\":{\"name\":\"lease\",\"className\":\"Lease\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Lease\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Lease\",\"collectionExportName\":\"LeaseCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"b24cdace\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Agreement\":{\"name\":\"agreement\",\"className\":\"Agreement\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Agreement\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Agreement\",\"collectionExportName\":\"AgreementCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"28f0c394\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:PurchaseOrder\":{\"name\":\"purchaseorder\",\"className\":\"PurchaseOrder\",\"qualifiedName\":\"@happyvertical/smrt-commerce:PurchaseOrder\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"PurchaseOrder\",\"collectionExportName\":\"PurchaseOrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"91ec64bb\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:WholesaleOrder\":{\"name\":\"wholesaleorder\",\"className\":\"WholesaleOrder\",\"qualifiedName\":\"@happyvertical/smrt-commerce:WholesaleOrder\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"WholesaleOrder\",\"collectionExportName\":\"WholesaleOrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"ccb8a3ae\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:ProductionOrder\":{\"name\":\"productionorder\",\"className\":\"ProductionOrder\",\"qualifiedName\":\"@happyvertical/smrt-commerce:ProductionOrder\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"productId\":{\"type\":\"meta\",\"required\":false,\"default\":\"\",\"_meta\":{\"underlyingType\":\"text\"}},\"bomId\":{\"type\":\"meta\",\"required\":false,\"default\":\"\",\"_meta\":{\"underlyingType\":\"text\"}}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"ProductionOrder\",\"collectionExportName\":\"ProductionOrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"c6b977a5\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Cart\":{\"name\":\"cart\",\"className\":\"Cart\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Cart\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Cart\",\"collectionExportName\":\"CartCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"fba16d4f\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:LicenseSale\":{\"name\":\"licensesale\",\"className\":\"LicenseSale\",\"qualifiedName\":\"@happyvertical/smrt-commerce:LicenseSale\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"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\":{\"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\":[],\"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\"},\"extends\":\"Contract\",\"exportName\":\"LicenseSale\",\"collectionExportName\":\"LicenseSaleCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"d6d82bad\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:ContractLineItem\":{\"name\":\"contractlineitem\",\"className\":\"ContractLineItem\",\"qualifiedName\":\"@happyvertical/smrt-commerce:ContractLineItem\",\"collection\":\"contractlineitems\",\"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\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"quantity\":{\"type\":\"decimal\",\"required\":false,\"default\":1},\"unitPrice\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"discount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxRate\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"productId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-products:Product\"},\"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\":{\"calculateAmount\":{\"name\":\"calculateAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"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\",\"schema\":{\"tableName\":\"contract_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contract_line_items\\\" (\\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 \\\"tax_rate\\\" REAL DEFAULT 0,\\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\":{\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"default\":0},\"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_product_id_idx\",\"columns\":[\"product_id\"]}],\"version\":\"be2b46cd\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Customer\":{\"name\":\"customer\",\"className\":\"Customer\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Customer\",\"collection\":\"customers\",\"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\"},\"creditLimit\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"paymentTerms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"taxExempt\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"taxId\":{\"type\":\"text\",\"required\":false,\"default\":\"\",\"_meta\":{\"sensitive\":true},\"sensitive\":true},\"defaultShippingAddress\":{\"type\":\"json\",\"required\":false},\"defaultBillingAddress\":{\"type\":\"json\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false},\"customerType\":{\"type\":\"text\",\"required\":false},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Customer\",\"collectionExportName\":\"CustomerCollection\",\"schema\":{\"tableName\":\"customers\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"customers\\\" (\\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_shipping_address\\\" JSON,\\n \\\"default_billing_address\\\" JSON,\\n \\\"status\\\" TEXT,\\n \\\"customer_type\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT ''\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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_shipping_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"default_billing_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"customer_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"notes\":{\"type\":\"TEXT\",\"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\"]}],\"version\":\"ad1b9967\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Fulfillment\":{\"name\":\"fulfillment\",\"className\":\"Fulfillment\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Fulfillment\",\"collection\":\"fulfillments\",\"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\":\"Contract\"},\"fulfillmentType\":{\"type\":\"text\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false},\"trackingNumber\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"carrier\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"shippingAddress\":{\"type\":\"json\",\"required\":false},\"shippedAt\":{\"type\":\"datetime\",\"required\":false},\"deliveredAt\":{\"type\":\"datetime\",\"required\":false},\"estimatedDelivery\":{\"type\":\"datetime\",\"required\":false},\"notes\":{\"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\":[],\"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 \\\"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\":{\"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\":\"2f708fc5\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:FulfillmentLineItem\":{\"name\":\"fulfillmentlineitem\",\"className\":\"FulfillmentLineItem\",\"qualifiedName\":\"@happyvertical/smrt-commerce:FulfillmentLineItem\",\"collection\":\"fulfillmentlineitems\",\"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\"},\"contractLineItemId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ContractLineItem\"},\"quantityFulfilled\":{\"type\":\"decimal\",\"required\":false,\"default\":1},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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 \\\"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\":{\"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\":\"14537dbe\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Invoice\":{\"name\":\"invoice\",\"className\":\"Invoice\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Invoice\",\"collection\":\"invoices\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/commerce/src/models/Invoice.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\"},\"contractId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Contract\"},\"invoiceNumber\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"paidDate\":{\"type\":\"datetime\",\"required\":false},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"providerTaxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"amountPaid\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"CAD\"},\"status\":{\"type\":\"text\",\"required\":false},\"arJournalId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-ledgers:Journal\"},\"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},\"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\":\"\"},\"customerNotes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"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\":[],\"returnType\":\"Promise<this>\",\"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},\"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},\"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\":[],\"returnType\":\"Promise<AccountingInvoiceInput>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"],\"writable\":[\"customerId\",\"contractId\",\"invoiceNumber\",\"reference\",\"issueDate\",\"dueDate\",\"currency\",\"notes\",\"customerNotes\",\"terms\",\"externalId\",\"customerExternalId\",\"externalProvider\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Invoice\",\"collectionExportName\":\"InvoiceCollection\",\"schema\":{\"tableName\":\"invoices\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoices\\\" (\\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 \\\"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 \\\"status\\\" TEXT,\\n \\\"ar_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 \\\"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\":{\"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\"}},\"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\"},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"ar_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},\"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\":\"invoices_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"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_revenue_journal_id_idx\",\"columns\":[\"revenue_journal_id\"]}],\"version\":\"40c25b56\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:InvoiceLineItem\":{\"name\":\"invoicelineitem\",\"className\":\"InvoiceLineItem\",\"qualifiedName\":\"@happyvertical/smrt-commerce:InvoiceLineItem\",\"collection\":\"invoicelineitems\",\"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\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sku\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"quantity\":{\"type\":\"integer\",\"required\":false,\"default\":1},\"unitPrice\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"discount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxRate\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"sourceType\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"periodStart\":{\"type\":\"datetime\",\"required\":false},\"periodEnd\":{\"type\":\"datetime\",\"required\":false},\"revenueAccountId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-ledgers:Account\"},\"sortOrder\":{\"type\":\"integer\",\"required\":false,\"default\":0}},\"methods\":{\"calculateAmount\":{\"name\":\"calculateAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getSubtotal\":{\"name\":\"getSubtotal\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getTaxAmount\":{\"name\":\"getTaxAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"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},\"toAccountingLineItem\":{\"name\":\"toAccountingLineItem\",\"async\":false,\"parameters\":[{\"name\":\"currency\",\"type\":\"string\",\"optional\":true}],\"returnType\":\"AccountingLineItemInput\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"InvoiceLineItem\",\"collectionExportName\":\"InvoiceLineItemCollection\",\"schema\":{\"tableName\":\"invoice_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoice_line_items\\\" (\\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 \\\"description\\\" TEXT DEFAULT '',\\n \\\"sku\\\" TEXT DEFAULT '',\\n \\\"quantity\\\" INTEGER DEFAULT 1,\\n \\\"unit_price\\\" INTEGER DEFAULT 0,\\n \\\"discount\\\" INTEGER DEFAULT 0,\\n \\\"tax_rate\\\" REAL DEFAULT 0,\\n \\\"amount\\\" INTEGER DEFAULT 0,\\n \\\"source_type\\\" TEXT DEFAULT '',\\n \\\"source_id\\\" TEXT DEFAULT '',\\n \\\"period_start\\\" TIMESTAMP,\\n \\\"period_end\\\" TIMESTAMP,\\n \\\"revenue_account_id\\\" UUID,\\n \\\"sort_order\\\" INTEGER DEFAULT 0\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"invoice_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"invoices\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"sku\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"quantity\":{\"type\":\"INTEGER\",\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"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\":\"\"},\"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_revenue_account_id_idx\",\"columns\":[\"revenue_account_id\"]}],\"version\":\"f96d2656\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Payment\":{\"name\":\"payment\",\"className\":\"Payment\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Payment\",\"collection\":\"payments\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/commerce/src/models/Payment.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\":\"Contract\"},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"method\":{\"type\":\"text\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false},\"transactionId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"journalId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-ledgers:Journal\"},\"paidAt\":{\"type\":\"datetime\",\"required\":false},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"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}},\"methods\":{\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"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},\"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\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"],\"writable\":[\"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\",\"schema\":{\"tableName\":\"payments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payments\\\" (\\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 \\\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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}},\"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\":\"33f80e50\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:PaymentAllocation\":{\"name\":\"paymentallocation\",\"className\":\"PaymentAllocation\",\"qualifiedName\":\"@happyvertical/smrt-commerce:PaymentAllocation\",\"collection\":\"paymentallocations\",\"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\"},\"invoiceId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Invoice\"},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"allocatedAt\":{\"type\":\"datetime\",\"required\":false},\"allocatedBy\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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\":\"PaymentAllocation\",\"collectionExportName\":\"PaymentAllocationCollection\",\"schema\":{\"tableName\":\"payment_allocations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_allocations\\\" (\\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\":{\"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\":\"102e6fbc\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:PaymentInstrument\":{\"name\":\"paymentinstrument\",\"className\":\"PaymentInstrument\",\"qualifiedName\":\"@happyvertical/smrt-commerce:PaymentInstrument\",\"collection\":\"paymentinstruments\",\"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}},\"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 \\\"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\":{\"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\":\"722393fe\"},\"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},\"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\":\"\"}},\"methods\":{\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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 \\\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\":\"\"}},\"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\":\"c565aaef\"},\"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},\"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\":[],\"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 \\\"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\":{\"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\":\"98fa81d5\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Vendor\":{\"name\":\"vendor\",\"className\":\"Vendor\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Vendor\",\"collection\":\"vendors\",\"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\"},\"leadTimeDays\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"minimumOrderAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"paymentTerms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"defaultContactEmail\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"defaultContactPhone\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"status\":{\"type\":\"text\",\"required\":false},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"payoutAddresses\":{\"type\":\"json\",\"required\":false,\"default\":{},\"_meta\":{\"sensitive\":true},\"sensitive\":true}},\"methods\":{\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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 \\\"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 \\\"default_contact_email\\\" TEXT DEFAULT '',\\n \\\"default_contact_phone\\\" TEXT DEFAULT '',\\n \\\"status\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT '',\\n \\\"payout_addresses\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\"},\"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\":{}}},\"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\"]}],\"version\":\"1dc2b65e\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:BillingAccount\":{\"name\":\"billingaccount\",\"className\":\"BillingAccount\",\"qualifiedName\":\"@happyvertical/smrt-commerce:BillingAccount\",\"collection\":\"billingaccounts\",\"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\"},\"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\",\"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 \\\"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\":{\"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\":\"58124e47\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:BillingPeriodClose\":{\"name\":\"billingperiodclose\",\"className\":\"BillingPeriodClose\",\"qualifiedName\":\"@happyvertical/smrt-commerce:BillingPeriodClose\",\"collection\":\"billingperiodcloses\",\"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\"},\"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\"},\"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 \\\"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\":{\"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\":\"753d2e86\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:BillingLineSource\":{\"name\":\"billinglinesource\",\"className\":\"BillingLineSource\",\"qualifiedName\":\"@happyvertical/smrt-commerce:BillingLineSource\",\"collection\":\"billinglinesources\",\"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\"},\"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 \\\"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\":{\"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\":\"35e3aaa7\"},\"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\",\"schema\":{\"tableName\":\"_smrt_billing_accounts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_accounts\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"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\":{\"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\":\"58124e47\"},\"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\",\"schema\":{\"tableName\":\"_smrt_billing_period_closes\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_period_closes\\\" (\\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\":{\"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\":\"753d2e86\"},\"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\",\"schema\":{\"tableName\":\"_smrt_billing_line_sources\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_line_sources\\\" (\\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\":{\"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\":\"35e3aaa7\"},\"importPath\":\"@happyvertical/smrt-commerce\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-jobs\",\"@happyvertical/smrt-ledgers\",\"@happyvertical/smrt-subscriptions\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
24
|
+
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-commerce\",\"packageVersion\":\"0.51.30\",\"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\":{\"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},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Contract\",\"exportName\":\"ContractCollection\",\"collectionExportName\":\"ContractCollectionCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"9c2e9c49\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ContractLineItem\",\"exportName\":\"ContractLineItemCollection\",\"collectionExportName\":\"ContractLineItemCollectionCollection\",\"schema\":{\"tableName\":\"contract_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contract_line_items\\\" (\\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 \\\"tax_rate\\\" REAL DEFAULT 0,\\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\":{\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"default\":0},\"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_product_id_idx\",\"columns\":[\"product_id\"]}],\"version\":\"be2b46cd\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Customer\",\"exportName\":\"CustomerCollection\",\"collectionExportName\":\"CustomerCollectionCollection\",\"schema\":{\"tableName\":\"customers\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"customers\\\" (\\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_shipping_address\\\" JSON,\\n \\\"default_billing_address\\\" JSON,\\n \\\"status\\\" TEXT,\\n \\\"customer_type\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT ''\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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_shipping_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"default_billing_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"customer_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"notes\":{\"type\":\"TEXT\",\"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\"]}],\"version\":\"ad1b9967\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Fulfillment\",\"exportName\":\"FulfillmentCollection\",\"collectionExportName\":\"FulfillmentCollectionCollection\",\"schema\":{\"tableName\":\"fulfillments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"fulfillments\\\" (\\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\":{\"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\":\"2f708fc5\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"FulfillmentLineItem\",\"exportName\":\"FulfillmentLineItemCollection\",\"collectionExportName\":\"FulfillmentLineItemCollectionCollection\",\"schema\":{\"tableName\":\"fulfillment_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"fulfillment_line_items\\\" (\\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\":{\"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\":\"14537dbe\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Invoice\",\"exportName\":\"InvoiceCollection\",\"collectionExportName\":\"InvoiceCollectionCollection\",\"schema\":{\"tableName\":\"invoices\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoices\\\" (\\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 \\\"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 \\\"status\\\" TEXT,\\n \\\"ar_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 \\\"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\":{\"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\"}},\"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\"},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"ar_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},\"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\":\"invoices_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"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_revenue_journal_id_idx\",\"columns\":[\"revenue_journal_id\"]}],\"version\":\"40c25b56\"},\"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\":{\"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},\"getSubtotalForInvoice\":{\"name\":\"getSubtotalForInvoice\",\"async\":true,\"parameters\":[{\"name\":\"invoiceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getTaxForInvoice\":{\"name\":\"getTaxForInvoice\",\"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},\"recalculateAmounts\":{\"name\":\"recalculateAmounts\",\"async\":true,\"parameters\":[{\"name\":\"invoiceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<InvoiceLineItem[]>\",\"isStatic\":false,\"isPublic\":true},\"toAccountingLineItems\":{\"name\":\"toAccountingLineItems\",\"async\":true,\"parameters\":[{\"name\":\"invoiceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AccountingLineItemInput[]>\",\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"InvoiceLineItem\",\"exportName\":\"InvoiceLineItemCollection\",\"collectionExportName\":\"InvoiceLineItemCollectionCollection\",\"schema\":{\"tableName\":\"invoice_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoice_line_items\\\" (\\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 \\\"description\\\" TEXT DEFAULT '',\\n \\\"sku\\\" TEXT DEFAULT '',\\n \\\"quantity\\\" INTEGER DEFAULT 1,\\n \\\"unit_price\\\" INTEGER DEFAULT 0,\\n \\\"discount\\\" INTEGER DEFAULT 0,\\n \\\"tax_rate\\\" REAL DEFAULT 0,\\n \\\"amount\\\" INTEGER DEFAULT 0,\\n \\\"source_type\\\" TEXT DEFAULT '',\\n \\\"source_id\\\" TEXT DEFAULT '',\\n \\\"period_start\\\" TIMESTAMP,\\n \\\"period_end\\\" TIMESTAMP,\\n \\\"revenue_account_id\\\" UUID,\\n \\\"sort_order\\\" INTEGER DEFAULT 0\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"invoice_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"invoices\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"sku\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"quantity\":{\"type\":\"INTEGER\",\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"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\":\"\"},\"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_revenue_account_id_idx\",\"columns\":[\"revenue_account_id\"]}],\"version\":\"f96d2656\"},\"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\":{\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"PaymentAllocation\",\"exportName\":\"PaymentAllocationCollection\",\"collectionExportName\":\"PaymentAllocationCollectionCollection\",\"schema\":{\"tableName\":\"payment_allocations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_allocations\\\" (\\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\":{\"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\":\"102e6fbc\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Payment\",\"exportName\":\"PaymentCollection\",\"collectionExportName\":\"PaymentCollectionCollection\",\"schema\":{\"tableName\":\"payments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payments\\\" (\\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 \\\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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}},\"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\":\"33f80e50\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"PaymentInstrument\",\"exportName\":\"PaymentInstrumentCollection\",\"collectionExportName\":\"PaymentInstrumentCollectionCollection\",\"schema\":{\"tableName\":\"payment_instruments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_instruments\\\" (\\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\":{\"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\":\"722393fe\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"PaymentIntent\",\"exportName\":\"PaymentIntentCollection\",\"collectionExportName\":\"PaymentIntentCollectionCollection\",\"schema\":{\"tableName\":\"payment_intents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_intents\\\" (\\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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\":\"\"}},\"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\":\"c565aaef\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Payout\",\"exportName\":\"PayoutCollection\",\"collectionExportName\":\"PayoutCollectionCollection\",\"schema\":{\"tableName\":\"payouts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payouts\\\" (\\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\":{\"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\":\"98fa81d5\"},\"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\":{},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Vendor\",\"exportName\":\"VendorCollection\",\"collectionExportName\":\"VendorCollectionCollection\",\"schema\":{\"tableName\":\"vendors\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"vendors\\\" (\\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 \\\"default_contact_email\\\" TEXT DEFAULT '',\\n \\\"default_contact_phone\\\" TEXT DEFAULT '',\\n \\\"status\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT '',\\n \\\"payout_addresses\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\"},\"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\":{}}},\"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\"]}],\"version\":\"1dc2b65e\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Contract\":{\"name\":\"contract\",\"className\":\"Contract\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Contract\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"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\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"9c2e9c49\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Estimate\":{\"name\":\"estimate\",\"className\":\"Estimate\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Estimate\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Estimate\",\"collectionExportName\":\"EstimateCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"2f1624b2\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Order\":{\"name\":\"order\",\"className\":\"Order\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Order\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Order\",\"collectionExportName\":\"OrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"b7667cf3\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Lease\":{\"name\":\"lease\",\"className\":\"Lease\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Lease\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Lease\",\"collectionExportName\":\"LeaseCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"b24cdace\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Agreement\":{\"name\":\"agreement\",\"className\":\"Agreement\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Agreement\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Agreement\",\"collectionExportName\":\"AgreementCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"28f0c394\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:PurchaseOrder\":{\"name\":\"purchaseorder\",\"className\":\"PurchaseOrder\",\"qualifiedName\":\"@happyvertical/smrt-commerce:PurchaseOrder\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"PurchaseOrder\",\"collectionExportName\":\"PurchaseOrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"91ec64bb\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:WholesaleOrder\":{\"name\":\"wholesaleorder\",\"className\":\"WholesaleOrder\",\"qualifiedName\":\"@happyvertical/smrt-commerce:WholesaleOrder\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"WholesaleOrder\",\"collectionExportName\":\"WholesaleOrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"ccb8a3ae\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:ProductionOrder\":{\"name\":\"productionorder\",\"className\":\"ProductionOrder\",\"qualifiedName\":\"@happyvertical/smrt-commerce:ProductionOrder\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"productId\":{\"type\":\"meta\",\"required\":false,\"default\":\"\",\"_meta\":{\"underlyingType\":\"text\"}},\"bomId\":{\"type\":\"meta\",\"required\":false,\"default\":\"\",\"_meta\":{\"underlyingType\":\"text\"}}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"ProductionOrder\",\"collectionExportName\":\"ProductionOrderCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"c6b977a5\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Cart\":{\"name\":\"cart\",\"className\":\"Cart\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Cart\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":{\"mode\":\"optional\"},\"tableName\":\"contracts\",\"tableStrategy\":\"sti\"},\"extends\":\"Contract\",\"exportName\":\"Cart\",\"collectionExportName\":\"CartCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"fba16d4f\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:LicenseSale\":{\"name\":\"licensesale\",\"className\":\"LicenseSale\",\"qualifiedName\":\"@happyvertical/smrt-commerce:LicenseSale\",\"collection\":\"contracts\",\"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},\"status\":{\"type\":\"text\",\"required\":false},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"vendorId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Vendor\"},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"expiryDate\":{\"type\":\"datetime\",\"required\":false},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"channelId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"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\":{\"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\":[],\"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\"},\"extends\":\"Contract\",\"exportName\":\"LicenseSale\",\"collectionExportName\":\"LicenseSaleCollection\",\"schema\":{\"tableName\":\"contracts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contracts\\\" (\\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 \\\"customer_id\\\" UUID,\\n \\\"vendor_id\\\" UUID,\\n \\\"subtotal\\\" INTEGER DEFAULT 0,\\n \\\"tax_amount\\\" INTEGER DEFAULT 0,\\n \\\"total_amount\\\" INTEGER DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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);\",\"columns\":{\"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},\"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\"}},\"subtotal\":{\"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\"},\"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\":\"\"}},\"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\":\"d6d82bad\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:ContractLineItem\":{\"name\":\"contractlineitem\",\"className\":\"ContractLineItem\",\"qualifiedName\":\"@happyvertical/smrt-commerce:ContractLineItem\",\"collection\":\"contractlineitems\",\"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\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"quantity\":{\"type\":\"decimal\",\"required\":false,\"default\":1},\"unitPrice\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"discount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxRate\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"productId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-products:Product\"},\"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\":{\"calculateAmount\":{\"name\":\"calculateAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"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\",\"schema\":{\"tableName\":\"contract_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"contract_line_items\\\" (\\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 \\\"tax_rate\\\" REAL DEFAULT 0,\\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\":{\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"default\":0},\"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_product_id_idx\",\"columns\":[\"product_id\"]}],\"version\":\"be2b46cd\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Customer\":{\"name\":\"customer\",\"className\":\"Customer\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Customer\",\"collection\":\"customers\",\"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\"},\"creditLimit\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"paymentTerms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"taxExempt\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"taxId\":{\"type\":\"text\",\"required\":false,\"default\":\"\",\"_meta\":{\"sensitive\":true},\"sensitive\":true},\"defaultShippingAddress\":{\"type\":\"json\",\"required\":false},\"defaultBillingAddress\":{\"type\":\"json\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false},\"customerType\":{\"type\":\"text\",\"required\":false},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"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\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Customer\",\"collectionExportName\":\"CustomerCollection\",\"schema\":{\"tableName\":\"customers\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"customers\\\" (\\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_shipping_address\\\" JSON,\\n \\\"default_billing_address\\\" JSON,\\n \\\"status\\\" TEXT,\\n \\\"customer_type\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT ''\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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_shipping_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"default_billing_address\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"customer_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"notes\":{\"type\":\"TEXT\",\"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\"]}],\"version\":\"ad1b9967\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Fulfillment\":{\"name\":\"fulfillment\",\"className\":\"Fulfillment\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Fulfillment\",\"collection\":\"fulfillments\",\"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\":\"Contract\"},\"fulfillmentType\":{\"type\":\"text\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false},\"trackingNumber\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"carrier\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"shippingAddress\":{\"type\":\"json\",\"required\":false},\"shippedAt\":{\"type\":\"datetime\",\"required\":false},\"deliveredAt\":{\"type\":\"datetime\",\"required\":false},\"estimatedDelivery\":{\"type\":\"datetime\",\"required\":false},\"notes\":{\"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\":[],\"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 \\\"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\":{\"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\":\"2f708fc5\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:FulfillmentLineItem\":{\"name\":\"fulfillmentlineitem\",\"className\":\"FulfillmentLineItem\",\"qualifiedName\":\"@happyvertical/smrt-commerce:FulfillmentLineItem\",\"collection\":\"fulfillmentlineitems\",\"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\"},\"contractLineItemId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ContractLineItem\"},\"quantityFulfilled\":{\"type\":\"decimal\",\"required\":false,\"default\":1},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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 \\\"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\":{\"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\":\"14537dbe\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Invoice\":{\"name\":\"invoice\",\"className\":\"Invoice\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Invoice\",\"collection\":\"invoices\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/commerce/src/models/Invoice.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\"},\"contractId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Contract\"},\"invoiceNumber\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"issueDate\":{\"type\":\"datetime\",\"required\":false},\"dueDate\":{\"type\":\"datetime\",\"required\":false},\"paidDate\":{\"type\":\"datetime\",\"required\":false},\"subtotal\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"providerTaxAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"amountPaid\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"CAD\"},\"status\":{\"type\":\"text\",\"required\":false},\"arJournalId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-ledgers:Journal\"},\"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},\"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\":\"\"},\"customerNotes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"terms\":{\"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\":[],\"returnType\":\"Promise<this>\",\"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},\"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},\"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\":[],\"returnType\":\"Promise<AccountingInvoiceInput>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"],\"writable\":[\"customerId\",\"contractId\",\"invoiceNumber\",\"reference\",\"issueDate\",\"dueDate\",\"currency\",\"notes\",\"customerNotes\",\"terms\",\"externalId\",\"customerExternalId\",\"externalProvider\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Invoice\",\"collectionExportName\":\"InvoiceCollection\",\"schema\":{\"tableName\":\"invoices\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoices\\\" (\\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 \\\"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 \\\"status\\\" TEXT,\\n \\\"ar_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 \\\"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\":{\"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\"}},\"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\"},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"ar_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},\"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\":\"invoices_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"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_revenue_journal_id_idx\",\"columns\":[\"revenue_journal_id\"]}],\"version\":\"40c25b56\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:InvoiceLineItem\":{\"name\":\"invoicelineitem\",\"className\":\"InvoiceLineItem\",\"qualifiedName\":\"@happyvertical/smrt-commerce:InvoiceLineItem\",\"collection\":\"invoicelineitems\",\"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\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sku\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"quantity\":{\"type\":\"integer\",\"required\":false,\"default\":1},\"unitPrice\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"discount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"taxRate\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"sourceType\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"periodStart\":{\"type\":\"datetime\",\"required\":false},\"periodEnd\":{\"type\":\"datetime\",\"required\":false},\"revenueAccountId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-ledgers:Account\"},\"sortOrder\":{\"type\":\"integer\",\"required\":false,\"default\":0}},\"methods\":{\"calculateAmount\":{\"name\":\"calculateAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getSubtotal\":{\"name\":\"getSubtotal\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"isStatic\":false,\"isPublic\":true},\"getTaxAmount\":{\"name\":\"getTaxAmount\",\"async\":false,\"parameters\":[],\"returnType\":\"number\",\"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},\"toAccountingLineItem\":{\"name\":\"toAccountingLineItem\",\"async\":false,\"parameters\":[{\"name\":\"currency\",\"type\":\"string\",\"optional\":true}],\"returnType\":\"AccountingLineItemInput\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"InvoiceLineItem\",\"collectionExportName\":\"InvoiceLineItemCollection\",\"schema\":{\"tableName\":\"invoice_line_items\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"invoice_line_items\\\" (\\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 \\\"description\\\" TEXT DEFAULT '',\\n \\\"sku\\\" TEXT DEFAULT '',\\n \\\"quantity\\\" INTEGER DEFAULT 1,\\n \\\"unit_price\\\" INTEGER DEFAULT 0,\\n \\\"discount\\\" INTEGER DEFAULT 0,\\n \\\"tax_rate\\\" REAL DEFAULT 0,\\n \\\"amount\\\" INTEGER DEFAULT 0,\\n \\\"source_type\\\" TEXT DEFAULT '',\\n \\\"source_id\\\" TEXT DEFAULT '',\\n \\\"period_start\\\" TIMESTAMP,\\n \\\"period_end\\\" TIMESTAMP,\\n \\\"revenue_account_id\\\" UUID,\\n \\\"sort_order\\\" INTEGER DEFAULT 0\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"invoice_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false,\"foreignKey\":{\"table\":\"invoices\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"sku\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"quantity\":{\"type\":\"INTEGER\",\"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},\"tax_rate\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"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\":\"\"},\"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_revenue_account_id_idx\",\"columns\":[\"revenue_account_id\"]}],\"version\":\"f96d2656\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Payment\":{\"name\":\"payment\",\"className\":\"Payment\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Payment\",\"collection\":\"payments\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/commerce/src/models/Payment.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\":\"Contract\"},\"customerId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Customer\"},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"method\":{\"type\":\"text\",\"required\":false},\"status\":{\"type\":\"text\",\"required\":false},\"transactionId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"reference\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"journalId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-ledgers:Journal\"},\"paidAt\":{\"type\":\"datetime\",\"required\":false},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"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}},\"methods\":{\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"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},\"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\":{\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"],\"writable\":[\"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\",\"schema\":{\"tableName\":\"payments\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payments\\\" (\\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 \\\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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}},\"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\":\"33f80e50\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:PaymentAllocation\":{\"name\":\"paymentallocation\",\"className\":\"PaymentAllocation\",\"qualifiedName\":\"@happyvertical/smrt-commerce:PaymentAllocation\",\"collection\":\"paymentallocations\",\"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\"},\"invoiceId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Invoice\"},\"amount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"allocatedAt\":{\"type\":\"datetime\",\"required\":false},\"allocatedBy\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"}},\"methods\":{\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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\":\"PaymentAllocation\",\"collectionExportName\":\"PaymentAllocationCollection\",\"schema\":{\"tableName\":\"payment_allocations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"payment_allocations\\\" (\\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\":{\"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\":\"102e6fbc\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:PaymentInstrument\":{\"name\":\"paymentinstrument\",\"className\":\"PaymentInstrument\",\"qualifiedName\":\"@happyvertical/smrt-commerce:PaymentInstrument\",\"collection\":\"paymentinstruments\",\"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}},\"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 \\\"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\":{\"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\":\"722393fe\"},\"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},\"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\":\"\"}},\"methods\":{\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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 \\\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\":\"\"}},\"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\":\"c565aaef\"},\"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},\"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\":[],\"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 \\\"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\":{\"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\":\"98fa81d5\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:Vendor\":{\"name\":\"vendor\",\"className\":\"Vendor\",\"qualifiedName\":\"@happyvertical/smrt-commerce:Vendor\",\"collection\":\"vendors\",\"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\"},\"leadTimeDays\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"minimumOrderAmount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"paymentTerms\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"defaultContactEmail\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"defaultContactPhone\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"status\":{\"type\":\"text\",\"required\":false},\"notes\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"payoutAddresses\":{\"type\":\"json\",\"required\":false,\"default\":{},\"_meta\":{\"sensitive\":true},\"sensitive\":true}},\"methods\":{\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"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 \\\"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 \\\"default_contact_email\\\" TEXT DEFAULT '',\\n \\\"default_contact_phone\\\" TEXT DEFAULT '',\\n \\\"status\\\" TEXT,\\n \\\"notes\\\" TEXT DEFAULT '',\\n \\\"payout_addresses\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"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\"},\"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\":{}}},\"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\"]}],\"version\":\"1dc2b65e\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:BillingAccount\":{\"name\":\"billingaccount\",\"className\":\"BillingAccount\",\"qualifiedName\":\"@happyvertical/smrt-commerce:BillingAccount\",\"collection\":\"billingaccounts\",\"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\"},\"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\",\"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 \\\"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\":{\"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\":\"58124e47\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:BillingPeriodClose\":{\"name\":\"billingperiodclose\",\"className\":\"BillingPeriodClose\",\"qualifiedName\":\"@happyvertical/smrt-commerce:BillingPeriodClose\",\"collection\":\"billingperiodcloses\",\"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\"},\"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\"},\"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 \\\"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\":{\"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\":\"753d2e86\"},\"importPath\":\"@happyvertical/smrt-commerce\"},\"@happyvertical/smrt-commerce:BillingLineSource\":{\"name\":\"billinglinesource\",\"className\":\"BillingLineSource\",\"qualifiedName\":\"@happyvertical/smrt-commerce:BillingLineSource\",\"collection\":\"billinglinesources\",\"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\"},\"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 \\\"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\":{\"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\":\"35e3aaa7\"},\"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\",\"schema\":{\"tableName\":\"_smrt_billing_accounts\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_accounts\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"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\":{\"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\":\"58124e47\"},\"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\",\"schema\":{\"tableName\":\"_smrt_billing_period_closes\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_period_closes\\\" (\\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\":{\"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\":\"753d2e86\"},\"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\",\"schema\":{\"tableName\":\"_smrt_billing_line_sources\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_line_sources\\\" (\\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\":{\"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\":\"35e3aaa7\"},\"importPath\":\"@happyvertical/smrt-commerce\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-jobs\",\"@happyvertical/smrt-ledgers\",\"@happyvertical/smrt-subscriptions\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/billing/cycles.ts
|
|
27
27
|
function daysInMonth(year, month) {
|
|
@@ -174,6 +174,562 @@ function enqueueBillingEvents(options) {
|
|
|
174
174
|
return enqueue(getBillingRuntime(options.runtime), "processBillingEvents", options.limit !== void 0 ? { limit: options.limit } : {}, options);
|
|
175
175
|
}
|
|
176
176
|
//#endregion
|
|
177
|
+
//#region src/models/Customer.ts
|
|
178
|
+
var __defProp$13 = Object.defineProperty;
|
|
179
|
+
var __getOwnPropDesc$13 = Object.getOwnPropertyDescriptor;
|
|
180
|
+
var __decorateClass$13 = (decorators, target, key, kind) => {
|
|
181
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$13(target, key) : target;
|
|
182
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
183
|
+
if (kind && result) __defProp$13(target, key, result);
|
|
184
|
+
return result;
|
|
185
|
+
};
|
|
186
|
+
var Customer = class extends SmrtObject {
|
|
187
|
+
tenantId = null;
|
|
188
|
+
profileId = "";
|
|
189
|
+
/**
|
|
190
|
+
* Maximum credit extended to this customer, in **integer minor units**
|
|
191
|
+
* (cents, satoshis).
|
|
192
|
+
*
|
|
193
|
+
* Converts with the rest of commerce because
|
|
194
|
+
* {@link Customer.hasAvailableCredit} compares it directly against a money
|
|
195
|
+
* amount; a dollars-vs-cents split there would approve every request off by
|
|
196
|
+
* a factor of 100 (#2401).
|
|
197
|
+
*/
|
|
198
|
+
creditLimit = 0;
|
|
199
|
+
/**
|
|
200
|
+
* Payment terms (e.g., "Net 30", "Due on receipt", "2/10 Net 30")
|
|
201
|
+
*/
|
|
202
|
+
paymentTerms = "";
|
|
203
|
+
/**
|
|
204
|
+
* Whether customer is exempt from tax
|
|
205
|
+
*/
|
|
206
|
+
taxExempt = false;
|
|
207
|
+
taxId = "";
|
|
208
|
+
/**
|
|
209
|
+
* Default shipping address
|
|
210
|
+
*/
|
|
211
|
+
defaultShippingAddress = {};
|
|
212
|
+
/**
|
|
213
|
+
* Default billing address
|
|
214
|
+
*/
|
|
215
|
+
defaultBillingAddress = {};
|
|
216
|
+
/**
|
|
217
|
+
* Customer status
|
|
218
|
+
*/
|
|
219
|
+
status = CustomerStatus.ACTIVE;
|
|
220
|
+
/**
|
|
221
|
+
* Customer classification — DTC, wholesale, or retail.
|
|
222
|
+
*
|
|
223
|
+
* Drives channel access (wholesale portal vs. storefront vs. POS), default
|
|
224
|
+
* price tier, and credit terms. Defaults to DTC for backwards compatibility.
|
|
225
|
+
*/
|
|
226
|
+
customerType = CustomerType.DTC;
|
|
227
|
+
/**
|
|
228
|
+
* Internal notes about this customer
|
|
229
|
+
*/
|
|
230
|
+
notes = "";
|
|
231
|
+
constructor(options = {}) {
|
|
232
|
+
super(options);
|
|
233
|
+
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
234
|
+
if (options.profileId !== void 0) this.profileId = options.profileId;
|
|
235
|
+
if (options.creditLimit !== void 0) this.creditLimit = options.creditLimit;
|
|
236
|
+
if (options.paymentTerms !== void 0) this.paymentTerms = options.paymentTerms;
|
|
237
|
+
if (options.taxExempt !== void 0) this.taxExempt = options.taxExempt;
|
|
238
|
+
if (options.taxId !== void 0) this.taxId = options.taxId;
|
|
239
|
+
if (options.defaultShippingAddress !== void 0) this.defaultShippingAddress = options.defaultShippingAddress;
|
|
240
|
+
if (options.defaultBillingAddress !== void 0) this.defaultBillingAddress = options.defaultBillingAddress;
|
|
241
|
+
if (options.status !== void 0) this.status = options.status;
|
|
242
|
+
if (options.customerType !== void 0 && options.customerType !== null) this.customerType = options.customerType;
|
|
243
|
+
if (options.notes !== void 0) this.notes = options.notes;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Convenience predicate: is this a wholesale customer?
|
|
247
|
+
*/
|
|
248
|
+
isWholesale() {
|
|
249
|
+
return this.customerType === CustomerType.WHOLESALE;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Check if customer is active
|
|
253
|
+
*/
|
|
254
|
+
isActive() {
|
|
255
|
+
return this.status === CustomerStatus.ACTIVE;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Check if customer has available credit
|
|
259
|
+
*/
|
|
260
|
+
hasAvailableCredit(amount) {
|
|
261
|
+
return this.creditLimit >= amount;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Get the profile ID for external lookup.
|
|
265
|
+
*
|
|
266
|
+
* To get the actual Profile object, use the ProfileCollection from smrt-profiles:
|
|
267
|
+
* ```typescript
|
|
268
|
+
* const profiles = await ProfileCollection.create(options);
|
|
269
|
+
* const profile = await profiles.get({ id: customer.profileId });
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @returns The profile ID or empty string if not set
|
|
273
|
+
*/
|
|
274
|
+
getProfileId() {
|
|
275
|
+
return this.profileId;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
__decorateClass$13([tenantId({ nullable: true })], Customer.prototype, "tenantId", 2);
|
|
279
|
+
__decorateClass$13([crossPackageRef("@happyvertical/smrt-profiles:Profile")], Customer.prototype, "profileId", 2);
|
|
280
|
+
__decorateClass$13([field({ sensitive: true })], Customer.prototype, "taxId", 2);
|
|
281
|
+
Customer = __decorateClass$13([TenantScoped({ mode: "optional" }), smrt({
|
|
282
|
+
api: { include: [
|
|
283
|
+
"list",
|
|
284
|
+
"get",
|
|
285
|
+
"create",
|
|
286
|
+
"update"
|
|
287
|
+
] },
|
|
288
|
+
mcp: { include: ["list", "get"] },
|
|
289
|
+
cli: { skipApiCheck: true }
|
|
290
|
+
})], Customer);
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/collections/CustomerCollection.ts
|
|
293
|
+
var CustomerCollection = class extends SmrtCollection {
|
|
294
|
+
static _itemClass = Customer;
|
|
295
|
+
/**
|
|
296
|
+
* Find customers by profile ID
|
|
297
|
+
*
|
|
298
|
+
* @param profileId - Profile ID from smrt-profiles
|
|
299
|
+
* @returns Array of customers linked to this profile
|
|
300
|
+
*/
|
|
301
|
+
async findByProfile(profileId) {
|
|
302
|
+
return await this.list({
|
|
303
|
+
where: { profileId },
|
|
304
|
+
orderBy: "created_at DESC"
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Find all active customers
|
|
309
|
+
*
|
|
310
|
+
* @returns Array of active customers
|
|
311
|
+
*/
|
|
312
|
+
async findActive() {
|
|
313
|
+
return await this.list({
|
|
314
|
+
where: { status: CustomerStatus.ACTIVE },
|
|
315
|
+
orderBy: "created_at DESC"
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Find customers by status
|
|
320
|
+
*
|
|
321
|
+
* @param status - Customer status
|
|
322
|
+
* @returns Array of customers
|
|
323
|
+
*/
|
|
324
|
+
async findByStatus(status) {
|
|
325
|
+
return await this.list({
|
|
326
|
+
where: { status },
|
|
327
|
+
orderBy: "created_at DESC"
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Get or create a customer for a profile
|
|
332
|
+
*
|
|
333
|
+
* @param profileId - Profile ID
|
|
334
|
+
* @param defaults - Default values if creating
|
|
335
|
+
* @returns Customer
|
|
336
|
+
*/
|
|
337
|
+
async getOrCreateForProfile(profileId, defaults = {}) {
|
|
338
|
+
const existing = await this.findByProfile(profileId);
|
|
339
|
+
if (existing.length > 0) return existing[0];
|
|
340
|
+
const customer = await this.create({
|
|
341
|
+
profileId,
|
|
342
|
+
creditLimit: defaults.creditLimit ?? 0,
|
|
343
|
+
paymentTerms: defaults.paymentTerms ?? "",
|
|
344
|
+
status: CustomerStatus.ACTIVE
|
|
345
|
+
});
|
|
346
|
+
await customer.save();
|
|
347
|
+
return customer;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Find all customers belonging to a specific tenant
|
|
351
|
+
*
|
|
352
|
+
* @param tenantId - Tenant ID
|
|
353
|
+
* @returns Array of customers for the tenant
|
|
354
|
+
*/
|
|
355
|
+
async findByTenant(tenantId) {
|
|
356
|
+
return this.list({ where: { tenantId } });
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Find all global customers (not associated with any tenant).
|
|
360
|
+
*
|
|
361
|
+
* Routes through the shared tenant-global helper so it does not throw under
|
|
362
|
+
* an active tenant context (an explicit `tenant_id IS NULL` filter would be
|
|
363
|
+
* flagged as an isolation violation). (#1600)
|
|
364
|
+
*
|
|
365
|
+
* @returns Array of global customers
|
|
366
|
+
*/
|
|
367
|
+
async findGlobal() {
|
|
368
|
+
return queryGlobal(this);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Find customers for a tenant including global customers.
|
|
372
|
+
*
|
|
373
|
+
* Fails closed if an active tenant context requests a different tenant's
|
|
374
|
+
* rows; the admin/system path keeps the cross-tenant capability. (#1600)
|
|
375
|
+
*
|
|
376
|
+
* @param tenantId - Tenant ID
|
|
377
|
+
* @returns Array of tenant-specific and global customers
|
|
378
|
+
*/
|
|
379
|
+
async findWithGlobals(tenantId) {
|
|
380
|
+
return queryWithGlobals(this, tenantId, "Customer.findWithGlobals");
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/models/PaymentInstrument.ts
|
|
385
|
+
var __defProp$12 = Object.defineProperty;
|
|
386
|
+
var __getOwnPropDesc$12 = Object.getOwnPropertyDescriptor;
|
|
387
|
+
var __decorateClass$12 = (decorators, target, key, kind) => {
|
|
388
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$12(target, key) : target;
|
|
389
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
390
|
+
if (kind && result) __defProp$12(target, key, result);
|
|
391
|
+
return result;
|
|
392
|
+
};
|
|
393
|
+
var PaymentInstrument = class extends SmrtObject {
|
|
394
|
+
tenantId = null;
|
|
395
|
+
customerId = "";
|
|
396
|
+
/**
|
|
397
|
+
* Stable identifier of the `PaymentBackend` adapter that vaulted the method —
|
|
398
|
+
* e.g. `stripe`. Mirrors {@link Payment.backendId}.
|
|
399
|
+
*/
|
|
400
|
+
backendId = "";
|
|
401
|
+
/**
|
|
402
|
+
* Provider customer reference (e.g. a Stripe `cus_...`). A reference, not
|
|
403
|
+
* card data.
|
|
404
|
+
*/
|
|
405
|
+
providerCustomerId = "";
|
|
406
|
+
/**
|
|
407
|
+
* Provider payment-method reference (e.g. a Stripe `pm_...`). Used, together
|
|
408
|
+
* with {@link providerCustomerId}, to charge the saved method off-session. A
|
|
409
|
+
* reference, not card data.
|
|
410
|
+
*/
|
|
411
|
+
providerPaymentMethodId = "";
|
|
412
|
+
/**
|
|
413
|
+
* Instrument type as reported by the backend — e.g. `card`,
|
|
414
|
+
* `us_bank_account`.
|
|
415
|
+
*/
|
|
416
|
+
type = "card";
|
|
417
|
+
/**
|
|
418
|
+
* Card brand for display (e.g. `visa`). Display-only, not PCI-sensitive.
|
|
419
|
+
*/
|
|
420
|
+
brand = "";
|
|
421
|
+
/**
|
|
422
|
+
* Last four digits for display. Not the full card number.
|
|
423
|
+
*/
|
|
424
|
+
last4 = "";
|
|
425
|
+
/**
|
|
426
|
+
* Card expiry month (1–12). `0` when unknown / not a card.
|
|
427
|
+
*/
|
|
428
|
+
expMonth = 0;
|
|
429
|
+
/**
|
|
430
|
+
* Card expiry year (four digits). `0` when unknown / not a card.
|
|
431
|
+
*/
|
|
432
|
+
expYear = 0;
|
|
433
|
+
/**
|
|
434
|
+
* Whether this is the customer's default instrument. Use
|
|
435
|
+
* {@link PaymentInstrumentCollection.setDefaultForCustomer} to flip the
|
|
436
|
+
* default so only one instrument per customer is marked default.
|
|
437
|
+
*/
|
|
438
|
+
isDefault = false;
|
|
439
|
+
/**
|
|
440
|
+
* Lifecycle status — `active` while chargeable, `expired` once the card has
|
|
441
|
+
* lapsed, `removed` when the customer detaches it.
|
|
442
|
+
*/
|
|
443
|
+
status = PaymentInstrumentStatus.ACTIVE;
|
|
444
|
+
constructor(options = {}) {
|
|
445
|
+
super(options);
|
|
446
|
+
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
447
|
+
if (options.customerId !== void 0) this.customerId = options.customerId;
|
|
448
|
+
if (options.backendId !== void 0) this.backendId = options.backendId;
|
|
449
|
+
if (options.providerCustomerId !== void 0) this.providerCustomerId = options.providerCustomerId;
|
|
450
|
+
if (options.providerPaymentMethodId !== void 0) this.providerPaymentMethodId = options.providerPaymentMethodId;
|
|
451
|
+
if (options.type !== void 0) this.type = options.type;
|
|
452
|
+
if (options.brand !== void 0) this.brand = options.brand;
|
|
453
|
+
if (options.last4 !== void 0) this.last4 = options.last4;
|
|
454
|
+
if (options.expMonth !== void 0) this.expMonth = options.expMonth;
|
|
455
|
+
if (options.expYear !== void 0) this.expYear = options.expYear;
|
|
456
|
+
if (options.isDefault !== void 0) this.isDefault = options.isDefault;
|
|
457
|
+
if (options.status !== void 0) this.status = options.status;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* True while the instrument is active (chargeable).
|
|
461
|
+
*/
|
|
462
|
+
isActive() {
|
|
463
|
+
return this.status === PaymentInstrumentStatus.ACTIVE;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* True once the instrument has been marked expired.
|
|
467
|
+
*/
|
|
468
|
+
isExpired() {
|
|
469
|
+
return this.status === PaymentInstrumentStatus.EXPIRED;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* True once the instrument has been removed/detached.
|
|
473
|
+
*/
|
|
474
|
+
isRemoved() {
|
|
475
|
+
return this.status === PaymentInstrumentStatus.REMOVED;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Mark the instrument expired (e.g. the card lapsed). A removed instrument
|
|
479
|
+
* is not revived by this.
|
|
480
|
+
*/
|
|
481
|
+
markExpired() {
|
|
482
|
+
if (this.status === PaymentInstrumentStatus.REMOVED) return;
|
|
483
|
+
this.status = PaymentInstrumentStatus.EXPIRED;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Mark the instrument removed/detached and clear its default flag.
|
|
487
|
+
*/
|
|
488
|
+
markRemoved() {
|
|
489
|
+
this.status = PaymentInstrumentStatus.REMOVED;
|
|
490
|
+
this.isDefault = false;
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
__decorateClass$12([tenantId({ nullable: true })], PaymentInstrument.prototype, "tenantId", 2);
|
|
494
|
+
__decorateClass$12([foreignKey("Customer")], PaymentInstrument.prototype, "customerId", 2);
|
|
495
|
+
PaymentInstrument = __decorateClass$12([TenantScoped({ mode: "optional" }), smrt({
|
|
496
|
+
api: {
|
|
497
|
+
include: [
|
|
498
|
+
"list",
|
|
499
|
+
"get",
|
|
500
|
+
"create",
|
|
501
|
+
"update"
|
|
502
|
+
],
|
|
503
|
+
writable: [
|
|
504
|
+
"customerId",
|
|
505
|
+
"backendId",
|
|
506
|
+
"providerCustomerId",
|
|
507
|
+
"providerPaymentMethodId",
|
|
508
|
+
"type",
|
|
509
|
+
"brand",
|
|
510
|
+
"last4",
|
|
511
|
+
"expMonth",
|
|
512
|
+
"expYear",
|
|
513
|
+
"status"
|
|
514
|
+
]
|
|
515
|
+
},
|
|
516
|
+
mcp: { include: ["list", "get"] },
|
|
517
|
+
cli: { skipApiCheck: true }
|
|
518
|
+
})], PaymentInstrument);
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/collections/PaymentInstrumentCollection.ts
|
|
521
|
+
var PaymentInstrumentCollection = class extends SmrtCollection {
|
|
522
|
+
static _itemClass = PaymentInstrument;
|
|
523
|
+
/**
|
|
524
|
+
* Find all instruments saved by a customer, newest first.
|
|
525
|
+
*
|
|
526
|
+
* @param customerId - Customer ID
|
|
527
|
+
* @returns Array of instruments
|
|
528
|
+
*/
|
|
529
|
+
async findByCustomer(customerId) {
|
|
530
|
+
return await this.list({
|
|
531
|
+
where: { customerId },
|
|
532
|
+
orderBy: "created_at DESC"
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Find a customer's active instruments, newest first.
|
|
537
|
+
*
|
|
538
|
+
* @param customerId - Customer ID
|
|
539
|
+
* @returns Array of active instruments
|
|
540
|
+
*/
|
|
541
|
+
async findActiveByCustomer(customerId) {
|
|
542
|
+
return await this.list({
|
|
543
|
+
where: {
|
|
544
|
+
customerId,
|
|
545
|
+
status: PaymentInstrumentStatus.ACTIVE
|
|
546
|
+
},
|
|
547
|
+
orderBy: "created_at DESC"
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Find a customer's default instrument, or null if none is set.
|
|
552
|
+
*
|
|
553
|
+
* @param customerId - Customer ID
|
|
554
|
+
* @returns The default instrument or null
|
|
555
|
+
*/
|
|
556
|
+
async findDefaultForCustomer(customerId) {
|
|
557
|
+
return (await this.list({
|
|
558
|
+
where: {
|
|
559
|
+
customerId,
|
|
560
|
+
isDefault: true
|
|
561
|
+
},
|
|
562
|
+
orderBy: "created_at DESC"
|
|
563
|
+
})).find((instrument) => !instrument.isRemoved()) ?? null;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Find an instrument by its provider payment-method reference (e.g. a Stripe
|
|
567
|
+
* `pm_...`).
|
|
568
|
+
*
|
|
569
|
+
* @param providerPaymentMethodId - Provider payment-method id
|
|
570
|
+
* @returns The instrument or null
|
|
571
|
+
*/
|
|
572
|
+
async findByProviderPaymentMethodId(providerPaymentMethodId) {
|
|
573
|
+
return (await this.list({
|
|
574
|
+
where: { providerPaymentMethodId },
|
|
575
|
+
limit: 1
|
|
576
|
+
}))[0] || null;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Make one of a customer's instruments the default, clearing the flag on the
|
|
580
|
+
* others so only a single default is ever set. Only rows whose flag actually
|
|
581
|
+
* changes are re-saved.
|
|
582
|
+
*
|
|
583
|
+
* @param customerId - Customer ID
|
|
584
|
+
* @param instrumentId - The instrument to make default
|
|
585
|
+
*/
|
|
586
|
+
async setDefaultForCustomer(customerId, instrumentId) {
|
|
587
|
+
const instruments = await this.findByCustomer(customerId);
|
|
588
|
+
const target = instruments.find((instrument) => instrument.id === instrumentId);
|
|
589
|
+
if (!target) throw new Error(`PaymentInstrument ${instrumentId} not found for customer ${customerId}`);
|
|
590
|
+
if (target.isRemoved()) throw new Error(`PaymentInstrument ${instrumentId} is removed and cannot be made default`);
|
|
591
|
+
for (const instrument of instruments) {
|
|
592
|
+
const shouldBeDefault = instrument.id === instrumentId;
|
|
593
|
+
if (instrument.isDefault !== shouldBeDefault) {
|
|
594
|
+
instrument.isDefault = shouldBeDefault;
|
|
595
|
+
await instrument.save();
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Find all instruments belonging to a specific tenant.
|
|
601
|
+
*
|
|
602
|
+
* @param tenantId - Tenant ID
|
|
603
|
+
* @returns Array of instruments for the tenant
|
|
604
|
+
*/
|
|
605
|
+
async findByTenant(tenantId) {
|
|
606
|
+
return this.list({ where: { tenantId } });
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Find all global instruments (not associated with any tenant). Routes
|
|
610
|
+
* through the shared tenant-global helper so it does not throw under an
|
|
611
|
+
* active tenant context. (#1600)
|
|
612
|
+
*
|
|
613
|
+
* @returns Array of global instruments
|
|
614
|
+
*/
|
|
615
|
+
async findGlobal() {
|
|
616
|
+
return queryGlobal(this);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Find instruments for a tenant including global instruments. Fails closed if
|
|
620
|
+
* an active tenant context requests a different tenant's rows. (#1600)
|
|
621
|
+
*
|
|
622
|
+
* @param tenantId - Tenant ID
|
|
623
|
+
* @returns Array of tenant-specific and global instruments
|
|
624
|
+
*/
|
|
625
|
+
async findWithGlobals(tenantId) {
|
|
626
|
+
return queryWithGlobals(this, tenantId, "PaymentInstrument.findWithGlobals");
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/billing/cards.ts
|
|
631
|
+
var CARD_SETUP_PURPOSE = "card_setup";
|
|
632
|
+
var SAVE_CARD_METADATA = "smrt_save_card";
|
|
633
|
+
var COLLECT_ADDRESS_METADATA = "smrt_collect_address";
|
|
634
|
+
function assertPayerContext(payerTenantId) {
|
|
635
|
+
if (!isSystemContext() && !isSuperAdminBypass() && tenantKey(getTenantId()) !== payerTenantId) throw new TenantIsolationError("Only the payer can manage its payment methods.");
|
|
636
|
+
}
|
|
637
|
+
async function createCardSetupCheckout(runtime, input) {
|
|
638
|
+
const createSetupCheckout = runtime.provider.createSetupCheckout;
|
|
639
|
+
if (!createSetupCheckout) throw new Error(`Billing provider ${runtime.provider.name} cannot save a payment method.`);
|
|
640
|
+
assertCanSaveCards(runtime);
|
|
641
|
+
if (!input.setupId) throw new Error("setupId is required.");
|
|
642
|
+
const payer = canonicalTenantId(input.payerTenantId, "payerTenantId");
|
|
643
|
+
assertPayerContext(payer);
|
|
644
|
+
const account = await runtime.getAccount(payer);
|
|
645
|
+
if (!account?.id) throw new Error(`No billing account for payer ${payer}.`);
|
|
646
|
+
const synced = await runtime.ensureProviderCustomer(account, { requireTaxLocation: false });
|
|
647
|
+
const key = await deterministicId([
|
|
648
|
+
"billing-card-setup",
|
|
649
|
+
runtime.sellerTenantId,
|
|
650
|
+
String(account.id),
|
|
651
|
+
input.setupId
|
|
652
|
+
]);
|
|
653
|
+
const collectBillingAddress = input.collectBillingAddress ?? (synced.automaticTax && !synced.hasTaxLocation);
|
|
654
|
+
return createSetupCheckout.call(runtime.provider, {
|
|
655
|
+
idempotencyKey: `smrt-card-setup:${key}`,
|
|
656
|
+
providerCustomerId: synced.providerCustomerId,
|
|
657
|
+
currency: normalizeCurrency(input.currency),
|
|
658
|
+
successUrl: input.successUrl,
|
|
659
|
+
cancelUrl: input.cancelUrl,
|
|
660
|
+
collectBillingAddress,
|
|
661
|
+
metadata: {
|
|
662
|
+
smrt_purpose: CARD_SETUP_PURPOSE,
|
|
663
|
+
smrt_seller: runtime.sellerTenantId,
|
|
664
|
+
smrt_payer: payer,
|
|
665
|
+
smrt_account: String(account.id),
|
|
666
|
+
...collectBillingAddress ? { [COLLECT_ADDRESS_METADATA]: "1" } : {}
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
function assertCanSaveCards(runtime) {
|
|
671
|
+
if (!runtime.provider.getCheckout || !runtime.provider.setDefaultPaymentMethod) throw new Error(`Billing provider ${runtime.provider.name} cannot apply a saved payment method (getCheckout and setDefaultPaymentMethod are required).`);
|
|
672
|
+
}
|
|
673
|
+
async function savedCardFromCheckout(runtime, metadata, state, savesCard) {
|
|
674
|
+
if (!state.complete) return null;
|
|
675
|
+
const paymentMethodId = savesCard ? state.paymentMethodId : void 0;
|
|
676
|
+
const billingAddress = metadata["smrt_collect_address"] === "1" && state.billingAddress?.country ? state.billingAddress : void 0;
|
|
677
|
+
if (!paymentMethodId && !billingAddress) return null;
|
|
678
|
+
if (tenantKey(metadata.smrt_seller) !== runtime.sellerTenantId) return null;
|
|
679
|
+
const account = await runtime.accounts.get(metadata.smrt_account ?? "");
|
|
680
|
+
if (!account?.id || tenantKey(account.sellerTenantId) !== runtime.sellerTenantId || tenantKey(account.payerTenantId) !== tenantKey(metadata.smrt_payer) || account.provider !== runtime.provider.name || !account.providerCustomerId || state.providerCustomerId !== account.providerCustomerId) throw new Error(`Checkout ${state.sessionId} saved a card for a customer that is not its billing account's.`);
|
|
681
|
+
return {
|
|
682
|
+
account,
|
|
683
|
+
providerCustomerId: account.providerCustomerId,
|
|
684
|
+
paymentMethodId,
|
|
685
|
+
billingAddress
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
async function recordSavedCard(runtime, db, card) {
|
|
689
|
+
await withTenant({ tenantId: runtime.sellerTenantId }, async () => {
|
|
690
|
+
if (card.paymentMethodId) await recordInstrument(runtime, db, card);
|
|
691
|
+
if (card.billingAddress?.country) {
|
|
692
|
+
const customer = await (await CustomerCollection.create({ db })).get(card.account.customerId);
|
|
693
|
+
if (customer) {
|
|
694
|
+
customer.defaultBillingAddress = card.billingAddress;
|
|
695
|
+
await customer.save();
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
async function recordInstrument(runtime, db, card) {
|
|
701
|
+
const paymentMethodId = String(card.paymentMethodId);
|
|
702
|
+
const instruments = await PaymentInstrumentCollection.create({ db });
|
|
703
|
+
const id = await deterministicId([
|
|
704
|
+
"billing-payment-instrument",
|
|
705
|
+
runtime.provider.name,
|
|
706
|
+
runtime.sellerTenantId,
|
|
707
|
+
paymentMethodId
|
|
708
|
+
]);
|
|
709
|
+
let instrument = await instruments.get(id);
|
|
710
|
+
if (!instrument) instrument = await instruments.create({
|
|
711
|
+
id,
|
|
712
|
+
tenantId: runtime.sellerTenantId,
|
|
713
|
+
customerId: card.account.customerId,
|
|
714
|
+
backendId: runtime.provider.name,
|
|
715
|
+
providerCustomerId: card.providerCustomerId,
|
|
716
|
+
providerPaymentMethodId: paymentMethodId,
|
|
717
|
+
type: "card",
|
|
718
|
+
status: PaymentInstrumentStatus.ACTIVE,
|
|
719
|
+
_insertOnly: true
|
|
720
|
+
});
|
|
721
|
+
else if (instrument.customerId !== card.account.customerId) throw new Error(`Payment method ${paymentMethodId} is already saved for another customer.`);
|
|
722
|
+
else if (!instrument.isActive()) {
|
|
723
|
+
instrument.status = PaymentInstrumentStatus.ACTIVE;
|
|
724
|
+
await instrument.save();
|
|
725
|
+
}
|
|
726
|
+
await instruments.setDefaultForCustomer(card.account.customerId, String(instrument.id));
|
|
727
|
+
}
|
|
728
|
+
async function defaultCardFor(runtime, account, providerCustomerId) {
|
|
729
|
+
const instrument = await withTenant({ tenantId: runtime.sellerTenantId }, () => runtime.instruments.findDefaultForCustomer(account.customerId));
|
|
730
|
+
return Boolean(instrument?.isActive() && instrument.backendId === runtime.provider.name && instrument.providerCustomerId === providerCustomerId);
|
|
731
|
+
}
|
|
732
|
+
//#endregion
|
|
177
733
|
//#region src/billing/period-close.ts
|
|
178
734
|
var BillingPeriodCloseError = class extends Error {
|
|
179
735
|
constructor(result) {
|
|
@@ -986,6 +1542,7 @@ async function pushToProvider(runtime, close, invoice, account) {
|
|
|
986
1542
|
periodEnd: item.periodEnd ?? void 0
|
|
987
1543
|
});
|
|
988
1544
|
}
|
|
1545
|
+
const chargeAutomatically = runtime.autoChargeInvoices && await defaultCardFor(runtime, account, synced.providerCustomerId);
|
|
989
1546
|
const { providerInvoiceId } = await runtime.provider.pushInvoice({
|
|
990
1547
|
invoiceId: String(invoice.id),
|
|
991
1548
|
invoiceNumber: invoice.invoiceNumber,
|
|
@@ -997,6 +1554,7 @@ async function pushToProvider(runtime, close, invoice, account) {
|
|
|
997
1554
|
subtotal: invoice.subtotal,
|
|
998
1555
|
idempotencyKey: `smrt-billing-close:${close.id}`,
|
|
999
1556
|
automaticTax: synced.automaticTax,
|
|
1557
|
+
collectionMethod: chargeAutomatically ? "charge_automatically" : "send_invoice",
|
|
1000
1558
|
memo: invoice.customerNotes || void 0
|
|
1001
1559
|
});
|
|
1002
1560
|
await withTenant({ tenantId: runtime.sellerTenantId }, async () => {
|
|
@@ -1014,267 +1572,60 @@ async function sendAndReconcile(runtime, close, invoice, account) {
|
|
|
1014
1572
|
const providerInvoiceId = close.providerInvoiceId;
|
|
1015
1573
|
let state = await runtime.provider.getInvoice(providerInvoiceId);
|
|
1016
1574
|
if (state.status === "draft") {
|
|
1017
|
-
await runtime.ensureProviderCustomer(account);
|
|
1018
|
-
await runtime.provider.sendInvoice(providerInvoiceId);
|
|
1019
|
-
state = await runtime.provider.getInvoice(providerInvoiceId);
|
|
1020
|
-
}
|
|
1021
|
-
if (state.status === "draft" || state.status === "void") throw new Error(`Provider invoice ${providerInvoiceId} is ${state.status}; expected it to be sent.`);
|
|
1022
|
-
if (state.currency !== close.currency || state.subtotal !== invoice.subtotal || state.total !== state.subtotal + state.taxAmount) throw new Error(`Provider invoice ${providerInvoiceId} does not match invoice ${invoice.invoiceNumber}: provider ${state.subtotal}+${state.taxAmount}=${state.total} ${state.currency}, local subtotal ${invoice.subtotal} ${close.currency}.`);
|
|
1023
|
-
await withTenant({ tenantId: runtime.sellerTenantId }, async () => {
|
|
1024
|
-
invoice.providerTaxAmount = state.taxAmount;
|
|
1025
|
-
if (invoice.status === InvoiceStatus.DRAFT) invoice.markSent();
|
|
1026
|
-
await invoice.save();
|
|
1027
|
-
});
|
|
1028
|
-
if (invoice.totalAmount !== state.total) throw new Error(`Invoice ${invoice.invoiceNumber} total ${invoice.totalAmount} does not match provider total ${state.total}.`);
|
|
1029
|
-
close.status = "sent";
|
|
1030
|
-
await close.save();
|
|
1031
|
-
}
|
|
1032
|
-
async function postRevenue(runtime, invoice) {
|
|
1033
|
-
if (invoice.totalAmount <= 0 || invoice.arJournalId) return;
|
|
1034
|
-
await withTenant({ tenantId: runtime.sellerTenantId }, async () => {
|
|
1035
|
-
const posted = await runtime.journals.list({
|
|
1036
|
-
where: {
|
|
1037
|
-
sourceModule: "smrt-commerce",
|
|
1038
|
-
sourceRef: String(invoice.id),
|
|
1039
|
-
status: "posted"
|
|
1040
|
-
},
|
|
1041
|
-
limit: 1
|
|
1042
|
-
});
|
|
1043
|
-
if (posted[0]?.id) {
|
|
1044
|
-
invoice.arJournalId = String(posted[0].id);
|
|
1045
|
-
await invoice.save();
|
|
1046
|
-
return;
|
|
1047
|
-
}
|
|
1048
|
-
await invoice.recognizeRevenue({
|
|
1049
|
-
arAccountId: runtime.ledger.arAccountId,
|
|
1050
|
-
revenueAccountId: runtime.ledger.revenueAccountId,
|
|
1051
|
-
taxAccountId: runtime.ledger.taxAccountId
|
|
1052
|
-
});
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
//#endregion
|
|
1056
|
-
//#region src/billing/provider.ts
|
|
1057
|
-
var BillingWebhookVerificationError = class extends Error {
|
|
1058
|
-
constructor(message = "Billing webhook signature verification failed.") {
|
|
1059
|
-
super(message);
|
|
1060
|
-
this.name = "BillingWebhookVerificationError";
|
|
1061
|
-
}
|
|
1062
|
-
};
|
|
1063
|
-
//#endregion
|
|
1064
|
-
//#region src/models/Customer.ts
|
|
1065
|
-
var __defProp$13 = Object.defineProperty;
|
|
1066
|
-
var __getOwnPropDesc$13 = Object.getOwnPropertyDescriptor;
|
|
1067
|
-
var __decorateClass$13 = (decorators, target, key, kind) => {
|
|
1068
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$13(target, key) : target;
|
|
1069
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1070
|
-
if (kind && result) __defProp$13(target, key, result);
|
|
1071
|
-
return result;
|
|
1072
|
-
};
|
|
1073
|
-
var Customer = class extends SmrtObject {
|
|
1074
|
-
tenantId = null;
|
|
1075
|
-
profileId = "";
|
|
1076
|
-
/**
|
|
1077
|
-
* Maximum credit extended to this customer, in **integer minor units**
|
|
1078
|
-
* (cents, satoshis).
|
|
1079
|
-
*
|
|
1080
|
-
* Converts with the rest of commerce because
|
|
1081
|
-
* {@link Customer.hasAvailableCredit} compares it directly against a money
|
|
1082
|
-
* amount; a dollars-vs-cents split there would approve every request off by
|
|
1083
|
-
* a factor of 100 (#2401).
|
|
1084
|
-
*/
|
|
1085
|
-
creditLimit = 0;
|
|
1086
|
-
/**
|
|
1087
|
-
* Payment terms (e.g., "Net 30", "Due on receipt", "2/10 Net 30")
|
|
1088
|
-
*/
|
|
1089
|
-
paymentTerms = "";
|
|
1090
|
-
/**
|
|
1091
|
-
* Whether customer is exempt from tax
|
|
1092
|
-
*/
|
|
1093
|
-
taxExempt = false;
|
|
1094
|
-
taxId = "";
|
|
1095
|
-
/**
|
|
1096
|
-
* Default shipping address
|
|
1097
|
-
*/
|
|
1098
|
-
defaultShippingAddress = {};
|
|
1099
|
-
/**
|
|
1100
|
-
* Default billing address
|
|
1101
|
-
*/
|
|
1102
|
-
defaultBillingAddress = {};
|
|
1103
|
-
/**
|
|
1104
|
-
* Customer status
|
|
1105
|
-
*/
|
|
1106
|
-
status = CustomerStatus.ACTIVE;
|
|
1107
|
-
/**
|
|
1108
|
-
* Customer classification — DTC, wholesale, or retail.
|
|
1109
|
-
*
|
|
1110
|
-
* Drives channel access (wholesale portal vs. storefront vs. POS), default
|
|
1111
|
-
* price tier, and credit terms. Defaults to DTC for backwards compatibility.
|
|
1112
|
-
*/
|
|
1113
|
-
customerType = CustomerType.DTC;
|
|
1114
|
-
/**
|
|
1115
|
-
* Internal notes about this customer
|
|
1116
|
-
*/
|
|
1117
|
-
notes = "";
|
|
1118
|
-
constructor(options = {}) {
|
|
1119
|
-
super(options);
|
|
1120
|
-
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
1121
|
-
if (options.profileId !== void 0) this.profileId = options.profileId;
|
|
1122
|
-
if (options.creditLimit !== void 0) this.creditLimit = options.creditLimit;
|
|
1123
|
-
if (options.paymentTerms !== void 0) this.paymentTerms = options.paymentTerms;
|
|
1124
|
-
if (options.taxExempt !== void 0) this.taxExempt = options.taxExempt;
|
|
1125
|
-
if (options.taxId !== void 0) this.taxId = options.taxId;
|
|
1126
|
-
if (options.defaultShippingAddress !== void 0) this.defaultShippingAddress = options.defaultShippingAddress;
|
|
1127
|
-
if (options.defaultBillingAddress !== void 0) this.defaultBillingAddress = options.defaultBillingAddress;
|
|
1128
|
-
if (options.status !== void 0) this.status = options.status;
|
|
1129
|
-
if (options.customerType !== void 0 && options.customerType !== null) this.customerType = options.customerType;
|
|
1130
|
-
if (options.notes !== void 0) this.notes = options.notes;
|
|
1131
|
-
}
|
|
1132
|
-
/**
|
|
1133
|
-
* Convenience predicate: is this a wholesale customer?
|
|
1134
|
-
*/
|
|
1135
|
-
isWholesale() {
|
|
1136
|
-
return this.customerType === CustomerType.WHOLESALE;
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* Check if customer is active
|
|
1140
|
-
*/
|
|
1141
|
-
isActive() {
|
|
1142
|
-
return this.status === CustomerStatus.ACTIVE;
|
|
1143
|
-
}
|
|
1144
|
-
/**
|
|
1145
|
-
* Check if customer has available credit
|
|
1146
|
-
*/
|
|
1147
|
-
hasAvailableCredit(amount) {
|
|
1148
|
-
return this.creditLimit >= amount;
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* Get the profile ID for external lookup.
|
|
1152
|
-
*
|
|
1153
|
-
* To get the actual Profile object, use the ProfileCollection from smrt-profiles:
|
|
1154
|
-
* ```typescript
|
|
1155
|
-
* const profiles = await ProfileCollection.create(options);
|
|
1156
|
-
* const profile = await profiles.get({ id: customer.profileId });
|
|
1157
|
-
* ```
|
|
1158
|
-
*
|
|
1159
|
-
* @returns The profile ID or empty string if not set
|
|
1160
|
-
*/
|
|
1161
|
-
getProfileId() {
|
|
1162
|
-
return this.profileId;
|
|
1163
|
-
}
|
|
1164
|
-
};
|
|
1165
|
-
__decorateClass$13([tenantId({ nullable: true })], Customer.prototype, "tenantId", 2);
|
|
1166
|
-
__decorateClass$13([crossPackageRef("@happyvertical/smrt-profiles:Profile")], Customer.prototype, "profileId", 2);
|
|
1167
|
-
__decorateClass$13([field({ sensitive: true })], Customer.prototype, "taxId", 2);
|
|
1168
|
-
Customer = __decorateClass$13([TenantScoped({ mode: "optional" }), smrt({
|
|
1169
|
-
api: { include: [
|
|
1170
|
-
"list",
|
|
1171
|
-
"get",
|
|
1172
|
-
"create",
|
|
1173
|
-
"update"
|
|
1174
|
-
] },
|
|
1175
|
-
mcp: { include: ["list", "get"] },
|
|
1176
|
-
cli: { skipApiCheck: true }
|
|
1177
|
-
})], Customer);
|
|
1178
|
-
//#endregion
|
|
1179
|
-
//#region src/collections/CustomerCollection.ts
|
|
1180
|
-
var CustomerCollection = class extends SmrtCollection {
|
|
1181
|
-
static _itemClass = Customer;
|
|
1182
|
-
/**
|
|
1183
|
-
* Find customers by profile ID
|
|
1184
|
-
*
|
|
1185
|
-
* @param profileId - Profile ID from smrt-profiles
|
|
1186
|
-
* @returns Array of customers linked to this profile
|
|
1187
|
-
*/
|
|
1188
|
-
async findByProfile(profileId) {
|
|
1189
|
-
return await this.list({
|
|
1190
|
-
where: { profileId },
|
|
1191
|
-
orderBy: "created_at DESC"
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
|
-
/**
|
|
1195
|
-
* Find all active customers
|
|
1196
|
-
*
|
|
1197
|
-
* @returns Array of active customers
|
|
1198
|
-
*/
|
|
1199
|
-
async findActive() {
|
|
1200
|
-
return await this.list({
|
|
1201
|
-
where: { status: CustomerStatus.ACTIVE },
|
|
1202
|
-
orderBy: "created_at DESC"
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
/**
|
|
1206
|
-
* Find customers by status
|
|
1207
|
-
*
|
|
1208
|
-
* @param status - Customer status
|
|
1209
|
-
* @returns Array of customers
|
|
1210
|
-
*/
|
|
1211
|
-
async findByStatus(status) {
|
|
1212
|
-
return await this.list({
|
|
1213
|
-
where: { status },
|
|
1214
|
-
orderBy: "created_at DESC"
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
/**
|
|
1218
|
-
* Get or create a customer for a profile
|
|
1219
|
-
*
|
|
1220
|
-
* @param profileId - Profile ID
|
|
1221
|
-
* @param defaults - Default values if creating
|
|
1222
|
-
* @returns Customer
|
|
1223
|
-
*/
|
|
1224
|
-
async getOrCreateForProfile(profileId, defaults = {}) {
|
|
1225
|
-
const existing = await this.findByProfile(profileId);
|
|
1226
|
-
if (existing.length > 0) return existing[0];
|
|
1227
|
-
const customer = await this.create({
|
|
1228
|
-
profileId,
|
|
1229
|
-
creditLimit: defaults.creditLimit ?? 0,
|
|
1230
|
-
paymentTerms: defaults.paymentTerms ?? "",
|
|
1231
|
-
status: CustomerStatus.ACTIVE
|
|
1232
|
-
});
|
|
1233
|
-
await customer.save();
|
|
1234
|
-
return customer;
|
|
1235
|
-
}
|
|
1236
|
-
/**
|
|
1237
|
-
* Find all customers belonging to a specific tenant
|
|
1238
|
-
*
|
|
1239
|
-
* @param tenantId - Tenant ID
|
|
1240
|
-
* @returns Array of customers for the tenant
|
|
1241
|
-
*/
|
|
1242
|
-
async findByTenant(tenantId) {
|
|
1243
|
-
return this.list({ where: { tenantId } });
|
|
1244
|
-
}
|
|
1245
|
-
/**
|
|
1246
|
-
* Find all global customers (not associated with any tenant).
|
|
1247
|
-
*
|
|
1248
|
-
* Routes through the shared tenant-global helper so it does not throw under
|
|
1249
|
-
* an active tenant context (an explicit `tenant_id IS NULL` filter would be
|
|
1250
|
-
* flagged as an isolation violation). (#1600)
|
|
1251
|
-
*
|
|
1252
|
-
* @returns Array of global customers
|
|
1253
|
-
*/
|
|
1254
|
-
async findGlobal() {
|
|
1255
|
-
return queryGlobal(this);
|
|
1575
|
+
await runtime.ensureProviderCustomer(account);
|
|
1576
|
+
await runtime.provider.sendInvoice(providerInvoiceId);
|
|
1577
|
+
state = await runtime.provider.getInvoice(providerInvoiceId);
|
|
1256
1578
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1579
|
+
if (state.status === "draft" || state.status === "void") throw new Error(`Provider invoice ${providerInvoiceId} is ${state.status}; expected it to be sent.`);
|
|
1580
|
+
if (state.currency !== close.currency || state.subtotal !== invoice.subtotal || state.total !== state.subtotal + state.taxAmount) throw new Error(`Provider invoice ${providerInvoiceId} does not match invoice ${invoice.invoiceNumber}: provider ${state.subtotal}+${state.taxAmount}=${state.total} ${state.currency}, local subtotal ${invoice.subtotal} ${close.currency}.`);
|
|
1581
|
+
await withTenant({ tenantId: runtime.sellerTenantId }, async () => {
|
|
1582
|
+
invoice.providerTaxAmount = state.taxAmount;
|
|
1583
|
+
if (invoice.status === InvoiceStatus.DRAFT) invoice.markSent();
|
|
1584
|
+
await invoice.save();
|
|
1585
|
+
});
|
|
1586
|
+
if (invoice.totalAmount !== state.total) throw new Error(`Invoice ${invoice.invoiceNumber} total ${invoice.totalAmount} does not match provider total ${state.total}.`);
|
|
1587
|
+
close.status = "sent";
|
|
1588
|
+
await close.save();
|
|
1589
|
+
}
|
|
1590
|
+
async function postRevenue(runtime, invoice) {
|
|
1591
|
+
if (invoice.totalAmount <= 0 || invoice.arJournalId) return;
|
|
1592
|
+
await withTenant({ tenantId: runtime.sellerTenantId }, async () => {
|
|
1593
|
+
const posted = await runtime.journals.list({
|
|
1594
|
+
where: {
|
|
1595
|
+
sourceModule: "smrt-commerce",
|
|
1596
|
+
sourceRef: String(invoice.id),
|
|
1597
|
+
status: "posted"
|
|
1598
|
+
},
|
|
1599
|
+
limit: 1
|
|
1600
|
+
});
|
|
1601
|
+
if (posted[0]?.id) {
|
|
1602
|
+
invoice.arJournalId = String(posted[0].id);
|
|
1603
|
+
await invoice.save();
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
await invoice.recognizeRevenue({
|
|
1607
|
+
arAccountId: runtime.ledger.arAccountId,
|
|
1608
|
+
revenueAccountId: runtime.ledger.revenueAccountId,
|
|
1609
|
+
taxAccountId: runtime.ledger.taxAccountId
|
|
1610
|
+
});
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
//#endregion
|
|
1614
|
+
//#region src/billing/provider.ts
|
|
1615
|
+
var BillingWebhookVerificationError = class extends Error {
|
|
1616
|
+
constructor(message = "Billing webhook signature verification failed.") {
|
|
1617
|
+
super(message);
|
|
1618
|
+
this.name = "BillingWebhookVerificationError";
|
|
1268
1619
|
}
|
|
1269
1620
|
};
|
|
1270
1621
|
//#endregion
|
|
1271
1622
|
//#region src/models/Invoice.ts
|
|
1272
|
-
var __defProp$
|
|
1273
|
-
var __getOwnPropDesc$
|
|
1274
|
-
var __decorateClass$
|
|
1275
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1623
|
+
var __defProp$11 = Object.defineProperty;
|
|
1624
|
+
var __getOwnPropDesc$11 = Object.getOwnPropertyDescriptor;
|
|
1625
|
+
var __decorateClass$11 = (decorators, target, key, kind) => {
|
|
1626
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$11(target, key) : target;
|
|
1276
1627
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1277
|
-
if (kind && result) __defProp$
|
|
1628
|
+
if (kind && result) __defProp$11(target, key, result);
|
|
1278
1629
|
return result;
|
|
1279
1630
|
};
|
|
1280
1631
|
var INVOICE_STATUS_TRANSITIONS = {
|
|
@@ -1875,12 +2226,12 @@ var Invoice = class extends SmrtObject {
|
|
|
1875
2226
|
};
|
|
1876
2227
|
}
|
|
1877
2228
|
};
|
|
1878
|
-
__decorateClass$
|
|
1879
|
-
__decorateClass$
|
|
1880
|
-
__decorateClass$
|
|
1881
|
-
__decorateClass$
|
|
1882
|
-
__decorateClass$
|
|
1883
|
-
Invoice = __decorateClass$
|
|
2229
|
+
__decorateClass$11([tenantId({ nullable: true })], Invoice.prototype, "tenantId", 2);
|
|
2230
|
+
__decorateClass$11([foreignKey("Customer")], Invoice.prototype, "customerId", 2);
|
|
2231
|
+
__decorateClass$11([foreignKey("Contract")], Invoice.prototype, "contractId", 2);
|
|
2232
|
+
__decorateClass$11([crossPackageRef("@happyvertical/smrt-ledgers:Journal")], Invoice.prototype, "arJournalId", 2);
|
|
2233
|
+
__decorateClass$11([crossPackageRef("@happyvertical/smrt-ledgers:Journal")], Invoice.prototype, "revenueJournalId", 2);
|
|
2234
|
+
Invoice = __decorateClass$11([TenantScoped({ mode: "optional" }), smrt({
|
|
1884
2235
|
api: {
|
|
1885
2236
|
include: [
|
|
1886
2237
|
"list",
|
|
@@ -2146,12 +2497,12 @@ var InvoiceCollection = class extends SmrtCollection {
|
|
|
2146
2497
|
};
|
|
2147
2498
|
//#endregion
|
|
2148
2499
|
//#region src/models/InvoiceLineItem.ts
|
|
2149
|
-
var __defProp$
|
|
2150
|
-
var __getOwnPropDesc$
|
|
2151
|
-
var __decorateClass$
|
|
2152
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
2500
|
+
var __defProp$10 = Object.defineProperty;
|
|
2501
|
+
var __getOwnPropDesc$10 = Object.getOwnPropertyDescriptor;
|
|
2502
|
+
var __decorateClass$10 = (decorators, target, key, kind) => {
|
|
2503
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$10(target, key) : target;
|
|
2153
2504
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2154
|
-
if (kind && result) __defProp$
|
|
2505
|
+
if (kind && result) __defProp$10(target, key, result);
|
|
2155
2506
|
return result;
|
|
2156
2507
|
};
|
|
2157
2508
|
var InvoiceLineItem = class extends SmrtObject {
|
|
@@ -2307,10 +2658,10 @@ var InvoiceLineItem = class extends SmrtObject {
|
|
|
2307
2658
|
};
|
|
2308
2659
|
}
|
|
2309
2660
|
};
|
|
2310
|
-
__decorateClass$
|
|
2311
|
-
__decorateClass$
|
|
2312
|
-
__decorateClass$
|
|
2313
|
-
InvoiceLineItem = __decorateClass$
|
|
2661
|
+
__decorateClass$10([tenantId({ nullable: true })], InvoiceLineItem.prototype, "tenantId", 2);
|
|
2662
|
+
__decorateClass$10([foreignKey("Invoice")], InvoiceLineItem.prototype, "invoiceId", 2);
|
|
2663
|
+
__decorateClass$10([crossPackageRef("@happyvertical/smrt-ledgers:Account")], InvoiceLineItem.prototype, "revenueAccountId", 2);
|
|
2664
|
+
InvoiceLineItem = __decorateClass$10([TenantScoped({ mode: "optional" }), smrt({
|
|
2314
2665
|
api: { include: [
|
|
2315
2666
|
"list",
|
|
2316
2667
|
"get",
|
|
@@ -2462,12 +2813,12 @@ var InvoiceLineItemCollection = class extends SmrtCollection {
|
|
|
2462
2813
|
};
|
|
2463
2814
|
//#endregion
|
|
2464
2815
|
//#region src/models/billing.ts
|
|
2465
|
-
var __defProp$
|
|
2466
|
-
var __getOwnPropDesc$
|
|
2467
|
-
var __decorateClass$
|
|
2468
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
2816
|
+
var __defProp$9 = Object.defineProperty;
|
|
2817
|
+
var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
|
|
2818
|
+
var __decorateClass$9 = (decorators, target, key, kind) => {
|
|
2819
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
|
|
2469
2820
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2470
|
-
if (kind && result) __defProp$
|
|
2821
|
+
if (kind && result) __defProp$9(target, key, result);
|
|
2471
2822
|
return result;
|
|
2472
2823
|
};
|
|
2473
2824
|
var STANDINGS = [
|
|
@@ -2512,14 +2863,14 @@ var BillingAccount = class extends SmrtObject {
|
|
|
2512
2863
|
if (this.billingAnchorAt !== null && (!(this.billingAnchorAt instanceof Date) || !Number.isFinite(this.billingAnchorAt.getTime()))) throw new Error("billingAnchorAt must be a valid date or null.");
|
|
2513
2864
|
}
|
|
2514
2865
|
};
|
|
2515
|
-
__decorateClass$
|
|
2516
|
-
__decorateClass$
|
|
2517
|
-
__decorateClass$
|
|
2518
|
-
__decorateClass$
|
|
2866
|
+
__decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingAccount.prototype, "sellerTenantId", 2);
|
|
2867
|
+
__decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingAccount.prototype, "payerTenantId", 2);
|
|
2868
|
+
__decorateClass$9([foreignKey("Customer")], BillingAccount.prototype, "customerId", 2);
|
|
2869
|
+
__decorateClass$9([field({
|
|
2519
2870
|
type: "datetime",
|
|
2520
2871
|
nullable: true
|
|
2521
2872
|
})], BillingAccount.prototype, "billingAnchorAt", 2);
|
|
2522
|
-
BillingAccount = __decorateClass$
|
|
2873
|
+
BillingAccount = __decorateClass$9([smrt({
|
|
2523
2874
|
tableName: "_smrt_billing_accounts",
|
|
2524
2875
|
conflictColumns: ["seller_tenant_id", "payer_tenant_id"],
|
|
2525
2876
|
api: false,
|
|
@@ -2563,21 +2914,21 @@ var BillingPeriodClose = class extends SmrtObject {
|
|
|
2563
2914
|
return runBillingEventsJob(args);
|
|
2564
2915
|
}
|
|
2565
2916
|
};
|
|
2566
|
-
__decorateClass$
|
|
2567
|
-
__decorateClass$
|
|
2568
|
-
__decorateClass$
|
|
2569
|
-
__decorateClass$
|
|
2570
|
-
__decorateClass$
|
|
2917
|
+
__decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingPeriodClose.prototype, "sellerTenantId", 2);
|
|
2918
|
+
__decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingPeriodClose.prototype, "payerTenantId", 2);
|
|
2919
|
+
__decorateClass$9([foreignKey("BillingAccount")], BillingPeriodClose.prototype, "billingAccountId", 2);
|
|
2920
|
+
__decorateClass$9([foreignKey("Invoice")], BillingPeriodClose.prototype, "invoiceId", 2);
|
|
2921
|
+
__decorateClass$9([field({
|
|
2571
2922
|
type: "text",
|
|
2572
2923
|
nullable: true
|
|
2573
2924
|
})], BillingPeriodClose.prototype, "leaseToken", 2);
|
|
2574
|
-
__decorateClass$
|
|
2925
|
+
__decorateClass$9([field({
|
|
2575
2926
|
type: "datetime",
|
|
2576
2927
|
nullable: true
|
|
2577
2928
|
})], BillingPeriodClose.prototype, "leaseExpiresAt", 2);
|
|
2578
|
-
__decorateClass$
|
|
2579
|
-
__decorateClass$
|
|
2580
|
-
BillingPeriodClose = __decorateClass$
|
|
2929
|
+
__decorateClass$9([backgroundEligible()], BillingPeriodClose.prototype, "runPeriodClose", 1);
|
|
2930
|
+
__decorateClass$9([backgroundEligible()], BillingPeriodClose.prototype, "processBillingEvents", 1);
|
|
2931
|
+
BillingPeriodClose = __decorateClass$9([smrt({
|
|
2581
2932
|
tableName: "_smrt_billing_period_closes",
|
|
2582
2933
|
conflictColumns: [
|
|
2583
2934
|
"seller_tenant_id",
|
|
@@ -2618,9 +2969,9 @@ var BillingLineSource = class extends SmrtObject {
|
|
|
2618
2969
|
periodStart = null;
|
|
2619
2970
|
periodEnd = null;
|
|
2620
2971
|
};
|
|
2621
|
-
__decorateClass$
|
|
2622
|
-
__decorateClass$
|
|
2623
|
-
BillingLineSource = __decorateClass$
|
|
2972
|
+
__decorateClass$9([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingLineSource.prototype, "sellerTenantId", 2);
|
|
2973
|
+
__decorateClass$9([foreignKey("BillingPeriodClose")], BillingLineSource.prototype, "periodCloseId", 2);
|
|
2974
|
+
BillingLineSource = __decorateClass$9([smrt({
|
|
2624
2975
|
tableName: "_smrt_billing_line_sources",
|
|
2625
2976
|
conflictColumns: ["source_type", "source_id"],
|
|
2626
2977
|
indexes: [{
|
|
@@ -2683,6 +3034,8 @@ async function createCreditCheckout(runtime, input) {
|
|
|
2683
3034
|
const account = await runtime.getAccount(payer);
|
|
2684
3035
|
if (!account?.id) throw new Error(`No billing account for payer ${payer}.`);
|
|
2685
3036
|
const currency = normalizeCurrency(policy.currency);
|
|
3037
|
+
if (input.savePaymentMethod) assertCanSaveCards(runtime);
|
|
3038
|
+
const synced = input.savePaymentMethod ? await runtime.ensureProviderCustomer(account, { requireTaxLocation: false }) : null;
|
|
2686
3039
|
const metadata = encodeMetadata({
|
|
2687
3040
|
purpose: CREDIT_PURCHASE_PURPOSE,
|
|
2688
3041
|
sellerTenantId: runtime.sellerTenantId,
|
|
@@ -2699,7 +3052,10 @@ async function createCreditCheckout(runtime, input) {
|
|
|
2699
3052
|
String(policy.id),
|
|
2700
3053
|
input.purchaseId
|
|
2701
3054
|
]);
|
|
2702
|
-
const providerCustomerId = account.provider === runtime.provider.name ? account.providerCustomerId : "";
|
|
3055
|
+
const providerCustomerId = synced?.providerCustomerId ?? (account.provider === runtime.provider.name ? account.providerCustomerId : "");
|
|
3056
|
+
const automaticTax = input.automaticTax ?? await runtime.accountIsTaxed(account);
|
|
3057
|
+
if (synced) metadata[SAVE_CARD_METADATA] = "1";
|
|
3058
|
+
if (automaticTax && providerCustomerId && runtime.provider.getCheckout && !await runtime.hasTaxLocation(account)) metadata[COLLECT_ADDRESS_METADATA] = "1";
|
|
2703
3059
|
return runtime.provider.createCheckout({
|
|
2704
3060
|
idempotencyKey: `smrt-credit-checkout:${key}`,
|
|
2705
3061
|
providerCustomerId: providerCustomerId || void 0,
|
|
@@ -2709,17 +3065,19 @@ async function createCreditCheckout(runtime, input) {
|
|
|
2709
3065
|
description: input.description || "Prepaid credit",
|
|
2710
3066
|
successUrl: input.successUrl,
|
|
2711
3067
|
cancelUrl: input.cancelUrl,
|
|
2712
|
-
metadata
|
|
3068
|
+
metadata,
|
|
3069
|
+
automaticTax,
|
|
3070
|
+
...input.savePaymentMethod ? { savePaymentMethod: true } : {}
|
|
2713
3071
|
});
|
|
2714
3072
|
}
|
|
2715
3073
|
//#endregion
|
|
2716
3074
|
//#region src/models/PaymentAllocation.ts
|
|
2717
|
-
var __defProp$
|
|
2718
|
-
var __getOwnPropDesc$
|
|
2719
|
-
var __decorateClass$
|
|
2720
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
3075
|
+
var __defProp$8 = Object.defineProperty;
|
|
3076
|
+
var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
|
|
3077
|
+
var __decorateClass$8 = (decorators, target, key, kind) => {
|
|
3078
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
|
|
2721
3079
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2722
|
-
if (kind && result) __defProp$
|
|
3080
|
+
if (kind && result) __defProp$8(target, key, result);
|
|
2723
3081
|
return result;
|
|
2724
3082
|
};
|
|
2725
3083
|
var PaymentAllocation = class extends SmrtObject {
|
|
@@ -2810,10 +3168,10 @@ var PaymentAllocation = class extends SmrtObject {
|
|
|
2810
3168
|
return super.save();
|
|
2811
3169
|
}
|
|
2812
3170
|
};
|
|
2813
|
-
__decorateClass$
|
|
2814
|
-
__decorateClass$
|
|
2815
|
-
__decorateClass$
|
|
2816
|
-
PaymentAllocation = __decorateClass$
|
|
3171
|
+
__decorateClass$8([tenantId({ nullable: true })], PaymentAllocation.prototype, "tenantId", 2);
|
|
3172
|
+
__decorateClass$8([foreignKey("Payment")], PaymentAllocation.prototype, "paymentId", 2);
|
|
3173
|
+
__decorateClass$8([foreignKey("Invoice")], PaymentAllocation.prototype, "invoiceId", 2);
|
|
3174
|
+
PaymentAllocation = __decorateClass$8([TenantScoped({ mode: "optional" }), smrt({
|
|
2817
3175
|
api: { include: ["list", "get"] },
|
|
2818
3176
|
mcp: { include: ["list", "get"] },
|
|
2819
3177
|
cli: { include: ["list", "get"] }
|
|
@@ -2959,12 +3317,12 @@ var PaymentAllocationCollection = class extends SmrtCollection {
|
|
|
2959
3317
|
};
|
|
2960
3318
|
//#endregion
|
|
2961
3319
|
//#region src/models/Payment.ts
|
|
2962
|
-
var __defProp$
|
|
2963
|
-
var __getOwnPropDesc$
|
|
2964
|
-
var __decorateClass$
|
|
2965
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
3320
|
+
var __defProp$7 = Object.defineProperty;
|
|
3321
|
+
var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
|
|
3322
|
+
var __decorateClass$7 = (decorators, target, key, kind) => {
|
|
3323
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
|
|
2966
3324
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2967
|
-
if (kind && result) __defProp$
|
|
3325
|
+
if (kind && result) __defProp$7(target, key, result);
|
|
2968
3326
|
return result;
|
|
2969
3327
|
};
|
|
2970
3328
|
var PAYMENT_STATUS_TRANSITIONS = {
|
|
@@ -3371,11 +3729,11 @@ var Payment = class extends SmrtObject {
|
|
|
3371
3729
|
this.status = PaymentStatus.CANCELLED;
|
|
3372
3730
|
}
|
|
3373
3731
|
};
|
|
3374
|
-
__decorateClass$
|
|
3375
|
-
__decorateClass$
|
|
3376
|
-
__decorateClass$
|
|
3377
|
-
__decorateClass$
|
|
3378
|
-
Payment = __decorateClass$
|
|
3732
|
+
__decorateClass$7([tenantId({ nullable: true })], Payment.prototype, "tenantId", 2);
|
|
3733
|
+
__decorateClass$7([foreignKey("Contract")], Payment.prototype, "contractId", 2);
|
|
3734
|
+
__decorateClass$7([foreignKey("Customer")], Payment.prototype, "customerId", 2);
|
|
3735
|
+
__decorateClass$7([crossPackageRef("@happyvertical/smrt-ledgers:Journal")], Payment.prototype, "journalId", 2);
|
|
3736
|
+
Payment = __decorateClass$7([TenantScoped({ mode: "optional" }), smrt({
|
|
3379
3737
|
api: {
|
|
3380
3738
|
include: [
|
|
3381
3739
|
"list",
|
|
@@ -3561,6 +3919,213 @@ var PaymentCollection = class extends SmrtCollection {
|
|
|
3561
3919
|
}
|
|
3562
3920
|
};
|
|
3563
3921
|
//#endregion
|
|
3922
|
+
//#region src/billing/top-up.ts
|
|
3923
|
+
var AUTO_TOP_UP_CHARGE_PREFIX = "smrt-auto-top-up:";
|
|
3924
|
+
var AUTO_TOP_UP_REFERENCE_PREFIX = "auto-top-up:";
|
|
3925
|
+
var DEFAULT_RETRY_AFTER_MS = 3600 * 1e3;
|
|
3926
|
+
var DEFAULT_RECHECK_AFTER_MS = 60 * 1e3;
|
|
3927
|
+
function autoTopUpChargeKey(paymentId) {
|
|
3928
|
+
return `${AUTO_TOP_UP_CHARGE_PREFIX}${paymentId}`;
|
|
3929
|
+
}
|
|
3930
|
+
function autoTopUpPaymentId(chargeKey) {
|
|
3931
|
+
if (!chargeKey.startsWith("smrt-auto-top-up:")) return null;
|
|
3932
|
+
return chargeKey.slice(17) || null;
|
|
3933
|
+
}
|
|
3934
|
+
function positiveMs(value, fallback) {
|
|
3935
|
+
if (value === void 0) return fallback;
|
|
3936
|
+
if (!Number.isFinite(value) || value < 0) throw new Error("Auto top-up intervals must be non-negative numbers.");
|
|
3937
|
+
return value;
|
|
3938
|
+
}
|
|
3939
|
+
function createAutoTopUpHook(runtime, options = {}) {
|
|
3940
|
+
const retryAfterMs = positiveMs(options.retryAfterMs, DEFAULT_RETRY_AFTER_MS);
|
|
3941
|
+
const recheckAfterMs = positiveMs(options.recheckAfterMs, DEFAULT_RECHECK_AFTER_MS);
|
|
3942
|
+
return async (request) => {
|
|
3943
|
+
const charge = runtime.provider.chargeSavedPaymentMethod;
|
|
3944
|
+
if (!charge) return null;
|
|
3945
|
+
const attempt = await withSystemContext(() => claimAttempt(runtime, request, options, retryAfterMs, recheckAfterMs));
|
|
3946
|
+
if (!attempt) return null;
|
|
3947
|
+
const { payment, payerTenantId, providerCustomerId } = attempt;
|
|
3948
|
+
const paymentId = String(payment.id);
|
|
3949
|
+
const result = await charge.call(runtime.provider, {
|
|
3950
|
+
providerCustomerId,
|
|
3951
|
+
amount: payment.amount,
|
|
3952
|
+
currency: payment.currency,
|
|
3953
|
+
idempotencyKey: autoTopUpChargeKey(paymentId),
|
|
3954
|
+
description: options.description || "Prepaid credit top-up",
|
|
3955
|
+
metadata: {
|
|
3956
|
+
smrt_purpose: "auto_top_up",
|
|
3957
|
+
smrt_seller: runtime.sellerTenantId,
|
|
3958
|
+
smrt_payer: payerTenantId,
|
|
3959
|
+
smrt_policy: request.policyId
|
|
3960
|
+
}
|
|
3961
|
+
});
|
|
3962
|
+
const outcome = {
|
|
3963
|
+
status: result.status,
|
|
3964
|
+
providerPaymentId: result.providerPaymentId,
|
|
3965
|
+
providerCustomerId,
|
|
3966
|
+
amount: result.amount,
|
|
3967
|
+
currency: result.currency,
|
|
3968
|
+
failureCode: result.failureCode
|
|
3969
|
+
};
|
|
3970
|
+
return (await withTenant({ tenantId: runtime.sellerTenantId }, () => inTransaction(runtime.db, (tx) => applyAutoTopUpOutcome(runtime, tx, paymentId, outcome)))).grant;
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
async function claimAttempt(runtime, request, options, retryAfterMs, recheckAfterMs) {
|
|
3974
|
+
const policy = await runtime.policies.get(request.policyId);
|
|
3975
|
+
if (!policy?.id || policy.period !== "balance" || !policy.active) return null;
|
|
3976
|
+
const currency = normalizeCurrency(policy.currency);
|
|
3977
|
+
if (normalizeCurrency(request.currency) !== currency) return null;
|
|
3978
|
+
const payerTenantId = canonicalTenantId(tenantKey(policy.setByTenantId) || String(policy.tenantId), "payerTenantId");
|
|
3979
|
+
const account = await runtime.getAccount(payerTenantId);
|
|
3980
|
+
if (!account?.id || account.provider !== runtime.provider.name || !account.providerCustomerId) return null;
|
|
3981
|
+
const providerCustomerId = account.providerCustomerId;
|
|
3982
|
+
const payments = await PaymentCollection.create({ db: runtime.db });
|
|
3983
|
+
const where = {
|
|
3984
|
+
tenantId: runtime.sellerTenantId,
|
|
3985
|
+
reference: `${AUTO_TOP_UP_REFERENCE_PREFIX}${policy.id}`,
|
|
3986
|
+
externalProvider: runtime.provider.name
|
|
3987
|
+
};
|
|
3988
|
+
const attemptId = (sequence2) => deterministicId([
|
|
3989
|
+
"billing-auto-top-up",
|
|
3990
|
+
runtime.provider.name,
|
|
3991
|
+
runtime.sellerTenantId,
|
|
3992
|
+
String(policy.id),
|
|
3993
|
+
String(sequence2)
|
|
3994
|
+
]);
|
|
3995
|
+
const sequence = await payments.count({ where });
|
|
3996
|
+
const latest = sequence > 0 ? await payments.get(await attemptId(sequence - 1)) : null;
|
|
3997
|
+
if (sequence > 0 && !latest) throw new Error(`Auto top-up attempt ${sequence - 1} is missing.`);
|
|
3998
|
+
const now = Date.now();
|
|
3999
|
+
if (latest?.status === PaymentStatus.PENDING) {
|
|
4000
|
+
if (now - timeOf(latest) < recheckAfterMs) return null;
|
|
4001
|
+
return {
|
|
4002
|
+
payment: latest,
|
|
4003
|
+
payerTenantId,
|
|
4004
|
+
providerCustomerId
|
|
4005
|
+
};
|
|
4006
|
+
}
|
|
4007
|
+
if (latest?.status === PaymentStatus.FAILED && now - timeOf(latest) < retryAfterMs) return null;
|
|
4008
|
+
if (options.taxedAccounts !== "charge_untaxed" && await runtime.accountIsTaxed(account)) return null;
|
|
4009
|
+
if (!await defaultCardFor(runtime, account, providerCustomerId)) return null;
|
|
4010
|
+
const shortfall = request.currentShortfall ? await request.currentShortfall() : request.shortfall;
|
|
4011
|
+
if (shortfall <= 0) return null;
|
|
4012
|
+
const current = {
|
|
4013
|
+
...request,
|
|
4014
|
+
shortfall
|
|
4015
|
+
};
|
|
4016
|
+
const requested = options.amount ? await options.amount(current) : shortfall;
|
|
4017
|
+
if (!requested) return null;
|
|
4018
|
+
if (!Number.isSafeInteger(requested) || requested <= 0) throw new Error("Auto top-up amount must be positive integer minor units.");
|
|
4019
|
+
const id = await attemptId(sequence);
|
|
4020
|
+
try {
|
|
4021
|
+
return {
|
|
4022
|
+
payment: await payments.create({
|
|
4023
|
+
id,
|
|
4024
|
+
tenantId: runtime.sellerTenantId,
|
|
4025
|
+
customerId: account.customerId,
|
|
4026
|
+
amount: requested,
|
|
4027
|
+
currency,
|
|
4028
|
+
method: PaymentMethod.CREDIT_CARD,
|
|
4029
|
+
status: PaymentStatus.PENDING,
|
|
4030
|
+
reference: where.reference,
|
|
4031
|
+
externalProvider: runtime.provider.name,
|
|
4032
|
+
backendId: runtime.provider.name,
|
|
4033
|
+
notes: `attempt ${sequence}`,
|
|
4034
|
+
_insertOnly: true
|
|
4035
|
+
}),
|
|
4036
|
+
payerTenantId,
|
|
4037
|
+
providerCustomerId
|
|
4038
|
+
};
|
|
4039
|
+
} catch (error) {
|
|
4040
|
+
if (isUniqueViolationError(error) || await payments.get(id)) return null;
|
|
4041
|
+
throw error;
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
function inTransaction(db, operation) {
|
|
4045
|
+
if (!db.transaction) throw new Error("Auto top-up requires a database adapter with transaction().");
|
|
4046
|
+
let result;
|
|
4047
|
+
return db.transaction(async (tx) => {
|
|
4048
|
+
result = await operation(tx);
|
|
4049
|
+
}).then(() => result);
|
|
4050
|
+
}
|
|
4051
|
+
function timeOf(payment) {
|
|
4052
|
+
const at = payment.updated_at ?? payment.created_at;
|
|
4053
|
+
return at instanceof Date ? at.getTime() : new Date(String(at)).getTime();
|
|
4054
|
+
}
|
|
4055
|
+
async function applyAutoTopUpOutcome(runtime, db, paymentId, outcome) {
|
|
4056
|
+
const payments = await PaymentCollection.create({ db });
|
|
4057
|
+
const pending = (await payments.query(`UPDATE ${payments.tableName}
|
|
4058
|
+
SET updated_at = ?
|
|
4059
|
+
WHERE id = ? AND tenant_id = ? AND status = ?
|
|
4060
|
+
RETURNING id`, [
|
|
4061
|
+
(/* @__PURE__ */ new Date()).toISOString(),
|
|
4062
|
+
paymentId,
|
|
4063
|
+
runtime.sellerTenantId,
|
|
4064
|
+
PaymentStatus.PENDING
|
|
4065
|
+
], { allowRawOnTenantScoped: true })).length === 1;
|
|
4066
|
+
const payment = await payments.get(paymentId);
|
|
4067
|
+
if (!payment?.id || tenantKey(payment.tenantId) !== runtime.sellerTenantId || payment.externalProvider !== runtime.provider.name || !payment.reference.startsWith("auto-top-up:")) throw new Error(`Auto top-up attempt ${paymentId} was not found.`);
|
|
4068
|
+
const policyId = payment.reference.slice(12);
|
|
4069
|
+
const policy = await withSystemContext(() => runtime.policies.get(policyId));
|
|
4070
|
+
if (!policy?.id) throw new Error(`Auto top-up policy ${policyId} was not found.`);
|
|
4071
|
+
const setBy = tenantKey(policy.setByTenantId);
|
|
4072
|
+
const payerTenantId = canonicalTenantId(setBy || String(policy.tenantId), "payerTenantId");
|
|
4073
|
+
const account = await withSystemContext(() => runtime.getAccount(payerTenantId));
|
|
4074
|
+
if (outcome.amount !== void 0 && outcome.amount !== payment.amount || outcome.currency !== void 0 && normalizeCurrency(outcome.currency) !== normalizeCurrency(payment.currency) || outcome.providerCustomerId !== void 0 && outcome.providerCustomerId !== account?.providerCustomerId) throw new Error(`Charge for auto top-up ${paymentId} does not match it: ${outcome.amount} ${outcome.currency} for ${payment.amount} ${payment.currency}.`);
|
|
4075
|
+
if (outcome.status === "succeeded") {
|
|
4076
|
+
if (payment.status === PaymentStatus.FAILED) throw new Error(`Auto top-up ${paymentId} was recorded as failed but its charge succeeded.`);
|
|
4077
|
+
const grant = {
|
|
4078
|
+
amount: payment.amount,
|
|
4079
|
+
source: `${runtime.provider.name}-auto-top-up`,
|
|
4080
|
+
sourceId: autoTopUpChargeKey(paymentId),
|
|
4081
|
+
reason: "Automatic prepaid credit top-up"
|
|
4082
|
+
};
|
|
4083
|
+
if (pending) {
|
|
4084
|
+
await withSystemContext(async () => {
|
|
4085
|
+
await (await SpendingPolicyEvaluator.create({ db })).grantCredit({
|
|
4086
|
+
spendingPolicyId: policyId,
|
|
4087
|
+
amount: grant.amount,
|
|
4088
|
+
reason: grant.reason,
|
|
4089
|
+
source: grant.source,
|
|
4090
|
+
sourceId: grant.sourceId,
|
|
4091
|
+
...setBy ? { grantedByTenantId: setBy } : {}
|
|
4092
|
+
});
|
|
4093
|
+
});
|
|
4094
|
+
if (outcome.providerPaymentId) payment.externalId = outcome.providerPaymentId;
|
|
4095
|
+
await payment.recordPayment({
|
|
4096
|
+
ledgerId: "",
|
|
4097
|
+
cashAccountId: runtime.ledger.cashAccountId,
|
|
4098
|
+
receivablesAccountId: runtime.ledger.prepaidCreditAccountId
|
|
4099
|
+
});
|
|
4100
|
+
}
|
|
4101
|
+
return { grant };
|
|
4102
|
+
}
|
|
4103
|
+
if (!pending) return { grant: null };
|
|
4104
|
+
if (outcome.status === "processing") {
|
|
4105
|
+
if (outcome.providerPaymentId && !payment.externalId) {
|
|
4106
|
+
payment.externalId = outcome.providerPaymentId;
|
|
4107
|
+
await payment.save();
|
|
4108
|
+
}
|
|
4109
|
+
return { grant: null };
|
|
4110
|
+
}
|
|
4111
|
+
payment.status = PaymentStatus.FAILED;
|
|
4112
|
+
if (outcome.providerPaymentId && !payment.externalId) payment.externalId = outcome.providerPaymentId;
|
|
4113
|
+
payment.notes = `${outcome.status}${outcome.failureCode ? `: ${outcome.failureCode}` : ""}`;
|
|
4114
|
+
await payment.save();
|
|
4115
|
+
await runtime.onAutoTopUpFailed?.({
|
|
4116
|
+
sellerTenantId: runtime.sellerTenantId,
|
|
4117
|
+
payerTenantId,
|
|
4118
|
+
spendingPolicyId: policyId,
|
|
4119
|
+
paymentId,
|
|
4120
|
+
status: outcome.status,
|
|
4121
|
+
failureCode: outcome.failureCode,
|
|
4122
|
+
amount: payment.amount,
|
|
4123
|
+
currency: normalizeCurrency(payment.currency),
|
|
4124
|
+
db
|
|
4125
|
+
});
|
|
4126
|
+
return { grant: null };
|
|
4127
|
+
}
|
|
4128
|
+
//#endregion
|
|
3564
4129
|
//#region src/billing/events.ts
|
|
3565
4130
|
var PROJECTION = "billing-provider-events";
|
|
3566
4131
|
async function processBillingEvents(runtime, limit) {
|
|
@@ -3593,8 +4158,15 @@ function createBillingEventProjector(runtime) {
|
|
|
3593
4158
|
event,
|
|
3594
4159
|
subscription: await runtime.provider.getSubscription(event.providerSubscriptionId)
|
|
3595
4160
|
};
|
|
3596
|
-
else if (event.kind === "checkout_completed") value =
|
|
3597
|
-
else
|
|
4161
|
+
else if (event.kind === "checkout_completed") value = await observeCheckout(runtime, event);
|
|
4162
|
+
else if (event.kind === "payment") {
|
|
4163
|
+
const paymentId = autoTopUpPaymentId(event.chargeKey);
|
|
4164
|
+
if (!paymentId || !await isOwnTopUp(runtime, paymentId)) return null;
|
|
4165
|
+
value = {
|
|
4166
|
+
event,
|
|
4167
|
+
paymentId
|
|
4168
|
+
};
|
|
4169
|
+
} else return null;
|
|
3598
4170
|
return {
|
|
3599
4171
|
projection: PROJECTION,
|
|
3600
4172
|
subjectKey: event.eventId,
|
|
@@ -3606,10 +4178,48 @@ function createBillingEventProjector(runtime) {
|
|
|
3606
4178
|
const value = observation.value;
|
|
3607
4179
|
if ("invoice" in value) await applyInvoiceEvent(runtime, context.db, value.event, value.invoice);
|
|
3608
4180
|
else if ("subscription" in value) await applySubscriptionState(runtime, context.db, value.subscription);
|
|
3609
|
-
else await
|
|
4181
|
+
else if ("paymentId" in value) await applyAutoTopUpOutcome(runtime, context.db, value.paymentId, {
|
|
4182
|
+
status: value.event.status,
|
|
4183
|
+
providerPaymentId: value.event.providerPaymentId,
|
|
4184
|
+
providerCustomerId: value.event.providerCustomerId,
|
|
4185
|
+
amount: value.event.amount,
|
|
4186
|
+
currency: value.event.currency,
|
|
4187
|
+
failureCode: value.event.failureCode
|
|
4188
|
+
});
|
|
4189
|
+
else {
|
|
4190
|
+
if (value.card) await recordSavedCard(runtime, context.db, value.card);
|
|
4191
|
+
await applyCheckout(runtime, context.db, value.event, value.checkout);
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4194
|
+
};
|
|
4195
|
+
}
|
|
4196
|
+
async function observeCheckout(runtime, event) {
|
|
4197
|
+
const getCheckout = runtime.provider.getCheckout;
|
|
4198
|
+
const checkout = getCheckout ? await getCheckout.call(runtime.provider, event.sessionId) : null;
|
|
4199
|
+
if (checkout && checkout.sessionId !== event.sessionId) throw new Error(`Checkout ${event.sessionId} re-read as ${checkout.sessionId}.`);
|
|
4200
|
+
const savesCard = event.mode === "setup" && event.metadata.smrt_purpose === "card_setup" || event.metadata["smrt_save_card"] === "1";
|
|
4201
|
+
const collectsAddress = event.metadata[COLLECT_ADDRESS_METADATA] === "1";
|
|
4202
|
+
let card = null;
|
|
4203
|
+
if ((savesCard || collectsAddress) && !checkout) throw new Error(`Billing provider ${runtime.provider.name} cannot re-read checkout ${event.sessionId} to apply what it saved.`);
|
|
4204
|
+
if (checkout && (savesCard || collectsAddress)) {
|
|
4205
|
+
card = await savedCardFromCheckout(runtime, event.metadata, checkout, savesCard);
|
|
4206
|
+
if (card?.paymentMethodId) {
|
|
4207
|
+
const setDefault = runtime.provider.setDefaultPaymentMethod;
|
|
4208
|
+
if (!setDefault) throw new Error(`Billing provider ${runtime.provider.name} cannot set a default payment method.`);
|
|
4209
|
+
await setDefault.call(runtime.provider, card.providerCustomerId, card.paymentMethodId);
|
|
3610
4210
|
}
|
|
4211
|
+
}
|
|
4212
|
+
return {
|
|
4213
|
+
event,
|
|
4214
|
+
checkout,
|
|
4215
|
+
card
|
|
3611
4216
|
};
|
|
3612
4217
|
}
|
|
4218
|
+
async function isOwnTopUp(runtime, paymentId) {
|
|
4219
|
+
const payments = await PaymentCollection.create({ db: runtime.db });
|
|
4220
|
+
const payment = await withSystemContext(() => payments.get(paymentId));
|
|
4221
|
+
return Boolean(payment && tenantKey(payment.tenantId) === runtime.sellerTenantId && payment.externalProvider === runtime.provider.name);
|
|
4222
|
+
}
|
|
3613
4223
|
function readEvent(delivery) {
|
|
3614
4224
|
const event = delivery.payload.event;
|
|
3615
4225
|
if (!event || typeof event !== "object" || !event.kind || !event.eventId) throw new Error(`Billing delivery ${delivery.deliveryId} has no event.`);
|
|
@@ -3633,10 +4243,16 @@ async function applyInvoiceEvent(runtime, db, event, state) {
|
|
|
3633
4243
|
await settlePaidInvoice(runtime, db, invoice, state);
|
|
3634
4244
|
standing = "current";
|
|
3635
4245
|
} else if (state.status === "void") {
|
|
3636
|
-
if (invoice.status !== InvoiceStatus.PAID && invoice.status !== InvoiceStatus.CANCELLED) {
|
|
4246
|
+
if (invoice.status !== InvoiceStatus.PAID && invoice.status !== InvoiceStatus.CANCELLED && invoice.status !== InvoiceStatus.WRITTEN_OFF) {
|
|
3637
4247
|
invoice.cancel();
|
|
3638
4248
|
await invoice.save();
|
|
3639
4249
|
}
|
|
4250
|
+
} else if (state.status === "uncollectible") {
|
|
4251
|
+
if (invoice.status === InvoiceStatus.DRAFT || invoice.status === InvoiceStatus.SENT || invoice.status === InvoiceStatus.VIEWED || invoice.status === InvoiceStatus.PARTIAL || invoice.status === InvoiceStatus.OVERDUE) {
|
|
4252
|
+
invoice.status = InvoiceStatus.WRITTEN_OFF;
|
|
4253
|
+
await invoice.save();
|
|
4254
|
+
standing = "uncollectible";
|
|
4255
|
+
}
|
|
3640
4256
|
} else if (state.status === "open") {
|
|
3641
4257
|
if (event.type === "payment_failed" || event.type === "overdue") {
|
|
3642
4258
|
standing = "past_due";
|
|
@@ -3692,6 +4308,7 @@ async function settlePaidInvoice(runtime, db, invoice, state) {
|
|
|
3692
4308
|
_insertOnly: true
|
|
3693
4309
|
});
|
|
3694
4310
|
}
|
|
4311
|
+
if (invoice.status === InvoiceStatus.WRITTEN_OFF) return;
|
|
3695
4312
|
invoice.updatePaymentStatus(await allocations.getTotalAllocatedToInvoice(String(invoice.id)));
|
|
3696
4313
|
await invoice.save();
|
|
3697
4314
|
}
|
|
@@ -3753,13 +4370,16 @@ async function applySubscriptionState(runtime, db, state) {
|
|
|
3753
4370
|
}
|
|
3754
4371
|
});
|
|
3755
4372
|
}
|
|
3756
|
-
async function applyCheckout(runtime, db, event) {
|
|
4373
|
+
async function applyCheckout(runtime, db, event, checkout) {
|
|
3757
4374
|
const metadata = creditMetadata(event.metadata);
|
|
3758
4375
|
if (!metadata || metadata.purpose !== "credit_purchase") return;
|
|
3759
4376
|
if (metadata.sellerTenantId !== runtime.sellerTenantId) return;
|
|
3760
|
-
if (!event.paid) return;
|
|
3761
|
-
|
|
3762
|
-
|
|
4377
|
+
if (!(checkout ? checkout.complete && checkout.paid : event.paid)) return;
|
|
4378
|
+
const currency = normalizeCurrency((checkout ? checkout.currency : event.currency) ?? "");
|
|
4379
|
+
const subtotal = checkout ? checkout.amountSubtotal : event.amountSubtotal;
|
|
4380
|
+
const tax = (checkout ? checkout.amountTax : event.amountTax) ?? 0;
|
|
4381
|
+
const total = checkout ? checkout.amountTotal : event.amountTotal;
|
|
4382
|
+
if (currency !== metadata.currency || subtotal !== metadata.amount || !Number.isSafeInteger(tax) || tax < 0 || total !== metadata.amount + tax) throw new Error(`Checkout ${event.sessionId} collected ${total} (${subtotal} + ${tax} tax) ${currency}; expected ${metadata.amount} ${metadata.currency} plus tax.`);
|
|
3763
4383
|
await withSystemContext(async () => {
|
|
3764
4384
|
await (await SpendingPolicyEvaluator.create({ db })).grantCredit({
|
|
3765
4385
|
spendingPolicyId: metadata.spendingPolicyId,
|
|
@@ -3782,7 +4402,7 @@ async function applyCheckout(runtime, db, event) {
|
|
|
3782
4402
|
id: paymentId,
|
|
3783
4403
|
tenantId: runtime.sellerTenantId,
|
|
3784
4404
|
customerId: account.customerId,
|
|
3785
|
-
amount:
|
|
4405
|
+
amount: total,
|
|
3786
4406
|
currency: metadata.currency,
|
|
3787
4407
|
method: PaymentMethod.CREDIT_CARD,
|
|
3788
4408
|
reference: `credit:${metadata.spendingPolicyId}`,
|
|
@@ -3790,17 +4410,39 @@ async function applyCheckout(runtime, db, event) {
|
|
|
3790
4410
|
externalProvider: runtime.provider.name,
|
|
3791
4411
|
_insertOnly: true
|
|
3792
4412
|
});
|
|
3793
|
-
if (payment.status !== PaymentStatus.COMPLETED)
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
4413
|
+
if (payment.status !== PaymentStatus.COMPLETED) {
|
|
4414
|
+
await payment.recordPayment({
|
|
4415
|
+
ledgerId: "",
|
|
4416
|
+
cashAccountId: runtime.ledger.cashAccountId,
|
|
4417
|
+
receivablesAccountId: runtime.ledger.prepaidCreditAccountId
|
|
4418
|
+
});
|
|
4419
|
+
if (tax > 0) {
|
|
4420
|
+
const journal = await (await JournalCollection.create({ db })).create({
|
|
4421
|
+
date: /* @__PURE__ */ new Date(),
|
|
4422
|
+
description: `Tax collected on prepaid credit ${event.sessionId}`,
|
|
4423
|
+
sourceModule: "smrt-commerce",
|
|
4424
|
+
sourceRef: `${paymentId}:tax`
|
|
4425
|
+
});
|
|
4426
|
+
await journal.save();
|
|
4427
|
+
await journal.addEntry({
|
|
4428
|
+
accountId: runtime.ledger.prepaidCreditAccountId,
|
|
4429
|
+
debit: tax,
|
|
4430
|
+
memo: `Tax on credit ${metadata.spendingPolicyId}`
|
|
4431
|
+
});
|
|
4432
|
+
await journal.addEntry({
|
|
4433
|
+
accountId: runtime.ledger.taxAccountId,
|
|
4434
|
+
credit: tax,
|
|
4435
|
+
memo: `Tax on credit ${metadata.spendingPolicyId}`
|
|
4436
|
+
});
|
|
4437
|
+
await journal.post();
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
3798
4440
|
}
|
|
3799
4441
|
//#endregion
|
|
3800
4442
|
//#region src/billing/runtime.ts
|
|
3801
4443
|
var DEFAULT_LEASE_MS = 600 * 1e3;
|
|
3802
4444
|
var BillingRuntime = class BillingRuntime {
|
|
3803
|
-
constructor(options, db, accounts, closes, sources, customers, invoices, lineItems, journals, charges, adjustments, retailCharges, books, subscriptions, plans, policies) {
|
|
4445
|
+
constructor(options, db, accounts, closes, sources, customers, invoices, lineItems, journals, charges, adjustments, retailCharges, books, subscriptions, plans, policies, instruments) {
|
|
3804
4446
|
this.db = db;
|
|
3805
4447
|
this.accounts = accounts;
|
|
3806
4448
|
this.closes = closes;
|
|
@@ -3816,6 +4458,7 @@ var BillingRuntime = class BillingRuntime {
|
|
|
3816
4458
|
this.subscriptions = subscriptions;
|
|
3817
4459
|
this.plans = plans;
|
|
3818
4460
|
this.policies = policies;
|
|
4461
|
+
this.instruments = instruments;
|
|
3819
4462
|
this.sellerTenantId = canonicalTenantId(options.sellerTenantId, "sellerTenantId");
|
|
3820
4463
|
if (options.kind !== "provider" && options.kind !== "reseller") throw new Error("Billing runtime kind must be provider or reseller.");
|
|
3821
4464
|
this.kind = options.kind;
|
|
@@ -3826,6 +4469,8 @@ var BillingRuntime = class BillingRuntime {
|
|
|
3826
4469
|
this.onPayerStanding = options.onPayerStanding;
|
|
3827
4470
|
this.leaseMs = options.leaseMs ?? DEFAULT_LEASE_MS;
|
|
3828
4471
|
this.pageSize = options.pageSize ?? 500;
|
|
4472
|
+
this.autoChargeInvoices = options.autoChargeInvoices ?? false;
|
|
4473
|
+
this.onAutoTopUpFailed = options.onAutoTopUpFailed;
|
|
3829
4474
|
this.eventProvider = `${options.provider.name}-billing:${this.sellerTenantId}`;
|
|
3830
4475
|
if (!Number.isFinite(this.leaseMs) || this.leaseMs <= 0) throw new Error("leaseMs must be a positive number.");
|
|
3831
4476
|
if (!Number.isSafeInteger(this.pageSize) || this.pageSize <= 0) throw new Error("pageSize must be a positive integer.");
|
|
@@ -3846,6 +4491,7 @@ var BillingRuntime = class BillingRuntime {
|
|
|
3846
4491
|
subscriptions;
|
|
3847
4492
|
plans;
|
|
3848
4493
|
policies;
|
|
4494
|
+
instruments;
|
|
3849
4495
|
sellerTenantId;
|
|
3850
4496
|
kind;
|
|
3851
4497
|
provider;
|
|
@@ -3855,16 +4501,18 @@ var BillingRuntime = class BillingRuntime {
|
|
|
3855
4501
|
onPayerStanding;
|
|
3856
4502
|
leaseMs;
|
|
3857
4503
|
pageSize;
|
|
4504
|
+
autoChargeInvoices;
|
|
4505
|
+
onAutoTopUpFailed;
|
|
3858
4506
|
/** The inbox provider namespace for this runtime's events (per seller). */
|
|
3859
4507
|
eventProvider;
|
|
3860
4508
|
static async create(options) {
|
|
3861
|
-
const { sellerTenantId: _seller, kind: _kind, provider: _provider, billingRelationships: _relationships, ledger: _ledger, invoiceNumberPrefix: _prefix, onPayerStanding: _hook, leaseMs: _leaseMs, pageSize: _pageSize, ...classOptions } = options;
|
|
4509
|
+
const { sellerTenantId: _seller, kind: _kind, provider: _provider, billingRelationships: _relationships, ledger: _ledger, invoiceNumberPrefix: _prefix, onPayerStanding: _hook, leaseMs: _leaseMs, pageSize: _pageSize, autoChargeInvoices: _autoCharge, onAutoTopUpFailed: _topUpFailed, ...classOptions } = options;
|
|
3862
4510
|
const accounts = await BillingAccountCollection.create(classOptions);
|
|
3863
4511
|
const shared = {
|
|
3864
4512
|
...classOptions,
|
|
3865
4513
|
db: accounts.db
|
|
3866
4514
|
};
|
|
3867
|
-
return new BillingRuntime(options, accounts.db, accounts, await BillingPeriodCloseCollection.create(shared), await BillingLineSourceCollection.create(shared), await CustomerCollection.create(shared), await InvoiceCollection.create(shared), await InvoiceLineItemCollection.create(shared), await JournalCollection.create(shared), await ClientChargeCollection.create(shared), await BillingAdjustmentCollection.create(shared), await RetailChargeCollection.create(shared), await PriceBookCollection.create(shared), await TenantSubscriptionCollection.create(shared), await SubscriptionPlanCollection.create(shared), await SpendingPolicyCollection.create(shared));
|
|
4515
|
+
return new BillingRuntime(options, accounts.db, accounts, await BillingPeriodCloseCollection.create(shared), await BillingLineSourceCollection.create(shared), await CustomerCollection.create(shared), await InvoiceCollection.create(shared), await InvoiceLineItemCollection.create(shared), await JournalCollection.create(shared), await ClientChargeCollection.create(shared), await BillingAdjustmentCollection.create(shared), await RetailChargeCollection.create(shared), await PriceBookCollection.create(shared), await TenantSubscriptionCollection.create(shared), await SubscriptionPlanCollection.create(shared), await SpendingPolicyCollection.create(shared), await PaymentInstrumentCollection.create(shared));
|
|
3868
4516
|
}
|
|
3869
4517
|
async getAccount(payerTenantId) {
|
|
3870
4518
|
return this.accounts.get(await this.accountId(payerTenantId));
|
|
@@ -3929,14 +4577,15 @@ var BillingRuntime = class BillingRuntime {
|
|
|
3929
4577
|
}
|
|
3930
4578
|
/**
|
|
3931
4579
|
* Create or update the provider customer, including its tax location.
|
|
3932
|
-
*
|
|
3933
|
-
* dies between creation and this save
|
|
4580
|
+
* Creation is idempotent per account at the provider (sdk#1268): an
|
|
4581
|
+
* attempt that dies between creation and this save finds the same
|
|
4582
|
+
* customer on retry.
|
|
3934
4583
|
*/
|
|
3935
|
-
async ensureProviderCustomer(account) {
|
|
4584
|
+
async ensureProviderCustomer(account, options = {}) {
|
|
3936
4585
|
const customer = await withTenant({ tenantId: this.sellerTenantId }, () => this.customers.get(account.customerId));
|
|
3937
4586
|
if (!customer) throw new Error(`Billing account ${account.id} has no customer.`);
|
|
3938
4587
|
const address = customer.defaultBillingAddress ?? {};
|
|
3939
|
-
if (account.automaticTax && !customer.taxExempt && !address.country) throw new Error(`Billing account ${account.id} has no tax location; set a billing address country.`);
|
|
4588
|
+
if (options.requireTaxLocation !== false && account.automaticTax && !customer.taxExempt && !address.country) throw new Error(`Billing account ${account.id} has no tax location; set a billing address country.`);
|
|
3940
4589
|
const providerCustomerId = account.provider === this.provider.name ? account.providerCustomerId : "";
|
|
3941
4590
|
const synced = await this.provider.syncCustomer({
|
|
3942
4591
|
accountId: String(account.id),
|
|
@@ -3954,9 +4603,20 @@ var BillingRuntime = class BillingRuntime {
|
|
|
3954
4603
|
return {
|
|
3955
4604
|
account,
|
|
3956
4605
|
providerCustomerId: synced.providerCustomerId,
|
|
3957
|
-
automaticTax: account.automaticTax && !customer.taxExempt
|
|
4606
|
+
automaticTax: account.automaticTax && !customer.taxExempt,
|
|
4607
|
+
hasTaxLocation: Boolean(address.country)
|
|
3958
4608
|
};
|
|
3959
4609
|
}
|
|
4610
|
+
/** Whether the account's customer has a tax location (address country). */
|
|
4611
|
+
async hasTaxLocation(account) {
|
|
4612
|
+
const customer = await withTenant({ tenantId: this.sellerTenantId }, () => this.customers.get(account.customerId));
|
|
4613
|
+
return Boolean(customer?.defaultBillingAddress?.country);
|
|
4614
|
+
}
|
|
4615
|
+
/** Whether provider-calculated tax applies to this account's charges. */
|
|
4616
|
+
async accountIsTaxed(account) {
|
|
4617
|
+
if (!account.automaticTax) return false;
|
|
4618
|
+
return !(await withTenant({ tenantId: this.sellerTenantId }, () => this.customers.get(account.customerId)))?.taxExempt;
|
|
4619
|
+
}
|
|
3960
4620
|
/**
|
|
3961
4621
|
* Close billing periods. Without a period, each payer's last ended period
|
|
3962
4622
|
* on its own schedule (the previous UTC calendar month unless its account
|
|
@@ -4039,6 +4699,39 @@ var BillingRuntime = class BillingRuntime {
|
|
|
4039
4699
|
createCreditCheckout(input) {
|
|
4040
4700
|
return createCreditCheckout(this, input);
|
|
4041
4701
|
}
|
|
4702
|
+
/**
|
|
4703
|
+
* Start a provider checkout that saves the payer's card without charging
|
|
4704
|
+
* it. When the checkout completes, event processing makes the card the
|
|
4705
|
+
* provider customer's default, records it as the payer's default
|
|
4706
|
+
* `PaymentInstrument`, and adopts the billing address collected at
|
|
4707
|
+
* checkout as its tax location. Callable by the payer or in a system
|
|
4708
|
+
* context. Throws when the provider cannot save payment methods.
|
|
4709
|
+
*/
|
|
4710
|
+
createCardSetupCheckout(input) {
|
|
4711
|
+
return createCardSetupCheckout(this, input);
|
|
4712
|
+
}
|
|
4713
|
+
/**
|
|
4714
|
+
* The `autoTopUp` hook for smrt-subscriptions' `SpendingPolicyEvaluator`:
|
|
4715
|
+
* charges the payer's saved card off-session and credits the balance once
|
|
4716
|
+
* the charge succeeds. Without a provider that can charge a saved card (or
|
|
4717
|
+
* without a card) it never tops up. Enable `payment_intent.*` events on
|
|
4718
|
+
* the provider webhook: charges that settle later are credited from them.
|
|
4719
|
+
*/
|
|
4720
|
+
autoTopUpHook(options) {
|
|
4721
|
+
return createAutoTopUpHook(this, options);
|
|
4722
|
+
}
|
|
4723
|
+
/**
|
|
4724
|
+
* Write off a sent, unpaid invoice at the provider (#3139). The provider's
|
|
4725
|
+
* `uncollectible` event then moves the payer to `uncollectible` standing.
|
|
4726
|
+
* Call only from trusted operator code. Throws when the provider cannot.
|
|
4727
|
+
*/
|
|
4728
|
+
async markInvoiceUncollectible(invoiceId) {
|
|
4729
|
+
const markUncollectible = this.provider.markInvoiceUncollectible;
|
|
4730
|
+
if (!markUncollectible) throw new Error(`Billing provider ${this.provider.name} cannot write off invoices.`);
|
|
4731
|
+
const invoice = await this.getInvoice(invoiceId);
|
|
4732
|
+
if (invoice.externalProvider !== this.provider.name || !invoice.externalId || invoice.status !== InvoiceStatus.SENT && invoice.status !== InvoiceStatus.VIEWED && invoice.status !== InvoiceStatus.PARTIAL && invoice.status !== InvoiceStatus.OVERDUE) throw new Error(`Invoice ${invoice.invoiceNumber} is not a sent, unpaid ${this.provider.name} invoice.`);
|
|
4733
|
+
await markUncollectible.call(this.provider, invoice.externalId);
|
|
4734
|
+
}
|
|
4042
4735
|
/** Run in a system context (cross-tenant reads and payer-owned writes). */
|
|
4043
4736
|
system(operation) {
|
|
4044
4737
|
return withSystemContext(operation);
|
|
@@ -4062,6 +4755,25 @@ var SUBSCRIPTION_EVENTS = /* @__PURE__ */ new Set([
|
|
|
4062
4755
|
"customer.subscription.resumed"
|
|
4063
4756
|
]);
|
|
4064
4757
|
var CHECKOUT_EVENTS = /* @__PURE__ */ new Set(["checkout.session.completed", "checkout.session.async_payment_succeeded"]);
|
|
4758
|
+
var PAYMENT_EVENTS = /* @__PURE__ */ new Set([
|
|
4759
|
+
"payment_intent.succeeded",
|
|
4760
|
+
"payment_intent.processing",
|
|
4761
|
+
"payment_intent.payment_failed",
|
|
4762
|
+
"payment_intent.canceled"
|
|
4763
|
+
]);
|
|
4764
|
+
var CHARGE_STATUSES = /* @__PURE__ */ new Set([
|
|
4765
|
+
"succeeded",
|
|
4766
|
+
"processing",
|
|
4767
|
+
"requires_action",
|
|
4768
|
+
"failed",
|
|
4769
|
+
"canceled"
|
|
4770
|
+
]);
|
|
4771
|
+
var INVOICE_STATUSES = {
|
|
4772
|
+
draft: "draft",
|
|
4773
|
+
paid: "paid",
|
|
4774
|
+
voided: "void",
|
|
4775
|
+
uncollectible: "uncollectible"
|
|
4776
|
+
};
|
|
4065
4777
|
var SUBSCRIPTION_STATUSES = {
|
|
4066
4778
|
active: "active",
|
|
4067
4779
|
trialing: "trialing",
|
|
@@ -4072,15 +4784,19 @@ var SUBSCRIPTION_STATUSES = {
|
|
|
4072
4784
|
incomplete_expired: "canceled",
|
|
4073
4785
|
paused: "unpaid"
|
|
4074
4786
|
};
|
|
4075
|
-
function
|
|
4076
|
-
const
|
|
4077
|
-
|
|
4078
|
-
return code;
|
|
4787
|
+
async function sha256Hex(value) {
|
|
4788
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
|
|
4789
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
4079
4790
|
}
|
|
4080
4791
|
function createStripeBillingProvider(options) {
|
|
4081
4792
|
const { stripe, webhookSecret } = options;
|
|
4082
4793
|
if (!webhookSecret) throw new Error("A Stripe webhook signing secret is required.");
|
|
4083
|
-
|
|
4794
|
+
const retrieveCheckoutSession = stripe.billing.retrieveCheckoutSession?.bind(stripe.billing);
|
|
4795
|
+
if (!retrieveCheckoutSession) throw new Error("The Stripe provider cannot retrieve checkout sessions; upgrade @happyvertical/accounting to 0.92 or later.");
|
|
4796
|
+
const chargeSaved = stripe.payments.chargeSavedPaymentMethod?.bind(stripe.payments);
|
|
4797
|
+
const setDefault = stripe.billing.setDefaultPaymentMethod?.bind(stripe.billing);
|
|
4798
|
+
const markUncollectible = stripe.invoices.markUncollectible?.bind(stripe.invoices);
|
|
4799
|
+
const provider = {
|
|
4084
4800
|
name: "stripe",
|
|
4085
4801
|
async syncCustomer(input) {
|
|
4086
4802
|
const customer = {
|
|
@@ -4091,7 +4807,17 @@ function createStripeBillingProvider(options) {
|
|
|
4091
4807
|
billingAddress: input.billingAddress,
|
|
4092
4808
|
taxExempt: input.taxExempt
|
|
4093
4809
|
};
|
|
4094
|
-
return { providerCustomerId: (await stripe.customers.sync(customer)).externalId };
|
|
4810
|
+
if (customer.externalId) return { providerCustomerId: (await stripe.customers.sync(customer)).externalId };
|
|
4811
|
+
const digest = await sha256Hex(JSON.stringify(customer));
|
|
4812
|
+
const created = await stripe.customers.sync({
|
|
4813
|
+
...customer,
|
|
4814
|
+
idempotencyKey: `smrt-billing-customer:${input.accountId}:${digest.slice(0, 32)}`
|
|
4815
|
+
});
|
|
4816
|
+
await stripe.customers.sync({
|
|
4817
|
+
...customer,
|
|
4818
|
+
externalId: created.externalId
|
|
4819
|
+
});
|
|
4820
|
+
return { providerCustomerId: created.externalId };
|
|
4095
4821
|
},
|
|
4096
4822
|
async pushInvoice(input) {
|
|
4097
4823
|
const currency = normalizeCurrency(input.currency);
|
|
@@ -4116,7 +4842,8 @@ function createStripeBillingProvider(options) {
|
|
|
4116
4842
|
currency: currency.toLowerCase(),
|
|
4117
4843
|
memo: input.memo,
|
|
4118
4844
|
idempotencyKey: input.idempotencyKey,
|
|
4119
|
-
automaticTax: input.automaticTax
|
|
4845
|
+
automaticTax: input.automaticTax,
|
|
4846
|
+
collectionMethod: input.collectionMethod ?? "send_invoice"
|
|
4120
4847
|
})).externalId };
|
|
4121
4848
|
},
|
|
4122
4849
|
async sendInvoice(providerInvoiceId) {
|
|
@@ -4125,7 +4852,7 @@ function createStripeBillingProvider(options) {
|
|
|
4125
4852
|
async getInvoice(providerInvoiceId) {
|
|
4126
4853
|
const invoice = await stripe.invoices.pull(providerInvoiceId);
|
|
4127
4854
|
const currency = normalizeCurrency(invoice.currency);
|
|
4128
|
-
const status = invoice.status
|
|
4855
|
+
const status = INVOICE_STATUSES[invoice.status] ?? "open";
|
|
4129
4856
|
return {
|
|
4130
4857
|
providerInvoiceId: invoice.externalId,
|
|
4131
4858
|
status,
|
|
@@ -4152,22 +4879,29 @@ function createStripeBillingProvider(options) {
|
|
|
4152
4879
|
};
|
|
4153
4880
|
},
|
|
4154
4881
|
async createCheckout(input) {
|
|
4155
|
-
const currency =
|
|
4882
|
+
const currency = normalizeCurrency(input.currency);
|
|
4156
4883
|
if (!Number.isSafeInteger(input.amount) || input.amount <= 0) throw new Error("Checkout amount must be positive integer minor units.");
|
|
4884
|
+
const customerExternalId = input.providerCustomerId || void 0;
|
|
4885
|
+
if (input.savePaymentMethod && !customerExternalId) throw new Error("Saving a payment method requires a provider customer.");
|
|
4157
4886
|
const session = await stripe.billing.createCheckoutSession({
|
|
4158
4887
|
mode: "payment",
|
|
4159
4888
|
successUrl: input.successUrl,
|
|
4160
4889
|
cancelUrl: input.cancelUrl,
|
|
4161
|
-
customerExternalId
|
|
4162
|
-
customerEmail: input.customerEmail || void 0,
|
|
4890
|
+
customerExternalId,
|
|
4891
|
+
customerEmail: customerExternalId ? void 0 : input.customerEmail || void 0,
|
|
4163
4892
|
lineItems: [{
|
|
4164
4893
|
quantity: 1,
|
|
4165
4894
|
priceData: {
|
|
4166
4895
|
currency: currency.toLowerCase(),
|
|
4167
|
-
|
|
4896
|
+
unitAmountMinor: input.amount,
|
|
4168
4897
|
productName: input.description
|
|
4169
4898
|
}
|
|
4170
4899
|
}],
|
|
4900
|
+
...input.automaticTax ? {
|
|
4901
|
+
automaticTax: true,
|
|
4902
|
+
...customerExternalId ? { customerUpdate: { address: "auto" } } : { billingAddressCollection: "required" }
|
|
4903
|
+
} : {},
|
|
4904
|
+
...input.savePaymentMethod ? { setupFutureUsage: "off_session" } : {},
|
|
4171
4905
|
metadata: await signMetadata(input.metadata, webhookSecret),
|
|
4172
4906
|
idempotencyKey: input.idempotencyKey
|
|
4173
4907
|
});
|
|
@@ -4176,11 +4910,74 @@ function createStripeBillingProvider(options) {
|
|
|
4176
4910
|
url: session.url
|
|
4177
4911
|
};
|
|
4178
4912
|
},
|
|
4913
|
+
async createSetupCheckout(input) {
|
|
4914
|
+
if (!input.providerCustomerId) throw new Error("A setup checkout requires a provider customer.");
|
|
4915
|
+
const session = await stripe.billing.createCheckoutSession({
|
|
4916
|
+
mode: "setup",
|
|
4917
|
+
successUrl: input.successUrl,
|
|
4918
|
+
cancelUrl: input.cancelUrl,
|
|
4919
|
+
customerExternalId: input.providerCustomerId,
|
|
4920
|
+
currency: normalizeCurrency(input.currency).toLowerCase(),
|
|
4921
|
+
...input.collectBillingAddress ? {
|
|
4922
|
+
billingAddressCollection: "required",
|
|
4923
|
+
customerUpdate: { address: "auto" }
|
|
4924
|
+
} : {},
|
|
4925
|
+
metadata: await signMetadata(input.metadata, webhookSecret),
|
|
4926
|
+
idempotencyKey: input.idempotencyKey
|
|
4927
|
+
});
|
|
4928
|
+
return {
|
|
4929
|
+
sessionId: session.externalId,
|
|
4930
|
+
url: session.url
|
|
4931
|
+
};
|
|
4932
|
+
},
|
|
4933
|
+
async getCheckout(sessionId) {
|
|
4934
|
+
const session = await retrieveCheckoutSession(sessionId);
|
|
4935
|
+
const mode = session.mode === "payment" || session.mode === "setup" ? session.mode : "other";
|
|
4936
|
+
const complete = session.status === "complete";
|
|
4937
|
+
const state = {
|
|
4938
|
+
sessionId: session.externalId,
|
|
4939
|
+
mode,
|
|
4940
|
+
complete,
|
|
4941
|
+
paid: session.paymentStatus === "paid",
|
|
4942
|
+
providerCustomerId: session.customerExternalId,
|
|
4943
|
+
paymentMethodId: session.paymentMethodExternalId,
|
|
4944
|
+
currency: session.currency,
|
|
4945
|
+
amountSubtotal: session.amountSubtotalMinor,
|
|
4946
|
+
amountTax: session.amountTaxMinor,
|
|
4947
|
+
amountTotal: session.amountTotalMinor
|
|
4948
|
+
};
|
|
4949
|
+
if (complete && session.customerExternalId && session.metadata["smrt_collect_address"] === "1") {
|
|
4950
|
+
const customer = await stripe.customers.pull(session.customerExternalId);
|
|
4951
|
+
if (customer.billingAddress?.country) state.billingAddress = customer.billingAddress;
|
|
4952
|
+
}
|
|
4953
|
+
return state;
|
|
4954
|
+
},
|
|
4179
4955
|
async verifyWebhook(payload, signature) {
|
|
4180
4956
|
if (!stripe.webhooks.verify(payload, signature, webhookSecret)) throw new BillingWebhookVerificationError();
|
|
4181
4957
|
return normalizeStripeEvent(stripe.webhooks.parse(payload), webhookSecret);
|
|
4182
4958
|
}
|
|
4183
4959
|
};
|
|
4960
|
+
if (chargeSaved) provider.chargeSavedPaymentMethod = async (input) => {
|
|
4961
|
+
const result = await chargeSaved({
|
|
4962
|
+
customerExternalId: input.providerCustomerId,
|
|
4963
|
+
amountMinor: input.amount,
|
|
4964
|
+
currency: normalizeCurrency(input.currency),
|
|
4965
|
+
idempotencyKey: input.idempotencyKey,
|
|
4966
|
+
description: input.description,
|
|
4967
|
+
metadata: input.metadata
|
|
4968
|
+
});
|
|
4969
|
+
return {
|
|
4970
|
+
status: result.status,
|
|
4971
|
+
providerPaymentId: result.paymentExternalId,
|
|
4972
|
+
amount: result.amountMinor,
|
|
4973
|
+
currency: result.currency,
|
|
4974
|
+
failureCode: result.failureCode,
|
|
4975
|
+
failureMessage: result.failureMessage
|
|
4976
|
+
};
|
|
4977
|
+
};
|
|
4978
|
+
if (setDefault) provider.setDefaultPaymentMethod = (providerCustomerId, paymentMethodId) => setDefault(providerCustomerId, paymentMethodId);
|
|
4979
|
+
if (markUncollectible) provider.markInvoiceUncollectible = (providerInvoiceId) => markUncollectible(providerInvoiceId);
|
|
4980
|
+
return provider;
|
|
4184
4981
|
}
|
|
4185
4982
|
async function normalizeStripeEvent(event, webhookSecret) {
|
|
4186
4983
|
const eventId = event.id;
|
|
@@ -4213,23 +5010,41 @@ async function normalizeStripeEvent(event, webhookSecret) {
|
|
|
4213
5010
|
const session = stripeObject(event);
|
|
4214
5011
|
const metadata = smrtMetadata(session.metadata);
|
|
4215
5012
|
const id = session.id;
|
|
4216
|
-
const
|
|
4217
|
-
const
|
|
4218
|
-
if (
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
5013
|
+
const mode = session.mode;
|
|
5014
|
+
const expected = mode === "payment" && metadata.smrt_purpose === "credit_purchase" || mode === "setup" && metadata.smrt_purpose === "card_setup";
|
|
5015
|
+
if (!expected || !await metadataSignatureValid(metadata, webhookSecret) || typeof id !== "string" || !id || mode === "payment" && typeof session.currency !== "string") {
|
|
5016
|
+
if (!expected) return ignored;
|
|
5017
|
+
return {
|
|
5018
|
+
...ignored,
|
|
5019
|
+
type: mode === "payment" ? `${event.type}:unverified_credit_purchase` : `${event.type}:unverified_card_setup`
|
|
5020
|
+
};
|
|
5021
|
+
}
|
|
4222
5022
|
return {
|
|
4223
5023
|
kind: "checkout_completed",
|
|
4224
5024
|
eventId,
|
|
4225
5025
|
sessionId: id,
|
|
5026
|
+
mode,
|
|
4226
5027
|
paid: session.payment_status === "paid",
|
|
4227
|
-
currency: session.currency.toUpperCase(),
|
|
4228
|
-
amountSubtotal: amount,
|
|
4229
|
-
amountTotal: collected,
|
|
5028
|
+
currency: typeof session.currency === "string" ? session.currency.toUpperCase() : "",
|
|
4230
5029
|
metadata
|
|
4231
5030
|
};
|
|
4232
5031
|
}
|
|
5032
|
+
if (PAYMENT_EVENTS.has(event.type)) {
|
|
5033
|
+
const payment = event.payment;
|
|
5034
|
+
const chargeKey = payment?.chargeKey;
|
|
5035
|
+
if (!payment || !chargeKey?.startsWith("smrt-auto-top-up:") || !CHARGE_STATUSES.has(payment.status) || !payment.paymentExternalId) return ignored;
|
|
5036
|
+
return {
|
|
5037
|
+
kind: "payment",
|
|
5038
|
+
eventId,
|
|
5039
|
+
chargeKey,
|
|
5040
|
+
status: payment.status,
|
|
5041
|
+
providerPaymentId: payment.paymentExternalId,
|
|
5042
|
+
providerCustomerId: payment.customerExternalId,
|
|
5043
|
+
amount: payment.amountMinor,
|
|
5044
|
+
currency: payment.currency,
|
|
5045
|
+
failureCode: payment.failureCode
|
|
5046
|
+
};
|
|
5047
|
+
}
|
|
4233
5048
|
return ignored;
|
|
4234
5049
|
}
|
|
4235
5050
|
function stripeObject(event) {
|
|
@@ -4272,12 +5087,12 @@ function smrtMetadata(value) {
|
|
|
4272
5087
|
}
|
|
4273
5088
|
//#endregion
|
|
4274
5089
|
//#region src/models/Vendor.ts
|
|
4275
|
-
var __defProp$
|
|
4276
|
-
var __getOwnPropDesc$
|
|
4277
|
-
var __decorateClass$
|
|
4278
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
5090
|
+
var __defProp$6 = Object.defineProperty;
|
|
5091
|
+
var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
|
|
5092
|
+
var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
5093
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
|
|
4279
5094
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
4280
|
-
if (kind && result) __defProp$
|
|
5095
|
+
if (kind && result) __defProp$6(target, key, result);
|
|
4281
5096
|
return result;
|
|
4282
5097
|
};
|
|
4283
5098
|
var Vendor = class extends SmrtObject {
|
|
@@ -4442,10 +5257,10 @@ var Vendor = class extends SmrtObject {
|
|
|
4442
5257
|
return out;
|
|
4443
5258
|
}
|
|
4444
5259
|
};
|
|
4445
|
-
__decorateClass$
|
|
4446
|
-
__decorateClass$
|
|
4447
|
-
__decorateClass$
|
|
4448
|
-
Vendor = __decorateClass$
|
|
5260
|
+
__decorateClass$6([tenantId({ nullable: true })], Vendor.prototype, "tenantId", 2);
|
|
5261
|
+
__decorateClass$6([crossPackageRef("@happyvertical/smrt-profiles:Profile")], Vendor.prototype, "profileId", 2);
|
|
5262
|
+
__decorateClass$6([field({ sensitive: true })], Vendor.prototype, "payoutAddresses", 2);
|
|
5263
|
+
Vendor = __decorateClass$6([TenantScoped({ mode: "optional" }), smrt({
|
|
4449
5264
|
api: { include: [
|
|
4450
5265
|
"list",
|
|
4451
5266
|
"get",
|
|
@@ -4457,18 +5272,18 @@ Vendor = __decorateClass$7([TenantScoped({ mode: "optional" }), smrt({
|
|
|
4457
5272
|
})], Vendor);
|
|
4458
5273
|
//#endregion
|
|
4459
5274
|
//#region src/models/Contract.ts
|
|
4460
|
-
var __defProp$
|
|
4461
|
-
var __getOwnPropDesc$
|
|
4462
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp$
|
|
5275
|
+
var __defProp$5 = Object.defineProperty;
|
|
5276
|
+
var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
|
|
5277
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp$5(obj, key, {
|
|
4463
5278
|
enumerable: true,
|
|
4464
5279
|
configurable: true,
|
|
4465
5280
|
writable: true,
|
|
4466
5281
|
value
|
|
4467
5282
|
}) : obj[key] = value;
|
|
4468
|
-
var __decorateClass$
|
|
4469
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
5283
|
+
var __decorateClass$5 = (decorators, target, key, kind) => {
|
|
5284
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
|
|
4470
5285
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
4471
|
-
if (kind && result) __defProp$
|
|
5286
|
+
if (kind && result) __defProp$5(target, key, result);
|
|
4472
5287
|
return result;
|
|
4473
5288
|
};
|
|
4474
5289
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -4684,10 +5499,10 @@ var Contract = class extends SmrtObject {
|
|
|
4684
5499
|
* STI discriminator field
|
|
4685
5500
|
*/
|
|
4686
5501
|
__publicField(Contract, "_stiField", "contractType");
|
|
4687
|
-
__decorateClass$
|
|
4688
|
-
__decorateClass$
|
|
4689
|
-
__decorateClass$
|
|
4690
|
-
Contract = __decorateClass$
|
|
5502
|
+
__decorateClass$5([tenantId({ nullable: true })], Contract.prototype, "tenantId", 2);
|
|
5503
|
+
__decorateClass$5([foreignKey(Customer)], Contract.prototype, "customerId", 2);
|
|
5504
|
+
__decorateClass$5([foreignKey(Vendor)], Contract.prototype, "vendorId", 2);
|
|
5505
|
+
Contract = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt({
|
|
4691
5506
|
tableStrategy: "sti",
|
|
4692
5507
|
api: { include: [
|
|
4693
5508
|
"list",
|
|
@@ -4701,27 +5516,27 @@ Contract = __decorateClass$6([TenantScoped({ mode: "optional" }), smrt({
|
|
|
4701
5516
|
var Estimate = class extends Contract {
|
|
4702
5517
|
contractType = ContractType.ESTIMATE;
|
|
4703
5518
|
};
|
|
4704
|
-
Estimate = __decorateClass$
|
|
5519
|
+
Estimate = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], Estimate);
|
|
4705
5520
|
var Order = class extends Contract {
|
|
4706
5521
|
contractType = ContractType.ORDER;
|
|
4707
5522
|
};
|
|
4708
|
-
Order = __decorateClass$
|
|
5523
|
+
Order = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], Order);
|
|
4709
5524
|
var Lease = class extends Contract {
|
|
4710
5525
|
contractType = ContractType.LEASE;
|
|
4711
5526
|
};
|
|
4712
|
-
Lease = __decorateClass$
|
|
5527
|
+
Lease = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], Lease);
|
|
4713
5528
|
var Agreement = class extends Contract {
|
|
4714
5529
|
contractType = ContractType.AGREEMENT;
|
|
4715
5530
|
};
|
|
4716
|
-
Agreement = __decorateClass$
|
|
5531
|
+
Agreement = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], Agreement);
|
|
4717
5532
|
var PurchaseOrder = class extends Contract {
|
|
4718
5533
|
contractType = ContractType.PURCHASE_ORDER;
|
|
4719
5534
|
};
|
|
4720
|
-
PurchaseOrder = __decorateClass$
|
|
5535
|
+
PurchaseOrder = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], PurchaseOrder);
|
|
4721
5536
|
var WholesaleOrder = class extends Contract {
|
|
4722
5537
|
contractType = ContractType.WHOLESALE_ORDER;
|
|
4723
5538
|
};
|
|
4724
|
-
WholesaleOrder = __decorateClass$
|
|
5539
|
+
WholesaleOrder = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], WholesaleOrder);
|
|
4725
5540
|
var ProductionOrder = class extends Contract {
|
|
4726
5541
|
contractType = ContractType.PRODUCTION_ORDER;
|
|
4727
5542
|
/**
|
|
@@ -4738,11 +5553,11 @@ var ProductionOrder = class extends Contract {
|
|
|
4738
5553
|
*/
|
|
4739
5554
|
bomId = "";
|
|
4740
5555
|
};
|
|
4741
|
-
ProductionOrder = __decorateClass$
|
|
5556
|
+
ProductionOrder = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], ProductionOrder);
|
|
4742
5557
|
var Cart = class extends Contract {
|
|
4743
5558
|
contractType = ContractType.CART;
|
|
4744
5559
|
};
|
|
4745
|
-
Cart = __decorateClass$
|
|
5560
|
+
Cart = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], Cart);
|
|
4746
5561
|
var issuedRightsSnapshot = /* @__PURE__ */ new WeakMap();
|
|
4747
5562
|
var LicenseSale = class extends Contract {
|
|
4748
5563
|
contractType = ContractType.LICENSE_SALE;
|
|
@@ -4904,7 +5719,7 @@ var LicenseSale = class extends Contract {
|
|
|
4904
5719
|
});
|
|
4905
5720
|
}
|
|
4906
5721
|
};
|
|
4907
|
-
LicenseSale = __decorateClass$
|
|
5722
|
+
LicenseSale = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt()], LicenseSale);
|
|
4908
5723
|
//#endregion
|
|
4909
5724
|
//#region src/collections/ContractCollection.ts
|
|
4910
5725
|
var ContractCollection = class extends SmrtCollection {
|
|
@@ -5052,12 +5867,12 @@ var ContractCollection = class extends SmrtCollection {
|
|
|
5052
5867
|
};
|
|
5053
5868
|
//#endregion
|
|
5054
5869
|
//#region src/models/ContractLineItem.ts
|
|
5055
|
-
var __defProp$
|
|
5056
|
-
var __getOwnPropDesc$
|
|
5057
|
-
var __decorateClass$
|
|
5058
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
5870
|
+
var __defProp$4 = Object.defineProperty;
|
|
5871
|
+
var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
5872
|
+
var __decorateClass$4 = (decorators, target, key, kind) => {
|
|
5873
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
|
|
5059
5874
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
5060
|
-
if (kind && result) __defProp$
|
|
5875
|
+
if (kind && result) __defProp$4(target, key, result);
|
|
5061
5876
|
return result;
|
|
5062
5877
|
};
|
|
5063
5878
|
var ContractLineItem = class extends SmrtObject {
|
|
@@ -5165,10 +5980,10 @@ var ContractLineItem = class extends SmrtObject {
|
|
|
5165
5980
|
return true;
|
|
5166
5981
|
}
|
|
5167
5982
|
};
|
|
5168
|
-
__decorateClass$
|
|
5169
|
-
__decorateClass$
|
|
5170
|
-
__decorateClass$
|
|
5171
|
-
ContractLineItem = __decorateClass$
|
|
5983
|
+
__decorateClass$4([tenantId({ nullable: true })], ContractLineItem.prototype, "tenantId", 2);
|
|
5984
|
+
__decorateClass$4([foreignKey("Contract")], ContractLineItem.prototype, "contractId", 2);
|
|
5985
|
+
__decorateClass$4([crossPackageRef("@happyvertical/smrt-products:Product")], ContractLineItem.prototype, "productId", 2);
|
|
5986
|
+
ContractLineItem = __decorateClass$4([TenantScoped({ mode: "optional" }), smrt({
|
|
5172
5987
|
tableStrategy: "sti",
|
|
5173
5988
|
api: { include: [
|
|
5174
5989
|
"list",
|
|
@@ -5233,12 +6048,12 @@ var ContractLineItemCollection = class extends SmrtCollection {
|
|
|
5233
6048
|
};
|
|
5234
6049
|
//#endregion
|
|
5235
6050
|
//#region src/models/Fulfillment.ts
|
|
5236
|
-
var __defProp$
|
|
5237
|
-
var __getOwnPropDesc$
|
|
5238
|
-
var __decorateClass$
|
|
5239
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
6051
|
+
var __defProp$3 = Object.defineProperty;
|
|
6052
|
+
var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
|
|
6053
|
+
var __decorateClass$3 = (decorators, target, key, kind) => {
|
|
6054
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
|
|
5240
6055
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
5241
|
-
if (kind && result) __defProp$
|
|
6056
|
+
if (kind && result) __defProp$3(target, key, result);
|
|
5242
6057
|
return result;
|
|
5243
6058
|
};
|
|
5244
6059
|
var FULFILLMENT_STATUS_TRANSITIONS = {
|
|
@@ -5415,9 +6230,9 @@ var Fulfillment = class extends SmrtObject {
|
|
|
5415
6230
|
this.status = FulfillmentStatus.CANCELLED;
|
|
5416
6231
|
}
|
|
5417
6232
|
};
|
|
5418
|
-
__decorateClass$
|
|
5419
|
-
__decorateClass$
|
|
5420
|
-
Fulfillment = __decorateClass$
|
|
6233
|
+
__decorateClass$3([tenantId({ nullable: true })], Fulfillment.prototype, "tenantId", 2);
|
|
6234
|
+
__decorateClass$3([foreignKey("Contract")], Fulfillment.prototype, "contractId", 2);
|
|
6235
|
+
Fulfillment = __decorateClass$3([TenantScoped({ mode: "optional" }), smrt({
|
|
5421
6236
|
api: { include: [
|
|
5422
6237
|
"list",
|
|
5423
6238
|
"get",
|
|
@@ -5548,12 +6363,12 @@ var FulfillmentCollection = class extends SmrtCollection {
|
|
|
5548
6363
|
};
|
|
5549
6364
|
//#endregion
|
|
5550
6365
|
//#region src/models/FulfillmentLineItem.ts
|
|
5551
|
-
var __defProp$
|
|
5552
|
-
var __getOwnPropDesc$
|
|
5553
|
-
var __decorateClass$
|
|
5554
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
6366
|
+
var __defProp$2 = Object.defineProperty;
|
|
6367
|
+
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
6368
|
+
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
6369
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
|
|
5555
6370
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
5556
|
-
if (kind && result) __defProp$
|
|
6371
|
+
if (kind && result) __defProp$2(target, key, result);
|
|
5557
6372
|
return result;
|
|
5558
6373
|
};
|
|
5559
6374
|
var FULFILLMENT_QUANTITY_EPSILON = .01;
|
|
@@ -5619,10 +6434,10 @@ var FulfillmentLineItem = class extends SmrtObject {
|
|
|
5619
6434
|
return super.save();
|
|
5620
6435
|
}
|
|
5621
6436
|
};
|
|
5622
|
-
__decorateClass$
|
|
5623
|
-
__decorateClass$
|
|
5624
|
-
__decorateClass$
|
|
5625
|
-
FulfillmentLineItem = __decorateClass$
|
|
6437
|
+
__decorateClass$2([tenantId({ nullable: true })], FulfillmentLineItem.prototype, "tenantId", 2);
|
|
6438
|
+
__decorateClass$2([foreignKey("Fulfillment")], FulfillmentLineItem.prototype, "fulfillmentId", 2);
|
|
6439
|
+
__decorateClass$2([foreignKey("ContractLineItem")], FulfillmentLineItem.prototype, "contractLineItemId", 2);
|
|
6440
|
+
FulfillmentLineItem = __decorateClass$2([TenantScoped({ mode: "optional" }), smrt({
|
|
5626
6441
|
api: { include: [
|
|
5627
6442
|
"list",
|
|
5628
6443
|
"get",
|
|
@@ -5709,252 +6524,6 @@ var FulfillmentLineItemCollection = class extends SmrtCollection {
|
|
|
5709
6524
|
}
|
|
5710
6525
|
};
|
|
5711
6526
|
//#endregion
|
|
5712
|
-
//#region src/models/PaymentInstrument.ts
|
|
5713
|
-
var __defProp$2 = Object.defineProperty;
|
|
5714
|
-
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
5715
|
-
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
5716
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
|
|
5717
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
5718
|
-
if (kind && result) __defProp$2(target, key, result);
|
|
5719
|
-
return result;
|
|
5720
|
-
};
|
|
5721
|
-
var PaymentInstrument = class extends SmrtObject {
|
|
5722
|
-
tenantId = null;
|
|
5723
|
-
customerId = "";
|
|
5724
|
-
/**
|
|
5725
|
-
* Stable identifier of the `PaymentBackend` adapter that vaulted the method —
|
|
5726
|
-
* e.g. `stripe`. Mirrors {@link Payment.backendId}.
|
|
5727
|
-
*/
|
|
5728
|
-
backendId = "";
|
|
5729
|
-
/**
|
|
5730
|
-
* Provider customer reference (e.g. a Stripe `cus_...`). A reference, not
|
|
5731
|
-
* card data.
|
|
5732
|
-
*/
|
|
5733
|
-
providerCustomerId = "";
|
|
5734
|
-
/**
|
|
5735
|
-
* Provider payment-method reference (e.g. a Stripe `pm_...`). Used, together
|
|
5736
|
-
* with {@link providerCustomerId}, to charge the saved method off-session. A
|
|
5737
|
-
* reference, not card data.
|
|
5738
|
-
*/
|
|
5739
|
-
providerPaymentMethodId = "";
|
|
5740
|
-
/**
|
|
5741
|
-
* Instrument type as reported by the backend — e.g. `card`,
|
|
5742
|
-
* `us_bank_account`.
|
|
5743
|
-
*/
|
|
5744
|
-
type = "card";
|
|
5745
|
-
/**
|
|
5746
|
-
* Card brand for display (e.g. `visa`). Display-only, not PCI-sensitive.
|
|
5747
|
-
*/
|
|
5748
|
-
brand = "";
|
|
5749
|
-
/**
|
|
5750
|
-
* Last four digits for display. Not the full card number.
|
|
5751
|
-
*/
|
|
5752
|
-
last4 = "";
|
|
5753
|
-
/**
|
|
5754
|
-
* Card expiry month (1–12). `0` when unknown / not a card.
|
|
5755
|
-
*/
|
|
5756
|
-
expMonth = 0;
|
|
5757
|
-
/**
|
|
5758
|
-
* Card expiry year (four digits). `0` when unknown / not a card.
|
|
5759
|
-
*/
|
|
5760
|
-
expYear = 0;
|
|
5761
|
-
/**
|
|
5762
|
-
* Whether this is the customer's default instrument. Use
|
|
5763
|
-
* {@link PaymentInstrumentCollection.setDefaultForCustomer} to flip the
|
|
5764
|
-
* default so only one instrument per customer is marked default.
|
|
5765
|
-
*/
|
|
5766
|
-
isDefault = false;
|
|
5767
|
-
/**
|
|
5768
|
-
* Lifecycle status — `active` while chargeable, `expired` once the card has
|
|
5769
|
-
* lapsed, `removed` when the customer detaches it.
|
|
5770
|
-
*/
|
|
5771
|
-
status = PaymentInstrumentStatus.ACTIVE;
|
|
5772
|
-
constructor(options = {}) {
|
|
5773
|
-
super(options);
|
|
5774
|
-
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
5775
|
-
if (options.customerId !== void 0) this.customerId = options.customerId;
|
|
5776
|
-
if (options.backendId !== void 0) this.backendId = options.backendId;
|
|
5777
|
-
if (options.providerCustomerId !== void 0) this.providerCustomerId = options.providerCustomerId;
|
|
5778
|
-
if (options.providerPaymentMethodId !== void 0) this.providerPaymentMethodId = options.providerPaymentMethodId;
|
|
5779
|
-
if (options.type !== void 0) this.type = options.type;
|
|
5780
|
-
if (options.brand !== void 0) this.brand = options.brand;
|
|
5781
|
-
if (options.last4 !== void 0) this.last4 = options.last4;
|
|
5782
|
-
if (options.expMonth !== void 0) this.expMonth = options.expMonth;
|
|
5783
|
-
if (options.expYear !== void 0) this.expYear = options.expYear;
|
|
5784
|
-
if (options.isDefault !== void 0) this.isDefault = options.isDefault;
|
|
5785
|
-
if (options.status !== void 0) this.status = options.status;
|
|
5786
|
-
}
|
|
5787
|
-
/**
|
|
5788
|
-
* True while the instrument is active (chargeable).
|
|
5789
|
-
*/
|
|
5790
|
-
isActive() {
|
|
5791
|
-
return this.status === PaymentInstrumentStatus.ACTIVE;
|
|
5792
|
-
}
|
|
5793
|
-
/**
|
|
5794
|
-
* True once the instrument has been marked expired.
|
|
5795
|
-
*/
|
|
5796
|
-
isExpired() {
|
|
5797
|
-
return this.status === PaymentInstrumentStatus.EXPIRED;
|
|
5798
|
-
}
|
|
5799
|
-
/**
|
|
5800
|
-
* True once the instrument has been removed/detached.
|
|
5801
|
-
*/
|
|
5802
|
-
isRemoved() {
|
|
5803
|
-
return this.status === PaymentInstrumentStatus.REMOVED;
|
|
5804
|
-
}
|
|
5805
|
-
/**
|
|
5806
|
-
* Mark the instrument expired (e.g. the card lapsed). A removed instrument
|
|
5807
|
-
* is not revived by this.
|
|
5808
|
-
*/
|
|
5809
|
-
markExpired() {
|
|
5810
|
-
if (this.status === PaymentInstrumentStatus.REMOVED) return;
|
|
5811
|
-
this.status = PaymentInstrumentStatus.EXPIRED;
|
|
5812
|
-
}
|
|
5813
|
-
/**
|
|
5814
|
-
* Mark the instrument removed/detached and clear its default flag.
|
|
5815
|
-
*/
|
|
5816
|
-
markRemoved() {
|
|
5817
|
-
this.status = PaymentInstrumentStatus.REMOVED;
|
|
5818
|
-
this.isDefault = false;
|
|
5819
|
-
}
|
|
5820
|
-
};
|
|
5821
|
-
__decorateClass$2([tenantId({ nullable: true })], PaymentInstrument.prototype, "tenantId", 2);
|
|
5822
|
-
__decorateClass$2([foreignKey("Customer")], PaymentInstrument.prototype, "customerId", 2);
|
|
5823
|
-
PaymentInstrument = __decorateClass$2([TenantScoped({ mode: "optional" }), smrt({
|
|
5824
|
-
api: {
|
|
5825
|
-
include: [
|
|
5826
|
-
"list",
|
|
5827
|
-
"get",
|
|
5828
|
-
"create",
|
|
5829
|
-
"update"
|
|
5830
|
-
],
|
|
5831
|
-
writable: [
|
|
5832
|
-
"customerId",
|
|
5833
|
-
"backendId",
|
|
5834
|
-
"providerCustomerId",
|
|
5835
|
-
"providerPaymentMethodId",
|
|
5836
|
-
"type",
|
|
5837
|
-
"brand",
|
|
5838
|
-
"last4",
|
|
5839
|
-
"expMonth",
|
|
5840
|
-
"expYear",
|
|
5841
|
-
"status"
|
|
5842
|
-
]
|
|
5843
|
-
},
|
|
5844
|
-
mcp: { include: ["list", "get"] },
|
|
5845
|
-
cli: { skipApiCheck: true }
|
|
5846
|
-
})], PaymentInstrument);
|
|
5847
|
-
//#endregion
|
|
5848
|
-
//#region src/collections/PaymentInstrumentCollection.ts
|
|
5849
|
-
var PaymentInstrumentCollection = class extends SmrtCollection {
|
|
5850
|
-
static _itemClass = PaymentInstrument;
|
|
5851
|
-
/**
|
|
5852
|
-
* Find all instruments saved by a customer, newest first.
|
|
5853
|
-
*
|
|
5854
|
-
* @param customerId - Customer ID
|
|
5855
|
-
* @returns Array of instruments
|
|
5856
|
-
*/
|
|
5857
|
-
async findByCustomer(customerId) {
|
|
5858
|
-
return await this.list({
|
|
5859
|
-
where: { customerId },
|
|
5860
|
-
orderBy: "created_at DESC"
|
|
5861
|
-
});
|
|
5862
|
-
}
|
|
5863
|
-
/**
|
|
5864
|
-
* Find a customer's active instruments, newest first.
|
|
5865
|
-
*
|
|
5866
|
-
* @param customerId - Customer ID
|
|
5867
|
-
* @returns Array of active instruments
|
|
5868
|
-
*/
|
|
5869
|
-
async findActiveByCustomer(customerId) {
|
|
5870
|
-
return await this.list({
|
|
5871
|
-
where: {
|
|
5872
|
-
customerId,
|
|
5873
|
-
status: PaymentInstrumentStatus.ACTIVE
|
|
5874
|
-
},
|
|
5875
|
-
orderBy: "created_at DESC"
|
|
5876
|
-
});
|
|
5877
|
-
}
|
|
5878
|
-
/**
|
|
5879
|
-
* Find a customer's default instrument, or null if none is set.
|
|
5880
|
-
*
|
|
5881
|
-
* @param customerId - Customer ID
|
|
5882
|
-
* @returns The default instrument or null
|
|
5883
|
-
*/
|
|
5884
|
-
async findDefaultForCustomer(customerId) {
|
|
5885
|
-
return (await this.list({
|
|
5886
|
-
where: {
|
|
5887
|
-
customerId,
|
|
5888
|
-
isDefault: true
|
|
5889
|
-
},
|
|
5890
|
-
orderBy: "created_at DESC"
|
|
5891
|
-
})).find((instrument) => !instrument.isRemoved()) ?? null;
|
|
5892
|
-
}
|
|
5893
|
-
/**
|
|
5894
|
-
* Find an instrument by its provider payment-method reference (e.g. a Stripe
|
|
5895
|
-
* `pm_...`).
|
|
5896
|
-
*
|
|
5897
|
-
* @param providerPaymentMethodId - Provider payment-method id
|
|
5898
|
-
* @returns The instrument or null
|
|
5899
|
-
*/
|
|
5900
|
-
async findByProviderPaymentMethodId(providerPaymentMethodId) {
|
|
5901
|
-
return (await this.list({
|
|
5902
|
-
where: { providerPaymentMethodId },
|
|
5903
|
-
limit: 1
|
|
5904
|
-
}))[0] || null;
|
|
5905
|
-
}
|
|
5906
|
-
/**
|
|
5907
|
-
* Make one of a customer's instruments the default, clearing the flag on the
|
|
5908
|
-
* others so only a single default is ever set. Only rows whose flag actually
|
|
5909
|
-
* changes are re-saved.
|
|
5910
|
-
*
|
|
5911
|
-
* @param customerId - Customer ID
|
|
5912
|
-
* @param instrumentId - The instrument to make default
|
|
5913
|
-
*/
|
|
5914
|
-
async setDefaultForCustomer(customerId, instrumentId) {
|
|
5915
|
-
const instruments = await this.findByCustomer(customerId);
|
|
5916
|
-
const target = instruments.find((instrument) => instrument.id === instrumentId);
|
|
5917
|
-
if (!target) throw new Error(`PaymentInstrument ${instrumentId} not found for customer ${customerId}`);
|
|
5918
|
-
if (target.isRemoved()) throw new Error(`PaymentInstrument ${instrumentId} is removed and cannot be made default`);
|
|
5919
|
-
for (const instrument of instruments) {
|
|
5920
|
-
const shouldBeDefault = instrument.id === instrumentId;
|
|
5921
|
-
if (instrument.isDefault !== shouldBeDefault) {
|
|
5922
|
-
instrument.isDefault = shouldBeDefault;
|
|
5923
|
-
await instrument.save();
|
|
5924
|
-
}
|
|
5925
|
-
}
|
|
5926
|
-
}
|
|
5927
|
-
/**
|
|
5928
|
-
* Find all instruments belonging to a specific tenant.
|
|
5929
|
-
*
|
|
5930
|
-
* @param tenantId - Tenant ID
|
|
5931
|
-
* @returns Array of instruments for the tenant
|
|
5932
|
-
*/
|
|
5933
|
-
async findByTenant(tenantId) {
|
|
5934
|
-
return this.list({ where: { tenantId } });
|
|
5935
|
-
}
|
|
5936
|
-
/**
|
|
5937
|
-
* Find all global instruments (not associated with any tenant). Routes
|
|
5938
|
-
* through the shared tenant-global helper so it does not throw under an
|
|
5939
|
-
* active tenant context. (#1600)
|
|
5940
|
-
*
|
|
5941
|
-
* @returns Array of global instruments
|
|
5942
|
-
*/
|
|
5943
|
-
async findGlobal() {
|
|
5944
|
-
return queryGlobal(this);
|
|
5945
|
-
}
|
|
5946
|
-
/**
|
|
5947
|
-
* Find instruments for a tenant including global instruments. Fails closed if
|
|
5948
|
-
* an active tenant context requests a different tenant's rows. (#1600)
|
|
5949
|
-
*
|
|
5950
|
-
* @param tenantId - Tenant ID
|
|
5951
|
-
* @returns Array of tenant-specific and global instruments
|
|
5952
|
-
*/
|
|
5953
|
-
async findWithGlobals(tenantId) {
|
|
5954
|
-
return queryWithGlobals(this, tenantId, "PaymentInstrument.findWithGlobals");
|
|
5955
|
-
}
|
|
5956
|
-
};
|
|
5957
|
-
//#endregion
|
|
5958
6527
|
//#region src/models/PaymentIntent.ts
|
|
5959
6528
|
var __defProp$1 = Object.defineProperty;
|
|
5960
6529
|
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|