@happyvertical/smrt-commerce 0.55.23 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/AGENTS.md +9 -9
  2. package/README.md +75 -4
  3. package/agents/customer-vendor-ui.md +61 -2
  4. package/agents/purchasing-ui.md +4 -3
  5. package/agents/quote-ui.md +3 -2
  6. package/dist/chunks/types-zVnIjSOk.js.map +1 -1
  7. package/dist/collections/ContractCollection.d.ts +2 -0
  8. package/dist/collections/ContractCollection.d.ts.map +1 -1
  9. package/dist/collections/PurchaseContractCollection.d.ts +8 -0
  10. package/dist/collections/PurchaseContractCollection.d.ts.map +1 -0
  11. package/dist/collections/SalesContractCollection.d.ts +8 -0
  12. package/dist/collections/SalesContractCollection.d.ts.map +1 -0
  13. package/dist/collections/index.d.ts +2 -0
  14. package/dist/collections/index.d.ts.map +1 -1
  15. package/dist/index.d.ts +5 -3
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +502 -88
  18. package/dist/index.js.map +1 -1
  19. package/dist/manifest.json +2253 -847
  20. package/dist/migrations/partyLinks.d.ts +39 -0
  21. package/dist/migrations/partyLinks.d.ts.map +1 -0
  22. package/dist/models/Contract.d.ts +37 -27
  23. package/dist/models/Contract.d.ts.map +1 -1
  24. package/dist/models/ContractLineItem.d.ts.map +1 -1
  25. package/dist/models/Customer.d.ts +13 -1
  26. package/dist/models/Customer.d.ts.map +1 -1
  27. package/dist/models/Invoice.d.ts.map +1 -1
  28. package/dist/models/InvoiceLineItem.d.ts.map +1 -1
  29. package/dist/models/PaymentAllocation.d.ts.map +1 -1
  30. package/dist/models/Vendor.d.ts +6 -1
  31. package/dist/models/Vendor.d.ts.map +1 -1
  32. package/dist/models/index.d.ts +1 -1
  33. package/dist/models/index.d.ts.map +1 -1
  34. package/dist/party-contacts.d.ts +146 -0
  35. package/dist/party-contacts.d.ts.map +1 -0
  36. package/dist/recipes.d.ts +2 -32
  37. package/dist/recipes.d.ts.map +1 -1
  38. package/dist/smrt-knowledge.json +967 -365
  39. package/dist/svelte/components/CustomerDetail.svelte +16 -5
  40. package/dist/svelte/components/CustomerDetail.svelte.d.ts +5 -0
  41. package/dist/svelte/components/CustomerDetail.svelte.d.ts.map +1 -1
  42. package/dist/svelte/components/CustomerDirectory.svelte +16 -5
  43. package/dist/svelte/components/CustomerDirectory.svelte.d.ts +5 -0
  44. package/dist/svelte/components/CustomerDirectory.svelte.d.ts.map +1 -1
  45. package/dist/svelte/components/CustomerForm.svelte +23 -0
  46. package/dist/svelte/components/CustomerForm.svelte.d.ts +9 -2
  47. package/dist/svelte/components/CustomerForm.svelte.d.ts.map +1 -1
  48. package/dist/svelte/components/PartyContactFields.svelte +4 -0
  49. package/dist/svelte/components/PartyContactFields.svelte.d.ts.map +1 -1
  50. package/dist/svelte/components/VendorDetail.svelte +16 -5
  51. package/dist/svelte/components/VendorDetail.svelte.d.ts +5 -0
  52. package/dist/svelte/components/VendorDetail.svelte.d.ts.map +1 -1
  53. package/dist/svelte/components/VendorDirectory.svelte +16 -5
  54. package/dist/svelte/components/VendorDirectory.svelte.d.ts +5 -0
  55. package/dist/svelte/components/VendorDirectory.svelte.d.ts.map +1 -1
  56. package/dist/svelte/components/VendorForm.svelte +23 -0
  57. package/dist/svelte/components/VendorForm.svelte.d.ts +9 -2
  58. package/dist/svelte/components/VendorForm.svelte.d.ts.map +1 -1
  59. package/dist/svelte/index.d.ts +1 -1
  60. package/dist/svelte/index.d.ts.map +1 -1
  61. package/dist/svelte/party-types.d.ts +15 -1
  62. package/dist/svelte/party-types.d.ts.map +1 -1
  63. package/dist/svelte/party-types.js +1 -0
  64. package/dist/types/index.d.ts +25 -4
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/package.json +11 -11
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-commerce",
5
- "packageVersion": "0.55.23",
5
+ "packageVersion": "0.56.0",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-commerce:ContractCollection": {
8
8
  "name": "contractcollection",
@@ -164,7 +164,7 @@
164
164
  "collectionExportName": "ContractCollectionCollection",
165
165
  "schema": {
166
166
  "tableName": "contracts",
167
- "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);",
167
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
168
168
  "columns": {
169
169
  "id": {
170
170
  "type": "UUID",
@@ -212,28 +212,6 @@
212
212
  "type": "TEXT",
213
213
  "notNull": false
214
214
  },
215
- "customer_id": {
216
- "type": "UUID",
217
- "referenceKind": "foreignKey",
218
- "notNull": false,
219
- "foreignKey": {
220
- "table": "customers",
221
- "column": "id",
222
- "onDelete": "NO ACTION",
223
- "onUpdate": "CASCADE"
224
- }
225
- },
226
- "vendor_id": {
227
- "type": "UUID",
228
- "referenceKind": "foreignKey",
229
- "notNull": false,
230
- "foreignKey": {
231
- "table": "vendors",
232
- "column": "id",
233
- "onDelete": "NO ACTION",
234
- "onUpdate": "CASCADE"
235
- }
236
- },
237
215
  "subtotal": {
238
216
  "type": "INTEGER",
239
217
  "notNull": false,
@@ -285,6 +263,28 @@
285
263
  "type": "TEXT",
286
264
  "notNull": false,
287
265
  "default": ""
266
+ },
267
+ "customer_id": {
268
+ "type": "UUID",
269
+ "referenceKind": "foreignKey",
270
+ "notNull": false,
271
+ "foreignKey": {
272
+ "table": "customers",
273
+ "column": "id",
274
+ "onDelete": "NO ACTION",
275
+ "onUpdate": "CASCADE"
276
+ }
277
+ },
278
+ "vendor_id": {
279
+ "type": "UUID",
280
+ "referenceKind": "foreignKey",
281
+ "notNull": false,
282
+ "foreignKey": {
283
+ "table": "vendors",
284
+ "column": "id",
285
+ "onDelete": "NO ACTION",
286
+ "onUpdate": "CASCADE"
287
+ }
288
288
  }
289
289
  },
290
290
  "indexes": [
@@ -325,7 +325,7 @@
325
325
  ]
326
326
  }
327
327
  ],
328
- "version": "9c2e9c49"
328
+ "version": "0eb8f0eb"
329
329
  },
330
330
  "importPath": "@happyvertical/smrt-commerce"
331
331
  },
@@ -660,7 +660,7 @@
660
660
  "collectionExportName": "CustomerCollectionCollection",
661
661
  "schema": {
662
662
  "tableName": "customers",
663
- "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);",
663
+ "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 \"contacts\" JSON DEFAULT '[]'\n);",
664
664
  "columns": {
665
665
  "id": {
666
666
  "type": "UUID",
@@ -748,6 +748,12 @@
748
748
  "notNull": false,
749
749
  "unique": false,
750
750
  "default": ""
751
+ },
752
+ "contacts": {
753
+ "type": "JSON",
754
+ "notNull": false,
755
+ "unique": false,
756
+ "default": []
751
757
  }
752
758
  },
753
759
  "indexes": [
@@ -775,7 +781,7 @@
775
781
  ]
776
782
  }
777
783
  ],
778
- "version": "ad1b9967"
784
+ "version": "49587ccf"
779
785
  },
780
786
  "importPath": "@happyvertical/smrt-commerce"
781
787
  },
@@ -3650,119 +3656,65 @@
3650
3656
  },
3651
3657
  "importPath": "@happyvertical/smrt-commerce"
3652
3658
  },
3653
- "@happyvertical/smrt-commerce:VendorCollection": {
3654
- "name": "vendorcollection",
3655
- "className": "VendorCollection",
3656
- "qualifiedName": "@happyvertical/smrt-commerce:VendorCollection",
3657
- "collection": "vendors",
3658
- "filePath": "/home/runner/work/smrt/smrt/packages/commerce/src/collections/VendorCollection.ts",
3659
+ "@happyvertical/smrt-commerce:PurchaseContractCollection": {
3660
+ "name": "purchasecontractcollection",
3661
+ "className": "PurchaseContractCollection",
3662
+ "qualifiedName": "@happyvertical/smrt-commerce:PurchaseContractCollection",
3663
+ "collection": "contracts",
3664
+ "description": "Read supplier-side contracts across every purchase STI subtype.",
3665
+ "filePath": "/home/runner/work/smrt/smrt/packages/commerce/src/collections/PurchaseContractCollection.ts",
3659
3666
  "packageName": "@happyvertical/smrt-commerce",
3660
3667
  "fields": {},
3661
3668
  "methods": {
3662
- "findByProfile": {
3663
- "name": "findByProfile",
3664
- "async": true,
3665
- "parameters": [
3666
- {
3667
- "name": "profileId",
3668
- "type": "string",
3669
- "optional": false
3670
- }
3671
- ],
3672
- "returnType": "Promise<Vendor[]>",
3673
- "isStatic": false,
3674
- "isPublic": true
3675
- },
3676
- "findActive": {
3677
- "name": "findActive",
3678
- "async": true,
3679
- "parameters": [],
3680
- "returnType": "Promise<Vendor[]>",
3681
- "isStatic": false,
3682
- "isPublic": true
3683
- },
3684
- "findByStatus": {
3685
- "name": "findByStatus",
3686
- "async": true,
3687
- "parameters": [
3688
- {
3689
- "name": "status",
3690
- "type": "VendorStatus",
3691
- "optional": false
3692
- }
3693
- ],
3694
- "returnType": "Promise<Vendor[]>",
3695
- "isStatic": false,
3696
- "isPublic": true
3697
- },
3698
- "getOrCreateForProfile": {
3699
- "name": "getOrCreateForProfile",
3700
- "async": true,
3701
- "parameters": [
3702
- {
3703
- "name": "profileId",
3704
- "type": "string",
3705
- "optional": false
3706
- },
3707
- {
3708
- "name": "defaults",
3709
- "type": "Partial<object>",
3710
- "optional": true,
3711
- "memberTypes": [
3712
- "number",
3713
- "string"
3714
- ]
3715
- }
3716
- ],
3717
- "returnType": "Promise<Vendor>",
3718
- "isStatic": false,
3719
- "isPublic": true
3720
- },
3721
- "findByTenant": {
3722
- "name": "findByTenant",
3669
+ "findByVendor": {
3670
+ "name": "findByVendor",
3723
3671
  "async": true,
3724
3672
  "parameters": [
3725
3673
  {
3726
- "name": "tenantId",
3674
+ "name": "vendorId",
3727
3675
  "type": "string",
3728
3676
  "optional": false
3729
3677
  }
3730
3678
  ],
3731
- "returnType": "Promise<Vendor[]>",
3679
+ "returnType": "Promise<PurchaseContract[]>",
3732
3680
  "isStatic": false,
3733
3681
  "isPublic": true
3682
+ }
3683
+ },
3684
+ "decoratorConfig": {
3685
+ "tableName": "contracts",
3686
+ "api": {
3687
+ "exclude": [
3688
+ "create",
3689
+ "update",
3690
+ "delete",
3691
+ "findByVendor"
3692
+ ]
3734
3693
  },
3735
- "findGlobal": {
3736
- "name": "findGlobal",
3737
- "async": true,
3738
- "parameters": [],
3739
- "returnType": "Promise<Vendor[]>",
3740
- "isStatic": false,
3741
- "isPublic": true
3694
+ "mcp": {
3695
+ "exclude": [
3696
+ "create",
3697
+ "update",
3698
+ "delete",
3699
+ "findByVendor"
3700
+ ]
3742
3701
  },
3743
- "findWithGlobals": {
3744
- "name": "findWithGlobals",
3745
- "async": true,
3746
- "parameters": [
3747
- {
3748
- "name": "tenantId",
3749
- "type": "string",
3750
- "optional": false
3751
- }
3752
- ],
3753
- "returnType": "Promise<Vendor[]>",
3754
- "isStatic": false,
3755
- "isPublic": true
3702
+ "cli": {
3703
+ "exclude": [
3704
+ "create",
3705
+ "update",
3706
+ "delete",
3707
+ "findByVendor"
3708
+ ]
3756
3709
  }
3757
3710
  },
3758
- "decoratorConfig": {},
3759
3711
  "extends": "SmrtCollection",
3760
- "extendsTypeArg": "Vendor",
3761
- "exportName": "VendorCollection",
3762
- "collectionExportName": "VendorCollectionCollection",
3712
+ "extendsTypeArg": "PurchaseContract",
3713
+ "exportName": "PurchaseContractCollection",
3714
+ "collectionExportName": "PurchaseContractCollectionCollection",
3763
3715
  "schema": {
3764
- "tableName": "vendors",
3765
- "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);",
3716
+ "tableName": "contracts",
3717
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
3766
3718
  "columns": {
3767
3719
  "id": {
3768
3720
  "type": "UUID",
@@ -3779,6 +3731,14 @@
3779
3731
  "notNull": true,
3780
3732
  "default": ""
3781
3733
  },
3734
+ "_meta_type": {
3735
+ "type": "TEXT",
3736
+ "notNull": true
3737
+ },
3738
+ "_meta_data": {
3739
+ "type": "JSON",
3740
+ "notNull": false
3741
+ },
3782
3742
  "created_at": {
3783
3743
  "type": "TIMESTAMP",
3784
3744
  "notNull": true,
@@ -3792,104 +3752,1535 @@
3792
3752
  "tenant_id": {
3793
3753
  "type": "UUID",
3794
3754
  "referenceKind": "tenantId",
3795
- "notNull": false,
3796
- "unique": false
3755
+ "notNull": false
3797
3756
  },
3798
- "profile_id": {
3799
- "type": "UUID",
3800
- "referenceKind": "crossPackageRef",
3801
- "notNull": false,
3802
- "unique": false
3757
+ "contract_type": {
3758
+ "type": "TEXT",
3759
+ "notNull": false
3803
3760
  },
3804
- "lead_time_days": {
3761
+ "status": {
3762
+ "type": "TEXT",
3763
+ "notNull": false
3764
+ },
3765
+ "subtotal": {
3805
3766
  "type": "INTEGER",
3806
3767
  "notNull": false,
3807
- "unique": false,
3808
3768
  "default": 0
3809
3769
  },
3810
- "minimum_order_amount": {
3770
+ "tax_amount": {
3811
3771
  "type": "INTEGER",
3812
3772
  "notNull": false,
3813
- "unique": false,
3814
3773
  "default": 0
3815
3774
  },
3816
- "payment_terms": {
3817
- "type": "TEXT",
3775
+ "total_amount": {
3776
+ "type": "INTEGER",
3818
3777
  "notNull": false,
3819
- "unique": false,
3820
- "default": ""
3778
+ "default": 0
3821
3779
  },
3822
3780
  "currency": {
3823
3781
  "type": "TEXT",
3824
3782
  "notNull": false,
3825
- "unique": false,
3826
3783
  "default": "USD"
3827
3784
  },
3828
- "default_contact_email": {
3785
+ "issue_date": {
3786
+ "type": "TIMESTAMP",
3787
+ "notNull": false
3788
+ },
3789
+ "due_date": {
3790
+ "type": "TIMESTAMP",
3791
+ "notNull": false
3792
+ },
3793
+ "expiry_date": {
3794
+ "type": "TIMESTAMP",
3795
+ "notNull": false
3796
+ },
3797
+ "reference": {
3829
3798
  "type": "TEXT",
3830
3799
  "notNull": false,
3831
- "unique": false,
3832
3800
  "default": ""
3833
3801
  },
3834
- "default_contact_phone": {
3802
+ "notes": {
3835
3803
  "type": "TEXT",
3836
3804
  "notNull": false,
3837
- "unique": false,
3838
3805
  "default": ""
3839
3806
  },
3840
- "status": {
3807
+ "terms": {
3841
3808
  "type": "TEXT",
3842
3809
  "notNull": false,
3843
- "unique": false
3810
+ "default": ""
3844
3811
  },
3845
- "notes": {
3812
+ "channel_id": {
3846
3813
  "type": "TEXT",
3847
3814
  "notNull": false,
3848
- "unique": false,
3849
3815
  "default": ""
3850
3816
  },
3851
- "payout_addresses": {
3852
- "type": "JSON",
3817
+ "customer_id": {
3818
+ "type": "UUID",
3819
+ "referenceKind": "foreignKey",
3853
3820
  "notNull": false,
3854
- "unique": false,
3855
- "default": {}
3821
+ "foreignKey": {
3822
+ "table": "customers",
3823
+ "column": "id",
3824
+ "onDelete": "NO ACTION",
3825
+ "onUpdate": "CASCADE"
3826
+ }
3827
+ },
3828
+ "vendor_id": {
3829
+ "type": "UUID",
3830
+ "referenceKind": "foreignKey",
3831
+ "notNull": false,
3832
+ "foreignKey": {
3833
+ "table": "vendors",
3834
+ "column": "id",
3835
+ "onDelete": "NO ACTION",
3836
+ "onUpdate": "CASCADE"
3837
+ }
3856
3838
  }
3857
3839
  },
3858
3840
  "indexes": [
3859
3841
  {
3860
- "name": "vendors_slug_context_idx",
3842
+ "name": "contracts_slug_context_meta_type_idx",
3861
3843
  "columns": [
3862
3844
  "tenant_id",
3863
3845
  "slug",
3864
- "context"
3846
+ "context",
3847
+ "_meta_type"
3865
3848
  ],
3866
3849
  "unique": true,
3867
3850
  "nullsNotDistinct": true
3868
3851
  },
3869
3852
  {
3870
- "name": "vendors_tenant_id_created_at_idx",
3853
+ "name": "contracts_meta_type_idx",
3854
+ "columns": [
3855
+ "_meta_type"
3856
+ ]
3857
+ },
3858
+ {
3859
+ "name": "contracts_tenant_id_created_at_idx",
3860
+ "columns": [
3861
+ "tenant_id",
3862
+ "created_at"
3863
+ ]
3864
+ },
3865
+ {
3866
+ "name": "contracts_customer_id_idx",
3867
+ "columns": [
3868
+ "customer_id"
3869
+ ]
3870
+ },
3871
+ {
3872
+ "name": "contracts_vendor_id_idx",
3873
+ "columns": [
3874
+ "vendor_id"
3875
+ ]
3876
+ }
3877
+ ],
3878
+ "version": "456f7950"
3879
+ },
3880
+ "importPath": "@happyvertical/smrt-commerce"
3881
+ },
3882
+ "@happyvertical/smrt-commerce:SalesContractCollection": {
3883
+ "name": "salescontractcollection",
3884
+ "className": "SalesContractCollection",
3885
+ "qualifiedName": "@happyvertical/smrt-commerce:SalesContractCollection",
3886
+ "collection": "contracts",
3887
+ "description": "Read customer-side contracts across every sales STI subtype.",
3888
+ "filePath": "/home/runner/work/smrt/smrt/packages/commerce/src/collections/SalesContractCollection.ts",
3889
+ "packageName": "@happyvertical/smrt-commerce",
3890
+ "fields": {},
3891
+ "methods": {
3892
+ "findByCustomer": {
3893
+ "name": "findByCustomer",
3894
+ "async": true,
3895
+ "parameters": [
3896
+ {
3897
+ "name": "customerId",
3898
+ "type": "string",
3899
+ "optional": false
3900
+ }
3901
+ ],
3902
+ "returnType": "Promise<SalesContract[]>",
3903
+ "isStatic": false,
3904
+ "isPublic": true
3905
+ }
3906
+ },
3907
+ "decoratorConfig": {
3908
+ "tableName": "contracts",
3909
+ "api": {
3910
+ "exclude": [
3911
+ "create",
3912
+ "update",
3913
+ "delete",
3914
+ "findByCustomer"
3915
+ ]
3916
+ },
3917
+ "mcp": {
3918
+ "exclude": [
3919
+ "create",
3920
+ "update",
3921
+ "delete",
3922
+ "findByCustomer"
3923
+ ]
3924
+ },
3925
+ "cli": {
3926
+ "exclude": [
3927
+ "create",
3928
+ "update",
3929
+ "delete",
3930
+ "findByCustomer"
3931
+ ]
3932
+ }
3933
+ },
3934
+ "extends": "SmrtCollection",
3935
+ "extendsTypeArg": "SalesContract",
3936
+ "exportName": "SalesContractCollection",
3937
+ "collectionExportName": "SalesContractCollectionCollection",
3938
+ "schema": {
3939
+ "tableName": "contracts",
3940
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
3941
+ "columns": {
3942
+ "id": {
3943
+ "type": "UUID",
3944
+ "primaryKey": true,
3945
+ "referenceKind": "id",
3946
+ "notNull": true
3947
+ },
3948
+ "slug": {
3949
+ "type": "TEXT",
3950
+ "notNull": true
3951
+ },
3952
+ "context": {
3953
+ "type": "TEXT",
3954
+ "notNull": true,
3955
+ "default": ""
3956
+ },
3957
+ "_meta_type": {
3958
+ "type": "TEXT",
3959
+ "notNull": true
3960
+ },
3961
+ "_meta_data": {
3962
+ "type": "JSON",
3963
+ "notNull": false
3964
+ },
3965
+ "created_at": {
3966
+ "type": "TIMESTAMP",
3967
+ "notNull": true,
3968
+ "default": "current_timestamp"
3969
+ },
3970
+ "updated_at": {
3971
+ "type": "TIMESTAMP",
3972
+ "notNull": true,
3973
+ "default": "current_timestamp"
3974
+ },
3975
+ "tenant_id": {
3976
+ "type": "UUID",
3977
+ "referenceKind": "tenantId",
3978
+ "notNull": false
3979
+ },
3980
+ "contract_type": {
3981
+ "type": "TEXT",
3982
+ "notNull": false
3983
+ },
3984
+ "status": {
3985
+ "type": "TEXT",
3986
+ "notNull": false
3987
+ },
3988
+ "subtotal": {
3989
+ "type": "INTEGER",
3990
+ "notNull": false,
3991
+ "default": 0
3992
+ },
3993
+ "tax_amount": {
3994
+ "type": "INTEGER",
3995
+ "notNull": false,
3996
+ "default": 0
3997
+ },
3998
+ "total_amount": {
3999
+ "type": "INTEGER",
4000
+ "notNull": false,
4001
+ "default": 0
4002
+ },
4003
+ "currency": {
4004
+ "type": "TEXT",
4005
+ "notNull": false,
4006
+ "default": "USD"
4007
+ },
4008
+ "issue_date": {
4009
+ "type": "TIMESTAMP",
4010
+ "notNull": false
4011
+ },
4012
+ "due_date": {
4013
+ "type": "TIMESTAMP",
4014
+ "notNull": false
4015
+ },
4016
+ "expiry_date": {
4017
+ "type": "TIMESTAMP",
4018
+ "notNull": false
4019
+ },
4020
+ "reference": {
4021
+ "type": "TEXT",
4022
+ "notNull": false,
4023
+ "default": ""
4024
+ },
4025
+ "notes": {
4026
+ "type": "TEXT",
4027
+ "notNull": false,
4028
+ "default": ""
4029
+ },
4030
+ "terms": {
4031
+ "type": "TEXT",
4032
+ "notNull": false,
4033
+ "default": ""
4034
+ },
4035
+ "channel_id": {
4036
+ "type": "TEXT",
4037
+ "notNull": false,
4038
+ "default": ""
4039
+ },
4040
+ "customer_id": {
4041
+ "type": "UUID",
4042
+ "referenceKind": "foreignKey",
4043
+ "notNull": false,
4044
+ "foreignKey": {
4045
+ "table": "customers",
4046
+ "column": "id",
4047
+ "onDelete": "NO ACTION",
4048
+ "onUpdate": "CASCADE"
4049
+ }
4050
+ },
4051
+ "vendor_id": {
4052
+ "type": "UUID",
4053
+ "referenceKind": "foreignKey",
4054
+ "notNull": false,
4055
+ "foreignKey": {
4056
+ "table": "vendors",
4057
+ "column": "id",
4058
+ "onDelete": "NO ACTION",
4059
+ "onUpdate": "CASCADE"
4060
+ }
4061
+ }
4062
+ },
4063
+ "indexes": [
4064
+ {
4065
+ "name": "contracts_slug_context_meta_type_idx",
4066
+ "columns": [
4067
+ "tenant_id",
4068
+ "slug",
4069
+ "context",
4070
+ "_meta_type"
4071
+ ],
4072
+ "unique": true,
4073
+ "nullsNotDistinct": true
4074
+ },
4075
+ {
4076
+ "name": "contracts_meta_type_idx",
4077
+ "columns": [
4078
+ "_meta_type"
4079
+ ]
4080
+ },
4081
+ {
4082
+ "name": "contracts_tenant_id_created_at_idx",
4083
+ "columns": [
4084
+ "tenant_id",
4085
+ "created_at"
4086
+ ]
4087
+ },
4088
+ {
4089
+ "name": "contracts_customer_id_idx",
4090
+ "columns": [
4091
+ "customer_id"
4092
+ ]
4093
+ },
4094
+ {
4095
+ "name": "contracts_vendor_id_idx",
4096
+ "columns": [
4097
+ "vendor_id"
4098
+ ]
4099
+ }
4100
+ ],
4101
+ "version": "b3d6a501"
4102
+ },
4103
+ "importPath": "@happyvertical/smrt-commerce"
4104
+ },
4105
+ "@happyvertical/smrt-commerce:VendorCollection": {
4106
+ "name": "vendorcollection",
4107
+ "className": "VendorCollection",
4108
+ "qualifiedName": "@happyvertical/smrt-commerce:VendorCollection",
4109
+ "collection": "vendors",
4110
+ "filePath": "/home/runner/work/smrt/smrt/packages/commerce/src/collections/VendorCollection.ts",
4111
+ "packageName": "@happyvertical/smrt-commerce",
4112
+ "fields": {},
4113
+ "methods": {
4114
+ "findByProfile": {
4115
+ "name": "findByProfile",
4116
+ "async": true,
4117
+ "parameters": [
4118
+ {
4119
+ "name": "profileId",
4120
+ "type": "string",
4121
+ "optional": false
4122
+ }
4123
+ ],
4124
+ "returnType": "Promise<Vendor[]>",
4125
+ "isStatic": false,
4126
+ "isPublic": true
4127
+ },
4128
+ "findActive": {
4129
+ "name": "findActive",
4130
+ "async": true,
4131
+ "parameters": [],
4132
+ "returnType": "Promise<Vendor[]>",
4133
+ "isStatic": false,
4134
+ "isPublic": true
4135
+ },
4136
+ "findByStatus": {
4137
+ "name": "findByStatus",
4138
+ "async": true,
4139
+ "parameters": [
4140
+ {
4141
+ "name": "status",
4142
+ "type": "VendorStatus",
4143
+ "optional": false
4144
+ }
4145
+ ],
4146
+ "returnType": "Promise<Vendor[]>",
4147
+ "isStatic": false,
4148
+ "isPublic": true
4149
+ },
4150
+ "getOrCreateForProfile": {
4151
+ "name": "getOrCreateForProfile",
4152
+ "async": true,
4153
+ "parameters": [
4154
+ {
4155
+ "name": "profileId",
4156
+ "type": "string",
4157
+ "optional": false
4158
+ },
4159
+ {
4160
+ "name": "defaults",
4161
+ "type": "Partial<object>",
4162
+ "optional": true,
4163
+ "memberTypes": [
4164
+ "number",
4165
+ "string"
4166
+ ]
4167
+ }
4168
+ ],
4169
+ "returnType": "Promise<Vendor>",
4170
+ "isStatic": false,
4171
+ "isPublic": true
4172
+ },
4173
+ "findByTenant": {
4174
+ "name": "findByTenant",
4175
+ "async": true,
4176
+ "parameters": [
4177
+ {
4178
+ "name": "tenantId",
4179
+ "type": "string",
4180
+ "optional": false
4181
+ }
4182
+ ],
4183
+ "returnType": "Promise<Vendor[]>",
4184
+ "isStatic": false,
4185
+ "isPublic": true
4186
+ },
4187
+ "findGlobal": {
4188
+ "name": "findGlobal",
4189
+ "async": true,
4190
+ "parameters": [],
4191
+ "returnType": "Promise<Vendor[]>",
4192
+ "isStatic": false,
4193
+ "isPublic": true
4194
+ },
4195
+ "findWithGlobals": {
4196
+ "name": "findWithGlobals",
4197
+ "async": true,
4198
+ "parameters": [
4199
+ {
4200
+ "name": "tenantId",
4201
+ "type": "string",
4202
+ "optional": false
4203
+ }
4204
+ ],
4205
+ "returnType": "Promise<Vendor[]>",
4206
+ "isStatic": false,
4207
+ "isPublic": true
4208
+ }
4209
+ },
4210
+ "decoratorConfig": {},
4211
+ "extends": "SmrtCollection",
4212
+ "extendsTypeArg": "Vendor",
4213
+ "exportName": "VendorCollection",
4214
+ "collectionExportName": "VendorCollectionCollection",
4215
+ "schema": {
4216
+ "tableName": "vendors",
4217
+ "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 \"contacts\" JSON DEFAULT '[]'\n);",
4218
+ "columns": {
4219
+ "id": {
4220
+ "type": "UUID",
4221
+ "primaryKey": true,
4222
+ "referenceKind": "id",
4223
+ "notNull": true
4224
+ },
4225
+ "slug": {
4226
+ "type": "TEXT",
4227
+ "notNull": true
4228
+ },
4229
+ "context": {
4230
+ "type": "TEXT",
4231
+ "notNull": true,
4232
+ "default": ""
4233
+ },
4234
+ "created_at": {
4235
+ "type": "TIMESTAMP",
4236
+ "notNull": true,
4237
+ "default": "current_timestamp"
4238
+ },
4239
+ "updated_at": {
4240
+ "type": "TIMESTAMP",
4241
+ "notNull": true,
4242
+ "default": "current_timestamp"
4243
+ },
4244
+ "tenant_id": {
4245
+ "type": "UUID",
4246
+ "referenceKind": "tenantId",
4247
+ "notNull": false,
4248
+ "unique": false
4249
+ },
4250
+ "profile_id": {
4251
+ "type": "UUID",
4252
+ "referenceKind": "crossPackageRef",
4253
+ "notNull": false,
4254
+ "unique": false
4255
+ },
4256
+ "lead_time_days": {
4257
+ "type": "INTEGER",
4258
+ "notNull": false,
4259
+ "unique": false,
4260
+ "default": 0
4261
+ },
4262
+ "minimum_order_amount": {
4263
+ "type": "INTEGER",
4264
+ "notNull": false,
4265
+ "unique": false,
4266
+ "default": 0
4267
+ },
4268
+ "payment_terms": {
4269
+ "type": "TEXT",
4270
+ "notNull": false,
4271
+ "unique": false,
4272
+ "default": ""
4273
+ },
4274
+ "currency": {
4275
+ "type": "TEXT",
4276
+ "notNull": false,
4277
+ "unique": false,
4278
+ "default": "USD"
4279
+ },
4280
+ "default_contact_email": {
4281
+ "type": "TEXT",
4282
+ "notNull": false,
4283
+ "unique": false,
4284
+ "default": ""
4285
+ },
4286
+ "default_contact_phone": {
4287
+ "type": "TEXT",
4288
+ "notNull": false,
4289
+ "unique": false,
4290
+ "default": ""
4291
+ },
4292
+ "status": {
4293
+ "type": "TEXT",
4294
+ "notNull": false,
4295
+ "unique": false
4296
+ },
4297
+ "notes": {
4298
+ "type": "TEXT",
4299
+ "notNull": false,
4300
+ "unique": false,
4301
+ "default": ""
4302
+ },
4303
+ "payout_addresses": {
4304
+ "type": "JSON",
4305
+ "notNull": false,
4306
+ "unique": false,
4307
+ "default": {}
4308
+ },
4309
+ "contacts": {
4310
+ "type": "JSON",
4311
+ "notNull": false,
4312
+ "unique": false,
4313
+ "default": []
4314
+ }
4315
+ },
4316
+ "indexes": [
4317
+ {
4318
+ "name": "vendors_slug_context_idx",
4319
+ "columns": [
4320
+ "tenant_id",
4321
+ "slug",
4322
+ "context"
4323
+ ],
4324
+ "unique": true,
4325
+ "nullsNotDistinct": true
4326
+ },
4327
+ {
4328
+ "name": "vendors_tenant_id_created_at_idx",
4329
+ "columns": [
4330
+ "tenant_id",
4331
+ "created_at"
4332
+ ]
4333
+ },
4334
+ {
4335
+ "name": "vendors_profile_id_idx",
4336
+ "columns": [
4337
+ "profile_id"
4338
+ ]
4339
+ }
4340
+ ],
4341
+ "version": "0963c71f"
4342
+ },
4343
+ "importPath": "@happyvertical/smrt-commerce"
4344
+ },
4345
+ "@happyvertical/smrt-commerce:Contract": {
4346
+ "name": "contract",
4347
+ "className": "Contract",
4348
+ "qualifiedName": "@happyvertical/smrt-commerce:Contract",
4349
+ "collection": "contracts",
4350
+ "description": "Contract is the base class for all commercial agreements.",
4351
+ "filePath": "/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts",
4352
+ "packageName": "@happyvertical/smrt-commerce",
4353
+ "fields": {
4354
+ "created_at": {
4355
+ "type": "datetime",
4356
+ "required": false
4357
+ },
4358
+ "updated_at": {
4359
+ "type": "datetime",
4360
+ "required": false
4361
+ },
4362
+ "tenantId": {
4363
+ "type": "text",
4364
+ "required": false,
4365
+ "_meta": {
4366
+ "sqlType": "UUID",
4367
+ "nullable": true,
4368
+ "__tenancy": {
4369
+ "isTenantIdField": true,
4370
+ "autoFilter": true,
4371
+ "required": false,
4372
+ "autoPopulate": true,
4373
+ "nullable": true,
4374
+ "mode": "optional",
4375
+ "field": "tenantId",
4376
+ "allowSuperAdminBypass": false
4377
+ }
4378
+ }
4379
+ },
4380
+ "contractType": {
4381
+ "type": "text",
4382
+ "required": false,
4383
+ "description": "The kind of contract: order, estimate, lease, agreement and so on.",
4384
+ "_meta": {
4385
+ "description": "The kind of contract: order, estimate, lease, agreement and so on."
4386
+ },
4387
+ "enum": [
4388
+ "estimate",
4389
+ "order",
4390
+ "lease",
4391
+ "agreement",
4392
+ "purchase_order",
4393
+ "wholesale_order",
4394
+ "production_order",
4395
+ "cart",
4396
+ "license_sale"
4397
+ ]
4398
+ },
4399
+ "status": {
4400
+ "type": "text",
4401
+ "required": false,
4402
+ "description": "Where the order or agreement stands, for example draft, sent, accepted or completed.",
4403
+ "_meta": {
4404
+ "description": "Where the order or agreement stands, for example draft, sent, accepted or completed."
4405
+ },
4406
+ "enum": [
4407
+ "draft",
4408
+ "sent",
4409
+ "accepted",
4410
+ "declined",
4411
+ "completed",
4412
+ "cancelled"
4413
+ ]
4414
+ },
4415
+ "subtotal": {
4416
+ "type": "integer",
4417
+ "required": false,
4418
+ "default": 0,
4419
+ "description": "The amount before tax.",
4420
+ "_meta": {
4421
+ "description": "The amount before tax.",
4422
+ "ui": {
4423
+ "format": "money"
4424
+ }
4425
+ }
4426
+ },
4427
+ "taxAmount": {
4428
+ "type": "integer",
4429
+ "required": false,
4430
+ "default": 0,
4431
+ "description": "The tax charged.",
4432
+ "_meta": {
4433
+ "description": "The tax charged.",
4434
+ "ui": {
4435
+ "format": "money"
4436
+ }
4437
+ }
4438
+ },
4439
+ "totalAmount": {
4440
+ "type": "integer",
4441
+ "required": false,
4442
+ "default": 0,
4443
+ "description": "The full amount, tax included.",
4444
+ "_meta": {
4445
+ "description": "The full amount, tax included.",
4446
+ "ui": {
4447
+ "format": "money"
4448
+ }
4449
+ }
4450
+ },
4451
+ "currency": {
4452
+ "type": "text",
4453
+ "required": false,
4454
+ "default": "USD",
4455
+ "description": "The currency of the amounts.",
4456
+ "_meta": {
4457
+ "description": "The currency of the amounts.",
4458
+ "ui": {
4459
+ "widget": "currency"
4460
+ }
4461
+ }
4462
+ },
4463
+ "issueDate": {
4464
+ "type": "datetime",
4465
+ "required": false,
4466
+ "description": "The date it was issued or placed.",
4467
+ "_meta": {
4468
+ "description": "The date it was issued or placed."
4469
+ }
4470
+ },
4471
+ "dueDate": {
4472
+ "type": "datetime",
4473
+ "required": false,
4474
+ "description": "The date payment or delivery is due.",
4475
+ "_meta": {
4476
+ "description": "The date payment or delivery is due."
4477
+ }
4478
+ },
4479
+ "expiryDate": {
4480
+ "type": "datetime",
4481
+ "required": false,
4482
+ "description": "The last day the price or offer is good for.",
4483
+ "_meta": {
4484
+ "description": "The last day the price or offer is good for."
4485
+ }
4486
+ },
4487
+ "reference": {
4488
+ "type": "text",
4489
+ "required": false,
4490
+ "default": "",
4491
+ "description": "Your own number or note for finding this later, such as a purchase order or quote number.",
4492
+ "_meta": {
4493
+ "description": "Your own number or note for finding this later, such as a purchase order or quote number."
4494
+ }
4495
+ },
4496
+ "notes": {
4497
+ "type": "text",
4498
+ "required": false,
4499
+ "default": "",
4500
+ "description": "Anything worth remembering about this.",
4501
+ "_meta": {
4502
+ "description": "Anything worth remembering about this.",
4503
+ "ui": {
4504
+ "widget": "textarea"
4505
+ }
4506
+ }
4507
+ },
4508
+ "terms": {
4509
+ "type": "text",
4510
+ "required": false,
4511
+ "default": "",
4512
+ "description": "The conditions agreed, such as deposits, payment or delivery conditions.",
4513
+ "_meta": {
4514
+ "description": "The conditions agreed, such as deposits, payment or delivery conditions.",
4515
+ "ui": {
4516
+ "widget": "textarea"
4517
+ }
4518
+ }
4519
+ },
4520
+ "channelId": {
4521
+ "type": "text",
4522
+ "required": false,
4523
+ "default": "",
4524
+ "description": "Where it came from, for example your shop, a marketplace or a phone call.",
4525
+ "_meta": {
4526
+ "description": "Where it came from, for example your shop, a marketplace or a phone call."
4527
+ }
4528
+ }
4529
+ },
4530
+ "methods": {
4531
+ "isDraft": {
4532
+ "name": "isDraft",
4533
+ "async": false,
4534
+ "parameters": [],
4535
+ "returnType": "boolean",
4536
+ "isStatic": false,
4537
+ "isPublic": true
4538
+ },
4539
+ "isAccepted": {
4540
+ "name": "isAccepted",
4541
+ "async": false,
4542
+ "parameters": [],
4543
+ "returnType": "boolean",
4544
+ "isStatic": false,
4545
+ "isPublic": true
4546
+ },
4547
+ "isCompleted": {
4548
+ "name": "isCompleted",
4549
+ "async": false,
4550
+ "parameters": [],
4551
+ "returnType": "boolean",
4552
+ "isStatic": false,
4553
+ "isPublic": true
4554
+ },
4555
+ "isExpired": {
4556
+ "name": "isExpired",
4557
+ "async": false,
4558
+ "parameters": [],
4559
+ "returnType": "boolean",
4560
+ "isStatic": false,
4561
+ "isPublic": true
4562
+ },
4563
+ "isOverdue": {
4564
+ "name": "isOverdue",
4565
+ "async": false,
4566
+ "parameters": [],
4567
+ "returnType": "boolean",
4568
+ "isStatic": false,
4569
+ "isPublic": true
4570
+ },
4571
+ "recalculateTotals": {
4572
+ "name": "recalculateTotals",
4573
+ "async": true,
4574
+ "parameters": [],
4575
+ "returnType": "Promise<void>",
4576
+ "isStatic": false,
4577
+ "isPublic": true
4578
+ },
4579
+ "initialize": {
4580
+ "name": "initialize",
4581
+ "async": true,
4582
+ "parameters": [],
4583
+ "returnType": "Promise<this>",
4584
+ "isStatic": false,
4585
+ "isPublic": true
4586
+ },
4587
+ "save": {
4588
+ "name": "save",
4589
+ "async": true,
4590
+ "parameters": [],
4591
+ "returnType": "Promise<this>",
4592
+ "isStatic": false,
4593
+ "isPublic": true
4594
+ }
4595
+ },
4596
+ "decoratorConfig": {
4597
+ "tableStrategy": "sti",
4598
+ "api": {
4599
+ "include": [
4600
+ "list",
4601
+ "get",
4602
+ "create",
4603
+ "update"
4604
+ ]
4605
+ },
4606
+ "mcp": {
4607
+ "include": [
4608
+ "list",
4609
+ "get"
4610
+ ]
4611
+ },
4612
+ "cli": {
4613
+ "skipApiCheck": true
4614
+ },
4615
+ "tenantScoped": {
4616
+ "mode": "optional"
4617
+ },
4618
+ "conflictColumns": [
4619
+ "tenant_id",
4620
+ "slug",
4621
+ "context",
4622
+ "_meta_type"
4623
+ ]
4624
+ },
4625
+ "extends": "SmrtObject",
4626
+ "exportName": "Contract",
4627
+ "collectionExportName": "ContractCollection",
4628
+ "schema": {
4629
+ "tableName": "contracts",
4630
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
4631
+ "columns": {
4632
+ "id": {
4633
+ "type": "UUID",
4634
+ "primaryKey": true,
4635
+ "referenceKind": "id",
4636
+ "notNull": true
4637
+ },
4638
+ "slug": {
4639
+ "type": "TEXT",
4640
+ "notNull": true
4641
+ },
4642
+ "context": {
4643
+ "type": "TEXT",
4644
+ "notNull": true,
4645
+ "default": ""
4646
+ },
4647
+ "_meta_type": {
4648
+ "type": "TEXT",
4649
+ "notNull": true
4650
+ },
4651
+ "_meta_data": {
4652
+ "type": "JSON",
4653
+ "notNull": false
4654
+ },
4655
+ "created_at": {
4656
+ "type": "TIMESTAMP",
4657
+ "notNull": true,
4658
+ "default": "current_timestamp"
4659
+ },
4660
+ "updated_at": {
4661
+ "type": "TIMESTAMP",
4662
+ "notNull": true,
4663
+ "default": "current_timestamp"
4664
+ },
4665
+ "tenant_id": {
4666
+ "type": "UUID",
4667
+ "referenceKind": "tenantId",
4668
+ "notNull": false
4669
+ },
4670
+ "contract_type": {
4671
+ "type": "TEXT",
4672
+ "notNull": false
4673
+ },
4674
+ "status": {
4675
+ "type": "TEXT",
4676
+ "notNull": false
4677
+ },
4678
+ "subtotal": {
4679
+ "type": "INTEGER",
4680
+ "notNull": false,
4681
+ "default": 0
4682
+ },
4683
+ "tax_amount": {
4684
+ "type": "INTEGER",
4685
+ "notNull": false,
4686
+ "default": 0
4687
+ },
4688
+ "total_amount": {
4689
+ "type": "INTEGER",
4690
+ "notNull": false,
4691
+ "default": 0
4692
+ },
4693
+ "currency": {
4694
+ "type": "TEXT",
4695
+ "notNull": false,
4696
+ "default": "USD"
4697
+ },
4698
+ "issue_date": {
4699
+ "type": "TIMESTAMP",
4700
+ "notNull": false
4701
+ },
4702
+ "due_date": {
4703
+ "type": "TIMESTAMP",
4704
+ "notNull": false
4705
+ },
4706
+ "expiry_date": {
4707
+ "type": "TIMESTAMP",
4708
+ "notNull": false
4709
+ },
4710
+ "reference": {
4711
+ "type": "TEXT",
4712
+ "notNull": false,
4713
+ "default": ""
4714
+ },
4715
+ "notes": {
4716
+ "type": "TEXT",
4717
+ "notNull": false,
4718
+ "default": ""
4719
+ },
4720
+ "terms": {
4721
+ "type": "TEXT",
4722
+ "notNull": false,
4723
+ "default": ""
4724
+ },
4725
+ "channel_id": {
4726
+ "type": "TEXT",
4727
+ "notNull": false,
4728
+ "default": ""
4729
+ },
4730
+ "customer_id": {
4731
+ "type": "UUID",
4732
+ "referenceKind": "foreignKey",
4733
+ "notNull": false,
4734
+ "foreignKey": {
4735
+ "table": "customers",
4736
+ "column": "id",
4737
+ "onDelete": "NO ACTION",
4738
+ "onUpdate": "CASCADE"
4739
+ }
4740
+ },
4741
+ "vendor_id": {
4742
+ "type": "UUID",
4743
+ "referenceKind": "foreignKey",
4744
+ "notNull": false,
4745
+ "foreignKey": {
4746
+ "table": "vendors",
4747
+ "column": "id",
4748
+ "onDelete": "NO ACTION",
4749
+ "onUpdate": "CASCADE"
4750
+ }
4751
+ }
4752
+ },
4753
+ "indexes": [
4754
+ {
4755
+ "name": "contracts_slug_context_meta_type_idx",
4756
+ "columns": [
4757
+ "tenant_id",
4758
+ "slug",
4759
+ "context",
4760
+ "_meta_type"
4761
+ ],
4762
+ "unique": true,
4763
+ "nullsNotDistinct": true
4764
+ },
4765
+ {
4766
+ "name": "contracts_meta_type_idx",
4767
+ "columns": [
4768
+ "_meta_type"
4769
+ ]
4770
+ },
4771
+ {
4772
+ "name": "contracts_tenant_id_created_at_idx",
4773
+ "columns": [
4774
+ "tenant_id",
4775
+ "created_at"
4776
+ ]
4777
+ },
4778
+ {
4779
+ "name": "contracts_customer_id_idx",
4780
+ "columns": [
4781
+ "customer_id"
4782
+ ]
4783
+ },
4784
+ {
4785
+ "name": "contracts_vendor_id_idx",
4786
+ "columns": [
4787
+ "vendor_id"
4788
+ ]
4789
+ }
4790
+ ],
4791
+ "version": "0eb8f0eb"
4792
+ },
4793
+ "importPath": "@happyvertical/smrt-commerce"
4794
+ },
4795
+ "@happyvertical/smrt-commerce:SalesContract": {
4796
+ "name": "salescontract",
4797
+ "className": "SalesContract",
4798
+ "qualifiedName": "@happyvertical/smrt-commerce:SalesContract",
4799
+ "collection": "contracts",
4800
+ "description": "Customer-side contracts, including orders, estimates, and licenses.",
4801
+ "filePath": "/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts",
4802
+ "packageName": "@happyvertical/smrt-commerce",
4803
+ "fields": {
4804
+ "created_at": {
4805
+ "type": "datetime",
4806
+ "required": false
4807
+ },
4808
+ "updated_at": {
4809
+ "type": "datetime",
4810
+ "required": false
4811
+ },
4812
+ "tenantId": {
4813
+ "type": "text",
4814
+ "required": false,
4815
+ "_meta": {
4816
+ "sqlType": "UUID",
4817
+ "nullable": true,
4818
+ "__tenancy": {
4819
+ "isTenantIdField": true,
4820
+ "autoFilter": true,
4821
+ "required": false,
4822
+ "autoPopulate": true,
4823
+ "nullable": true,
4824
+ "mode": "optional",
4825
+ "field": "tenantId",
4826
+ "allowSuperAdminBypass": false
4827
+ }
4828
+ }
4829
+ },
4830
+ "contractType": {
4831
+ "type": "text",
4832
+ "required": false,
4833
+ "description": "The kind of contract: order, estimate, lease, agreement and so on.",
4834
+ "_meta": {
4835
+ "description": "The kind of contract: order, estimate, lease, agreement and so on."
4836
+ },
4837
+ "enum": [
4838
+ "estimate",
4839
+ "order",
4840
+ "lease",
4841
+ "agreement",
4842
+ "purchase_order",
4843
+ "wholesale_order",
4844
+ "production_order",
4845
+ "cart",
4846
+ "license_sale"
4847
+ ]
4848
+ },
4849
+ "status": {
4850
+ "type": "text",
4851
+ "required": false,
4852
+ "description": "Where the order or agreement stands, for example draft, sent, accepted or completed.",
4853
+ "_meta": {
4854
+ "description": "Where the order or agreement stands, for example draft, sent, accepted or completed."
4855
+ },
4856
+ "enum": [
4857
+ "draft",
4858
+ "sent",
4859
+ "accepted",
4860
+ "declined",
4861
+ "completed",
4862
+ "cancelled"
4863
+ ]
4864
+ },
4865
+ "subtotal": {
4866
+ "type": "integer",
4867
+ "required": false,
4868
+ "default": 0,
4869
+ "description": "The amount before tax.",
4870
+ "_meta": {
4871
+ "description": "The amount before tax.",
4872
+ "ui": {
4873
+ "format": "money"
4874
+ }
4875
+ }
4876
+ },
4877
+ "taxAmount": {
4878
+ "type": "integer",
4879
+ "required": false,
4880
+ "default": 0,
4881
+ "description": "The tax charged.",
4882
+ "_meta": {
4883
+ "description": "The tax charged.",
4884
+ "ui": {
4885
+ "format": "money"
4886
+ }
4887
+ }
4888
+ },
4889
+ "totalAmount": {
4890
+ "type": "integer",
4891
+ "required": false,
4892
+ "default": 0,
4893
+ "description": "The full amount, tax included.",
4894
+ "_meta": {
4895
+ "description": "The full amount, tax included.",
4896
+ "ui": {
4897
+ "format": "money"
4898
+ }
4899
+ }
4900
+ },
4901
+ "currency": {
4902
+ "type": "text",
4903
+ "required": false,
4904
+ "default": "USD",
4905
+ "description": "The currency of the amounts.",
4906
+ "_meta": {
4907
+ "description": "The currency of the amounts.",
4908
+ "ui": {
4909
+ "widget": "currency"
4910
+ }
4911
+ }
4912
+ },
4913
+ "issueDate": {
4914
+ "type": "datetime",
4915
+ "required": false,
4916
+ "description": "The date it was issued or placed.",
4917
+ "_meta": {
4918
+ "description": "The date it was issued or placed."
4919
+ }
4920
+ },
4921
+ "dueDate": {
4922
+ "type": "datetime",
4923
+ "required": false,
4924
+ "description": "The date payment or delivery is due.",
4925
+ "_meta": {
4926
+ "description": "The date payment or delivery is due."
4927
+ }
4928
+ },
4929
+ "expiryDate": {
4930
+ "type": "datetime",
4931
+ "required": false,
4932
+ "description": "The last day the price or offer is good for.",
4933
+ "_meta": {
4934
+ "description": "The last day the price or offer is good for."
4935
+ }
4936
+ },
4937
+ "reference": {
4938
+ "type": "text",
4939
+ "required": false,
4940
+ "default": "",
4941
+ "description": "Your own number or note for finding this later, such as a purchase order or quote number.",
4942
+ "_meta": {
4943
+ "description": "Your own number or note for finding this later, such as a purchase order or quote number."
4944
+ }
4945
+ },
4946
+ "notes": {
4947
+ "type": "text",
4948
+ "required": false,
4949
+ "default": "",
4950
+ "description": "Anything worth remembering about this.",
4951
+ "_meta": {
4952
+ "description": "Anything worth remembering about this.",
4953
+ "ui": {
4954
+ "widget": "textarea"
4955
+ }
4956
+ }
4957
+ },
4958
+ "terms": {
4959
+ "type": "text",
4960
+ "required": false,
4961
+ "default": "",
4962
+ "description": "The conditions agreed, such as deposits, payment or delivery conditions.",
4963
+ "_meta": {
4964
+ "description": "The conditions agreed, such as deposits, payment or delivery conditions.",
4965
+ "ui": {
4966
+ "widget": "textarea"
4967
+ }
4968
+ }
4969
+ },
4970
+ "channelId": {
4971
+ "type": "text",
4972
+ "required": false,
4973
+ "default": "",
4974
+ "description": "Where it came from, for example your shop, a marketplace or a phone call.",
4975
+ "_meta": {
4976
+ "description": "Where it came from, for example your shop, a marketplace or a phone call."
4977
+ }
4978
+ },
4979
+ "customerId": {
4980
+ "type": "foreignKey",
4981
+ "required": false,
4982
+ "related": "Customer",
4983
+ "_meta": {
4984
+ "description": "The customer a sales order or agreement is for."
4985
+ }
4986
+ }
4987
+ },
4988
+ "methods": {
4989
+ "isDraft": {
4990
+ "name": "isDraft",
4991
+ "async": false,
4992
+ "parameters": [],
4993
+ "returnType": "boolean",
4994
+ "isStatic": false,
4995
+ "isPublic": true
4996
+ },
4997
+ "isAccepted": {
4998
+ "name": "isAccepted",
4999
+ "async": false,
5000
+ "parameters": [],
5001
+ "returnType": "boolean",
5002
+ "isStatic": false,
5003
+ "isPublic": true
5004
+ },
5005
+ "isCompleted": {
5006
+ "name": "isCompleted",
5007
+ "async": false,
5008
+ "parameters": [],
5009
+ "returnType": "boolean",
5010
+ "isStatic": false,
5011
+ "isPublic": true
5012
+ },
5013
+ "isExpired": {
5014
+ "name": "isExpired",
5015
+ "async": false,
5016
+ "parameters": [],
5017
+ "returnType": "boolean",
5018
+ "isStatic": false,
5019
+ "isPublic": true
5020
+ },
5021
+ "isOverdue": {
5022
+ "name": "isOverdue",
5023
+ "async": false,
5024
+ "parameters": [],
5025
+ "returnType": "boolean",
5026
+ "isStatic": false,
5027
+ "isPublic": true
5028
+ },
5029
+ "recalculateTotals": {
5030
+ "name": "recalculateTotals",
5031
+ "async": true,
5032
+ "parameters": [],
5033
+ "returnType": "Promise<void>",
5034
+ "isStatic": false,
5035
+ "isPublic": true
5036
+ },
5037
+ "initialize": {
5038
+ "name": "initialize",
5039
+ "async": true,
5040
+ "parameters": [],
5041
+ "returnType": "Promise<this>",
5042
+ "isStatic": false,
5043
+ "isPublic": true
5044
+ },
5045
+ "save": {
5046
+ "name": "save",
5047
+ "async": true,
5048
+ "parameters": [],
5049
+ "returnType": "Promise<this>",
5050
+ "isStatic": false,
5051
+ "isPublic": true
5052
+ }
5053
+ },
5054
+ "decoratorConfig": {
5055
+ "abstract": true,
5056
+ "tenantScoped": {
5057
+ "mode": "optional"
5058
+ },
5059
+ "tableName": "contracts",
5060
+ "tableStrategy": "sti",
5061
+ "api": {
5062
+ "exclude": [
5063
+ "create",
5064
+ "update",
5065
+ "delete",
5066
+ "isDraft",
5067
+ "isAccepted",
5068
+ "isCompleted",
5069
+ "isExpired",
5070
+ "isOverdue",
5071
+ "recalculateTotals",
5072
+ "initialize",
5073
+ "save"
5074
+ ]
5075
+ },
5076
+ "mcp": {
5077
+ "exclude": [
5078
+ "create",
5079
+ "update",
5080
+ "delete",
5081
+ "isDraft",
5082
+ "isAccepted",
5083
+ "isCompleted",
5084
+ "isExpired",
5085
+ "isOverdue",
5086
+ "recalculateTotals",
5087
+ "initialize",
5088
+ "save"
5089
+ ]
5090
+ },
5091
+ "cli": {
5092
+ "exclude": [
5093
+ "create",
5094
+ "update",
5095
+ "delete",
5096
+ "isDraft",
5097
+ "isAccepted",
5098
+ "isCompleted",
5099
+ "isExpired",
5100
+ "isOverdue",
5101
+ "recalculateTotals",
5102
+ "initialize",
5103
+ "save"
5104
+ ]
5105
+ }
5106
+ },
5107
+ "extends": "Contract",
5108
+ "exportName": "SalesContract",
5109
+ "collectionExportName": "SalesContractCollection",
5110
+ "abstractDeclaredApi": null,
5111
+ "schema": {
5112
+ "tableName": "contracts",
5113
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
5114
+ "columns": {
5115
+ "id": {
5116
+ "type": "UUID",
5117
+ "primaryKey": true,
5118
+ "referenceKind": "id",
5119
+ "notNull": true
5120
+ },
5121
+ "slug": {
5122
+ "type": "TEXT",
5123
+ "notNull": true
5124
+ },
5125
+ "context": {
5126
+ "type": "TEXT",
5127
+ "notNull": true,
5128
+ "default": ""
5129
+ },
5130
+ "_meta_type": {
5131
+ "type": "TEXT",
5132
+ "notNull": true
5133
+ },
5134
+ "_meta_data": {
5135
+ "type": "JSON",
5136
+ "notNull": false
5137
+ },
5138
+ "created_at": {
5139
+ "type": "TIMESTAMP",
5140
+ "notNull": true,
5141
+ "default": "current_timestamp"
5142
+ },
5143
+ "updated_at": {
5144
+ "type": "TIMESTAMP",
5145
+ "notNull": true,
5146
+ "default": "current_timestamp"
5147
+ },
5148
+ "tenant_id": {
5149
+ "type": "UUID",
5150
+ "referenceKind": "tenantId",
5151
+ "notNull": false
5152
+ },
5153
+ "contract_type": {
5154
+ "type": "TEXT",
5155
+ "notNull": false
5156
+ },
5157
+ "status": {
5158
+ "type": "TEXT",
5159
+ "notNull": false
5160
+ },
5161
+ "subtotal": {
5162
+ "type": "INTEGER",
5163
+ "notNull": false,
5164
+ "default": 0
5165
+ },
5166
+ "tax_amount": {
5167
+ "type": "INTEGER",
5168
+ "notNull": false,
5169
+ "default": 0
5170
+ },
5171
+ "total_amount": {
5172
+ "type": "INTEGER",
5173
+ "notNull": false,
5174
+ "default": 0
5175
+ },
5176
+ "currency": {
5177
+ "type": "TEXT",
5178
+ "notNull": false,
5179
+ "default": "USD"
5180
+ },
5181
+ "issue_date": {
5182
+ "type": "TIMESTAMP",
5183
+ "notNull": false
5184
+ },
5185
+ "due_date": {
5186
+ "type": "TIMESTAMP",
5187
+ "notNull": false
5188
+ },
5189
+ "expiry_date": {
5190
+ "type": "TIMESTAMP",
5191
+ "notNull": false
5192
+ },
5193
+ "reference": {
5194
+ "type": "TEXT",
5195
+ "notNull": false,
5196
+ "default": ""
5197
+ },
5198
+ "notes": {
5199
+ "type": "TEXT",
5200
+ "notNull": false,
5201
+ "default": ""
5202
+ },
5203
+ "terms": {
5204
+ "type": "TEXT",
5205
+ "notNull": false,
5206
+ "default": ""
5207
+ },
5208
+ "channel_id": {
5209
+ "type": "TEXT",
5210
+ "notNull": false,
5211
+ "default": ""
5212
+ },
5213
+ "customer_id": {
5214
+ "type": "UUID",
5215
+ "referenceKind": "foreignKey",
5216
+ "notNull": false,
5217
+ "foreignKey": {
5218
+ "table": "customers",
5219
+ "column": "id",
5220
+ "onDelete": "NO ACTION",
5221
+ "onUpdate": "CASCADE"
5222
+ }
5223
+ },
5224
+ "vendor_id": {
5225
+ "type": "UUID",
5226
+ "referenceKind": "foreignKey",
5227
+ "notNull": false,
5228
+ "foreignKey": {
5229
+ "table": "vendors",
5230
+ "column": "id",
5231
+ "onDelete": "NO ACTION",
5232
+ "onUpdate": "CASCADE"
5233
+ }
5234
+ }
5235
+ },
5236
+ "indexes": [
5237
+ {
5238
+ "name": "contracts_slug_context_meta_type_idx",
5239
+ "columns": [
5240
+ "tenant_id",
5241
+ "slug",
5242
+ "context",
5243
+ "_meta_type"
5244
+ ],
5245
+ "unique": true,
5246
+ "nullsNotDistinct": true
5247
+ },
5248
+ {
5249
+ "name": "contracts_meta_type_idx",
5250
+ "columns": [
5251
+ "_meta_type"
5252
+ ]
5253
+ },
5254
+ {
5255
+ "name": "contracts_tenant_id_created_at_idx",
3871
5256
  "columns": [
3872
5257
  "tenant_id",
3873
5258
  "created_at"
3874
5259
  ]
3875
5260
  },
3876
5261
  {
3877
- "name": "vendors_profile_id_idx",
5262
+ "name": "contracts_customer_id_idx",
3878
5263
  "columns": [
3879
- "profile_id"
5264
+ "customer_id"
5265
+ ]
5266
+ },
5267
+ {
5268
+ "name": "contracts_vendor_id_idx",
5269
+ "columns": [
5270
+ "vendor_id"
3880
5271
  ]
3881
5272
  }
3882
5273
  ],
3883
- "version": "1dc2b65e"
5274
+ "version": "b3d6a501"
3884
5275
  },
3885
5276
  "importPath": "@happyvertical/smrt-commerce"
3886
5277
  },
3887
- "@happyvertical/smrt-commerce:Contract": {
3888
- "name": "contract",
3889
- "className": "Contract",
3890
- "qualifiedName": "@happyvertical/smrt-commerce:Contract",
5278
+ "@happyvertical/smrt-commerce:PurchaseContract": {
5279
+ "name": "purchasecontract",
5280
+ "className": "PurchaseContract",
5281
+ "qualifiedName": "@happyvertical/smrt-commerce:PurchaseContract",
3891
5282
  "collection": "contracts",
3892
- "description": "Contract is the base class for all commercial agreements.",
5283
+ "description": "Supplier-side contracts, including purchase and production orders.",
3893
5284
  "filePath": "/home/runner/work/smrt/smrt/packages/commerce/src/models/Contract.ts",
3894
5285
  "packageName": "@happyvertical/smrt-commerce",
3895
5286
  "fields": {
@@ -3954,29 +5345,16 @@
3954
5345
  "cancelled"
3955
5346
  ]
3956
5347
  },
3957
- "customerId": {
3958
- "type": "foreignKey",
3959
- "required": false,
3960
- "related": "Customer",
3961
- "_meta": {
3962
- "description": "The customer a sales order or agreement is for."
3963
- }
3964
- },
3965
- "vendorId": {
3966
- "type": "foreignKey",
3967
- "required": false,
3968
- "related": "Vendor",
3969
- "_meta": {
3970
- "description": "The vendor a purchase order is placed with."
3971
- }
3972
- },
3973
5348
  "subtotal": {
3974
5349
  "type": "integer",
3975
5350
  "required": false,
3976
5351
  "default": 0,
3977
5352
  "description": "The amount before tax.",
3978
5353
  "_meta": {
3979
- "description": "The amount before tax."
5354
+ "description": "The amount before tax.",
5355
+ "ui": {
5356
+ "format": "money"
5357
+ }
3980
5358
  }
3981
5359
  },
3982
5360
  "taxAmount": {
@@ -3985,7 +5363,10 @@
3985
5363
  "default": 0,
3986
5364
  "description": "The tax charged.",
3987
5365
  "_meta": {
3988
- "description": "The tax charged."
5366
+ "description": "The tax charged.",
5367
+ "ui": {
5368
+ "format": "money"
5369
+ }
3989
5370
  }
3990
5371
  },
3991
5372
  "totalAmount": {
@@ -3994,7 +5375,10 @@
3994
5375
  "default": 0,
3995
5376
  "description": "The full amount, tax included.",
3996
5377
  "_meta": {
3997
- "description": "The full amount, tax included."
5378
+ "description": "The full amount, tax included.",
5379
+ "ui": {
5380
+ "format": "money"
5381
+ }
3998
5382
  }
3999
5383
  },
4000
5384
  "currency": {
@@ -4074,6 +5458,14 @@
4074
5458
  "_meta": {
4075
5459
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
4076
5460
  }
5461
+ },
5462
+ "vendorId": {
5463
+ "type": "foreignKey",
5464
+ "required": false,
5465
+ "related": "Vendor",
5466
+ "_meta": {
5467
+ "description": "The vendor a purchase order is placed with."
5468
+ }
4077
5469
  }
4078
5470
  },
4079
5471
  "methods": {
@@ -4143,40 +5535,65 @@
4143
5535
  }
4144
5536
  },
4145
5537
  "decoratorConfig": {
5538
+ "abstract": true,
5539
+ "tenantScoped": {
5540
+ "mode": "optional"
5541
+ },
5542
+ "tableName": "contracts",
4146
5543
  "tableStrategy": "sti",
4147
5544
  "api": {
4148
- "include": [
4149
- "list",
4150
- "get",
5545
+ "exclude": [
4151
5546
  "create",
4152
- "update"
5547
+ "update",
5548
+ "delete",
5549
+ "isDraft",
5550
+ "isAccepted",
5551
+ "isCompleted",
5552
+ "isExpired",
5553
+ "isOverdue",
5554
+ "recalculateTotals",
5555
+ "initialize",
5556
+ "save"
4153
5557
  ]
4154
5558
  },
4155
5559
  "mcp": {
4156
- "include": [
4157
- "list",
4158
- "get"
5560
+ "exclude": [
5561
+ "create",
5562
+ "update",
5563
+ "delete",
5564
+ "isDraft",
5565
+ "isAccepted",
5566
+ "isCompleted",
5567
+ "isExpired",
5568
+ "isOverdue",
5569
+ "recalculateTotals",
5570
+ "initialize",
5571
+ "save"
4159
5572
  ]
4160
5573
  },
4161
5574
  "cli": {
4162
- "skipApiCheck": true
4163
- },
4164
- "tenantScoped": {
4165
- "mode": "optional"
4166
- },
4167
- "conflictColumns": [
4168
- "tenant_id",
4169
- "slug",
4170
- "context",
4171
- "_meta_type"
4172
- ]
5575
+ "exclude": [
5576
+ "create",
5577
+ "update",
5578
+ "delete",
5579
+ "isDraft",
5580
+ "isAccepted",
5581
+ "isCompleted",
5582
+ "isExpired",
5583
+ "isOverdue",
5584
+ "recalculateTotals",
5585
+ "initialize",
5586
+ "save"
5587
+ ]
5588
+ }
4173
5589
  },
4174
- "extends": "SmrtObject",
4175
- "exportName": "Contract",
4176
- "collectionExportName": "ContractCollection",
5590
+ "extends": "Contract",
5591
+ "exportName": "PurchaseContract",
5592
+ "collectionExportName": "PurchaseContractCollection",
5593
+ "abstractDeclaredApi": null,
4177
5594
  "schema": {
4178
5595
  "tableName": "contracts",
4179
- "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);",
5596
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
4180
5597
  "columns": {
4181
5598
  "id": {
4182
5599
  "type": "UUID",
@@ -4224,28 +5641,6 @@
4224
5641
  "type": "TEXT",
4225
5642
  "notNull": false
4226
5643
  },
4227
- "customer_id": {
4228
- "type": "UUID",
4229
- "referenceKind": "foreignKey",
4230
- "notNull": false,
4231
- "foreignKey": {
4232
- "table": "customers",
4233
- "column": "id",
4234
- "onDelete": "NO ACTION",
4235
- "onUpdate": "CASCADE"
4236
- }
4237
- },
4238
- "vendor_id": {
4239
- "type": "UUID",
4240
- "referenceKind": "foreignKey",
4241
- "notNull": false,
4242
- "foreignKey": {
4243
- "table": "vendors",
4244
- "column": "id",
4245
- "onDelete": "NO ACTION",
4246
- "onUpdate": "CASCADE"
4247
- }
4248
- },
4249
5644
  "subtotal": {
4250
5645
  "type": "INTEGER",
4251
5646
  "notNull": false,
@@ -4293,10 +5688,32 @@
4293
5688
  "notNull": false,
4294
5689
  "default": ""
4295
5690
  },
4296
- "channel_id": {
4297
- "type": "TEXT",
5691
+ "channel_id": {
5692
+ "type": "TEXT",
5693
+ "notNull": false,
5694
+ "default": ""
5695
+ },
5696
+ "customer_id": {
5697
+ "type": "UUID",
5698
+ "referenceKind": "foreignKey",
5699
+ "notNull": false,
5700
+ "foreignKey": {
5701
+ "table": "customers",
5702
+ "column": "id",
5703
+ "onDelete": "NO ACTION",
5704
+ "onUpdate": "CASCADE"
5705
+ }
5706
+ },
5707
+ "vendor_id": {
5708
+ "type": "UUID",
5709
+ "referenceKind": "foreignKey",
4298
5710
  "notNull": false,
4299
- "default": ""
5711
+ "foreignKey": {
5712
+ "table": "vendors",
5713
+ "column": "id",
5714
+ "onDelete": "NO ACTION",
5715
+ "onUpdate": "CASCADE"
5716
+ }
4300
5717
  }
4301
5718
  },
4302
5719
  "indexes": [
@@ -4337,7 +5754,7 @@
4337
5754
  ]
4338
5755
  }
4339
5756
  ],
4340
- "version": "9c2e9c49"
5757
+ "version": "456f7950"
4341
5758
  },
4342
5759
  "importPath": "@happyvertical/smrt-commerce"
4343
5760
  },
@@ -4378,22 +5795,7 @@
4378
5795
  },
4379
5796
  "contractType": {
4380
5797
  "type": "text",
4381
- "required": false,
4382
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
4383
- "_meta": {
4384
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
4385
- },
4386
- "enum": [
4387
- "estimate",
4388
- "order",
4389
- "lease",
4390
- "agreement",
4391
- "purchase_order",
4392
- "wholesale_order",
4393
- "production_order",
4394
- "cart",
4395
- "license_sale"
4396
- ]
5798
+ "required": false
4397
5799
  },
4398
5800
  "status": {
4399
5801
  "type": "text",
@@ -4411,29 +5813,16 @@
4411
5813
  "cancelled"
4412
5814
  ]
4413
5815
  },
4414
- "customerId": {
4415
- "type": "foreignKey",
4416
- "required": false,
4417
- "related": "Customer",
4418
- "_meta": {
4419
- "description": "The customer a sales order or agreement is for."
4420
- }
4421
- },
4422
- "vendorId": {
4423
- "type": "foreignKey",
4424
- "required": false,
4425
- "related": "Vendor",
4426
- "_meta": {
4427
- "description": "The vendor a purchase order is placed with."
4428
- }
4429
- },
4430
5816
  "subtotal": {
4431
5817
  "type": "integer",
4432
5818
  "required": false,
4433
5819
  "default": 0,
4434
5820
  "description": "The amount before tax.",
4435
5821
  "_meta": {
4436
- "description": "The amount before tax."
5822
+ "description": "The amount before tax.",
5823
+ "ui": {
5824
+ "format": "money"
5825
+ }
4437
5826
  }
4438
5827
  },
4439
5828
  "taxAmount": {
@@ -4442,7 +5831,10 @@
4442
5831
  "default": 0,
4443
5832
  "description": "The tax charged.",
4444
5833
  "_meta": {
4445
- "description": "The tax charged."
5834
+ "description": "The tax charged.",
5835
+ "ui": {
5836
+ "format": "money"
5837
+ }
4446
5838
  }
4447
5839
  },
4448
5840
  "totalAmount": {
@@ -4451,7 +5843,10 @@
4451
5843
  "default": 0,
4452
5844
  "description": "The full amount, tax included.",
4453
5845
  "_meta": {
4454
- "description": "The full amount, tax included."
5846
+ "description": "The full amount, tax included.",
5847
+ "ui": {
5848
+ "format": "money"
5849
+ }
4455
5850
  }
4456
5851
  },
4457
5852
  "currency": {
@@ -4531,6 +5926,14 @@
4531
5926
  "_meta": {
4532
5927
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
4533
5928
  }
5929
+ },
5930
+ "customerId": {
5931
+ "type": "foreignKey",
5932
+ "required": true,
5933
+ "related": "Customer",
5934
+ "_meta": {
5935
+ "required": true
5936
+ }
4534
5937
  }
4535
5938
  },
4536
5939
  "methods": {
@@ -4606,12 +6009,19 @@
4606
6009
  "tableName": "contracts",
4607
6010
  "tableStrategy": "sti"
4608
6011
  },
4609
- "extends": "Contract",
6012
+ "extends": "SalesContract",
4610
6013
  "exportName": "Estimate",
4611
6014
  "collectionExportName": "EstimateCollection",
6015
+ "validationRules": [
6016
+ {
6017
+ "field": "customerId",
6018
+ "rule": "required",
6019
+ "fieldType": "foreignKey"
6020
+ }
6021
+ ],
4612
6022
  "schema": {
4613
6023
  "tableName": "contracts",
4614
- "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);",
6024
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
4615
6025
  "columns": {
4616
6026
  "id": {
4617
6027
  "type": "UUID",
@@ -4659,28 +6069,6 @@
4659
6069
  "type": "TEXT",
4660
6070
  "notNull": false
4661
6071
  },
4662
- "customer_id": {
4663
- "type": "UUID",
4664
- "referenceKind": "foreignKey",
4665
- "notNull": false,
4666
- "foreignKey": {
4667
- "table": "customers",
4668
- "column": "id",
4669
- "onDelete": "NO ACTION",
4670
- "onUpdate": "CASCADE"
4671
- }
4672
- },
4673
- "vendor_id": {
4674
- "type": "UUID",
4675
- "referenceKind": "foreignKey",
4676
- "notNull": false,
4677
- "foreignKey": {
4678
- "table": "vendors",
4679
- "column": "id",
4680
- "onDelete": "NO ACTION",
4681
- "onUpdate": "CASCADE"
4682
- }
4683
- },
4684
6072
  "subtotal": {
4685
6073
  "type": "INTEGER",
4686
6074
  "notNull": false,
@@ -4732,6 +6120,28 @@
4732
6120
  "type": "TEXT",
4733
6121
  "notNull": false,
4734
6122
  "default": ""
6123
+ },
6124
+ "customer_id": {
6125
+ "type": "UUID",
6126
+ "referenceKind": "foreignKey",
6127
+ "notNull": false,
6128
+ "foreignKey": {
6129
+ "table": "customers",
6130
+ "column": "id",
6131
+ "onDelete": "NO ACTION",
6132
+ "onUpdate": "CASCADE"
6133
+ }
6134
+ },
6135
+ "vendor_id": {
6136
+ "type": "UUID",
6137
+ "referenceKind": "foreignKey",
6138
+ "notNull": false,
6139
+ "foreignKey": {
6140
+ "table": "vendors",
6141
+ "column": "id",
6142
+ "onDelete": "NO ACTION",
6143
+ "onUpdate": "CASCADE"
6144
+ }
4735
6145
  }
4736
6146
  },
4737
6147
  "indexes": [
@@ -4772,7 +6182,7 @@
4772
6182
  ]
4773
6183
  }
4774
6184
  ],
4775
- "version": "2f1624b2"
6185
+ "version": "97ec77c2"
4776
6186
  },
4777
6187
  "importPath": "@happyvertical/smrt-commerce"
4778
6188
  },
@@ -4813,22 +6223,7 @@
4813
6223
  },
4814
6224
  "contractType": {
4815
6225
  "type": "text",
4816
- "required": false,
4817
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
4818
- "_meta": {
4819
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
4820
- },
4821
- "enum": [
4822
- "estimate",
4823
- "order",
4824
- "lease",
4825
- "agreement",
4826
- "purchase_order",
4827
- "wholesale_order",
4828
- "production_order",
4829
- "cart",
4830
- "license_sale"
4831
- ]
6226
+ "required": false
4832
6227
  },
4833
6228
  "status": {
4834
6229
  "type": "text",
@@ -4846,29 +6241,16 @@
4846
6241
  "cancelled"
4847
6242
  ]
4848
6243
  },
4849
- "customerId": {
4850
- "type": "foreignKey",
4851
- "required": false,
4852
- "related": "Customer",
4853
- "_meta": {
4854
- "description": "The customer a sales order or agreement is for."
4855
- }
4856
- },
4857
- "vendorId": {
4858
- "type": "foreignKey",
4859
- "required": false,
4860
- "related": "Vendor",
4861
- "_meta": {
4862
- "description": "The vendor a purchase order is placed with."
4863
- }
4864
- },
4865
6244
  "subtotal": {
4866
6245
  "type": "integer",
4867
6246
  "required": false,
4868
6247
  "default": 0,
4869
6248
  "description": "The amount before tax.",
4870
6249
  "_meta": {
4871
- "description": "The amount before tax."
6250
+ "description": "The amount before tax.",
6251
+ "ui": {
6252
+ "format": "money"
6253
+ }
4872
6254
  }
4873
6255
  },
4874
6256
  "taxAmount": {
@@ -4877,7 +6259,10 @@
4877
6259
  "default": 0,
4878
6260
  "description": "The tax charged.",
4879
6261
  "_meta": {
4880
- "description": "The tax charged."
6262
+ "description": "The tax charged.",
6263
+ "ui": {
6264
+ "format": "money"
6265
+ }
4881
6266
  }
4882
6267
  },
4883
6268
  "totalAmount": {
@@ -4886,7 +6271,10 @@
4886
6271
  "default": 0,
4887
6272
  "description": "The full amount, tax included.",
4888
6273
  "_meta": {
4889
- "description": "The full amount, tax included."
6274
+ "description": "The full amount, tax included.",
6275
+ "ui": {
6276
+ "format": "money"
6277
+ }
4890
6278
  }
4891
6279
  },
4892
6280
  "currency": {
@@ -4966,6 +6354,14 @@
4966
6354
  "_meta": {
4967
6355
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
4968
6356
  }
6357
+ },
6358
+ "customerId": {
6359
+ "type": "foreignKey",
6360
+ "required": true,
6361
+ "related": "Customer",
6362
+ "_meta": {
6363
+ "required": true
6364
+ }
4969
6365
  }
4970
6366
  },
4971
6367
  "methods": {
@@ -5041,12 +6437,19 @@
5041
6437
  "tableName": "contracts",
5042
6438
  "tableStrategy": "sti"
5043
6439
  },
5044
- "extends": "Contract",
6440
+ "extends": "SalesContract",
5045
6441
  "exportName": "Order",
5046
6442
  "collectionExportName": "OrderCollection",
6443
+ "validationRules": [
6444
+ {
6445
+ "field": "customerId",
6446
+ "rule": "required",
6447
+ "fieldType": "foreignKey"
6448
+ }
6449
+ ],
5047
6450
  "schema": {
5048
6451
  "tableName": "contracts",
5049
- "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);",
6452
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
5050
6453
  "columns": {
5051
6454
  "id": {
5052
6455
  "type": "UUID",
@@ -5094,28 +6497,6 @@
5094
6497
  "type": "TEXT",
5095
6498
  "notNull": false
5096
6499
  },
5097
- "customer_id": {
5098
- "type": "UUID",
5099
- "referenceKind": "foreignKey",
5100
- "notNull": false,
5101
- "foreignKey": {
5102
- "table": "customers",
5103
- "column": "id",
5104
- "onDelete": "NO ACTION",
5105
- "onUpdate": "CASCADE"
5106
- }
5107
- },
5108
- "vendor_id": {
5109
- "type": "UUID",
5110
- "referenceKind": "foreignKey",
5111
- "notNull": false,
5112
- "foreignKey": {
5113
- "table": "vendors",
5114
- "column": "id",
5115
- "onDelete": "NO ACTION",
5116
- "onUpdate": "CASCADE"
5117
- }
5118
- },
5119
6500
  "subtotal": {
5120
6501
  "type": "INTEGER",
5121
6502
  "notNull": false,
@@ -5167,6 +6548,28 @@
5167
6548
  "type": "TEXT",
5168
6549
  "notNull": false,
5169
6550
  "default": ""
6551
+ },
6552
+ "customer_id": {
6553
+ "type": "UUID",
6554
+ "referenceKind": "foreignKey",
6555
+ "notNull": false,
6556
+ "foreignKey": {
6557
+ "table": "customers",
6558
+ "column": "id",
6559
+ "onDelete": "NO ACTION",
6560
+ "onUpdate": "CASCADE"
6561
+ }
6562
+ },
6563
+ "vendor_id": {
6564
+ "type": "UUID",
6565
+ "referenceKind": "foreignKey",
6566
+ "notNull": false,
6567
+ "foreignKey": {
6568
+ "table": "vendors",
6569
+ "column": "id",
6570
+ "onDelete": "NO ACTION",
6571
+ "onUpdate": "CASCADE"
6572
+ }
5170
6573
  }
5171
6574
  },
5172
6575
  "indexes": [
@@ -5207,7 +6610,7 @@
5207
6610
  ]
5208
6611
  }
5209
6612
  ],
5210
- "version": "b7667cf3"
6613
+ "version": "de738a76"
5211
6614
  },
5212
6615
  "importPath": "@happyvertical/smrt-commerce"
5213
6616
  },
@@ -5248,54 +6651,23 @@
5248
6651
  },
5249
6652
  "contractType": {
5250
6653
  "type": "text",
5251
- "required": false,
5252
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
5253
- "_meta": {
5254
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
5255
- },
5256
- "enum": [
5257
- "estimate",
5258
- "order",
5259
- "lease",
5260
- "agreement",
5261
- "purchase_order",
5262
- "wholesale_order",
5263
- "production_order",
5264
- "cart",
5265
- "license_sale"
5266
- ]
6654
+ "required": false
5267
6655
  },
5268
6656
  "status": {
5269
6657
  "type": "text",
5270
6658
  "required": false,
5271
6659
  "description": "Where the order or agreement stands, for example draft, sent, accepted or completed.",
5272
- "_meta": {
5273
- "description": "Where the order or agreement stands, for example draft, sent, accepted or completed."
5274
- },
5275
- "enum": [
5276
- "draft",
5277
- "sent",
5278
- "accepted",
5279
- "declined",
5280
- "completed",
5281
- "cancelled"
5282
- ]
5283
- },
5284
- "customerId": {
5285
- "type": "foreignKey",
5286
- "required": false,
5287
- "related": "Customer",
5288
- "_meta": {
5289
- "description": "The customer a sales order or agreement is for."
5290
- }
5291
- },
5292
- "vendorId": {
5293
- "type": "foreignKey",
5294
- "required": false,
5295
- "related": "Vendor",
5296
- "_meta": {
5297
- "description": "The vendor a purchase order is placed with."
5298
- }
6660
+ "_meta": {
6661
+ "description": "Where the order or agreement stands, for example draft, sent, accepted or completed."
6662
+ },
6663
+ "enum": [
6664
+ "draft",
6665
+ "sent",
6666
+ "accepted",
6667
+ "declined",
6668
+ "completed",
6669
+ "cancelled"
6670
+ ]
5299
6671
  },
5300
6672
  "subtotal": {
5301
6673
  "type": "integer",
@@ -5303,7 +6675,10 @@
5303
6675
  "default": 0,
5304
6676
  "description": "The amount before tax.",
5305
6677
  "_meta": {
5306
- "description": "The amount before tax."
6678
+ "description": "The amount before tax.",
6679
+ "ui": {
6680
+ "format": "money"
6681
+ }
5307
6682
  }
5308
6683
  },
5309
6684
  "taxAmount": {
@@ -5312,7 +6687,10 @@
5312
6687
  "default": 0,
5313
6688
  "description": "The tax charged.",
5314
6689
  "_meta": {
5315
- "description": "The tax charged."
6690
+ "description": "The tax charged.",
6691
+ "ui": {
6692
+ "format": "money"
6693
+ }
5316
6694
  }
5317
6695
  },
5318
6696
  "totalAmount": {
@@ -5321,7 +6699,10 @@
5321
6699
  "default": 0,
5322
6700
  "description": "The full amount, tax included.",
5323
6701
  "_meta": {
5324
- "description": "The full amount, tax included."
6702
+ "description": "The full amount, tax included.",
6703
+ "ui": {
6704
+ "format": "money"
6705
+ }
5325
6706
  }
5326
6707
  },
5327
6708
  "currency": {
@@ -5401,6 +6782,14 @@
5401
6782
  "_meta": {
5402
6783
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
5403
6784
  }
6785
+ },
6786
+ "customerId": {
6787
+ "type": "foreignKey",
6788
+ "required": true,
6789
+ "related": "Customer",
6790
+ "_meta": {
6791
+ "required": true
6792
+ }
5404
6793
  }
5405
6794
  },
5406
6795
  "methods": {
@@ -5476,12 +6865,19 @@
5476
6865
  "tableName": "contracts",
5477
6866
  "tableStrategy": "sti"
5478
6867
  },
5479
- "extends": "Contract",
6868
+ "extends": "SalesContract",
5480
6869
  "exportName": "Lease",
5481
6870
  "collectionExportName": "LeaseCollection",
6871
+ "validationRules": [
6872
+ {
6873
+ "field": "customerId",
6874
+ "rule": "required",
6875
+ "fieldType": "foreignKey"
6876
+ }
6877
+ ],
5482
6878
  "schema": {
5483
6879
  "tableName": "contracts",
5484
- "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);",
6880
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
5485
6881
  "columns": {
5486
6882
  "id": {
5487
6883
  "type": "UUID",
@@ -5529,28 +6925,6 @@
5529
6925
  "type": "TEXT",
5530
6926
  "notNull": false
5531
6927
  },
5532
- "customer_id": {
5533
- "type": "UUID",
5534
- "referenceKind": "foreignKey",
5535
- "notNull": false,
5536
- "foreignKey": {
5537
- "table": "customers",
5538
- "column": "id",
5539
- "onDelete": "NO ACTION",
5540
- "onUpdate": "CASCADE"
5541
- }
5542
- },
5543
- "vendor_id": {
5544
- "type": "UUID",
5545
- "referenceKind": "foreignKey",
5546
- "notNull": false,
5547
- "foreignKey": {
5548
- "table": "vendors",
5549
- "column": "id",
5550
- "onDelete": "NO ACTION",
5551
- "onUpdate": "CASCADE"
5552
- }
5553
- },
5554
6928
  "subtotal": {
5555
6929
  "type": "INTEGER",
5556
6930
  "notNull": false,
@@ -5602,6 +6976,28 @@
5602
6976
  "type": "TEXT",
5603
6977
  "notNull": false,
5604
6978
  "default": ""
6979
+ },
6980
+ "customer_id": {
6981
+ "type": "UUID",
6982
+ "referenceKind": "foreignKey",
6983
+ "notNull": false,
6984
+ "foreignKey": {
6985
+ "table": "customers",
6986
+ "column": "id",
6987
+ "onDelete": "NO ACTION",
6988
+ "onUpdate": "CASCADE"
6989
+ }
6990
+ },
6991
+ "vendor_id": {
6992
+ "type": "UUID",
6993
+ "referenceKind": "foreignKey",
6994
+ "notNull": false,
6995
+ "foreignKey": {
6996
+ "table": "vendors",
6997
+ "column": "id",
6998
+ "onDelete": "NO ACTION",
6999
+ "onUpdate": "CASCADE"
7000
+ }
5605
7001
  }
5606
7002
  },
5607
7003
  "indexes": [
@@ -5642,7 +7038,7 @@
5642
7038
  ]
5643
7039
  }
5644
7040
  ],
5645
- "version": "b24cdace"
7041
+ "version": "efe0fd5d"
5646
7042
  },
5647
7043
  "importPath": "@happyvertical/smrt-commerce"
5648
7044
  },
@@ -5683,22 +7079,7 @@
5683
7079
  },
5684
7080
  "contractType": {
5685
7081
  "type": "text",
5686
- "required": false,
5687
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
5688
- "_meta": {
5689
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
5690
- },
5691
- "enum": [
5692
- "estimate",
5693
- "order",
5694
- "lease",
5695
- "agreement",
5696
- "purchase_order",
5697
- "wholesale_order",
5698
- "production_order",
5699
- "cart",
5700
- "license_sale"
5701
- ]
7082
+ "required": false
5702
7083
  },
5703
7084
  "status": {
5704
7085
  "type": "text",
@@ -5716,29 +7097,16 @@
5716
7097
  "cancelled"
5717
7098
  ]
5718
7099
  },
5719
- "customerId": {
5720
- "type": "foreignKey",
5721
- "required": false,
5722
- "related": "Customer",
5723
- "_meta": {
5724
- "description": "The customer a sales order or agreement is for."
5725
- }
5726
- },
5727
- "vendorId": {
5728
- "type": "foreignKey",
5729
- "required": false,
5730
- "related": "Vendor",
5731
- "_meta": {
5732
- "description": "The vendor a purchase order is placed with."
5733
- }
5734
- },
5735
7100
  "subtotal": {
5736
7101
  "type": "integer",
5737
7102
  "required": false,
5738
7103
  "default": 0,
5739
7104
  "description": "The amount before tax.",
5740
7105
  "_meta": {
5741
- "description": "The amount before tax."
7106
+ "description": "The amount before tax.",
7107
+ "ui": {
7108
+ "format": "money"
7109
+ }
5742
7110
  }
5743
7111
  },
5744
7112
  "taxAmount": {
@@ -5747,7 +7115,10 @@
5747
7115
  "default": 0,
5748
7116
  "description": "The tax charged.",
5749
7117
  "_meta": {
5750
- "description": "The tax charged."
7118
+ "description": "The tax charged.",
7119
+ "ui": {
7120
+ "format": "money"
7121
+ }
5751
7122
  }
5752
7123
  },
5753
7124
  "totalAmount": {
@@ -5756,7 +7127,10 @@
5756
7127
  "default": 0,
5757
7128
  "description": "The full amount, tax included.",
5758
7129
  "_meta": {
5759
- "description": "The full amount, tax included."
7130
+ "description": "The full amount, tax included.",
7131
+ "ui": {
7132
+ "format": "money"
7133
+ }
5760
7134
  }
5761
7135
  },
5762
7136
  "currency": {
@@ -5836,6 +7210,14 @@
5836
7210
  "_meta": {
5837
7211
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
5838
7212
  }
7213
+ },
7214
+ "customerId": {
7215
+ "type": "foreignKey",
7216
+ "required": true,
7217
+ "related": "Customer",
7218
+ "_meta": {
7219
+ "required": true
7220
+ }
5839
7221
  }
5840
7222
  },
5841
7223
  "methods": {
@@ -5911,12 +7293,19 @@
5911
7293
  "tableName": "contracts",
5912
7294
  "tableStrategy": "sti"
5913
7295
  },
5914
- "extends": "Contract",
7296
+ "extends": "SalesContract",
5915
7297
  "exportName": "Agreement",
5916
7298
  "collectionExportName": "AgreementCollection",
7299
+ "validationRules": [
7300
+ {
7301
+ "field": "customerId",
7302
+ "rule": "required",
7303
+ "fieldType": "foreignKey"
7304
+ }
7305
+ ],
5917
7306
  "schema": {
5918
7307
  "tableName": "contracts",
5919
- "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);",
7308
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
5920
7309
  "columns": {
5921
7310
  "id": {
5922
7311
  "type": "UUID",
@@ -5964,28 +7353,6 @@
5964
7353
  "type": "TEXT",
5965
7354
  "notNull": false
5966
7355
  },
5967
- "customer_id": {
5968
- "type": "UUID",
5969
- "referenceKind": "foreignKey",
5970
- "notNull": false,
5971
- "foreignKey": {
5972
- "table": "customers",
5973
- "column": "id",
5974
- "onDelete": "NO ACTION",
5975
- "onUpdate": "CASCADE"
5976
- }
5977
- },
5978
- "vendor_id": {
5979
- "type": "UUID",
5980
- "referenceKind": "foreignKey",
5981
- "notNull": false,
5982
- "foreignKey": {
5983
- "table": "vendors",
5984
- "column": "id",
5985
- "onDelete": "NO ACTION",
5986
- "onUpdate": "CASCADE"
5987
- }
5988
- },
5989
7356
  "subtotal": {
5990
7357
  "type": "INTEGER",
5991
7358
  "notNull": false,
@@ -6037,6 +7404,28 @@
6037
7404
  "type": "TEXT",
6038
7405
  "notNull": false,
6039
7406
  "default": ""
7407
+ },
7408
+ "customer_id": {
7409
+ "type": "UUID",
7410
+ "referenceKind": "foreignKey",
7411
+ "notNull": false,
7412
+ "foreignKey": {
7413
+ "table": "customers",
7414
+ "column": "id",
7415
+ "onDelete": "NO ACTION",
7416
+ "onUpdate": "CASCADE"
7417
+ }
7418
+ },
7419
+ "vendor_id": {
7420
+ "type": "UUID",
7421
+ "referenceKind": "foreignKey",
7422
+ "notNull": false,
7423
+ "foreignKey": {
7424
+ "table": "vendors",
7425
+ "column": "id",
7426
+ "onDelete": "NO ACTION",
7427
+ "onUpdate": "CASCADE"
7428
+ }
6040
7429
  }
6041
7430
  },
6042
7431
  "indexes": [
@@ -6077,7 +7466,7 @@
6077
7466
  ]
6078
7467
  }
6079
7468
  ],
6080
- "version": "28f0c394"
7469
+ "version": "4fb506a2"
6081
7470
  },
6082
7471
  "importPath": "@happyvertical/smrt-commerce"
6083
7472
  },
@@ -6118,22 +7507,7 @@
6118
7507
  },
6119
7508
  "contractType": {
6120
7509
  "type": "text",
6121
- "required": false,
6122
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
6123
- "_meta": {
6124
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
6125
- },
6126
- "enum": [
6127
- "estimate",
6128
- "order",
6129
- "lease",
6130
- "agreement",
6131
- "purchase_order",
6132
- "wholesale_order",
6133
- "production_order",
6134
- "cart",
6135
- "license_sale"
6136
- ]
7510
+ "required": false
6137
7511
  },
6138
7512
  "status": {
6139
7513
  "type": "text",
@@ -6151,29 +7525,16 @@
6151
7525
  "cancelled"
6152
7526
  ]
6153
7527
  },
6154
- "customerId": {
6155
- "type": "foreignKey",
6156
- "required": false,
6157
- "related": "Customer",
6158
- "_meta": {
6159
- "description": "The customer a sales order or agreement is for."
6160
- }
6161
- },
6162
- "vendorId": {
6163
- "type": "foreignKey",
6164
- "required": false,
6165
- "related": "Vendor",
6166
- "_meta": {
6167
- "description": "The vendor a purchase order is placed with."
6168
- }
6169
- },
6170
7528
  "subtotal": {
6171
7529
  "type": "integer",
6172
7530
  "required": false,
6173
7531
  "default": 0,
6174
7532
  "description": "The amount before tax.",
6175
7533
  "_meta": {
6176
- "description": "The amount before tax."
7534
+ "description": "The amount before tax.",
7535
+ "ui": {
7536
+ "format": "money"
7537
+ }
6177
7538
  }
6178
7539
  },
6179
7540
  "taxAmount": {
@@ -6182,7 +7543,10 @@
6182
7543
  "default": 0,
6183
7544
  "description": "The tax charged.",
6184
7545
  "_meta": {
6185
- "description": "The tax charged."
7546
+ "description": "The tax charged.",
7547
+ "ui": {
7548
+ "format": "money"
7549
+ }
6186
7550
  }
6187
7551
  },
6188
7552
  "totalAmount": {
@@ -6191,7 +7555,10 @@
6191
7555
  "default": 0,
6192
7556
  "description": "The full amount, tax included.",
6193
7557
  "_meta": {
6194
- "description": "The full amount, tax included."
7558
+ "description": "The full amount, tax included.",
7559
+ "ui": {
7560
+ "format": "money"
7561
+ }
6195
7562
  }
6196
7563
  },
6197
7564
  "currency": {
@@ -6272,6 +7639,14 @@
6272
7639
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
6273
7640
  }
6274
7641
  },
7642
+ "vendorId": {
7643
+ "type": "foreignKey",
7644
+ "required": true,
7645
+ "related": "Vendor",
7646
+ "_meta": {
7647
+ "required": true
7648
+ }
7649
+ },
6275
7650
  "expectedDate": {
6276
7651
  "type": "meta",
6277
7652
  "required": false,
@@ -6366,12 +7741,19 @@
6366
7741
  "tableName": "contracts",
6367
7742
  "tableStrategy": "sti"
6368
7743
  },
6369
- "extends": "Contract",
7744
+ "extends": "PurchaseContract",
6370
7745
  "exportName": "PurchaseOrder",
6371
7746
  "collectionExportName": "PurchaseOrderCollection",
7747
+ "validationRules": [
7748
+ {
7749
+ "field": "vendorId",
7750
+ "rule": "required",
7751
+ "fieldType": "foreignKey"
7752
+ }
7753
+ ],
6372
7754
  "schema": {
6373
7755
  "tableName": "contracts",
6374
- "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);",
7756
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
6375
7757
  "columns": {
6376
7758
  "id": {
6377
7759
  "type": "UUID",
@@ -6419,28 +7801,6 @@
6419
7801
  "type": "TEXT",
6420
7802
  "notNull": false
6421
7803
  },
6422
- "customer_id": {
6423
- "type": "UUID",
6424
- "referenceKind": "foreignKey",
6425
- "notNull": false,
6426
- "foreignKey": {
6427
- "table": "customers",
6428
- "column": "id",
6429
- "onDelete": "NO ACTION",
6430
- "onUpdate": "CASCADE"
6431
- }
6432
- },
6433
- "vendor_id": {
6434
- "type": "UUID",
6435
- "referenceKind": "foreignKey",
6436
- "notNull": false,
6437
- "foreignKey": {
6438
- "table": "vendors",
6439
- "column": "id",
6440
- "onDelete": "NO ACTION",
6441
- "onUpdate": "CASCADE"
6442
- }
6443
- },
6444
7804
  "subtotal": {
6445
7805
  "type": "INTEGER",
6446
7806
  "notNull": false,
@@ -6486,12 +7846,34 @@
6486
7846
  "terms": {
6487
7847
  "type": "TEXT",
6488
7848
  "notNull": false,
6489
- "default": ""
7849
+ "default": ""
7850
+ },
7851
+ "channel_id": {
7852
+ "type": "TEXT",
7853
+ "notNull": false,
7854
+ "default": ""
7855
+ },
7856
+ "customer_id": {
7857
+ "type": "UUID",
7858
+ "referenceKind": "foreignKey",
7859
+ "notNull": false,
7860
+ "foreignKey": {
7861
+ "table": "customers",
7862
+ "column": "id",
7863
+ "onDelete": "NO ACTION",
7864
+ "onUpdate": "CASCADE"
7865
+ }
6490
7866
  },
6491
- "channel_id": {
6492
- "type": "TEXT",
7867
+ "vendor_id": {
7868
+ "type": "UUID",
7869
+ "referenceKind": "foreignKey",
6493
7870
  "notNull": false,
6494
- "default": ""
7871
+ "foreignKey": {
7872
+ "table": "vendors",
7873
+ "column": "id",
7874
+ "onDelete": "NO ACTION",
7875
+ "onUpdate": "CASCADE"
7876
+ }
6495
7877
  }
6496
7878
  },
6497
7879
  "indexes": [
@@ -6532,7 +7914,7 @@
6532
7914
  ]
6533
7915
  }
6534
7916
  ],
6535
- "version": "91ec64bb"
7917
+ "version": "6eabe226"
6536
7918
  },
6537
7919
  "importPath": "@happyvertical/smrt-commerce"
6538
7920
  },
@@ -6573,22 +7955,7 @@
6573
7955
  },
6574
7956
  "contractType": {
6575
7957
  "type": "text",
6576
- "required": false,
6577
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
6578
- "_meta": {
6579
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
6580
- },
6581
- "enum": [
6582
- "estimate",
6583
- "order",
6584
- "lease",
6585
- "agreement",
6586
- "purchase_order",
6587
- "wholesale_order",
6588
- "production_order",
6589
- "cart",
6590
- "license_sale"
6591
- ]
7958
+ "required": false
6592
7959
  },
6593
7960
  "status": {
6594
7961
  "type": "text",
@@ -6606,29 +7973,16 @@
6606
7973
  "cancelled"
6607
7974
  ]
6608
7975
  },
6609
- "customerId": {
6610
- "type": "foreignKey",
6611
- "required": false,
6612
- "related": "Customer",
6613
- "_meta": {
6614
- "description": "The customer a sales order or agreement is for."
6615
- }
6616
- },
6617
- "vendorId": {
6618
- "type": "foreignKey",
6619
- "required": false,
6620
- "related": "Vendor",
6621
- "_meta": {
6622
- "description": "The vendor a purchase order is placed with."
6623
- }
6624
- },
6625
7976
  "subtotal": {
6626
7977
  "type": "integer",
6627
7978
  "required": false,
6628
7979
  "default": 0,
6629
7980
  "description": "The amount before tax.",
6630
7981
  "_meta": {
6631
- "description": "The amount before tax."
7982
+ "description": "The amount before tax.",
7983
+ "ui": {
7984
+ "format": "money"
7985
+ }
6632
7986
  }
6633
7987
  },
6634
7988
  "taxAmount": {
@@ -6637,7 +7991,10 @@
6637
7991
  "default": 0,
6638
7992
  "description": "The tax charged.",
6639
7993
  "_meta": {
6640
- "description": "The tax charged."
7994
+ "description": "The tax charged.",
7995
+ "ui": {
7996
+ "format": "money"
7997
+ }
6641
7998
  }
6642
7999
  },
6643
8000
  "totalAmount": {
@@ -6646,7 +8003,10 @@
6646
8003
  "default": 0,
6647
8004
  "description": "The full amount, tax included.",
6648
8005
  "_meta": {
6649
- "description": "The full amount, tax included."
8006
+ "description": "The full amount, tax included.",
8007
+ "ui": {
8008
+ "format": "money"
8009
+ }
6650
8010
  }
6651
8011
  },
6652
8012
  "currency": {
@@ -6726,6 +8086,14 @@
6726
8086
  "_meta": {
6727
8087
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
6728
8088
  }
8089
+ },
8090
+ "customerId": {
8091
+ "type": "foreignKey",
8092
+ "required": true,
8093
+ "related": "Customer",
8094
+ "_meta": {
8095
+ "required": true
8096
+ }
6729
8097
  }
6730
8098
  },
6731
8099
  "methods": {
@@ -6801,12 +8169,19 @@
6801
8169
  "tableName": "contracts",
6802
8170
  "tableStrategy": "sti"
6803
8171
  },
6804
- "extends": "Contract",
8172
+ "extends": "SalesContract",
6805
8173
  "exportName": "WholesaleOrder",
6806
8174
  "collectionExportName": "WholesaleOrderCollection",
8175
+ "validationRules": [
8176
+ {
8177
+ "field": "customerId",
8178
+ "rule": "required",
8179
+ "fieldType": "foreignKey"
8180
+ }
8181
+ ],
6807
8182
  "schema": {
6808
8183
  "tableName": "contracts",
6809
- "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);",
8184
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
6810
8185
  "columns": {
6811
8186
  "id": {
6812
8187
  "type": "UUID",
@@ -6854,28 +8229,6 @@
6854
8229
  "type": "TEXT",
6855
8230
  "notNull": false
6856
8231
  },
6857
- "customer_id": {
6858
- "type": "UUID",
6859
- "referenceKind": "foreignKey",
6860
- "notNull": false,
6861
- "foreignKey": {
6862
- "table": "customers",
6863
- "column": "id",
6864
- "onDelete": "NO ACTION",
6865
- "onUpdate": "CASCADE"
6866
- }
6867
- },
6868
- "vendor_id": {
6869
- "type": "UUID",
6870
- "referenceKind": "foreignKey",
6871
- "notNull": false,
6872
- "foreignKey": {
6873
- "table": "vendors",
6874
- "column": "id",
6875
- "onDelete": "NO ACTION",
6876
- "onUpdate": "CASCADE"
6877
- }
6878
- },
6879
8232
  "subtotal": {
6880
8233
  "type": "INTEGER",
6881
8234
  "notNull": false,
@@ -6927,6 +8280,28 @@
6927
8280
  "type": "TEXT",
6928
8281
  "notNull": false,
6929
8282
  "default": ""
8283
+ },
8284
+ "customer_id": {
8285
+ "type": "UUID",
8286
+ "referenceKind": "foreignKey",
8287
+ "notNull": false,
8288
+ "foreignKey": {
8289
+ "table": "customers",
8290
+ "column": "id",
8291
+ "onDelete": "NO ACTION",
8292
+ "onUpdate": "CASCADE"
8293
+ }
8294
+ },
8295
+ "vendor_id": {
8296
+ "type": "UUID",
8297
+ "referenceKind": "foreignKey",
8298
+ "notNull": false,
8299
+ "foreignKey": {
8300
+ "table": "vendors",
8301
+ "column": "id",
8302
+ "onDelete": "NO ACTION",
8303
+ "onUpdate": "CASCADE"
8304
+ }
6930
8305
  }
6931
8306
  },
6932
8307
  "indexes": [
@@ -6967,7 +8342,7 @@
6967
8342
  ]
6968
8343
  }
6969
8344
  ],
6970
- "version": "ccb8a3ae"
8345
+ "version": "b7dcf847"
6971
8346
  },
6972
8347
  "importPath": "@happyvertical/smrt-commerce"
6973
8348
  },
@@ -7008,22 +8383,7 @@
7008
8383
  },
7009
8384
  "contractType": {
7010
8385
  "type": "text",
7011
- "required": false,
7012
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
7013
- "_meta": {
7014
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
7015
- },
7016
- "enum": [
7017
- "estimate",
7018
- "order",
7019
- "lease",
7020
- "agreement",
7021
- "purchase_order",
7022
- "wholesale_order",
7023
- "production_order",
7024
- "cart",
7025
- "license_sale"
7026
- ]
8386
+ "required": false
7027
8387
  },
7028
8388
  "status": {
7029
8389
  "type": "text",
@@ -7041,29 +8401,16 @@
7041
8401
  "cancelled"
7042
8402
  ]
7043
8403
  },
7044
- "customerId": {
7045
- "type": "foreignKey",
7046
- "required": false,
7047
- "related": "Customer",
7048
- "_meta": {
7049
- "description": "The customer a sales order or agreement is for."
7050
- }
7051
- },
7052
- "vendorId": {
7053
- "type": "foreignKey",
7054
- "required": false,
7055
- "related": "Vendor",
7056
- "_meta": {
7057
- "description": "The vendor a purchase order is placed with."
7058
- }
7059
- },
7060
8404
  "subtotal": {
7061
8405
  "type": "integer",
7062
8406
  "required": false,
7063
8407
  "default": 0,
7064
8408
  "description": "The amount before tax.",
7065
8409
  "_meta": {
7066
- "description": "The amount before tax."
8410
+ "description": "The amount before tax.",
8411
+ "ui": {
8412
+ "format": "money"
8413
+ }
7067
8414
  }
7068
8415
  },
7069
8416
  "taxAmount": {
@@ -7072,7 +8419,10 @@
7072
8419
  "default": 0,
7073
8420
  "description": "The tax charged.",
7074
8421
  "_meta": {
7075
- "description": "The tax charged."
8422
+ "description": "The tax charged.",
8423
+ "ui": {
8424
+ "format": "money"
8425
+ }
7076
8426
  }
7077
8427
  },
7078
8428
  "totalAmount": {
@@ -7081,7 +8431,10 @@
7081
8431
  "default": 0,
7082
8432
  "description": "The full amount, tax included.",
7083
8433
  "_meta": {
7084
- "description": "The full amount, tax included."
8434
+ "description": "The full amount, tax included.",
8435
+ "ui": {
8436
+ "format": "money"
8437
+ }
7085
8438
  }
7086
8439
  },
7087
8440
  "currency": {
@@ -7162,6 +8515,14 @@
7162
8515
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
7163
8516
  }
7164
8517
  },
8518
+ "vendorId": {
8519
+ "type": "foreignKey",
8520
+ "required": false,
8521
+ "related": "Vendor",
8522
+ "_meta": {
8523
+ "description": "The vendor a purchase order is placed with."
8524
+ }
8525
+ },
7165
8526
  "productId": {
7166
8527
  "type": "meta",
7167
8528
  "required": false,
@@ -7252,12 +8613,12 @@
7252
8613
  "tableName": "contracts",
7253
8614
  "tableStrategy": "sti"
7254
8615
  },
7255
- "extends": "Contract",
8616
+ "extends": "PurchaseContract",
7256
8617
  "exportName": "ProductionOrder",
7257
8618
  "collectionExportName": "ProductionOrderCollection",
7258
8619
  "schema": {
7259
8620
  "tableName": "contracts",
7260
- "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);",
8621
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
7261
8622
  "columns": {
7262
8623
  "id": {
7263
8624
  "type": "UUID",
@@ -7305,28 +8666,6 @@
7305
8666
  "type": "TEXT",
7306
8667
  "notNull": false
7307
8668
  },
7308
- "customer_id": {
7309
- "type": "UUID",
7310
- "referenceKind": "foreignKey",
7311
- "notNull": false,
7312
- "foreignKey": {
7313
- "table": "customers",
7314
- "column": "id",
7315
- "onDelete": "NO ACTION",
7316
- "onUpdate": "CASCADE"
7317
- }
7318
- },
7319
- "vendor_id": {
7320
- "type": "UUID",
7321
- "referenceKind": "foreignKey",
7322
- "notNull": false,
7323
- "foreignKey": {
7324
- "table": "vendors",
7325
- "column": "id",
7326
- "onDelete": "NO ACTION",
7327
- "onUpdate": "CASCADE"
7328
- }
7329
- },
7330
8669
  "subtotal": {
7331
8670
  "type": "INTEGER",
7332
8671
  "notNull": false,
@@ -7378,6 +8717,28 @@
7378
8717
  "type": "TEXT",
7379
8718
  "notNull": false,
7380
8719
  "default": ""
8720
+ },
8721
+ "customer_id": {
8722
+ "type": "UUID",
8723
+ "referenceKind": "foreignKey",
8724
+ "notNull": false,
8725
+ "foreignKey": {
8726
+ "table": "customers",
8727
+ "column": "id",
8728
+ "onDelete": "NO ACTION",
8729
+ "onUpdate": "CASCADE"
8730
+ }
8731
+ },
8732
+ "vendor_id": {
8733
+ "type": "UUID",
8734
+ "referenceKind": "foreignKey",
8735
+ "notNull": false,
8736
+ "foreignKey": {
8737
+ "table": "vendors",
8738
+ "column": "id",
8739
+ "onDelete": "NO ACTION",
8740
+ "onUpdate": "CASCADE"
8741
+ }
7381
8742
  }
7382
8743
  },
7383
8744
  "indexes": [
@@ -7418,7 +8779,7 @@
7418
8779
  ]
7419
8780
  }
7420
8781
  ],
7421
- "version": "c6b977a5"
8782
+ "version": "d9bb954b"
7422
8783
  },
7423
8784
  "importPath": "@happyvertical/smrt-commerce"
7424
8785
  },
@@ -7459,22 +8820,7 @@
7459
8820
  },
7460
8821
  "contractType": {
7461
8822
  "type": "text",
7462
- "required": false,
7463
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
7464
- "_meta": {
7465
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
7466
- },
7467
- "enum": [
7468
- "estimate",
7469
- "order",
7470
- "lease",
7471
- "agreement",
7472
- "purchase_order",
7473
- "wholesale_order",
7474
- "production_order",
7475
- "cart",
7476
- "license_sale"
7477
- ]
8823
+ "required": false
7478
8824
  },
7479
8825
  "status": {
7480
8826
  "type": "text",
@@ -7492,29 +8838,16 @@
7492
8838
  "cancelled"
7493
8839
  ]
7494
8840
  },
7495
- "customerId": {
7496
- "type": "foreignKey",
7497
- "required": false,
7498
- "related": "Customer",
7499
- "_meta": {
7500
- "description": "The customer a sales order or agreement is for."
7501
- }
7502
- },
7503
- "vendorId": {
7504
- "type": "foreignKey",
7505
- "required": false,
7506
- "related": "Vendor",
7507
- "_meta": {
7508
- "description": "The vendor a purchase order is placed with."
7509
- }
7510
- },
7511
8841
  "subtotal": {
7512
8842
  "type": "integer",
7513
8843
  "required": false,
7514
8844
  "default": 0,
7515
8845
  "description": "The amount before tax.",
7516
8846
  "_meta": {
7517
- "description": "The amount before tax."
8847
+ "description": "The amount before tax.",
8848
+ "ui": {
8849
+ "format": "money"
8850
+ }
7518
8851
  }
7519
8852
  },
7520
8853
  "taxAmount": {
@@ -7523,7 +8856,10 @@
7523
8856
  "default": 0,
7524
8857
  "description": "The tax charged.",
7525
8858
  "_meta": {
7526
- "description": "The tax charged."
8859
+ "description": "The tax charged.",
8860
+ "ui": {
8861
+ "format": "money"
8862
+ }
7527
8863
  }
7528
8864
  },
7529
8865
  "totalAmount": {
@@ -7532,7 +8868,10 @@
7532
8868
  "default": 0,
7533
8869
  "description": "The full amount, tax included.",
7534
8870
  "_meta": {
7535
- "description": "The full amount, tax included."
8871
+ "description": "The full amount, tax included.",
8872
+ "ui": {
8873
+ "format": "money"
8874
+ }
7536
8875
  }
7537
8876
  },
7538
8877
  "currency": {
@@ -7610,7 +8949,15 @@
7610
8949
  "default": "",
7611
8950
  "description": "Where it came from, for example your shop, a marketplace or a phone call.",
7612
8951
  "_meta": {
7613
- "description": "Where it came from, for example your shop, a marketplace or a phone call."
8952
+ "description": "Where it came from, for example your shop, a marketplace or a phone call."
8953
+ }
8954
+ },
8955
+ "customerId": {
8956
+ "type": "foreignKey",
8957
+ "required": false,
8958
+ "related": "Customer",
8959
+ "_meta": {
8960
+ "description": "The customer a sales order or agreement is for."
7614
8961
  }
7615
8962
  }
7616
8963
  },
@@ -7687,12 +9034,12 @@
7687
9034
  "tableName": "contracts",
7688
9035
  "tableStrategy": "sti"
7689
9036
  },
7690
- "extends": "Contract",
9037
+ "extends": "SalesContract",
7691
9038
  "exportName": "Cart",
7692
9039
  "collectionExportName": "CartCollection",
7693
9040
  "schema": {
7694
9041
  "tableName": "contracts",
7695
- "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);",
9042
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
7696
9043
  "columns": {
7697
9044
  "id": {
7698
9045
  "type": "UUID",
@@ -7740,28 +9087,6 @@
7740
9087
  "type": "TEXT",
7741
9088
  "notNull": false
7742
9089
  },
7743
- "customer_id": {
7744
- "type": "UUID",
7745
- "referenceKind": "foreignKey",
7746
- "notNull": false,
7747
- "foreignKey": {
7748
- "table": "customers",
7749
- "column": "id",
7750
- "onDelete": "NO ACTION",
7751
- "onUpdate": "CASCADE"
7752
- }
7753
- },
7754
- "vendor_id": {
7755
- "type": "UUID",
7756
- "referenceKind": "foreignKey",
7757
- "notNull": false,
7758
- "foreignKey": {
7759
- "table": "vendors",
7760
- "column": "id",
7761
- "onDelete": "NO ACTION",
7762
- "onUpdate": "CASCADE"
7763
- }
7764
- },
7765
9090
  "subtotal": {
7766
9091
  "type": "INTEGER",
7767
9092
  "notNull": false,
@@ -7813,6 +9138,28 @@
7813
9138
  "type": "TEXT",
7814
9139
  "notNull": false,
7815
9140
  "default": ""
9141
+ },
9142
+ "customer_id": {
9143
+ "type": "UUID",
9144
+ "referenceKind": "foreignKey",
9145
+ "notNull": false,
9146
+ "foreignKey": {
9147
+ "table": "customers",
9148
+ "column": "id",
9149
+ "onDelete": "NO ACTION",
9150
+ "onUpdate": "CASCADE"
9151
+ }
9152
+ },
9153
+ "vendor_id": {
9154
+ "type": "UUID",
9155
+ "referenceKind": "foreignKey",
9156
+ "notNull": false,
9157
+ "foreignKey": {
9158
+ "table": "vendors",
9159
+ "column": "id",
9160
+ "onDelete": "NO ACTION",
9161
+ "onUpdate": "CASCADE"
9162
+ }
7816
9163
  }
7817
9164
  },
7818
9165
  "indexes": [
@@ -7853,7 +9200,7 @@
7853
9200
  ]
7854
9201
  }
7855
9202
  ],
7856
- "version": "fba16d4f"
9203
+ "version": "43023a03"
7857
9204
  },
7858
9205
  "importPath": "@happyvertical/smrt-commerce"
7859
9206
  },
@@ -7894,22 +9241,7 @@
7894
9241
  },
7895
9242
  "contractType": {
7896
9243
  "type": "text",
7897
- "required": false,
7898
- "description": "The kind of contract: order, estimate, lease, agreement and so on.",
7899
- "_meta": {
7900
- "description": "The kind of contract: order, estimate, lease, agreement and so on."
7901
- },
7902
- "enum": [
7903
- "estimate",
7904
- "order",
7905
- "lease",
7906
- "agreement",
7907
- "purchase_order",
7908
- "wholesale_order",
7909
- "production_order",
7910
- "cart",
7911
- "license_sale"
7912
- ]
9244
+ "required": false
7913
9245
  },
7914
9246
  "status": {
7915
9247
  "type": "text",
@@ -7927,29 +9259,16 @@
7927
9259
  "cancelled"
7928
9260
  ]
7929
9261
  },
7930
- "customerId": {
7931
- "type": "foreignKey",
7932
- "required": false,
7933
- "related": "Customer",
7934
- "_meta": {
7935
- "description": "The customer a sales order or agreement is for."
7936
- }
7937
- },
7938
- "vendorId": {
7939
- "type": "foreignKey",
7940
- "required": false,
7941
- "related": "Vendor",
7942
- "_meta": {
7943
- "description": "The vendor a purchase order is placed with."
7944
- }
7945
- },
7946
9262
  "subtotal": {
7947
9263
  "type": "integer",
7948
9264
  "required": false,
7949
9265
  "default": 0,
7950
9266
  "description": "The amount before tax.",
7951
9267
  "_meta": {
7952
- "description": "The amount before tax."
9268
+ "description": "The amount before tax.",
9269
+ "ui": {
9270
+ "format": "money"
9271
+ }
7953
9272
  }
7954
9273
  },
7955
9274
  "taxAmount": {
@@ -7958,7 +9277,10 @@
7958
9277
  "default": 0,
7959
9278
  "description": "The tax charged.",
7960
9279
  "_meta": {
7961
- "description": "The tax charged."
9280
+ "description": "The tax charged.",
9281
+ "ui": {
9282
+ "format": "money"
9283
+ }
7962
9284
  }
7963
9285
  },
7964
9286
  "totalAmount": {
@@ -7967,7 +9289,10 @@
7967
9289
  "default": 0,
7968
9290
  "description": "The full amount, tax included.",
7969
9291
  "_meta": {
7970
- "description": "The full amount, tax included."
9292
+ "description": "The full amount, tax included.",
9293
+ "ui": {
9294
+ "format": "money"
9295
+ }
7971
9296
  }
7972
9297
  },
7973
9298
  "currency": {
@@ -8048,6 +9373,14 @@
8048
9373
  "description": "Where it came from, for example your shop, a marketplace or a phone call."
8049
9374
  }
8050
9375
  },
9376
+ "customerId": {
9377
+ "type": "foreignKey",
9378
+ "required": false,
9379
+ "related": "Customer",
9380
+ "_meta": {
9381
+ "description": "The customer a sales order or agreement is for."
9382
+ }
9383
+ },
8051
9384
  "skuId": {
8052
9385
  "type": "meta",
8053
9386
  "required": false,
@@ -8258,12 +9591,12 @@
8258
9591
  "tableName": "contracts",
8259
9592
  "tableStrategy": "sti"
8260
9593
  },
8261
- "extends": "Contract",
9594
+ "extends": "SalesContract",
8262
9595
  "exportName": "LicenseSale",
8263
9596
  "collectionExportName": "LicenseSaleCollection",
8264
9597
  "schema": {
8265
9598
  "tableName": "contracts",
8266
- "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);",
9599
+ "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 \"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 \"customer_id\" UUID,\n \"vendor_id\" UUID\n);",
8267
9600
  "columns": {
8268
9601
  "id": {
8269
9602
  "type": "UUID",
@@ -8311,28 +9644,6 @@
8311
9644
  "type": "TEXT",
8312
9645
  "notNull": false
8313
9646
  },
8314
- "customer_id": {
8315
- "type": "UUID",
8316
- "referenceKind": "foreignKey",
8317
- "notNull": false,
8318
- "foreignKey": {
8319
- "table": "customers",
8320
- "column": "id",
8321
- "onDelete": "NO ACTION",
8322
- "onUpdate": "CASCADE"
8323
- }
8324
- },
8325
- "vendor_id": {
8326
- "type": "UUID",
8327
- "referenceKind": "foreignKey",
8328
- "notNull": false,
8329
- "foreignKey": {
8330
- "table": "vendors",
8331
- "column": "id",
8332
- "onDelete": "NO ACTION",
8333
- "onUpdate": "CASCADE"
8334
- }
8335
- },
8336
9647
  "subtotal": {
8337
9648
  "type": "INTEGER",
8338
9649
  "notNull": false,
@@ -8384,6 +9695,28 @@
8384
9695
  "type": "TEXT",
8385
9696
  "notNull": false,
8386
9697
  "default": ""
9698
+ },
9699
+ "customer_id": {
9700
+ "type": "UUID",
9701
+ "referenceKind": "foreignKey",
9702
+ "notNull": false,
9703
+ "foreignKey": {
9704
+ "table": "customers",
9705
+ "column": "id",
9706
+ "onDelete": "NO ACTION",
9707
+ "onUpdate": "CASCADE"
9708
+ }
9709
+ },
9710
+ "vendor_id": {
9711
+ "type": "UUID",
9712
+ "referenceKind": "foreignKey",
9713
+ "notNull": false,
9714
+ "foreignKey": {
9715
+ "table": "vendors",
9716
+ "column": "id",
9717
+ "onDelete": "NO ACTION",
9718
+ "onUpdate": "CASCADE"
9719
+ }
8387
9720
  }
8388
9721
  },
8389
9722
  "indexes": [
@@ -8424,7 +9757,7 @@
8424
9757
  ]
8425
9758
  }
8426
9759
  ],
8427
- "version": "d6d82bad"
9760
+ "version": "720a1437"
8428
9761
  },
8429
9762
  "importPath": "@happyvertical/smrt-commerce"
8430
9763
  },
@@ -8469,7 +9802,8 @@
8469
9802
  "related": "Contract",
8470
9803
  "description": "The order, quote or agreement this line belongs to.",
8471
9804
  "_meta": {
8472
- "description": "The order, quote or agreement this line belongs to."
9805
+ "description": "The order, quote or agreement this line belongs to.",
9806
+ "role": "items"
8473
9807
  }
8474
9808
  },
8475
9809
  "description": {
@@ -8496,13 +9830,21 @@
8496
9830
  "default": 0,
8497
9831
  "description": "The price of one, before tax.",
8498
9832
  "_meta": {
8499
- "description": "The price of one, before tax."
9833
+ "description": "The price of one, before tax.",
9834
+ "ui": {
9835
+ "format": "money"
9836
+ }
8500
9837
  }
8501
9838
  },
8502
9839
  "discount": {
8503
9840
  "type": "integer",
8504
9841
  "required": false,
8505
- "default": 0
9842
+ "default": 0,
9843
+ "_meta": {
9844
+ "ui": {
9845
+ "format": "money"
9846
+ }
9847
+ }
8506
9848
  },
8507
9849
  "taxRate": {
8508
9850
  "type": "decimal",
@@ -8519,7 +9861,10 @@
8519
9861
  "default": 0,
8520
9862
  "description": "The line total.",
8521
9863
  "_meta": {
8522
- "description": "The line total."
9864
+ "description": "The line total.",
9865
+ "ui": {
9866
+ "format": "money"
9867
+ }
8523
9868
  }
8524
9869
  },
8525
9870
  "productId": {
@@ -8809,7 +10154,10 @@
8809
10154
  "default": 0,
8810
10155
  "description": "The most this customer may owe you at one time. Leave it at zero if you do not set limits.",
8811
10156
  "_meta": {
8812
- "description": "The most this customer may owe you at one time. Leave it at zero if you do not set limits."
10157
+ "description": "The most this customer may owe you at one time. Leave it at zero if you do not set limits.",
10158
+ "ui": {
10159
+ "format": "money"
10160
+ }
8813
10161
  }
8814
10162
  },
8815
10163
  "paymentTerms": {
@@ -8894,9 +10242,34 @@
8894
10242
  "widget": "textarea"
8895
10243
  }
8896
10244
  }
10245
+ },
10246
+ "contacts": {
10247
+ "type": "json",
10248
+ "required": false,
10249
+ "default": [],
10250
+ "description": "The people you deal with at this customer, with their role and how to reach them.",
10251
+ "_meta": {
10252
+ "description": "The people you deal with at this customer, with their role and how to reach them."
10253
+ }
8897
10254
  }
8898
10255
  },
8899
10256
  "methods": {
10257
+ "initialize": {
10258
+ "name": "initialize",
10259
+ "async": true,
10260
+ "parameters": [],
10261
+ "returnType": "Promise<this>",
10262
+ "isStatic": false,
10263
+ "isPublic": true
10264
+ },
10265
+ "save": {
10266
+ "name": "save",
10267
+ "async": true,
10268
+ "parameters": [],
10269
+ "returnType": "Promise<this>",
10270
+ "isStatic": false,
10271
+ "isPublic": true
10272
+ },
8900
10273
  "isWholesale": {
8901
10274
  "name": "isWholesale",
8902
10275
  "async": false,
@@ -8968,7 +10341,7 @@
8968
10341
  "collectionExportName": "CustomerCollection",
8969
10342
  "schema": {
8970
10343
  "tableName": "customers",
8971
- "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);",
10344
+ "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 \"contacts\" JSON DEFAULT '[]'\n);",
8972
10345
  "columns": {
8973
10346
  "id": {
8974
10347
  "type": "UUID",
@@ -9056,6 +10429,12 @@
9056
10429
  "notNull": false,
9057
10430
  "unique": false,
9058
10431
  "default": ""
10432
+ },
10433
+ "contacts": {
10434
+ "type": "JSON",
10435
+ "notNull": false,
10436
+ "unique": false,
10437
+ "default": []
9059
10438
  }
9060
10439
  },
9061
10440
  "indexes": [
@@ -9083,7 +10462,7 @@
9083
10462
  ]
9084
10463
  }
9085
10464
  ],
9086
- "version": "ad1b9967"
10465
+ "version": "49587ccf"
9087
10466
  },
9088
10467
  "importPath": "@happyvertical/smrt-commerce"
9089
10468
  },
@@ -9117,10 +10496,11 @@
9117
10496
  "contractId": {
9118
10497
  "type": "foreignKey",
9119
10498
  "required": false,
9120
- "related": "Contract",
10499
+ "related": "SalesContract",
9121
10500
  "description": "The order being fulfilled.",
9122
10501
  "_meta": {
9123
- "description": "The order being fulfilled."
10502
+ "description": "The order being fulfilled.",
10503
+ "validateSubtype": true
9124
10504
  }
9125
10505
  },
9126
10506
  "fulfillmentType": {
@@ -9470,7 +10850,8 @@
9470
10850
  "related": "Fulfillment",
9471
10851
  "description": "The shipment this line belongs to.",
9472
10852
  "_meta": {
9473
- "description": "The shipment this line belongs to."
10853
+ "description": "The shipment this line belongs to.",
10854
+ "role": "items"
9474
10855
  }
9475
10856
  },
9476
10857
  "contractLineItemId": {
@@ -9682,10 +11063,11 @@
9682
11063
  "contractId": {
9683
11064
  "type": "foreignKey",
9684
11065
  "required": false,
9685
- "related": "Contract",
11066
+ "related": "SalesContract",
9686
11067
  "description": "The order or agreement this invoice bills for, if any.",
9687
11068
  "_meta": {
9688
- "description": "The order or agreement this invoice bills for, if any."
11069
+ "description": "The order or agreement this invoice bills for, if any.",
11070
+ "validateSubtype": true
9689
11071
  }
9690
11072
  },
9691
11073
  "invoiceNumber": {
@@ -9732,7 +11114,10 @@
9732
11114
  "default": 0,
9733
11115
  "description": "The amount before tax.",
9734
11116
  "_meta": {
9735
- "description": "The amount before tax."
11117
+ "description": "The amount before tax.",
11118
+ "ui": {
11119
+ "format": "money"
11120
+ }
9736
11121
  }
9737
11122
  },
9738
11123
  "taxAmount": {
@@ -9741,13 +11126,21 @@
9741
11126
  "default": 0,
9742
11127
  "description": "The tax charged.",
9743
11128
  "_meta": {
9744
- "description": "The tax charged."
11129
+ "description": "The tax charged.",
11130
+ "ui": {
11131
+ "format": "money"
11132
+ }
9745
11133
  }
9746
11134
  },
9747
11135
  "providerTaxAmount": {
9748
11136
  "type": "integer",
9749
11137
  "required": false,
9750
- "default": 0
11138
+ "default": 0,
11139
+ "_meta": {
11140
+ "ui": {
11141
+ "format": "money"
11142
+ }
11143
+ }
9751
11144
  },
9752
11145
  "totalAmount": {
9753
11146
  "type": "integer",
@@ -9755,7 +11148,10 @@
9755
11148
  "default": 0,
9756
11149
  "description": "What the customer owes in all, tax included.",
9757
11150
  "_meta": {
9758
- "description": "What the customer owes in all, tax included."
11151
+ "description": "What the customer owes in all, tax included.",
11152
+ "ui": {
11153
+ "format": "money"
11154
+ }
9759
11155
  }
9760
11156
  },
9761
11157
  "amountPaid": {
@@ -9764,7 +11160,10 @@
9764
11160
  "default": 0,
9765
11161
  "description": "How much of the total has been paid so far.",
9766
11162
  "_meta": {
9767
- "description": "How much of the total has been paid so far."
11163
+ "description": "How much of the total has been paid so far.",
11164
+ "ui": {
11165
+ "format": "money"
11166
+ }
9768
11167
  }
9769
11168
  },
9770
11169
  "currency": {
@@ -10365,7 +11764,8 @@
10365
11764
  "related": "Invoice",
10366
11765
  "description": "The invoice this line belongs to.",
10367
11766
  "_meta": {
10368
- "description": "The invoice this line belongs to."
11767
+ "description": "The invoice this line belongs to.",
11768
+ "role": "items"
10369
11769
  }
10370
11770
  },
10371
11771
  "description": {
@@ -10402,13 +11802,21 @@
10402
11802
  "default": 0,
10403
11803
  "description": "The price of one, before tax.",
10404
11804
  "_meta": {
10405
- "description": "The price of one, before tax."
11805
+ "description": "The price of one, before tax.",
11806
+ "ui": {
11807
+ "format": "money"
11808
+ }
10406
11809
  }
10407
11810
  },
10408
11811
  "discount": {
10409
11812
  "type": "integer",
10410
11813
  "required": false,
10411
- "default": 0
11814
+ "default": 0,
11815
+ "_meta": {
11816
+ "ui": {
11817
+ "format": "money"
11818
+ }
11819
+ }
10412
11820
  },
10413
11821
  "taxRate": {
10414
11822
  "type": "decimal",
@@ -10425,7 +11833,10 @@
10425
11833
  "default": 0,
10426
11834
  "description": "The line total.",
10427
11835
  "_meta": {
10428
- "description": "The line total."
11836
+ "description": "The line total.",
11837
+ "ui": {
11838
+ "format": "money"
11839
+ }
10429
11840
  }
10430
11841
  },
10431
11842
  "sourceType": {
@@ -10780,10 +12191,11 @@
10780
12191
  "contractId": {
10781
12192
  "type": "foreignKey",
10782
12193
  "required": false,
10783
- "related": "Contract",
12194
+ "related": "SalesContract",
10784
12195
  "description": "The order or agreement this payment is for, if any.",
10785
12196
  "_meta": {
10786
- "description": "The order or agreement this payment is for, if any."
12197
+ "description": "The order or agreement this payment is for, if any.",
12198
+ "validateSubtype": true
10787
12199
  }
10788
12200
  },
10789
12201
  "customerId": {
@@ -10801,7 +12213,10 @@
10801
12213
  "default": 0,
10802
12214
  "description": "How much was paid.",
10803
12215
  "_meta": {
10804
- "description": "How much was paid."
12216
+ "description": "How much was paid.",
12217
+ "ui": {
12218
+ "format": "money"
12219
+ }
10805
12220
  }
10806
12221
  },
10807
12222
  "currency": {
@@ -11329,7 +12744,10 @@
11329
12744
  "default": 0,
11330
12745
  "description": "How much of the payment goes to this invoice.",
11331
12746
  "_meta": {
11332
- "description": "How much of the payment goes to this invoice."
12747
+ "description": "How much of the payment goes to this invoice.",
12748
+ "ui": {
12749
+ "format": "money"
12750
+ }
11333
12751
  }
11334
12752
  },
11335
12753
  "allocatedAt": {
@@ -12768,7 +14186,10 @@
12768
14186
  "default": 0,
12769
14187
  "description": "The smallest order the vendor will accept.",
12770
14188
  "_meta": {
12771
- "description": "The smallest order the vendor will accept."
14189
+ "description": "The smallest order the vendor will accept.",
14190
+ "ui": {
14191
+ "format": "money"
14192
+ }
12772
14193
  }
12773
14194
  },
12774
14195
  "paymentTerms": {
@@ -12851,6 +14272,15 @@
12851
14272
  "description": "Where payments to this vendor should be sent."
12852
14273
  },
12853
14274
  "sensitive": true
14275
+ },
14276
+ "contacts": {
14277
+ "type": "json",
14278
+ "required": false,
14279
+ "default": [],
14280
+ "description": "The people you deal with at this vendor, with their role and how to reach them.",
14281
+ "_meta": {
14282
+ "description": "The people you deal with at this vendor, with their role and how to reach them."
14283
+ }
12854
14284
  }
12855
14285
  },
12856
14286
  "methods": {
@@ -12980,7 +14410,7 @@
12980
14410
  "collectionExportName": "VendorCollection",
12981
14411
  "schema": {
12982
14412
  "tableName": "vendors",
12983
- "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);",
14413
+ "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 \"contacts\" JSON DEFAULT '[]'\n);",
12984
14414
  "columns": {
12985
14415
  "id": {
12986
14416
  "type": "UUID",
@@ -13071,6 +14501,12 @@
13071
14501
  "notNull": false,
13072
14502
  "unique": false,
13073
14503
  "default": {}
14504
+ },
14505
+ "contacts": {
14506
+ "type": "JSON",
14507
+ "notNull": false,
14508
+ "unique": false,
14509
+ "default": []
13074
14510
  }
13075
14511
  },
13076
14512
  "indexes": [
@@ -13098,7 +14534,7 @@
13098
14534
  ]
13099
14535
  }
13100
14536
  ],
13101
- "version": "1dc2b65e"
14537
+ "version": "0963c71f"
13102
14538
  },
13103
14539
  "importPath": "@happyvertical/smrt-commerce"
13104
14540
  },
@@ -15471,11 +16907,7 @@
15471
16907
  },
15472
16908
  "customerId": {
15473
16909
  "label": "Customer",
15474
- "order": 1,
15475
- "required": true
15476
- },
15477
- "vendorId": {
15478
- "visibility": "hidden"
16910
+ "order": 1
15479
16911
  },
15480
16912
  "subtotal": {
15481
16913
  "visibility": "hidden"
@@ -15636,14 +17068,9 @@
15636
17068
  "visibility": "hidden",
15637
17069
  "locked": true
15638
17070
  },
15639
- "vendorId": {
15640
- "visibility": "hidden",
15641
- "locked": true
15642
- },
15643
17071
  "customerId": {
15644
17072
  "label": "Customer",
15645
- "order": 1,
15646
- "required": true
17073
+ "order": 1
15647
17074
  },
15648
17075
  "channelId": {
15649
17076
  "visibility": "hidden"
@@ -16008,11 +17435,7 @@
16008
17435
  },
16009
17436
  "customerId": {
16010
17437
  "label": "Customer",
16011
- "order": 1,
16012
- "required": true
16013
- },
16014
- "vendorId": {
16015
- "visibility": "hidden"
17438
+ "order": 1
16016
17439
  },
16017
17440
  "subtotal": {
16018
17441
  "visibility": "hidden"
@@ -16113,11 +17536,7 @@
16113
17536
  },
16114
17537
  "customerId": {
16115
17538
  "label": "Customer",
16116
- "order": 1,
16117
- "required": true
16118
- },
16119
- "vendorId": {
16120
- "visibility": "hidden"
17539
+ "order": 1
16121
17540
  },
16122
17541
  "subtotal": {
16123
17542
  "visibility": "hidden"
@@ -16211,10 +17630,6 @@
16211
17630
  "visibility": "hidden",
16212
17631
  "locked": true
16213
17632
  },
16214
- "customerId": {
16215
- "visibility": "hidden",
16216
- "locked": true
16217
- },
16218
17633
  "vendorId": {
16219
17634
  "label": "Vendor",
16220
17635
  "order": 1
@@ -16317,14 +17732,9 @@
16317
17732
  "visibility": "hidden",
16318
17733
  "locked": true
16319
17734
  },
16320
- "vendorId": {
16321
- "visibility": "hidden",
16322
- "locked": true
16323
- },
16324
17735
  "customerId": {
16325
17736
  "label": "Customer",
16326
- "order": 1,
16327
- "required": true
17737
+ "order": 1
16328
17738
  },
16329
17739
  "channelId": {
16330
17740
  "visibility": "hidden"
@@ -16479,10 +17889,6 @@
16479
17889
  "visibility": "hidden",
16480
17890
  "locked": true
16481
17891
  },
16482
- "vendorId": {
16483
- "visibility": "hidden",
16484
- "locked": true
16485
- },
16486
17892
  "customerId": {
16487
17893
  "label": "Customer",
16488
17894
  "order": 1