@happyvertical/smrt-commerce 0.49.3 → 0.49.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-commerce",
5
- "packageVersion": "0.49.3",
5
+ "packageVersion": "0.49.5",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-commerce:ContractCollection": {
8
8
  "name": "contractcollection",
@@ -163,8 +163,8 @@
163
163
  "exportName": "ContractCollection",
164
164
  "collectionExportName": "ContractCollectionCollection",
165
165
  "schema": {
166
- "tableName": "contract_collections",
167
- "ddl": "CREATE TABLE IF NOT EXISTS \"contract_collections\" (\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);",
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);",
168
168
  "columns": {
169
169
  "id": {
170
170
  "type": "UUID",
@@ -181,6 +181,14 @@
181
181
  "notNull": true,
182
182
  "default": ""
183
183
  },
184
+ "_meta_type": {
185
+ "type": "TEXT",
186
+ "notNull": true
187
+ },
188
+ "_meta_data": {
189
+ "type": "JSON",
190
+ "notNull": false
191
+ },
184
192
  "created_at": {
185
193
  "type": "TIMESTAMP",
186
194
  "notNull": true,
@@ -190,25 +198,134 @@
190
198
  "type": "TIMESTAMP",
191
199
  "notNull": true,
192
200
  "default": "current_timestamp"
201
+ },
202
+ "tenant_id": {
203
+ "type": "UUID",
204
+ "referenceKind": "tenantId",
205
+ "notNull": false
206
+ },
207
+ "contract_type": {
208
+ "type": "TEXT",
209
+ "notNull": false
210
+ },
211
+ "status": {
212
+ "type": "TEXT",
213
+ "notNull": false
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
+ "subtotal": {
238
+ "type": "INTEGER",
239
+ "notNull": false,
240
+ "default": 0
241
+ },
242
+ "tax_amount": {
243
+ "type": "INTEGER",
244
+ "notNull": false,
245
+ "default": 0
246
+ },
247
+ "total_amount": {
248
+ "type": "INTEGER",
249
+ "notNull": false,
250
+ "default": 0
251
+ },
252
+ "currency": {
253
+ "type": "TEXT",
254
+ "notNull": false,
255
+ "default": "USD"
256
+ },
257
+ "issue_date": {
258
+ "type": "TIMESTAMP",
259
+ "notNull": false
260
+ },
261
+ "due_date": {
262
+ "type": "TIMESTAMP",
263
+ "notNull": false
264
+ },
265
+ "expiry_date": {
266
+ "type": "TIMESTAMP",
267
+ "notNull": false
268
+ },
269
+ "reference": {
270
+ "type": "TEXT",
271
+ "notNull": false,
272
+ "default": ""
273
+ },
274
+ "notes": {
275
+ "type": "TEXT",
276
+ "notNull": false,
277
+ "default": ""
278
+ },
279
+ "terms": {
280
+ "type": "TEXT",
281
+ "notNull": false,
282
+ "default": ""
283
+ },
284
+ "channel_id": {
285
+ "type": "TEXT",
286
+ "notNull": false,
287
+ "default": ""
193
288
  }
194
289
  },
195
290
  "indexes": [
196
291
  {
197
- "name": "contract_collections_slug_context_idx",
292
+ "name": "contracts_slug_context_meta_type_idx",
198
293
  "columns": [
294
+ "tenant_id",
199
295
  "slug",
200
- "context"
296
+ "context",
297
+ "_meta_type"
201
298
  ],
202
- "unique": true
299
+ "unique": true,
300
+ "nullsNotDistinct": true
203
301
  },
204
302
  {
205
- "name": "contract_collections_created_at_idx",
303
+ "name": "contracts_meta_type_idx",
206
304
  "columns": [
305
+ "_meta_type"
306
+ ]
307
+ },
308
+ {
309
+ "name": "contracts_tenant_id_created_at_idx",
310
+ "columns": [
311
+ "tenant_id",
207
312
  "created_at"
208
313
  ]
314
+ },
315
+ {
316
+ "name": "contracts_customer_id_idx",
317
+ "columns": [
318
+ "customer_id"
319
+ ]
320
+ },
321
+ {
322
+ "name": "contracts_vendor_id_idx",
323
+ "columns": [
324
+ "vendor_id"
325
+ ]
209
326
  }
210
327
  ],
211
- "version": "c2abc9f0"
328
+ "version": "9c2e9c49"
212
329
  }
213
330
  },
214
331
  "@happyvertical/smrt-commerce:ContractLineItemCollection": {
@@ -277,8 +394,8 @@
277
394
  "exportName": "ContractLineItemCollection",
278
395
  "collectionExportName": "ContractLineItemCollectionCollection",
279
396
  "schema": {
280
- "tableName": "contract_line_item_collections",
281
- "ddl": "CREATE TABLE IF NOT EXISTS \"contract_line_item_collections\" (\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);",
397
+ "tableName": "contract_line_items",
398
+ "ddl": "CREATE TABLE IF NOT EXISTS \"contract_line_items\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"contract_id\" UUID,\n \"description\" TEXT DEFAULT '',\n \"quantity\" REAL DEFAULT 1,\n \"unit_price\" INTEGER DEFAULT 0,\n \"discount\" INTEGER DEFAULT 0,\n \"tax_rate\" REAL DEFAULT 0,\n \"amount\" INTEGER DEFAULT 0,\n \"product_id\" UUID,\n \"sku\" TEXT DEFAULT '',\n \"start_date\" TIMESTAMP,\n \"end_date\" TIMESTAMP,\n \"billing_period\" TEXT DEFAULT '',\n \"sort_order\" INTEGER DEFAULT 0\n);",
282
399
  "columns": {
283
400
  "id": {
284
401
  "type": "UUID",
@@ -295,6 +412,14 @@
295
412
  "notNull": true,
296
413
  "default": ""
297
414
  },
415
+ "_meta_type": {
416
+ "type": "TEXT",
417
+ "notNull": true
418
+ },
419
+ "_meta_data": {
420
+ "type": "JSON",
421
+ "notNull": false
422
+ },
298
423
  "created_at": {
299
424
  "type": "TIMESTAMP",
300
425
  "notNull": true,
@@ -304,25 +429,121 @@
304
429
  "type": "TIMESTAMP",
305
430
  "notNull": true,
306
431
  "default": "current_timestamp"
432
+ },
433
+ "tenant_id": {
434
+ "type": "UUID",
435
+ "referenceKind": "tenantId",
436
+ "notNull": false
437
+ },
438
+ "contract_id": {
439
+ "type": "UUID",
440
+ "referenceKind": "foreignKey",
441
+ "notNull": false,
442
+ "foreignKey": {
443
+ "table": "contracts",
444
+ "column": "id",
445
+ "onDelete": "NO ACTION",
446
+ "onUpdate": "CASCADE"
447
+ }
448
+ },
449
+ "description": {
450
+ "type": "TEXT",
451
+ "notNull": false,
452
+ "default": ""
453
+ },
454
+ "quantity": {
455
+ "type": "REAL",
456
+ "notNull": false,
457
+ "default": 1
458
+ },
459
+ "unit_price": {
460
+ "type": "INTEGER",
461
+ "notNull": false,
462
+ "default": 0
463
+ },
464
+ "discount": {
465
+ "type": "INTEGER",
466
+ "notNull": false,
467
+ "default": 0
468
+ },
469
+ "tax_rate": {
470
+ "type": "REAL",
471
+ "notNull": false,
472
+ "default": 0
473
+ },
474
+ "amount": {
475
+ "type": "INTEGER",
476
+ "notNull": false,
477
+ "default": 0
478
+ },
479
+ "product_id": {
480
+ "type": "UUID",
481
+ "referenceKind": "crossPackageRef",
482
+ "notNull": false
483
+ },
484
+ "sku": {
485
+ "type": "TEXT",
486
+ "notNull": false,
487
+ "default": ""
488
+ },
489
+ "start_date": {
490
+ "type": "TIMESTAMP",
491
+ "notNull": false
492
+ },
493
+ "end_date": {
494
+ "type": "TIMESTAMP",
495
+ "notNull": false
496
+ },
497
+ "billing_period": {
498
+ "type": "TEXT",
499
+ "notNull": false,
500
+ "default": ""
501
+ },
502
+ "sort_order": {
503
+ "type": "INTEGER",
504
+ "notNull": false,
505
+ "default": 0
307
506
  }
308
507
  },
309
508
  "indexes": [
310
509
  {
311
- "name": "contract_line_item_collections_slug_context_idx",
510
+ "name": "contract_line_items_slug_context_meta_type_idx",
312
511
  "columns": [
512
+ "tenant_id",
313
513
  "slug",
314
- "context"
514
+ "context",
515
+ "_meta_type"
315
516
  ],
316
- "unique": true
517
+ "unique": true,
518
+ "nullsNotDistinct": true
317
519
  },
318
520
  {
319
- "name": "contract_line_item_collections_created_at_idx",
521
+ "name": "contract_line_items_meta_type_idx",
320
522
  "columns": [
523
+ "_meta_type"
524
+ ]
525
+ },
526
+ {
527
+ "name": "contract_line_items_tenant_id_created_at_idx",
528
+ "columns": [
529
+ "tenant_id",
321
530
  "created_at"
322
531
  ]
532
+ },
533
+ {
534
+ "name": "contract_line_items_contract_id_idx",
535
+ "columns": [
536
+ "contract_id"
537
+ ]
538
+ },
539
+ {
540
+ "name": "contract_line_items_product_id_idx",
541
+ "columns": [
542
+ "product_id"
543
+ ]
323
544
  }
324
545
  ],
325
- "version": "410887d1"
546
+ "version": "be2b46cd"
326
547
  }
327
548
  },
328
549
  "@happyvertical/smrt-commerce:CustomerCollection": {
@@ -436,8 +657,8 @@
436
657
  "exportName": "CustomerCollection",
437
658
  "collectionExportName": "CustomerCollectionCollection",
438
659
  "schema": {
439
- "tableName": "customer_collections",
440
- "ddl": "CREATE TABLE IF NOT EXISTS \"customer_collections\" (\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);",
660
+ "tableName": "customers",
661
+ "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);",
441
662
  "columns": {
442
663
  "id": {
443
664
  "type": "UUID",
@@ -463,25 +684,96 @@
463
684
  "type": "TIMESTAMP",
464
685
  "notNull": true,
465
686
  "default": "current_timestamp"
687
+ },
688
+ "tenant_id": {
689
+ "type": "UUID",
690
+ "referenceKind": "tenantId",
691
+ "notNull": false,
692
+ "unique": false
693
+ },
694
+ "profile_id": {
695
+ "type": "UUID",
696
+ "referenceKind": "crossPackageRef",
697
+ "notNull": false,
698
+ "unique": false
699
+ },
700
+ "credit_limit": {
701
+ "type": "INTEGER",
702
+ "notNull": false,
703
+ "unique": false,
704
+ "default": 0
705
+ },
706
+ "payment_terms": {
707
+ "type": "TEXT",
708
+ "notNull": false,
709
+ "unique": false,
710
+ "default": ""
711
+ },
712
+ "tax_exempt": {
713
+ "type": "BOOLEAN",
714
+ "notNull": false,
715
+ "unique": false,
716
+ "default": false
717
+ },
718
+ "tax_id": {
719
+ "type": "TEXT",
720
+ "notNull": false,
721
+ "unique": false,
722
+ "default": ""
723
+ },
724
+ "default_shipping_address": {
725
+ "type": "JSON",
726
+ "notNull": false,
727
+ "unique": false
728
+ },
729
+ "default_billing_address": {
730
+ "type": "JSON",
731
+ "notNull": false,
732
+ "unique": false
733
+ },
734
+ "status": {
735
+ "type": "TEXT",
736
+ "notNull": false,
737
+ "unique": false
738
+ },
739
+ "customer_type": {
740
+ "type": "TEXT",
741
+ "notNull": false,
742
+ "unique": false
743
+ },
744
+ "notes": {
745
+ "type": "TEXT",
746
+ "notNull": false,
747
+ "unique": false,
748
+ "default": ""
466
749
  }
467
750
  },
468
751
  "indexes": [
469
752
  {
470
- "name": "customer_collections_slug_context_idx",
753
+ "name": "customers_slug_context_idx",
471
754
  "columns": [
755
+ "tenant_id",
472
756
  "slug",
473
757
  "context"
474
758
  ],
475
- "unique": true
759
+ "unique": true,
760
+ "nullsNotDistinct": true
476
761
  },
477
762
  {
478
- "name": "customer_collections_created_at_idx",
763
+ "name": "customers_tenant_id_created_at_idx",
479
764
  "columns": [
765
+ "tenant_id",
480
766
  "created_at"
481
767
  ]
768
+ },
769
+ {
770
+ "name": "customers_profile_id_idx",
771
+ "columns": [
772
+ "profile_id"
773
+ ]
482
774
  }
483
775
  ],
484
- "version": "63593259"
776
+ "version": "ad1b9967"
485
777
  }
486
778
  },
487
779
  "@happyvertical/smrt-commerce:FulfillmentCollection": {
@@ -627,8 +919,8 @@
627
919
  "exportName": "FulfillmentCollection",
628
920
  "collectionExportName": "FulfillmentCollectionCollection",
629
921
  "schema": {
630
- "tableName": "fulfillment_collections",
631
- "ddl": "CREATE TABLE IF NOT EXISTS \"fulfillment_collections\" (\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);",
922
+ "tableName": "fulfillments",
923
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fulfillments\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"contract_id\" UUID,\n \"fulfillment_type\" TEXT,\n \"status\" TEXT,\n \"tracking_number\" TEXT DEFAULT '',\n \"carrier\" TEXT DEFAULT '',\n \"shipping_address\" JSON,\n \"shipped_at\" TIMESTAMP,\n \"delivered_at\" TIMESTAMP,\n \"estimated_delivery\" TIMESTAMP,\n \"notes\" TEXT DEFAULT ''\n);",
632
924
  "columns": {
633
925
  "id": {
634
926
  "type": "UUID",
@@ -654,25 +946,100 @@
654
946
  "type": "TIMESTAMP",
655
947
  "notNull": true,
656
948
  "default": "current_timestamp"
949
+ },
950
+ "tenant_id": {
951
+ "type": "UUID",
952
+ "referenceKind": "tenantId",
953
+ "notNull": false,
954
+ "unique": false
955
+ },
956
+ "contract_id": {
957
+ "type": "UUID",
958
+ "referenceKind": "foreignKey",
959
+ "notNull": false,
960
+ "unique": false,
961
+ "foreignKey": {
962
+ "table": "contracts",
963
+ "column": "id",
964
+ "onDelete": "NO ACTION",
965
+ "onUpdate": "CASCADE"
966
+ }
967
+ },
968
+ "fulfillment_type": {
969
+ "type": "TEXT",
970
+ "notNull": false,
971
+ "unique": false
972
+ },
973
+ "status": {
974
+ "type": "TEXT",
975
+ "notNull": false,
976
+ "unique": false
977
+ },
978
+ "tracking_number": {
979
+ "type": "TEXT",
980
+ "notNull": false,
981
+ "unique": false,
982
+ "default": ""
983
+ },
984
+ "carrier": {
985
+ "type": "TEXT",
986
+ "notNull": false,
987
+ "unique": false,
988
+ "default": ""
989
+ },
990
+ "shipping_address": {
991
+ "type": "JSON",
992
+ "notNull": false,
993
+ "unique": false
994
+ },
995
+ "shipped_at": {
996
+ "type": "TIMESTAMP",
997
+ "notNull": false,
998
+ "unique": false
999
+ },
1000
+ "delivered_at": {
1001
+ "type": "TIMESTAMP",
1002
+ "notNull": false,
1003
+ "unique": false
1004
+ },
1005
+ "estimated_delivery": {
1006
+ "type": "TIMESTAMP",
1007
+ "notNull": false,
1008
+ "unique": false
1009
+ },
1010
+ "notes": {
1011
+ "type": "TEXT",
1012
+ "notNull": false,
1013
+ "unique": false,
1014
+ "default": ""
657
1015
  }
658
1016
  },
659
1017
  "indexes": [
660
1018
  {
661
- "name": "fulfillment_collections_slug_context_idx",
1019
+ "name": "fulfillments_slug_context_idx",
662
1020
  "columns": [
1021
+ "tenant_id",
663
1022
  "slug",
664
1023
  "context"
665
1024
  ],
666
- "unique": true
1025
+ "unique": true,
1026
+ "nullsNotDistinct": true
667
1027
  },
668
1028
  {
669
- "name": "fulfillment_collections_created_at_idx",
1029
+ "name": "fulfillments_tenant_id_created_at_idx",
670
1030
  "columns": [
1031
+ "tenant_id",
671
1032
  "created_at"
672
1033
  ]
1034
+ },
1035
+ {
1036
+ "name": "fulfillments_contract_id_idx",
1037
+ "columns": [
1038
+ "contract_id"
1039
+ ]
673
1040
  }
674
1041
  ],
675
- "version": "0cb8f9e1"
1042
+ "version": "2f708fc5"
676
1043
  }
677
1044
  },
678
1045
  "@happyvertical/smrt-commerce:FulfillmentLineItemCollection": {
@@ -769,8 +1136,8 @@
769
1136
  "exportName": "FulfillmentLineItemCollection",
770
1137
  "collectionExportName": "FulfillmentLineItemCollectionCollection",
771
1138
  "schema": {
772
- "tableName": "fulfillment_line_item_collections",
773
- "ddl": "CREATE TABLE IF NOT EXISTS \"fulfillment_line_item_collections\" (\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);",
1139
+ "tableName": "fulfillment_line_items",
1140
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fulfillment_line_items\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"fulfillment_id\" UUID,\n \"contract_line_item_id\" UUID,\n \"quantity_fulfilled\" REAL DEFAULT 1,\n \"notes\" TEXT DEFAULT ''\n);",
774
1141
  "columns": {
775
1142
  "id": {
776
1143
  "type": "UUID",
@@ -796,25 +1163,82 @@
796
1163
  "type": "TIMESTAMP",
797
1164
  "notNull": true,
798
1165
  "default": "current_timestamp"
1166
+ },
1167
+ "tenant_id": {
1168
+ "type": "UUID",
1169
+ "referenceKind": "tenantId",
1170
+ "notNull": false,
1171
+ "unique": false
1172
+ },
1173
+ "fulfillment_id": {
1174
+ "type": "UUID",
1175
+ "referenceKind": "foreignKey",
1176
+ "notNull": false,
1177
+ "unique": false,
1178
+ "foreignKey": {
1179
+ "table": "fulfillments",
1180
+ "column": "id",
1181
+ "onDelete": "NO ACTION",
1182
+ "onUpdate": "CASCADE"
1183
+ }
1184
+ },
1185
+ "contract_line_item_id": {
1186
+ "type": "UUID",
1187
+ "referenceKind": "foreignKey",
1188
+ "notNull": false,
1189
+ "unique": false,
1190
+ "foreignKey": {
1191
+ "table": "contract_line_items",
1192
+ "column": "id",
1193
+ "onDelete": "NO ACTION",
1194
+ "onUpdate": "CASCADE"
1195
+ }
1196
+ },
1197
+ "quantity_fulfilled": {
1198
+ "type": "REAL",
1199
+ "notNull": false,
1200
+ "unique": false,
1201
+ "default": 1
1202
+ },
1203
+ "notes": {
1204
+ "type": "TEXT",
1205
+ "notNull": false,
1206
+ "unique": false,
1207
+ "default": ""
799
1208
  }
800
1209
  },
801
1210
  "indexes": [
802
1211
  {
803
- "name": "fulfillment_line_item_collections_slug_context_idx",
1212
+ "name": "fulfillment_line_items_slug_context_idx",
804
1213
  "columns": [
1214
+ "tenant_id",
805
1215
  "slug",
806
1216
  "context"
807
1217
  ],
808
- "unique": true
1218
+ "unique": true,
1219
+ "nullsNotDistinct": true
809
1220
  },
810
1221
  {
811
- "name": "fulfillment_line_item_collections_created_at_idx",
1222
+ "name": "fulfillment_line_items_tenant_id_created_at_idx",
812
1223
  "columns": [
1224
+ "tenant_id",
813
1225
  "created_at"
814
1226
  ]
1227
+ },
1228
+ {
1229
+ "name": "fulfillment_line_items_fulfillment_id_idx",
1230
+ "columns": [
1231
+ "fulfillment_id"
1232
+ ]
1233
+ },
1234
+ {
1235
+ "name": "fulfillment_line_items_contract_line_item_id_idx",
1236
+ "columns": [
1237
+ "contract_line_item_id"
1238
+ ]
815
1239
  }
816
1240
  ],
817
- "version": "88e7502e"
1241
+ "version": "14537dbe"
818
1242
  }
819
1243
  },
820
1244
  "@happyvertical/smrt-commerce:InvoiceCollection": {
@@ -1048,8 +1472,8 @@
1048
1472
  "exportName": "InvoiceCollection",
1049
1473
  "collectionExportName": "InvoiceCollectionCollection",
1050
1474
  "schema": {
1051
- "tableName": "invoice_collections",
1052
- "ddl": "CREATE TABLE IF NOT EXISTS \"invoice_collections\" (\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);",
1475
+ "tableName": "invoices",
1476
+ "ddl": "CREATE TABLE IF NOT EXISTS \"invoices\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"customer_id\" UUID,\n \"contract_id\" UUID,\n \"invoice_number\" TEXT DEFAULT '',\n \"reference\" TEXT DEFAULT '',\n \"issue_date\" TIMESTAMP,\n \"due_date\" TIMESTAMP,\n \"paid_date\" TIMESTAMP,\n \"subtotal\" INTEGER DEFAULT 0,\n \"tax_amount\" INTEGER DEFAULT 0,\n \"total_amount\" INTEGER DEFAULT 0,\n \"amount_paid\" INTEGER DEFAULT 0,\n \"currency\" TEXT DEFAULT 'CAD',\n \"status\" TEXT,\n \"ar_journal_id\" UUID,\n \"revenue_journal_id\" UUID,\n \"external_id\" TEXT DEFAULT '',\n \"customer_external_id\" TEXT DEFAULT '',\n \"external_provider\" TEXT DEFAULT '',\n \"synced_at\" TIMESTAMP,\n \"sent_at\" TIMESTAMP,\n \"viewed_at\" TIMESTAMP,\n \"reminders_sent\" INTEGER DEFAULT 0,\n \"last_reminder_at\" TIMESTAMP,\n \"notes\" TEXT DEFAULT '',\n \"customer_notes\" TEXT DEFAULT '',\n \"terms\" TEXT DEFAULT ''\n);",
1053
1477
  "columns": {
1054
1478
  "id": {
1055
1479
  "type": "UUID",
@@ -1075,25 +1499,218 @@
1075
1499
  "type": "TIMESTAMP",
1076
1500
  "notNull": true,
1077
1501
  "default": "current_timestamp"
1502
+ },
1503
+ "tenant_id": {
1504
+ "type": "UUID",
1505
+ "referenceKind": "tenantId",
1506
+ "notNull": false,
1507
+ "unique": false
1508
+ },
1509
+ "customer_id": {
1510
+ "type": "UUID",
1511
+ "referenceKind": "foreignKey",
1512
+ "notNull": false,
1513
+ "unique": false,
1514
+ "foreignKey": {
1515
+ "table": "customers",
1516
+ "column": "id",
1517
+ "onDelete": "NO ACTION",
1518
+ "onUpdate": "CASCADE"
1519
+ }
1520
+ },
1521
+ "contract_id": {
1522
+ "type": "UUID",
1523
+ "referenceKind": "foreignKey",
1524
+ "notNull": false,
1525
+ "unique": false,
1526
+ "foreignKey": {
1527
+ "table": "contracts",
1528
+ "column": "id",
1529
+ "onDelete": "NO ACTION",
1530
+ "onUpdate": "CASCADE"
1531
+ }
1532
+ },
1533
+ "invoice_number": {
1534
+ "type": "TEXT",
1535
+ "notNull": false,
1536
+ "unique": false,
1537
+ "default": ""
1538
+ },
1539
+ "reference": {
1540
+ "type": "TEXT",
1541
+ "notNull": false,
1542
+ "unique": false,
1543
+ "default": ""
1544
+ },
1545
+ "issue_date": {
1546
+ "type": "TIMESTAMP",
1547
+ "notNull": false,
1548
+ "unique": false
1549
+ },
1550
+ "due_date": {
1551
+ "type": "TIMESTAMP",
1552
+ "notNull": false,
1553
+ "unique": false
1554
+ },
1555
+ "paid_date": {
1556
+ "type": "TIMESTAMP",
1557
+ "notNull": false,
1558
+ "unique": false
1559
+ },
1560
+ "subtotal": {
1561
+ "type": "INTEGER",
1562
+ "notNull": false,
1563
+ "unique": false,
1564
+ "default": 0
1565
+ },
1566
+ "tax_amount": {
1567
+ "type": "INTEGER",
1568
+ "notNull": false,
1569
+ "unique": false,
1570
+ "default": 0
1571
+ },
1572
+ "total_amount": {
1573
+ "type": "INTEGER",
1574
+ "notNull": false,
1575
+ "unique": false,
1576
+ "default": 0
1577
+ },
1578
+ "amount_paid": {
1579
+ "type": "INTEGER",
1580
+ "notNull": false,
1581
+ "unique": false,
1582
+ "default": 0
1583
+ },
1584
+ "currency": {
1585
+ "type": "TEXT",
1586
+ "notNull": false,
1587
+ "unique": false,
1588
+ "default": "CAD"
1589
+ },
1590
+ "status": {
1591
+ "type": "TEXT",
1592
+ "notNull": false,
1593
+ "unique": false
1594
+ },
1595
+ "ar_journal_id": {
1596
+ "type": "UUID",
1597
+ "referenceKind": "crossPackageRef",
1598
+ "notNull": false,
1599
+ "unique": false
1600
+ },
1601
+ "revenue_journal_id": {
1602
+ "type": "UUID",
1603
+ "referenceKind": "crossPackageRef",
1604
+ "notNull": false,
1605
+ "unique": false
1606
+ },
1607
+ "external_id": {
1608
+ "type": "TEXT",
1609
+ "notNull": false,
1610
+ "unique": false,
1611
+ "default": ""
1612
+ },
1613
+ "customer_external_id": {
1614
+ "type": "TEXT",
1615
+ "notNull": false,
1616
+ "unique": false,
1617
+ "default": ""
1618
+ },
1619
+ "external_provider": {
1620
+ "type": "TEXT",
1621
+ "notNull": false,
1622
+ "unique": false,
1623
+ "default": ""
1624
+ },
1625
+ "synced_at": {
1626
+ "type": "TIMESTAMP",
1627
+ "notNull": false,
1628
+ "unique": false
1629
+ },
1630
+ "sent_at": {
1631
+ "type": "TIMESTAMP",
1632
+ "notNull": false,
1633
+ "unique": false
1634
+ },
1635
+ "viewed_at": {
1636
+ "type": "TIMESTAMP",
1637
+ "notNull": false,
1638
+ "unique": false
1639
+ },
1640
+ "reminders_sent": {
1641
+ "type": "INTEGER",
1642
+ "notNull": false,
1643
+ "unique": false,
1644
+ "default": 0
1645
+ },
1646
+ "last_reminder_at": {
1647
+ "type": "TIMESTAMP",
1648
+ "notNull": false,
1649
+ "unique": false
1650
+ },
1651
+ "notes": {
1652
+ "type": "TEXT",
1653
+ "notNull": false,
1654
+ "unique": false,
1655
+ "default": ""
1656
+ },
1657
+ "customer_notes": {
1658
+ "type": "TEXT",
1659
+ "notNull": false,
1660
+ "unique": false,
1661
+ "default": ""
1662
+ },
1663
+ "terms": {
1664
+ "type": "TEXT",
1665
+ "notNull": false,
1666
+ "unique": false,
1667
+ "default": ""
1078
1668
  }
1079
1669
  },
1080
1670
  "indexes": [
1081
1671
  {
1082
- "name": "invoice_collections_slug_context_idx",
1672
+ "name": "invoices_slug_context_idx",
1083
1673
  "columns": [
1674
+ "tenant_id",
1084
1675
  "slug",
1085
1676
  "context"
1086
1677
  ],
1087
- "unique": true
1678
+ "unique": true,
1679
+ "nullsNotDistinct": true
1088
1680
  },
1089
1681
  {
1090
- "name": "invoice_collections_created_at_idx",
1682
+ "name": "invoices_tenant_id_created_at_idx",
1091
1683
  "columns": [
1684
+ "tenant_id",
1092
1685
  "created_at"
1093
1686
  ]
1687
+ },
1688
+ {
1689
+ "name": "invoices_customer_id_idx",
1690
+ "columns": [
1691
+ "customer_id"
1692
+ ]
1693
+ },
1694
+ {
1695
+ "name": "invoices_contract_id_idx",
1696
+ "columns": [
1697
+ "contract_id"
1698
+ ]
1699
+ },
1700
+ {
1701
+ "name": "invoices_ar_journal_id_idx",
1702
+ "columns": [
1703
+ "ar_journal_id"
1704
+ ]
1705
+ },
1706
+ {
1707
+ "name": "invoices_revenue_journal_id_idx",
1708
+ "columns": [
1709
+ "revenue_journal_id"
1710
+ ]
1094
1711
  }
1095
1712
  ],
1096
- "version": "4877ccc3"
1713
+ "version": "ea71241c"
1097
1714
  }
1098
1715
  },
1099
1716
  "@happyvertical/smrt-commerce:InvoiceLineItemCollection": {
@@ -1279,8 +1896,8 @@
1279
1896
  "exportName": "InvoiceLineItemCollection",
1280
1897
  "collectionExportName": "InvoiceLineItemCollectionCollection",
1281
1898
  "schema": {
1282
- "tableName": "invoice_line_item_collections",
1283
- "ddl": "CREATE TABLE IF NOT EXISTS \"invoice_line_item_collections\" (\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);",
1899
+ "tableName": "invoice_line_items",
1900
+ "ddl": "CREATE TABLE IF NOT EXISTS \"invoice_line_items\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"invoice_id\" UUID,\n \"description\" TEXT DEFAULT '',\n \"sku\" TEXT DEFAULT '',\n \"quantity\" INTEGER DEFAULT 1,\n \"unit_price\" INTEGER DEFAULT 0,\n \"discount\" INTEGER DEFAULT 0,\n \"tax_rate\" REAL DEFAULT 0,\n \"amount\" INTEGER DEFAULT 0,\n \"source_type\" TEXT DEFAULT '',\n \"source_id\" TEXT DEFAULT '',\n \"period_start\" TIMESTAMP,\n \"period_end\" TIMESTAMP,\n \"revenue_account_id\" UUID,\n \"sort_order\" INTEGER DEFAULT 0\n);",
1284
1901
  "columns": {
1285
1902
  "id": {
1286
1903
  "type": "UUID",
@@ -1288,43 +1905,152 @@
1288
1905
  "referenceKind": "id",
1289
1906
  "notNull": true
1290
1907
  },
1291
- "slug": {
1908
+ "slug": {
1909
+ "type": "TEXT",
1910
+ "notNull": true
1911
+ },
1912
+ "context": {
1913
+ "type": "TEXT",
1914
+ "notNull": true,
1915
+ "default": ""
1916
+ },
1917
+ "created_at": {
1918
+ "type": "TIMESTAMP",
1919
+ "notNull": true,
1920
+ "default": "current_timestamp"
1921
+ },
1922
+ "updated_at": {
1923
+ "type": "TIMESTAMP",
1924
+ "notNull": true,
1925
+ "default": "current_timestamp"
1926
+ },
1927
+ "tenant_id": {
1928
+ "type": "UUID",
1929
+ "referenceKind": "tenantId",
1930
+ "notNull": false,
1931
+ "unique": false
1932
+ },
1933
+ "invoice_id": {
1934
+ "type": "UUID",
1935
+ "referenceKind": "foreignKey",
1936
+ "notNull": false,
1937
+ "unique": false,
1938
+ "foreignKey": {
1939
+ "table": "invoices",
1940
+ "column": "id",
1941
+ "onDelete": "NO ACTION",
1942
+ "onUpdate": "CASCADE"
1943
+ }
1944
+ },
1945
+ "description": {
1946
+ "type": "TEXT",
1947
+ "notNull": false,
1948
+ "unique": false,
1949
+ "default": ""
1950
+ },
1951
+ "sku": {
1292
1952
  "type": "TEXT",
1293
- "notNull": true
1953
+ "notNull": false,
1954
+ "unique": false,
1955
+ "default": ""
1294
1956
  },
1295
- "context": {
1957
+ "quantity": {
1958
+ "type": "INTEGER",
1959
+ "notNull": false,
1960
+ "unique": false,
1961
+ "default": 1
1962
+ },
1963
+ "unit_price": {
1964
+ "type": "INTEGER",
1965
+ "notNull": false,
1966
+ "unique": false,
1967
+ "default": 0
1968
+ },
1969
+ "discount": {
1970
+ "type": "INTEGER",
1971
+ "notNull": false,
1972
+ "unique": false,
1973
+ "default": 0
1974
+ },
1975
+ "tax_rate": {
1976
+ "type": "REAL",
1977
+ "notNull": false,
1978
+ "unique": false,
1979
+ "default": 0
1980
+ },
1981
+ "amount": {
1982
+ "type": "INTEGER",
1983
+ "notNull": false,
1984
+ "unique": false,
1985
+ "default": 0
1986
+ },
1987
+ "source_type": {
1296
1988
  "type": "TEXT",
1297
- "notNull": true,
1989
+ "notNull": false,
1990
+ "unique": false,
1298
1991
  "default": ""
1299
1992
  },
1300
- "created_at": {
1993
+ "source_id": {
1994
+ "type": "TEXT",
1995
+ "notNull": false,
1996
+ "unique": false,
1997
+ "default": ""
1998
+ },
1999
+ "period_start": {
1301
2000
  "type": "TIMESTAMP",
1302
- "notNull": true,
1303
- "default": "current_timestamp"
2001
+ "notNull": false,
2002
+ "unique": false
1304
2003
  },
1305
- "updated_at": {
2004
+ "period_end": {
1306
2005
  "type": "TIMESTAMP",
1307
- "notNull": true,
1308
- "default": "current_timestamp"
2006
+ "notNull": false,
2007
+ "unique": false
2008
+ },
2009
+ "revenue_account_id": {
2010
+ "type": "UUID",
2011
+ "referenceKind": "crossPackageRef",
2012
+ "notNull": false,
2013
+ "unique": false
2014
+ },
2015
+ "sort_order": {
2016
+ "type": "INTEGER",
2017
+ "notNull": false,
2018
+ "unique": false,
2019
+ "default": 0
1309
2020
  }
1310
2021
  },
1311
2022
  "indexes": [
1312
2023
  {
1313
- "name": "invoice_line_item_collections_slug_context_idx",
2024
+ "name": "invoice_line_items_slug_context_idx",
1314
2025
  "columns": [
2026
+ "tenant_id",
1315
2027
  "slug",
1316
2028
  "context"
1317
2029
  ],
1318
- "unique": true
2030
+ "unique": true,
2031
+ "nullsNotDistinct": true
1319
2032
  },
1320
2033
  {
1321
- "name": "invoice_line_item_collections_created_at_idx",
2034
+ "name": "invoice_line_items_tenant_id_created_at_idx",
1322
2035
  "columns": [
2036
+ "tenant_id",
1323
2037
  "created_at"
1324
2038
  ]
2039
+ },
2040
+ {
2041
+ "name": "invoice_line_items_invoice_id_idx",
2042
+ "columns": [
2043
+ "invoice_id"
2044
+ ]
2045
+ },
2046
+ {
2047
+ "name": "invoice_line_items_revenue_account_id_idx",
2048
+ "columns": [
2049
+ "revenue_account_id"
2050
+ ]
1325
2051
  }
1326
2052
  ],
1327
- "version": "27337dcf"
2053
+ "version": "f96d2656"
1328
2054
  }
1329
2055
  },
1330
2056
  "@happyvertical/smrt-commerce:PaymentAllocationCollection": {
@@ -1506,8 +2232,8 @@
1506
2232
  "exportName": "PaymentAllocationCollection",
1507
2233
  "collectionExportName": "PaymentAllocationCollectionCollection",
1508
2234
  "schema": {
1509
- "tableName": "payment_allocation_collections",
1510
- "ddl": "CREATE TABLE IF NOT EXISTS \"payment_allocation_collections\" (\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);",
2235
+ "tableName": "payment_allocations",
2236
+ "ddl": "CREATE TABLE IF NOT EXISTS \"payment_allocations\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"payment_id\" UUID,\n \"invoice_id\" UUID,\n \"amount\" INTEGER DEFAULT 0,\n \"allocated_at\" TIMESTAMP,\n \"allocated_by\" TEXT DEFAULT '',\n \"notes\" TEXT DEFAULT ''\n);",
1511
2237
  "columns": {
1512
2238
  "id": {
1513
2239
  "type": "UUID",
@@ -1533,25 +2259,93 @@
1533
2259
  "type": "TIMESTAMP",
1534
2260
  "notNull": true,
1535
2261
  "default": "current_timestamp"
2262
+ },
2263
+ "tenant_id": {
2264
+ "type": "UUID",
2265
+ "referenceKind": "tenantId",
2266
+ "notNull": false,
2267
+ "unique": false
2268
+ },
2269
+ "payment_id": {
2270
+ "type": "UUID",
2271
+ "referenceKind": "foreignKey",
2272
+ "notNull": false,
2273
+ "unique": false,
2274
+ "foreignKey": {
2275
+ "table": "payments",
2276
+ "column": "id",
2277
+ "onDelete": "NO ACTION",
2278
+ "onUpdate": "CASCADE"
2279
+ }
2280
+ },
2281
+ "invoice_id": {
2282
+ "type": "UUID",
2283
+ "referenceKind": "foreignKey",
2284
+ "notNull": false,
2285
+ "unique": false,
2286
+ "foreignKey": {
2287
+ "table": "invoices",
2288
+ "column": "id",
2289
+ "onDelete": "NO ACTION",
2290
+ "onUpdate": "CASCADE"
2291
+ }
2292
+ },
2293
+ "amount": {
2294
+ "type": "INTEGER",
2295
+ "notNull": false,
2296
+ "unique": false,
2297
+ "default": 0
2298
+ },
2299
+ "allocated_at": {
2300
+ "type": "TIMESTAMP",
2301
+ "notNull": false,
2302
+ "unique": false
2303
+ },
2304
+ "allocated_by": {
2305
+ "type": "TEXT",
2306
+ "notNull": false,
2307
+ "unique": false,
2308
+ "default": ""
2309
+ },
2310
+ "notes": {
2311
+ "type": "TEXT",
2312
+ "notNull": false,
2313
+ "unique": false,
2314
+ "default": ""
1536
2315
  }
1537
2316
  },
1538
2317
  "indexes": [
1539
2318
  {
1540
- "name": "payment_allocation_collections_slug_context_idx",
2319
+ "name": "payment_allocations_slug_context_idx",
1541
2320
  "columns": [
2321
+ "tenant_id",
1542
2322
  "slug",
1543
2323
  "context"
1544
2324
  ],
1545
- "unique": true
2325
+ "unique": true,
2326
+ "nullsNotDistinct": true
1546
2327
  },
1547
2328
  {
1548
- "name": "payment_allocation_collections_created_at_idx",
2329
+ "name": "payment_allocations_tenant_id_created_at_idx",
1549
2330
  "columns": [
2331
+ "tenant_id",
1550
2332
  "created_at"
1551
2333
  ]
2334
+ },
2335
+ {
2336
+ "name": "payment_allocations_payment_id_idx",
2337
+ "columns": [
2338
+ "payment_id"
2339
+ ]
2340
+ },
2341
+ {
2342
+ "name": "payment_allocations_invoice_id_idx",
2343
+ "columns": [
2344
+ "invoice_id"
2345
+ ]
1552
2346
  }
1553
2347
  ],
1554
- "version": "0d07c4d3"
2348
+ "version": "102e6fbc"
1555
2349
  }
1556
2350
  },
1557
2351
  "@happyvertical/smrt-commerce:PaymentCollection": {
@@ -1739,52 +2533,207 @@
1739
2533
  "exportName": "PaymentCollection",
1740
2534
  "collectionExportName": "PaymentCollectionCollection",
1741
2535
  "schema": {
1742
- "tableName": "payment_collections",
1743
- "ddl": "CREATE TABLE IF NOT EXISTS \"payment_collections\" (\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);",
2536
+ "tableName": "payments",
2537
+ "ddl": "CREATE TABLE IF NOT EXISTS \"payments\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"contract_id\" UUID,\n \"customer_id\" UUID,\n \"amount\" INTEGER DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"method\" TEXT,\n \"status\" TEXT,\n \"transaction_id\" TEXT DEFAULT '',\n \"reference\" TEXT DEFAULT '',\n \"journal_id\" UUID,\n \"paid_at\" TIMESTAMP,\n \"notes\" TEXT DEFAULT '',\n \"external_id\" TEXT DEFAULT '',\n \"external_provider\" TEXT DEFAULT '',\n \"synced_at\" TIMESTAMP,\n \"backend_id\" TEXT DEFAULT '',\n \"backend_tx_ref\" TEXT DEFAULT '',\n \"native_amount\" INTEGER DEFAULT 0,\n \"native_currency\" TEXT DEFAULT '',\n \"usd_at_quote\" INTEGER DEFAULT 0,\n \"usd_at_confirmation\" INTEGER DEFAULT 0\n);",
1744
2538
  "columns": {
1745
2539
  "id": {
1746
2540
  "type": "UUID",
1747
- "primaryKey": true,
1748
- "referenceKind": "id",
1749
- "notNull": true
2541
+ "primaryKey": true,
2542
+ "referenceKind": "id",
2543
+ "notNull": true
2544
+ },
2545
+ "slug": {
2546
+ "type": "TEXT",
2547
+ "notNull": true
2548
+ },
2549
+ "context": {
2550
+ "type": "TEXT",
2551
+ "notNull": true,
2552
+ "default": ""
2553
+ },
2554
+ "created_at": {
2555
+ "type": "TIMESTAMP",
2556
+ "notNull": true,
2557
+ "default": "current_timestamp"
2558
+ },
2559
+ "updated_at": {
2560
+ "type": "TIMESTAMP",
2561
+ "notNull": true,
2562
+ "default": "current_timestamp"
2563
+ },
2564
+ "tenant_id": {
2565
+ "type": "UUID",
2566
+ "referenceKind": "tenantId",
2567
+ "notNull": false,
2568
+ "unique": false
2569
+ },
2570
+ "contract_id": {
2571
+ "type": "UUID",
2572
+ "referenceKind": "foreignKey",
2573
+ "notNull": false,
2574
+ "unique": false,
2575
+ "foreignKey": {
2576
+ "table": "contracts",
2577
+ "column": "id",
2578
+ "onDelete": "NO ACTION",
2579
+ "onUpdate": "CASCADE"
2580
+ }
2581
+ },
2582
+ "customer_id": {
2583
+ "type": "UUID",
2584
+ "referenceKind": "foreignKey",
2585
+ "notNull": false,
2586
+ "unique": false,
2587
+ "foreignKey": {
2588
+ "table": "customers",
2589
+ "column": "id",
2590
+ "onDelete": "NO ACTION",
2591
+ "onUpdate": "CASCADE"
2592
+ }
2593
+ },
2594
+ "amount": {
2595
+ "type": "INTEGER",
2596
+ "notNull": false,
2597
+ "unique": false,
2598
+ "default": 0
2599
+ },
2600
+ "currency": {
2601
+ "type": "TEXT",
2602
+ "notNull": false,
2603
+ "unique": false,
2604
+ "default": "USD"
2605
+ },
2606
+ "method": {
2607
+ "type": "TEXT",
2608
+ "notNull": false,
2609
+ "unique": false
2610
+ },
2611
+ "status": {
2612
+ "type": "TEXT",
2613
+ "notNull": false,
2614
+ "unique": false
2615
+ },
2616
+ "transaction_id": {
2617
+ "type": "TEXT",
2618
+ "notNull": false,
2619
+ "unique": false,
2620
+ "default": ""
2621
+ },
2622
+ "reference": {
2623
+ "type": "TEXT",
2624
+ "notNull": false,
2625
+ "unique": false,
2626
+ "default": ""
2627
+ },
2628
+ "journal_id": {
2629
+ "type": "UUID",
2630
+ "referenceKind": "crossPackageRef",
2631
+ "notNull": false,
2632
+ "unique": false
1750
2633
  },
1751
- "slug": {
2634
+ "paid_at": {
2635
+ "type": "TIMESTAMP",
2636
+ "notNull": false,
2637
+ "unique": false
2638
+ },
2639
+ "notes": {
1752
2640
  "type": "TEXT",
1753
- "notNull": true
2641
+ "notNull": false,
2642
+ "unique": false,
2643
+ "default": ""
1754
2644
  },
1755
- "context": {
2645
+ "external_id": {
1756
2646
  "type": "TEXT",
1757
- "notNull": true,
2647
+ "notNull": false,
2648
+ "unique": false,
1758
2649
  "default": ""
1759
2650
  },
1760
- "created_at": {
1761
- "type": "TIMESTAMP",
1762
- "notNull": true,
1763
- "default": "current_timestamp"
2651
+ "external_provider": {
2652
+ "type": "TEXT",
2653
+ "notNull": false,
2654
+ "unique": false,
2655
+ "default": ""
1764
2656
  },
1765
- "updated_at": {
2657
+ "synced_at": {
1766
2658
  "type": "TIMESTAMP",
1767
- "notNull": true,
1768
- "default": "current_timestamp"
2659
+ "notNull": false,
2660
+ "unique": false
2661
+ },
2662
+ "backend_id": {
2663
+ "type": "TEXT",
2664
+ "notNull": false,
2665
+ "unique": false,
2666
+ "default": ""
2667
+ },
2668
+ "backend_tx_ref": {
2669
+ "type": "TEXT",
2670
+ "notNull": false,
2671
+ "unique": false,
2672
+ "default": ""
2673
+ },
2674
+ "native_amount": {
2675
+ "type": "INTEGER",
2676
+ "notNull": false,
2677
+ "unique": false,
2678
+ "default": 0
2679
+ },
2680
+ "native_currency": {
2681
+ "type": "TEXT",
2682
+ "notNull": false,
2683
+ "unique": false,
2684
+ "default": ""
2685
+ },
2686
+ "usd_at_quote": {
2687
+ "type": "INTEGER",
2688
+ "notNull": false,
2689
+ "unique": false,
2690
+ "default": 0
2691
+ },
2692
+ "usd_at_confirmation": {
2693
+ "type": "INTEGER",
2694
+ "notNull": false,
2695
+ "unique": false,
2696
+ "default": 0
1769
2697
  }
1770
2698
  },
1771
2699
  "indexes": [
1772
2700
  {
1773
- "name": "payment_collections_slug_context_idx",
2701
+ "name": "payments_slug_context_idx",
1774
2702
  "columns": [
2703
+ "tenant_id",
1775
2704
  "slug",
1776
2705
  "context"
1777
2706
  ],
1778
- "unique": true
2707
+ "unique": true,
2708
+ "nullsNotDistinct": true
1779
2709
  },
1780
2710
  {
1781
- "name": "payment_collections_created_at_idx",
2711
+ "name": "payments_tenant_id_created_at_idx",
1782
2712
  "columns": [
2713
+ "tenant_id",
1783
2714
  "created_at"
1784
2715
  ]
2716
+ },
2717
+ {
2718
+ "name": "payments_contract_id_idx",
2719
+ "columns": [
2720
+ "contract_id"
2721
+ ]
2722
+ },
2723
+ {
2724
+ "name": "payments_customer_id_idx",
2725
+ "columns": [
2726
+ "customer_id"
2727
+ ]
2728
+ },
2729
+ {
2730
+ "name": "payments_journal_id_idx",
2731
+ "columns": [
2732
+ "journal_id"
2733
+ ]
1785
2734
  }
1786
2735
  ],
1787
- "version": "bf759c9b"
2736
+ "version": "33f80e50"
1788
2737
  }
1789
2738
  },
1790
2739
  "@happyvertical/smrt-commerce:PaymentInstrumentCollection": {
@@ -1914,8 +2863,8 @@
1914
2863
  "exportName": "PaymentInstrumentCollection",
1915
2864
  "collectionExportName": "PaymentInstrumentCollectionCollection",
1916
2865
  "schema": {
1917
- "tableName": "payment_instrument_collections",
1918
- "ddl": "CREATE TABLE IF NOT EXISTS \"payment_instrument_collections\" (\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);",
2866
+ "tableName": "payment_instruments",
2867
+ "ddl": "CREATE TABLE IF NOT EXISTS \"payment_instruments\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"customer_id\" UUID,\n \"backend_id\" TEXT DEFAULT '',\n \"provider_customer_id\" TEXT DEFAULT '',\n \"provider_payment_method_id\" TEXT DEFAULT '',\n \"type\" TEXT DEFAULT 'card',\n \"brand\" TEXT DEFAULT '',\n \"last4\" TEXT DEFAULT '',\n \"exp_month\" INTEGER DEFAULT 0,\n \"exp_year\" INTEGER DEFAULT 0,\n \"is_default\" BOOLEAN DEFAULT FALSE,\n \"status\" TEXT\n);",
1919
2868
  "columns": {
1920
2869
  "id": {
1921
2870
  "type": "UUID",
@@ -1941,25 +2890,111 @@
1941
2890
  "type": "TIMESTAMP",
1942
2891
  "notNull": true,
1943
2892
  "default": "current_timestamp"
2893
+ },
2894
+ "tenant_id": {
2895
+ "type": "UUID",
2896
+ "referenceKind": "tenantId",
2897
+ "notNull": false,
2898
+ "unique": false
2899
+ },
2900
+ "customer_id": {
2901
+ "type": "UUID",
2902
+ "referenceKind": "foreignKey",
2903
+ "notNull": false,
2904
+ "unique": false,
2905
+ "foreignKey": {
2906
+ "table": "customers",
2907
+ "column": "id",
2908
+ "onDelete": "NO ACTION",
2909
+ "onUpdate": "CASCADE"
2910
+ }
2911
+ },
2912
+ "backend_id": {
2913
+ "type": "TEXT",
2914
+ "notNull": false,
2915
+ "unique": false,
2916
+ "default": ""
2917
+ },
2918
+ "provider_customer_id": {
2919
+ "type": "TEXT",
2920
+ "notNull": false,
2921
+ "unique": false,
2922
+ "default": ""
2923
+ },
2924
+ "provider_payment_method_id": {
2925
+ "type": "TEXT",
2926
+ "notNull": false,
2927
+ "unique": false,
2928
+ "default": ""
2929
+ },
2930
+ "type": {
2931
+ "type": "TEXT",
2932
+ "notNull": false,
2933
+ "unique": false,
2934
+ "default": "card"
2935
+ },
2936
+ "brand": {
2937
+ "type": "TEXT",
2938
+ "notNull": false,
2939
+ "unique": false,
2940
+ "default": ""
2941
+ },
2942
+ "last4": {
2943
+ "type": "TEXT",
2944
+ "notNull": false,
2945
+ "unique": false,
2946
+ "default": ""
2947
+ },
2948
+ "exp_month": {
2949
+ "type": "INTEGER",
2950
+ "notNull": false,
2951
+ "unique": false,
2952
+ "default": 0
2953
+ },
2954
+ "exp_year": {
2955
+ "type": "INTEGER",
2956
+ "notNull": false,
2957
+ "unique": false,
2958
+ "default": 0
2959
+ },
2960
+ "is_default": {
2961
+ "type": "BOOLEAN",
2962
+ "notNull": false,
2963
+ "unique": false,
2964
+ "default": false
2965
+ },
2966
+ "status": {
2967
+ "type": "TEXT",
2968
+ "notNull": false,
2969
+ "unique": false
1944
2970
  }
1945
2971
  },
1946
2972
  "indexes": [
1947
2973
  {
1948
- "name": "payment_instrument_collections_slug_context_idx",
2974
+ "name": "payment_instruments_slug_context_idx",
1949
2975
  "columns": [
2976
+ "tenant_id",
1950
2977
  "slug",
1951
2978
  "context"
1952
2979
  ],
1953
- "unique": true
2980
+ "unique": true,
2981
+ "nullsNotDistinct": true
1954
2982
  },
1955
2983
  {
1956
- "name": "payment_instrument_collections_created_at_idx",
2984
+ "name": "payment_instruments_tenant_id_created_at_idx",
1957
2985
  "columns": [
2986
+ "tenant_id",
1958
2987
  "created_at"
1959
2988
  ]
2989
+ },
2990
+ {
2991
+ "name": "payment_instruments_customer_id_idx",
2992
+ "columns": [
2993
+ "customer_id"
2994
+ ]
1960
2995
  }
1961
2996
  ],
1962
- "version": "dd2ca72c"
2997
+ "version": "722393fe"
1963
2998
  }
1964
2999
  },
1965
3000
  "@happyvertical/smrt-commerce:PaymentIntentCollection": {
@@ -2100,8 +3135,8 @@
2100
3135
  "exportName": "PaymentIntentCollection",
2101
3136
  "collectionExportName": "PaymentIntentCollectionCollection",
2102
3137
  "schema": {
2103
- "tableName": "payment_intent_collections",
2104
- "ddl": "CREATE TABLE IF NOT EXISTS \"payment_intent_collections\" (\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);",
3138
+ "tableName": "payment_intents",
3139
+ "ddl": "CREATE TABLE IF NOT EXISTS \"payment_intents\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"sku_id\" TEXT DEFAULT '',\n \"offering_ref\" TEXT DEFAULT '',\n \"licensee_email\" TEXT DEFAULT '',\n \"customer_id\" TEXT DEFAULT '',\n \"payment_options\" JSON DEFAULT '[]',\n \"usd_price_locked\" INTEGER DEFAULT 0,\n \"price_lock_window_ms\" INTEGER,\n \"price_lock_expires_at\" TIMESTAMP,\n \"status\" TEXT,\n \"idempotency_key\" TEXT DEFAULT '',\n \"paid_option_backend_id\" TEXT DEFAULT '',\n \"payment_id\" TEXT DEFAULT '',\n \"paid_at\" TIMESTAMP,\n \"issued_at\" TIMESTAMP,\n \"expired_at\" TIMESTAMP,\n \"cancelled_at\" TIMESTAMP,\n \"retired_at\" TIMESTAMP,\n \"notes\" TEXT DEFAULT ''\n);",
2105
3140
  "columns": {
2106
3141
  "id": {
2107
3142
  "type": "UUID",
@@ -2109,43 +3144,160 @@
2109
3144
  "referenceKind": "id",
2110
3145
  "notNull": true
2111
3146
  },
2112
- "slug": {
3147
+ "slug": {
3148
+ "type": "TEXT",
3149
+ "notNull": true
3150
+ },
3151
+ "context": {
3152
+ "type": "TEXT",
3153
+ "notNull": true,
3154
+ "default": ""
3155
+ },
3156
+ "created_at": {
3157
+ "type": "TIMESTAMP",
3158
+ "notNull": true,
3159
+ "default": "current_timestamp"
3160
+ },
3161
+ "updated_at": {
3162
+ "type": "TIMESTAMP",
3163
+ "notNull": true,
3164
+ "default": "current_timestamp"
3165
+ },
3166
+ "tenant_id": {
3167
+ "type": "UUID",
3168
+ "referenceKind": "tenantId",
3169
+ "notNull": false,
3170
+ "unique": false
3171
+ },
3172
+ "sku_id": {
3173
+ "type": "TEXT",
3174
+ "notNull": false,
3175
+ "unique": false,
3176
+ "default": ""
3177
+ },
3178
+ "offering_ref": {
3179
+ "type": "TEXT",
3180
+ "notNull": false,
3181
+ "unique": false,
3182
+ "default": ""
3183
+ },
3184
+ "licensee_email": {
3185
+ "type": "TEXT",
3186
+ "notNull": false,
3187
+ "unique": false,
3188
+ "default": ""
3189
+ },
3190
+ "customer_id": {
3191
+ "type": "TEXT",
3192
+ "notNull": false,
3193
+ "unique": false,
3194
+ "default": ""
3195
+ },
3196
+ "payment_options": {
3197
+ "type": "JSON",
3198
+ "notNull": false,
3199
+ "unique": false,
3200
+ "default": []
3201
+ },
3202
+ "usd_price_locked": {
3203
+ "type": "INTEGER",
3204
+ "notNull": false,
3205
+ "unique": false,
3206
+ "default": 0
3207
+ },
3208
+ "price_lock_window_ms": {
3209
+ "type": "INTEGER",
3210
+ "notNull": false,
3211
+ "unique": false
3212
+ },
3213
+ "price_lock_expires_at": {
3214
+ "type": "TIMESTAMP",
3215
+ "notNull": false,
3216
+ "unique": false
3217
+ },
3218
+ "status": {
2113
3219
  "type": "TEXT",
2114
- "notNull": true
3220
+ "notNull": false,
3221
+ "unique": false
2115
3222
  },
2116
- "context": {
3223
+ "idempotency_key": {
2117
3224
  "type": "TEXT",
2118
- "notNull": true,
3225
+ "notNull": false,
3226
+ "unique": false,
2119
3227
  "default": ""
2120
3228
  },
2121
- "created_at": {
3229
+ "paid_option_backend_id": {
3230
+ "type": "TEXT",
3231
+ "notNull": false,
3232
+ "unique": false,
3233
+ "default": ""
3234
+ },
3235
+ "payment_id": {
3236
+ "type": "TEXT",
3237
+ "notNull": false,
3238
+ "unique": false,
3239
+ "default": ""
3240
+ },
3241
+ "paid_at": {
2122
3242
  "type": "TIMESTAMP",
2123
- "notNull": true,
2124
- "default": "current_timestamp"
3243
+ "notNull": false,
3244
+ "unique": false
2125
3245
  },
2126
- "updated_at": {
3246
+ "issued_at": {
2127
3247
  "type": "TIMESTAMP",
2128
- "notNull": true,
2129
- "default": "current_timestamp"
3248
+ "notNull": false,
3249
+ "unique": false
3250
+ },
3251
+ "expired_at": {
3252
+ "type": "TIMESTAMP",
3253
+ "notNull": false,
3254
+ "unique": false
3255
+ },
3256
+ "cancelled_at": {
3257
+ "type": "TIMESTAMP",
3258
+ "notNull": false,
3259
+ "unique": false
3260
+ },
3261
+ "retired_at": {
3262
+ "type": "TIMESTAMP",
3263
+ "notNull": false,
3264
+ "unique": false
3265
+ },
3266
+ "notes": {
3267
+ "type": "TEXT",
3268
+ "notNull": false,
3269
+ "unique": false,
3270
+ "default": ""
2130
3271
  }
2131
3272
  },
2132
3273
  "indexes": [
2133
3274
  {
2134
- "name": "payment_intent_collections_slug_context_idx",
3275
+ "name": "payment_intents_tenant_id_offering_ref_idx",
3276
+ "columns": [
3277
+ "tenant_id",
3278
+ "offering_ref",
3279
+ "licensee_email",
3280
+ "idempotency_key"
3281
+ ],
3282
+ "unique": true,
3283
+ "nullsNotDistinct": true
3284
+ },
3285
+ {
3286
+ "name": "payment_intents_slug_context_idx",
2135
3287
  "columns": [
2136
3288
  "slug",
2137
3289
  "context"
2138
- ],
2139
- "unique": true
3290
+ ]
2140
3291
  },
2141
3292
  {
2142
- "name": "payment_intent_collections_created_at_idx",
3293
+ "name": "payment_intents_tenant_id_created_at_idx",
2143
3294
  "columns": [
3295
+ "tenant_id",
2144
3296
  "created_at"
2145
3297
  ]
2146
3298
  }
2147
3299
  ],
2148
- "version": "f79d1a8f"
3300
+ "version": "c565aaef"
2149
3301
  }
2150
3302
  },
2151
3303
  "@happyvertical/smrt-commerce:PayoutCollection": {
@@ -2300,8 +3452,8 @@
2300
3452
  "exportName": "PayoutCollection",
2301
3453
  "collectionExportName": "PayoutCollectionCollection",
2302
3454
  "schema": {
2303
- "tableName": "payout_collections",
2304
- "ddl": "CREATE TABLE IF NOT EXISTS \"payout_collections\" (\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);",
3455
+ "tableName": "payouts",
3456
+ "ddl": "CREATE TABLE IF NOT EXISTS \"payouts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"payment_id\" TEXT DEFAULT '',\n \"vendor_id\" UUID,\n \"gross_amount\" INTEGER DEFAULT 0,\n \"operator_fee\" INTEGER DEFAULT 0,\n \"supplier_net\" INTEGER DEFAULT 0,\n \"currency\" TEXT DEFAULT '',\n \"backend_id\" TEXT DEFAULT '',\n \"backend_tx_ref\" TEXT DEFAULT '',\n \"status\" TEXT,\n \"sent_at\" TIMESTAMP,\n \"confirmed_at\" TIMESTAMP,\n \"failed_at\" TIMESTAMP,\n \"failure_reason\" TEXT DEFAULT '',\n \"notes\" TEXT DEFAULT ''\n);",
2305
3457
  "columns": {
2306
3458
  "id": {
2307
3459
  "type": "UUID",
@@ -2327,25 +3479,126 @@
2327
3479
  "type": "TIMESTAMP",
2328
3480
  "notNull": true,
2329
3481
  "default": "current_timestamp"
3482
+ },
3483
+ "tenant_id": {
3484
+ "type": "UUID",
3485
+ "referenceKind": "tenantId",
3486
+ "notNull": false,
3487
+ "unique": false
3488
+ },
3489
+ "payment_id": {
3490
+ "type": "TEXT",
3491
+ "notNull": false,
3492
+ "unique": false,
3493
+ "default": ""
3494
+ },
3495
+ "vendor_id": {
3496
+ "type": "UUID",
3497
+ "referenceKind": "foreignKey",
3498
+ "notNull": false,
3499
+ "unique": false,
3500
+ "foreignKey": {
3501
+ "table": "vendors",
3502
+ "column": "id",
3503
+ "onDelete": "NO ACTION",
3504
+ "onUpdate": "CASCADE"
3505
+ }
3506
+ },
3507
+ "gross_amount": {
3508
+ "type": "INTEGER",
3509
+ "notNull": false,
3510
+ "unique": false,
3511
+ "default": 0
3512
+ },
3513
+ "operator_fee": {
3514
+ "type": "INTEGER",
3515
+ "notNull": false,
3516
+ "unique": false,
3517
+ "default": 0
3518
+ },
3519
+ "supplier_net": {
3520
+ "type": "INTEGER",
3521
+ "notNull": false,
3522
+ "unique": false,
3523
+ "default": 0
3524
+ },
3525
+ "currency": {
3526
+ "type": "TEXT",
3527
+ "notNull": false,
3528
+ "unique": false,
3529
+ "default": ""
3530
+ },
3531
+ "backend_id": {
3532
+ "type": "TEXT",
3533
+ "notNull": false,
3534
+ "unique": false,
3535
+ "default": ""
3536
+ },
3537
+ "backend_tx_ref": {
3538
+ "type": "TEXT",
3539
+ "notNull": false,
3540
+ "unique": false,
3541
+ "default": ""
3542
+ },
3543
+ "status": {
3544
+ "type": "TEXT",
3545
+ "notNull": false,
3546
+ "unique": false
3547
+ },
3548
+ "sent_at": {
3549
+ "type": "TIMESTAMP",
3550
+ "notNull": false,
3551
+ "unique": false
3552
+ },
3553
+ "confirmed_at": {
3554
+ "type": "TIMESTAMP",
3555
+ "notNull": false,
3556
+ "unique": false
3557
+ },
3558
+ "failed_at": {
3559
+ "type": "TIMESTAMP",
3560
+ "notNull": false,
3561
+ "unique": false
3562
+ },
3563
+ "failure_reason": {
3564
+ "type": "TEXT",
3565
+ "notNull": false,
3566
+ "unique": false,
3567
+ "default": ""
3568
+ },
3569
+ "notes": {
3570
+ "type": "TEXT",
3571
+ "notNull": false,
3572
+ "unique": false,
3573
+ "default": ""
2330
3574
  }
2331
3575
  },
2332
3576
  "indexes": [
2333
3577
  {
2334
- "name": "payout_collections_slug_context_idx",
3578
+ "name": "payouts_slug_context_idx",
2335
3579
  "columns": [
3580
+ "tenant_id",
2336
3581
  "slug",
2337
3582
  "context"
2338
3583
  ],
2339
- "unique": true
3584
+ "unique": true,
3585
+ "nullsNotDistinct": true
2340
3586
  },
2341
3587
  {
2342
- "name": "payout_collections_created_at_idx",
3588
+ "name": "payouts_tenant_id_created_at_idx",
2343
3589
  "columns": [
3590
+ "tenant_id",
2344
3591
  "created_at"
2345
3592
  ]
3593
+ },
3594
+ {
3595
+ "name": "payouts_vendor_id_idx",
3596
+ "columns": [
3597
+ "vendor_id"
3598
+ ]
2346
3599
  }
2347
3600
  ],
2348
- "version": "7dc3bcc1"
3601
+ "version": "98fa81d5"
2349
3602
  }
2350
3603
  },
2351
3604
  "@happyvertical/smrt-commerce:VendorCollection": {
@@ -2459,8 +3712,8 @@
2459
3712
  "exportName": "VendorCollection",
2460
3713
  "collectionExportName": "VendorCollectionCollection",
2461
3714
  "schema": {
2462
- "tableName": "vendor_collections",
2463
- "ddl": "CREATE TABLE IF NOT EXISTS \"vendor_collections\" (\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);",
3715
+ "tableName": "vendors",
3716
+ "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);",
2464
3717
  "columns": {
2465
3718
  "id": {
2466
3719
  "type": "UUID",
@@ -2486,25 +3739,99 @@
2486
3739
  "type": "TIMESTAMP",
2487
3740
  "notNull": true,
2488
3741
  "default": "current_timestamp"
3742
+ },
3743
+ "tenant_id": {
3744
+ "type": "UUID",
3745
+ "referenceKind": "tenantId",
3746
+ "notNull": false,
3747
+ "unique": false
3748
+ },
3749
+ "profile_id": {
3750
+ "type": "UUID",
3751
+ "referenceKind": "crossPackageRef",
3752
+ "notNull": false,
3753
+ "unique": false
3754
+ },
3755
+ "lead_time_days": {
3756
+ "type": "INTEGER",
3757
+ "notNull": false,
3758
+ "unique": false,
3759
+ "default": 0
3760
+ },
3761
+ "minimum_order_amount": {
3762
+ "type": "INTEGER",
3763
+ "notNull": false,
3764
+ "unique": false,
3765
+ "default": 0
3766
+ },
3767
+ "payment_terms": {
3768
+ "type": "TEXT",
3769
+ "notNull": false,
3770
+ "unique": false,
3771
+ "default": ""
3772
+ },
3773
+ "currency": {
3774
+ "type": "TEXT",
3775
+ "notNull": false,
3776
+ "unique": false,
3777
+ "default": "USD"
3778
+ },
3779
+ "default_contact_email": {
3780
+ "type": "TEXT",
3781
+ "notNull": false,
3782
+ "unique": false,
3783
+ "default": ""
3784
+ },
3785
+ "default_contact_phone": {
3786
+ "type": "TEXT",
3787
+ "notNull": false,
3788
+ "unique": false,
3789
+ "default": ""
3790
+ },
3791
+ "status": {
3792
+ "type": "TEXT",
3793
+ "notNull": false,
3794
+ "unique": false
3795
+ },
3796
+ "notes": {
3797
+ "type": "TEXT",
3798
+ "notNull": false,
3799
+ "unique": false,
3800
+ "default": ""
3801
+ },
3802
+ "payout_addresses": {
3803
+ "type": "JSON",
3804
+ "notNull": false,
3805
+ "unique": false,
3806
+ "default": {}
2489
3807
  }
2490
3808
  },
2491
3809
  "indexes": [
2492
3810
  {
2493
- "name": "vendor_collections_slug_context_idx",
3811
+ "name": "vendors_slug_context_idx",
2494
3812
  "columns": [
3813
+ "tenant_id",
2495
3814
  "slug",
2496
3815
  "context"
2497
3816
  ],
2498
- "unique": true
3817
+ "unique": true,
3818
+ "nullsNotDistinct": true
2499
3819
  },
2500
3820
  {
2501
- "name": "vendor_collections_created_at_idx",
3821
+ "name": "vendors_tenant_id_created_at_idx",
2502
3822
  "columns": [
3823
+ "tenant_id",
2503
3824
  "created_at"
2504
3825
  ]
3826
+ },
3827
+ {
3828
+ "name": "vendors_profile_id_idx",
3829
+ "columns": [
3830
+ "profile_id"
3831
+ ]
2505
3832
  }
2506
3833
  ],
2507
- "version": "ffdcddab"
3834
+ "version": "1dc2b65e"
2508
3835
  }
2509
3836
  },
2510
3837
  "@happyvertical/smrt-commerce:Contract": {
@@ -2844,7 +4171,8 @@
2844
4171
  "context",
2845
4172
  "_meta_type"
2846
4173
  ],
2847
- "unique": true
4174
+ "unique": true,
4175
+ "nullsNotDistinct": true
2848
4176
  },
2849
4177
  {
2850
4178
  "name": "contracts_meta_type_idx",
@@ -3190,7 +4518,8 @@
3190
4518
  "context",
3191
4519
  "_meta_type"
3192
4520
  ],
3193
- "unique": true
4521
+ "unique": true,
4522
+ "nullsNotDistinct": true
3194
4523
  },
3195
4524
  {
3196
4525
  "name": "contracts_meta_type_idx",
@@ -3536,7 +4865,8 @@
3536
4865
  "context",
3537
4866
  "_meta_type"
3538
4867
  ],
3539
- "unique": true
4868
+ "unique": true,
4869
+ "nullsNotDistinct": true
3540
4870
  },
3541
4871
  {
3542
4872
  "name": "contracts_meta_type_idx",
@@ -3882,7 +5212,8 @@
3882
5212
  "context",
3883
5213
  "_meta_type"
3884
5214
  ],
3885
- "unique": true
5215
+ "unique": true,
5216
+ "nullsNotDistinct": true
3886
5217
  },
3887
5218
  {
3888
5219
  "name": "contracts_meta_type_idx",
@@ -4228,7 +5559,8 @@
4228
5559
  "context",
4229
5560
  "_meta_type"
4230
5561
  ],
4231
- "unique": true
5562
+ "unique": true,
5563
+ "nullsNotDistinct": true
4232
5564
  },
4233
5565
  {
4234
5566
  "name": "contracts_meta_type_idx",
@@ -4574,7 +5906,8 @@
4574
5906
  "context",
4575
5907
  "_meta_type"
4576
5908
  ],
4577
- "unique": true
5909
+ "unique": true,
5910
+ "nullsNotDistinct": true
4578
5911
  },
4579
5912
  {
4580
5913
  "name": "contracts_meta_type_idx",
@@ -4920,7 +6253,8 @@
4920
6253
  "context",
4921
6254
  "_meta_type"
4922
6255
  ],
4923
- "unique": true
6256
+ "unique": true,
6257
+ "nullsNotDistinct": true
4924
6258
  },
4925
6259
  {
4926
6260
  "name": "contracts_meta_type_idx",
@@ -5282,7 +6616,8 @@
5282
6616
  "context",
5283
6617
  "_meta_type"
5284
6618
  ],
5285
- "unique": true
6619
+ "unique": true,
6620
+ "nullsNotDistinct": true
5286
6621
  },
5287
6622
  {
5288
6623
  "name": "contracts_meta_type_idx",
@@ -5628,7 +6963,8 @@
5628
6963
  "context",
5629
6964
  "_meta_type"
5630
6965
  ],
5631
- "unique": true
6966
+ "unique": true,
6967
+ "nullsNotDistinct": true
5632
6968
  },
5633
6969
  {
5634
6970
  "name": "contracts_meta_type_idx",
@@ -6110,7 +7446,8 @@
6110
7446
  "context",
6111
7447
  "_meta_type"
6112
7448
  ],
6113
- "unique": true
7449
+ "unique": true,
7450
+ "nullsNotDistinct": true
6114
7451
  },
6115
7452
  {
6116
7453
  "name": "contracts_meta_type_idx",
@@ -6419,7 +7756,8 @@
6419
7756
  "context",
6420
7757
  "_meta_type"
6421
7758
  ],
6422
- "unique": true
7759
+ "unique": true,
7760
+ "nullsNotDistinct": true
6423
7761
  },
6424
7762
  {
6425
7763
  "name": "contract_line_items_meta_type_idx",
@@ -6697,7 +8035,8 @@
6697
8035
  "slug",
6698
8036
  "context"
6699
8037
  ],
6700
- "unique": true
8038
+ "unique": true,
8039
+ "nullsNotDistinct": true
6701
8040
  },
6702
8041
  {
6703
8042
  "name": "customers_tenant_id_created_at_idx",
@@ -6998,7 +8337,8 @@
6998
8337
  "slug",
6999
8338
  "context"
7000
8339
  ],
7001
- "unique": true
8340
+ "unique": true,
8341
+ "nullsNotDistinct": true
7002
8342
  },
7003
8343
  {
7004
8344
  "name": "fulfillments_tenant_id_created_at_idx",
@@ -7183,7 +8523,8 @@
7183
8523
  "slug",
7184
8524
  "context"
7185
8525
  ],
7186
- "unique": true
8526
+ "unique": true,
8527
+ "nullsNotDistinct": true
7187
8528
  },
7188
8529
  {
7189
8530
  "name": "fulfillment_line_items_tenant_id_created_at_idx",
@@ -7748,7 +9089,8 @@
7748
9089
  "slug",
7749
9090
  "context"
7750
9091
  ],
7751
- "unique": true
9092
+ "unique": true,
9093
+ "nullsNotDistinct": true
7752
9094
  },
7753
9095
  {
7754
9096
  "name": "invoices_tenant_id_created_at_idx",
@@ -8093,7 +9435,8 @@
8093
9435
  "slug",
8094
9436
  "context"
8095
9437
  ],
8096
- "unique": true
9438
+ "unique": true,
9439
+ "nullsNotDistinct": true
8097
9440
  },
8098
9441
  {
8099
9442
  "name": "invoice_line_items_tenant_id_created_at_idx",
@@ -8555,7 +9898,8 @@
8555
9898
  "slug",
8556
9899
  "context"
8557
9900
  ],
8558
- "unique": true
9901
+ "unique": true,
9902
+ "nullsNotDistinct": true
8559
9903
  },
8560
9904
  {
8561
9905
  "name": "payments_tenant_id_created_at_idx",
@@ -8774,7 +10118,8 @@
8774
10118
  "slug",
8775
10119
  "context"
8776
10120
  ],
8777
- "unique": true
10121
+ "unique": true,
10122
+ "nullsNotDistinct": true
8778
10123
  },
8779
10124
  {
8780
10125
  "name": "payment_allocations_tenant_id_created_at_idx",
@@ -9079,7 +10424,8 @@
9079
10424
  "slug",
9080
10425
  "context"
9081
10426
  ],
9082
- "unique": true
10427
+ "unique": true,
10428
+ "nullsNotDistinct": true
9083
10429
  },
9084
10430
  {
9085
10431
  "name": "payment_instruments_tenant_id_created_at_idx",
@@ -9582,7 +10928,8 @@
9582
10928
  "licensee_email",
9583
10929
  "idempotency_key"
9584
10930
  ],
9585
- "unique": true
10931
+ "unique": true,
10932
+ "nullsNotDistinct": true
9586
10933
  },
9587
10934
  {
9588
10935
  "name": "payment_intents_slug_context_idx",
@@ -9958,7 +11305,8 @@
9958
11305
  "slug",
9959
11306
  "context"
9960
11307
  ],
9961
- "unique": true
11308
+ "unique": true,
11309
+ "nullsNotDistinct": true
9962
11310
  },
9963
11311
  {
9964
11312
  "name": "payouts_tenant_id_created_at_idx",
@@ -10285,7 +11633,8 @@
10285
11633
  "slug",
10286
11634
  "context"
10287
11635
  ],
10288
- "unique": true
11636
+ "unique": true,
11637
+ "nullsNotDistinct": true
10289
11638
  },
10290
11639
  {
10291
11640
  "name": "vendors_tenant_id_created_at_idx",