@happyvertical/smrt-expenses 0.60.13 → 0.60.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/AGENTS.md +15 -2
  2. package/README.md +8 -0
  3. package/agents/allocation-test-matrix.md +82 -0
  4. package/agents/reviewed-allocations.md +138 -0
  5. package/dist/allocation-internal.d.ts +6 -0
  6. package/dist/allocation-internal.d.ts.map +1 -0
  7. package/dist/chunks/{Expense-CimA4lxE.js → Expense-Deq19w2r.js} +28 -3
  8. package/dist/chunks/Expense-Deq19w2r.js.map +1 -0
  9. package/dist/chunks/{ExpenseReceiptCollection-CSBrNDzv.js → ExpenseReceiptCollection-D4Na93BF.js} +37 -3
  10. package/dist/chunks/ExpenseReceiptCollection-D4Na93BF.js.map +1 -0
  11. package/dist/chunks/{expense-actions-DiIhw0xO.js → expense-actions-DszuHacx.js} +2 -2
  12. package/dist/chunks/{expense-actions-DiIhw0xO.js.map → expense-actions-DszuHacx.js.map} +1 -1
  13. package/dist/collections/ExpenseCollection.d.ts +5 -5
  14. package/dist/collections/ExpenseCollection.d.ts.map +1 -1
  15. package/dist/expense-allocation.d.ts +133 -0
  16. package/dist/expense-allocation.d.ts.map +1 -0
  17. package/dist/index.d.ts +3 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1001 -21
  20. package/dist/index.js.map +1 -1
  21. package/dist/manifest.json +2359 -627
  22. package/dist/models/Expense.d.ts +2 -6
  23. package/dist/models/Expense.d.ts.map +1 -1
  24. package/dist/models/ExpenseAllocation.d.ts +117 -0
  25. package/dist/models/ExpenseAllocation.d.ts.map +1 -0
  26. package/dist/models/ExpenseReceipt.d.ts +7 -0
  27. package/dist/models/ExpenseReceipt.d.ts.map +1 -1
  28. package/dist/permissions.d.ts +5 -0
  29. package/dist/permissions.d.ts.map +1 -0
  30. package/dist/recipes.d.ts +3 -0
  31. package/dist/recipes.d.ts.map +1 -1
  32. package/dist/smrt-knowledge.json +746 -108
  33. package/dist/smrt-knowledge.okf.md +17 -3
  34. package/dist/types.d.ts +2 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js.map +1 -1
  37. package/package.json +9 -9
  38. package/dist/chunks/Expense-CimA4lxE.js.map +0 -1
  39. package/dist/chunks/ExpenseReceiptCollection-CSBrNDzv.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-expenses",
5
- "packageVersion": "0.60.13",
5
+ "packageVersion": "0.60.15",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-expenses:ExpenseCollection": {
8
8
  "name": "expensecollection",
@@ -242,6 +242,44 @@
242
242
  "isStatic": false,
243
243
  "isPublic": true
244
244
  },
245
+ "reviewAllocation": {
246
+ "name": "reviewAllocation",
247
+ "async": true,
248
+ "parameters": [
249
+ {
250
+ "name": "input",
251
+ "type": "ReviewExpenseAllocationInput",
252
+ "optional": false
253
+ },
254
+ {
255
+ "name": "authority",
256
+ "type": "ExpenseAllocationAuthority",
257
+ "optional": false
258
+ }
259
+ ],
260
+ "returnType": "Promise<ExpenseAllocationResult>",
261
+ "isStatic": false,
262
+ "isPublic": true
263
+ },
264
+ "withdrawAllocation": {
265
+ "name": "withdrawAllocation",
266
+ "async": true,
267
+ "parameters": [
268
+ {
269
+ "name": "input",
270
+ "type": "WithdrawExpenseAllocationInput",
271
+ "optional": false
272
+ },
273
+ {
274
+ "name": "authority",
275
+ "type": "ExpenseAllocationAuthority",
276
+ "optional": false
277
+ }
278
+ ],
279
+ "returnType": "Promise<WithdrawExpenseAllocationResult>",
280
+ "isStatic": false,
281
+ "isPublic": true
282
+ },
245
283
  "listReviewedTaxFacts": {
246
284
  "name": "listReviewedTaxFacts",
247
285
  "async": true,
@@ -301,7 +339,7 @@
301
339
  "collectionOf": "@happyvertical/smrt-expenses:Expense",
302
340
  "schema": {
303
341
  "tableName": "expenses",
304
- "ddl": "CREATE TABLE IF NOT EXISTS \"expenses\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"cost_object_type\" TEXT,\n \"cost_object_id\" TEXT,\n \"category\" TEXT,\n \"description\" TEXT,\n \"amount\" INTEGER,\n \"currency\" TEXT,\n \"financial_breakdown\" TEXT,\n \"supplier_payable_json\" TEXT,\n \"paid_by_name\" TEXT,\n \"refund_of_id\" UUID,\n \"refund_recipient\" TEXT,\n \"incurred_on\" TEXT,\n \"recorded_at\" TIMESTAMP,\n \"recorded_by_profile_id\" UUID,\n \"paid_by\" TEXT,\n \"paid_by_profile_id\" UUID,\n \"vendor_id\" UUID,\n \"commitment_id\" UUID,\n \"commitment_line_id\" UUID,\n \"review_status\" TEXT,\n \"reviewed_by_profile_id\" UUID,\n \"reviewed_at\" TIMESTAMP,\n \"review_note\" TEXT,\n \"duplicate_of_id\" UUID,\n \"reimbursable\" BOOLEAN,\n \"reimbursed_amount\" INTEGER,\n \"reimbursed_at\" TIMESTAMP,\n \"reimbursement_reference\" TEXT\n);",
342
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expenses\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"cost_object_type\" TEXT,\n \"cost_object_id\" TEXT,\n \"category\" TEXT,\n \"description\" TEXT,\n \"amount\" INTEGER,\n \"currency\" TEXT,\n \"financial_breakdown\" TEXT,\n \"supplier_payable_json\" TEXT,\n \"paid_by_name\" TEXT,\n \"refund_of_id\" UUID,\n \"refund_recipient\" TEXT,\n \"incurred_on\" TEXT,\n \"recorded_at\" TIMESTAMP,\n \"recorded_by_profile_id\" UUID,\n \"paid_by\" TEXT,\n \"paid_by_profile_id\" UUID,\n \"vendor_id\" UUID,\n \"commitment_id\" UUID,\n \"commitment_line_id\" UUID,\n \"review_status\" TEXT,\n \"reviewed_by_profile_id\" UUID,\n \"reviewed_at\" TIMESTAMP,\n \"review_note\" TEXT,\n \"duplicate_of_id\" UUID,\n \"reimbursable\" BOOLEAN,\n \"reimbursed_amount\" INTEGER,\n \"reimbursed_at\" TIMESTAMP,\n \"reimbursement_reference\" TEXT,\n \"active_allocation_revision_id\" UUID\n);",
305
343
  "columns": {
306
344
  "_sync_origin_device_id": {
307
345
  "type": "TEXT"
@@ -499,6 +537,18 @@
499
537
  "type": "TEXT",
500
538
  "notNull": false,
501
539
  "unique": false
540
+ },
541
+ "active_allocation_revision_id": {
542
+ "type": "UUID",
543
+ "referenceKind": "foreignKey",
544
+ "notNull": false,
545
+ "unique": false,
546
+ "foreignKey": {
547
+ "table": "expense_allocation_revisions",
548
+ "column": "id",
549
+ "onDelete": "RESTRICT",
550
+ "onUpdate": "CASCADE"
551
+ }
502
552
  }
503
553
  },
504
554
  "indexes": [
@@ -591,9 +641,15 @@
591
641
  "columns": [
592
642
  "duplicate_of_id"
593
643
  ]
644
+ },
645
+ {
646
+ "name": "expenses_active_allocation_revision_id_idx",
647
+ "columns": [
648
+ "active_allocation_revision_id"
649
+ ]
594
650
  }
595
651
  ],
596
- "version": "81a9a368"
652
+ "version": "f8413307"
597
653
  },
598
654
  "importPath": "@happyvertical/smrt-expenses"
599
655
  },
@@ -911,379 +967,2248 @@
911
967
  },
912
968
  "importPath": "@happyvertical/smrt-expenses"
913
969
  },
914
- "@happyvertical/smrt-expenses:Expense": {
915
- "name": "expense",
916
- "className": "Expense",
917
- "qualifiedName": "@happyvertical/smrt-expenses:Expense",
918
- "collection": "expenses",
919
- "description": "A cost someone incurred.",
920
- "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/models/Expense.ts",
970
+ "@happyvertical/smrt-expenses:Revisions": {
971
+ "name": "revisions",
972
+ "className": "Revisions",
973
+ "qualifiedName": "@happyvertical/smrt-expenses:Revisions",
974
+ "collection": "expenseallocationrevisions",
975
+ "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/expense-allocation.ts",
921
976
  "packageName": "@happyvertical/smrt-expenses",
922
- "fields": {
923
- "tenantId": {
924
- "type": "text",
925
- "required": false,
926
- "_meta": {
927
- "sqlType": "UUID",
928
- "nullable": true,
929
- "__tenancy": {
930
- "isTenantIdField": true,
931
- "autoFilter": true,
932
- "required": false,
933
- "autoPopulate": true,
934
- "nullable": true,
935
- "mode": "optional",
936
- "field": "tenantId",
937
- "allowSuperAdminBypass": false
938
- }
939
- }
940
- },
941
- "costObjectType": {
942
- "type": "text",
943
- "required": false,
944
- "_meta": {}
945
- },
946
- "costObjectId": {
947
- "type": "text",
948
- "required": false,
949
- "_meta": {}
950
- },
951
- "category": {
952
- "type": "text",
953
- "required": false,
954
- "_meta": {}
955
- },
956
- "description": {
957
- "type": "text",
958
- "required": false,
959
- "_meta": {}
960
- },
961
- "amount": {
962
- "type": "integer",
963
- "required": false,
964
- "_meta": {}
965
- },
966
- "currency": {
967
- "type": "text",
968
- "required": false,
969
- "_meta": {}
977
+ "fields": {},
978
+ "methods": {},
979
+ "decoratorConfig": {
980
+ "api": {
981
+ "include": []
970
982
  },
971
- "financialBreakdown": {
972
- "type": "text",
973
- "required": false,
974
- "_meta": {}
983
+ "mcp": {
984
+ "include": []
975
985
  },
976
- "supplierPayableJson": {
977
- "type": "text",
978
- "required": false,
979
- "_meta": {
980
- "nullable": true,
981
- "readonly": true
986
+ "cli": false,
987
+ "tableName": "expense_allocation_revisions"
988
+ },
989
+ "extends": "SmrtCollection",
990
+ "extendsTypeArg": "ExpenseAllocationRevision",
991
+ "exportName": "Revisions",
992
+ "collectionExportName": "RevisionsCollection",
993
+ "collectionOf": "@happyvertical/smrt-expenses:ExpenseAllocationRevision",
994
+ "schema": {
995
+ "tableName": "expense_allocation_revisions",
996
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expense_allocation_revisions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"kind\" TEXT DEFAULT 'allocation',\n \"source_cost_object_type\" TEXT,\n \"source_cost_object_id\" TEXT,\n \"incurred_on\" TEXT,\n \"paid_by\" TEXT DEFAULT 'company',\n \"reimbursable\" BOOLEAN NOT NULL DEFAULT FALSE,\n \"has_supplier_tax\" BOOLEAN,\n \"basis_equals_gross\" BOOLEAN NOT NULL DEFAULT FALSE,\n \"tenant_id\" UUID NOT NULL,\n \"source_expense_id\" UUID NOT NULL,\n \"previous_revision_id\" UUID,\n \"request_id\" TEXT,\n \"request_fingerprint\" TEXT,\n \"source_fingerprint\" TEXT,\n \"source_fingerprint_nonce\" TEXT,\n \"source_revision\" TEXT,\n \"amount_minor\" INTEGER,\n \"currency\" TEXT,\n \"reviewed_by_profile_id\" UUID NOT NULL,\n \"reviewed_by_user_id\" UUID NOT NULL,\n \"review_evidence\" TEXT\n);",
997
+ "columns": {
998
+ "_sync_origin_device_id": {
999
+ "type": "TEXT"
982
1000
  },
983
- "readonly": true
984
- },
985
- "paidByName": {
986
- "type": "text",
987
- "required": false,
988
- "_meta": {}
989
- },
990
- "refundOfId": {
991
- "type": "foreignKey",
992
- "required": false,
993
- "related": "Expense",
994
- "_meta": {
995
- "onDelete": "RESTRICT"
996
- }
997
- },
998
- "refundRecipient": {
999
- "type": "text",
1000
- "required": false,
1001
- "_meta": {}
1002
- },
1003
- "incurredOn": {
1004
- "type": "text",
1005
- "required": false,
1006
- "_meta": {}
1007
- },
1008
- "recordedAt": {
1009
- "type": "datetime",
1010
- "required": false,
1011
- "_meta": {}
1012
- },
1013
- "recordedByProfileId": {
1014
- "type": "crossPackageRef",
1015
- "required": false,
1016
- "related": "PROFILE"
1017
- },
1018
- "paidBy": {
1019
- "type": "text",
1020
- "required": false,
1021
- "_meta": {},
1022
- "enum": [
1023
- "company",
1024
- "person",
1025
- "third-party"
1026
- ]
1027
- },
1028
- "paidByProfileId": {
1029
- "type": "crossPackageRef",
1030
- "required": false,
1031
- "related": "PROFILE"
1032
- },
1033
- "vendorId": {
1034
- "type": "crossPackageRef",
1035
- "required": false,
1036
- "related": "@happyvertical/smrt-commerce:Vendor"
1037
- },
1038
- "commitmentId": {
1039
- "type": "crossPackageRef",
1040
- "required": false,
1041
- "related": "@happyvertical/smrt-commerce:PurchaseContract",
1042
- "_meta": {
1043
- "validateSubtype": true
1044
- }
1045
- },
1046
- "commitmentLineId": {
1047
- "type": "crossPackageRef",
1048
- "required": false,
1049
- "related": "@happyvertical/smrt-commerce:ContractLineItem"
1050
- },
1051
- "reviewStatus": {
1052
- "type": "text",
1053
- "required": false,
1054
- "_meta": {
1055
- "readonly": true
1001
+ "_sync_revision": {
1002
+ "type": "INTEGER"
1056
1003
  },
1057
- "enum": [
1058
- "unreviewed",
1059
- "reviewed",
1060
- "rejected"
1061
- ],
1062
- "readonly": true
1063
- },
1064
- "reviewedByProfileId": {
1065
- "type": "crossPackageRef",
1066
- "required": false,
1067
- "related": "PROFILE"
1068
- },
1069
- "reviewedAt": {
1070
- "type": "datetime",
1071
- "required": false,
1072
- "_meta": {
1073
- "readonly": true
1004
+ "id": {
1005
+ "type": "UUID",
1006
+ "primaryKey": true,
1007
+ "referenceKind": "id",
1008
+ "notNull": true
1074
1009
  },
1075
- "readonly": true
1076
- },
1077
- "reviewNote": {
1078
- "type": "text",
1079
- "required": false,
1080
- "_meta": {
1081
- "readonly": true
1010
+ "slug": {
1011
+ "type": "TEXT",
1012
+ "notNull": true
1082
1013
  },
1083
- "readonly": true
1084
- },
1085
- "duplicateOfId": {
1086
- "type": "foreignKey",
1087
- "required": false,
1088
- "related": "Expense",
1089
- "_meta": {
1090
- "onDelete": "SET NULL"
1091
- }
1092
- },
1093
- "reimbursable": {
1094
- "type": "boolean",
1095
- "required": false,
1096
- "_meta": {}
1097
- },
1098
- "reimbursedAmount": {
1099
- "type": "integer",
1100
- "required": false,
1101
- "_meta": {
1102
- "nullable": true,
1103
- "readonly": true
1014
+ "context": {
1015
+ "type": "TEXT",
1016
+ "notNull": true,
1017
+ "default": ""
1104
1018
  },
1105
- "readonly": true
1106
- },
1107
- "reimbursedAt": {
1108
- "type": "datetime",
1109
- "required": false,
1110
- "_meta": {
1019
+ "created_at": {
1020
+ "type": "TIMESTAMP",
1021
+ "notNull": true,
1022
+ "default": "current_timestamp"
1023
+ },
1024
+ "updated_at": {
1025
+ "type": "TIMESTAMP",
1026
+ "notNull": true,
1027
+ "default": "current_timestamp"
1028
+ },
1029
+ "kind": {
1030
+ "type": "TEXT",
1031
+ "notNull": false,
1032
+ "unique": false,
1033
+ "default": "allocation"
1034
+ },
1035
+ "source_cost_object_type": {
1036
+ "type": "TEXT",
1037
+ "notNull": false,
1038
+ "unique": false
1039
+ },
1040
+ "source_cost_object_id": {
1041
+ "type": "TEXT",
1042
+ "notNull": false,
1043
+ "unique": false
1044
+ },
1045
+ "incurred_on": {
1046
+ "type": "TEXT",
1047
+ "notNull": false,
1048
+ "unique": false
1049
+ },
1050
+ "paid_by": {
1051
+ "type": "TEXT",
1052
+ "notNull": false,
1053
+ "unique": false,
1054
+ "default": "company"
1055
+ },
1056
+ "reimbursable": {
1057
+ "type": "BOOLEAN",
1058
+ "notNull": true,
1059
+ "unique": false,
1060
+ "default": false
1061
+ },
1062
+ "has_supplier_tax": {
1063
+ "type": "BOOLEAN",
1064
+ "notNull": false,
1065
+ "unique": false
1066
+ },
1067
+ "basis_equals_gross": {
1068
+ "type": "BOOLEAN",
1069
+ "notNull": true,
1070
+ "unique": false,
1071
+ "default": false
1072
+ },
1073
+ "tenant_id": {
1074
+ "type": "UUID",
1075
+ "referenceKind": "tenantId",
1076
+ "notNull": true,
1077
+ "unique": false
1078
+ },
1079
+ "source_expense_id": {
1080
+ "type": "UUID",
1081
+ "referenceKind": "foreignKey",
1082
+ "notNull": true,
1083
+ "unique": false,
1084
+ "foreignKey": {
1085
+ "table": "expenses",
1086
+ "column": "id",
1087
+ "onDelete": "RESTRICT",
1088
+ "onUpdate": "CASCADE"
1089
+ }
1090
+ },
1091
+ "previous_revision_id": {
1092
+ "type": "UUID",
1093
+ "referenceKind": "foreignKey",
1094
+ "notNull": false,
1095
+ "unique": false,
1096
+ "foreignKey": {
1097
+ "table": "expense_allocation_revisions",
1098
+ "column": "id",
1099
+ "onDelete": "RESTRICT",
1100
+ "onUpdate": "CASCADE"
1101
+ }
1102
+ },
1103
+ "request_id": {
1104
+ "type": "TEXT",
1105
+ "notNull": false,
1106
+ "unique": false
1107
+ },
1108
+ "request_fingerprint": {
1109
+ "type": "TEXT",
1110
+ "notNull": false,
1111
+ "unique": false
1112
+ },
1113
+ "source_fingerprint": {
1114
+ "type": "TEXT",
1115
+ "notNull": false,
1116
+ "unique": false
1117
+ },
1118
+ "source_fingerprint_nonce": {
1119
+ "type": "TEXT",
1120
+ "notNull": false,
1121
+ "unique": false
1122
+ },
1123
+ "source_revision": {
1124
+ "type": "TEXT",
1125
+ "notNull": false,
1126
+ "unique": false
1127
+ },
1128
+ "amount_minor": {
1129
+ "type": "INTEGER",
1130
+ "notNull": false,
1131
+ "unique": false
1132
+ },
1133
+ "currency": {
1134
+ "type": "TEXT",
1135
+ "notNull": false,
1136
+ "unique": false
1137
+ },
1138
+ "reviewed_by_profile_id": {
1139
+ "type": "UUID",
1140
+ "referenceKind": "crossPackageRef",
1141
+ "notNull": true,
1142
+ "unique": false
1143
+ },
1144
+ "reviewed_by_user_id": {
1145
+ "type": "UUID",
1146
+ "referenceKind": "crossPackageRef",
1147
+ "notNull": true,
1148
+ "unique": false
1149
+ },
1150
+ "review_evidence": {
1151
+ "type": "TEXT",
1152
+ "notNull": false,
1153
+ "unique": false
1154
+ }
1155
+ },
1156
+ "indexes": [
1157
+ {
1158
+ "name": "expense_allocation_revisions_slug_context_idx",
1159
+ "columns": [
1160
+ "tenant_id",
1161
+ "slug",
1162
+ "context"
1163
+ ],
1164
+ "unique": true
1165
+ },
1166
+ {
1167
+ "name": "expense_allocation_request_key",
1168
+ "columns": [
1169
+ "source_expense_id",
1170
+ "request_id"
1171
+ ],
1172
+ "unique": true
1173
+ },
1174
+ {
1175
+ "name": "expense_allocation_revision_successor",
1176
+ "columns": [
1177
+ "previous_revision_id"
1178
+ ],
1179
+ "unique": true
1180
+ },
1181
+ {
1182
+ "name": "expense_allocation_revisions_tenant_id_created_at_idx",
1183
+ "columns": [
1184
+ "tenant_id",
1185
+ "created_at"
1186
+ ]
1187
+ },
1188
+ {
1189
+ "name": "expense_allocation_revisions_reviewed_by_profile_id_idx",
1190
+ "columns": [
1191
+ "reviewed_by_profile_id"
1192
+ ]
1193
+ },
1194
+ {
1195
+ "name": "expense_allocation_revisions_reviewed_by_user_id_idx",
1196
+ "columns": [
1197
+ "reviewed_by_user_id"
1198
+ ]
1199
+ }
1200
+ ],
1201
+ "version": "83425a51"
1202
+ },
1203
+ "importPath": "@happyvertical/smrt-expenses"
1204
+ },
1205
+ "@happyvertical/smrt-expenses:Portions": {
1206
+ "name": "portions",
1207
+ "className": "Portions",
1208
+ "qualifiedName": "@happyvertical/smrt-expenses:Portions",
1209
+ "collection": "expenseallocationportions",
1210
+ "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/expense-allocation.ts",
1211
+ "packageName": "@happyvertical/smrt-expenses",
1212
+ "fields": {},
1213
+ "methods": {},
1214
+ "decoratorConfig": {
1215
+ "api": {
1216
+ "include": []
1217
+ },
1218
+ "mcp": {
1219
+ "include": []
1220
+ },
1221
+ "cli": false,
1222
+ "tableName": "expense_allocation_portions"
1223
+ },
1224
+ "extends": "SmrtCollection",
1225
+ "extendsTypeArg": "ExpenseAllocationPortion",
1226
+ "exportName": "Portions",
1227
+ "collectionExportName": "PortionsCollection",
1228
+ "collectionOf": "@happyvertical/smrt-expenses:ExpenseAllocationPortion",
1229
+ "schema": {
1230
+ "tableName": "expense_allocation_portions",
1231
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expense_allocation_portions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"source_expense_id\" UUID NOT NULL,\n \"revision_id\" UUID NOT NULL,\n \"portion_key\" TEXT,\n \"cost_object_type\" TEXT,\n \"cost_object_id\" TEXT,\n \"cost_code_ref\" TEXT,\n \"amount_minor\" INTEGER,\n \"currency\" TEXT\n);",
1232
+ "columns": {
1233
+ "_sync_origin_device_id": {
1234
+ "type": "TEXT"
1235
+ },
1236
+ "_sync_revision": {
1237
+ "type": "INTEGER"
1238
+ },
1239
+ "id": {
1240
+ "type": "UUID",
1241
+ "primaryKey": true,
1242
+ "referenceKind": "id",
1243
+ "notNull": true
1244
+ },
1245
+ "slug": {
1246
+ "type": "TEXT",
1247
+ "notNull": true
1248
+ },
1249
+ "context": {
1250
+ "type": "TEXT",
1251
+ "notNull": true,
1252
+ "default": ""
1253
+ },
1254
+ "created_at": {
1255
+ "type": "TIMESTAMP",
1256
+ "notNull": true,
1257
+ "default": "current_timestamp"
1258
+ },
1259
+ "updated_at": {
1260
+ "type": "TIMESTAMP",
1261
+ "notNull": true,
1262
+ "default": "current_timestamp"
1263
+ },
1264
+ "tenant_id": {
1265
+ "type": "UUID",
1266
+ "referenceKind": "tenantId",
1267
+ "notNull": true,
1268
+ "unique": false
1269
+ },
1270
+ "source_expense_id": {
1271
+ "type": "UUID",
1272
+ "referenceKind": "foreignKey",
1273
+ "notNull": true,
1274
+ "unique": false,
1275
+ "foreignKey": {
1276
+ "table": "expenses",
1277
+ "column": "id",
1278
+ "onDelete": "RESTRICT",
1279
+ "onUpdate": "CASCADE"
1280
+ }
1281
+ },
1282
+ "revision_id": {
1283
+ "type": "UUID",
1284
+ "referenceKind": "foreignKey",
1285
+ "notNull": true,
1286
+ "unique": false,
1287
+ "foreignKey": {
1288
+ "table": "expense_allocation_revisions",
1289
+ "column": "id",
1290
+ "onDelete": "RESTRICT",
1291
+ "onUpdate": "CASCADE"
1292
+ }
1293
+ },
1294
+ "portion_key": {
1295
+ "type": "TEXT",
1296
+ "notNull": false,
1297
+ "unique": false
1298
+ },
1299
+ "cost_object_type": {
1300
+ "type": "TEXT",
1301
+ "notNull": false,
1302
+ "unique": false
1303
+ },
1304
+ "cost_object_id": {
1305
+ "type": "TEXT",
1306
+ "notNull": false,
1307
+ "unique": false
1308
+ },
1309
+ "cost_code_ref": {
1310
+ "type": "TEXT",
1311
+ "notNull": false,
1312
+ "unique": false
1313
+ },
1314
+ "amount_minor": {
1315
+ "type": "INTEGER",
1316
+ "notNull": false,
1317
+ "unique": false
1318
+ },
1319
+ "currency": {
1320
+ "type": "TEXT",
1321
+ "notNull": false,
1322
+ "unique": false
1323
+ }
1324
+ },
1325
+ "indexes": [
1326
+ {
1327
+ "name": "expense_allocation_portions_slug_context_idx",
1328
+ "columns": [
1329
+ "tenant_id",
1330
+ "slug",
1331
+ "context"
1332
+ ],
1333
+ "unique": true
1334
+ },
1335
+ {
1336
+ "name": "expense_allocation_portion_key",
1337
+ "columns": [
1338
+ "revision_id",
1339
+ "portion_key"
1340
+ ],
1341
+ "unique": true
1342
+ },
1343
+ {
1344
+ "name": "expense_allocation_portions_tenant_id_created_at_idx",
1345
+ "columns": [
1346
+ "tenant_id",
1347
+ "created_at"
1348
+ ]
1349
+ },
1350
+ {
1351
+ "name": "expense_allocation_portions_source_expense_id_idx",
1352
+ "columns": [
1353
+ "source_expense_id"
1354
+ ]
1355
+ }
1356
+ ],
1357
+ "version": "6b0600b1"
1358
+ },
1359
+ "importPath": "@happyvertical/smrt-expenses"
1360
+ },
1361
+ "@happyvertical/smrt-expenses:Billings": {
1362
+ "name": "billings",
1363
+ "className": "Billings",
1364
+ "qualifiedName": "@happyvertical/smrt-expenses:Billings",
1365
+ "collection": "expenseallocationbillings",
1366
+ "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/expense-allocation.ts",
1367
+ "packageName": "@happyvertical/smrt-expenses",
1368
+ "fields": {},
1369
+ "methods": {},
1370
+ "decoratorConfig": {
1371
+ "api": {
1372
+ "include": []
1373
+ },
1374
+ "mcp": {
1375
+ "include": []
1376
+ },
1377
+ "cli": false,
1378
+ "tableName": "expense_allocation_billings"
1379
+ },
1380
+ "extends": "SmrtCollection",
1381
+ "extendsTypeArg": "ExpenseAllocationBilling",
1382
+ "exportName": "Billings",
1383
+ "collectionExportName": "BillingsCollection",
1384
+ "collectionOf": "@happyvertical/smrt-expenses:ExpenseAllocationBilling",
1385
+ "schema": {
1386
+ "tableName": "expense_allocation_billings",
1387
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expense_allocation_billings\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"source_expense_id\" UUID NOT NULL,\n \"portion_id\" UUID NOT NULL,\n \"invoice_id\" UUID,\n \"draft_type\" TEXT,\n \"draft_id\" TEXT,\n \"invoice_line_id\" UUID,\n \"request_id\" TEXT,\n \"request_fingerprint\" TEXT,\n \"related_reservation_id\" UUID,\n \"kind\" TEXT\n);",
1388
+ "columns": {
1389
+ "_sync_origin_device_id": {
1390
+ "type": "TEXT"
1391
+ },
1392
+ "_sync_revision": {
1393
+ "type": "INTEGER"
1394
+ },
1395
+ "id": {
1396
+ "type": "UUID",
1397
+ "primaryKey": true,
1398
+ "referenceKind": "id",
1399
+ "notNull": true
1400
+ },
1401
+ "slug": {
1402
+ "type": "TEXT",
1403
+ "notNull": true
1404
+ },
1405
+ "context": {
1406
+ "type": "TEXT",
1407
+ "notNull": true,
1408
+ "default": ""
1409
+ },
1410
+ "created_at": {
1411
+ "type": "TIMESTAMP",
1412
+ "notNull": true,
1413
+ "default": "current_timestamp"
1414
+ },
1415
+ "updated_at": {
1416
+ "type": "TIMESTAMP",
1417
+ "notNull": true,
1418
+ "default": "current_timestamp"
1419
+ },
1420
+ "tenant_id": {
1421
+ "type": "UUID",
1422
+ "referenceKind": "tenantId",
1423
+ "notNull": true,
1424
+ "unique": false
1425
+ },
1426
+ "source_expense_id": {
1427
+ "type": "UUID",
1428
+ "referenceKind": "foreignKey",
1429
+ "notNull": true,
1430
+ "unique": false,
1431
+ "foreignKey": {
1432
+ "table": "expenses",
1433
+ "column": "id",
1434
+ "onDelete": "RESTRICT",
1435
+ "onUpdate": "CASCADE"
1436
+ }
1437
+ },
1438
+ "portion_id": {
1439
+ "type": "UUID",
1440
+ "referenceKind": "foreignKey",
1441
+ "notNull": true,
1442
+ "unique": false,
1443
+ "foreignKey": {
1444
+ "table": "expense_allocation_portions",
1445
+ "column": "id",
1446
+ "onDelete": "RESTRICT",
1447
+ "onUpdate": "CASCADE"
1448
+ }
1449
+ },
1450
+ "invoice_id": {
1451
+ "type": "UUID",
1452
+ "referenceKind": "crossPackageRef",
1453
+ "notNull": false,
1454
+ "unique": false
1455
+ },
1456
+ "draft_type": {
1457
+ "type": "TEXT",
1458
+ "notNull": false,
1459
+ "unique": false
1460
+ },
1461
+ "draft_id": {
1462
+ "type": "TEXT",
1463
+ "notNull": false,
1464
+ "unique": false
1465
+ },
1466
+ "invoice_line_id": {
1467
+ "type": "UUID",
1468
+ "referenceKind": "crossPackageRef",
1469
+ "notNull": false,
1470
+ "unique": false
1471
+ },
1472
+ "request_id": {
1473
+ "type": "TEXT",
1474
+ "notNull": false,
1475
+ "unique": false
1476
+ },
1477
+ "request_fingerprint": {
1478
+ "type": "TEXT",
1479
+ "notNull": false,
1480
+ "unique": false
1481
+ },
1482
+ "related_reservation_id": {
1483
+ "type": "UUID",
1484
+ "referenceKind": "foreignKey",
1485
+ "notNull": false,
1486
+ "unique": false,
1487
+ "foreignKey": {
1488
+ "table": "expense_allocation_billings",
1489
+ "column": "id",
1490
+ "onDelete": "RESTRICT",
1491
+ "onUpdate": "CASCADE"
1492
+ }
1493
+ },
1494
+ "kind": {
1495
+ "type": "TEXT",
1496
+ "notNull": false,
1497
+ "unique": false
1498
+ }
1499
+ },
1500
+ "indexes": [
1501
+ {
1502
+ "name": "expense_allocation_billings_slug_context_idx",
1503
+ "columns": [
1504
+ "tenant_id",
1505
+ "slug",
1506
+ "context"
1507
+ ],
1508
+ "unique": true
1509
+ },
1510
+ {
1511
+ "name": "expense_allocation_billing_request",
1512
+ "columns": [
1513
+ "source_expense_id",
1514
+ "request_id"
1515
+ ],
1516
+ "unique": true
1517
+ },
1518
+ {
1519
+ "name": "expense_allocation_billing_release",
1520
+ "columns": [
1521
+ "related_reservation_id",
1522
+ "kind"
1523
+ ],
1524
+ "unique": true
1525
+ },
1526
+ {
1527
+ "name": "expense_allocation_billings_tenant_id_created_at_idx",
1528
+ "columns": [
1529
+ "tenant_id",
1530
+ "created_at"
1531
+ ]
1532
+ },
1533
+ {
1534
+ "name": "expense_allocation_billings_portion_id_idx",
1535
+ "columns": [
1536
+ "portion_id"
1537
+ ]
1538
+ },
1539
+ {
1540
+ "name": "expense_allocation_billings_invoice_id_idx",
1541
+ "columns": [
1542
+ "invoice_id"
1543
+ ]
1544
+ },
1545
+ {
1546
+ "name": "expense_allocation_billings_invoice_line_id_idx",
1547
+ "columns": [
1548
+ "invoice_line_id"
1549
+ ]
1550
+ }
1551
+ ],
1552
+ "version": "432aeb1f"
1553
+ },
1554
+ "importPath": "@happyvertical/smrt-expenses"
1555
+ },
1556
+ "@happyvertical/smrt-expenses:Expense": {
1557
+ "name": "expense",
1558
+ "className": "Expense",
1559
+ "qualifiedName": "@happyvertical/smrt-expenses:Expense",
1560
+ "collection": "expenses",
1561
+ "description": "A cost someone incurred.",
1562
+ "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/models/Expense.ts",
1563
+ "packageName": "@happyvertical/smrt-expenses",
1564
+ "fields": {
1565
+ "tenantId": {
1566
+ "type": "text",
1567
+ "required": false,
1568
+ "_meta": {
1569
+ "sqlType": "UUID",
1570
+ "nullable": true,
1571
+ "__tenancy": {
1572
+ "isTenantIdField": true,
1573
+ "autoFilter": true,
1574
+ "required": false,
1575
+ "autoPopulate": true,
1576
+ "nullable": true,
1577
+ "mode": "optional",
1578
+ "field": "tenantId",
1579
+ "allowSuperAdminBypass": false
1580
+ }
1581
+ }
1582
+ },
1583
+ "costObjectType": {
1584
+ "type": "text",
1585
+ "required": false,
1586
+ "_meta": {}
1587
+ },
1588
+ "costObjectId": {
1589
+ "type": "text",
1590
+ "required": false,
1591
+ "_meta": {}
1592
+ },
1593
+ "category": {
1594
+ "type": "text",
1595
+ "required": false,
1596
+ "_meta": {}
1597
+ },
1598
+ "description": {
1599
+ "type": "text",
1600
+ "required": false,
1601
+ "_meta": {}
1602
+ },
1603
+ "amount": {
1604
+ "type": "integer",
1605
+ "required": false,
1606
+ "_meta": {}
1607
+ },
1608
+ "currency": {
1609
+ "type": "text",
1610
+ "required": false,
1611
+ "_meta": {}
1612
+ },
1613
+ "financialBreakdown": {
1614
+ "type": "text",
1615
+ "required": false,
1616
+ "_meta": {}
1617
+ },
1618
+ "supplierPayableJson": {
1619
+ "type": "text",
1620
+ "required": false,
1621
+ "_meta": {
1622
+ "nullable": true,
1623
+ "readonly": true
1624
+ },
1625
+ "readonly": true
1626
+ },
1627
+ "paidByName": {
1628
+ "type": "text",
1629
+ "required": false,
1630
+ "_meta": {}
1631
+ },
1632
+ "refundOfId": {
1633
+ "type": "foreignKey",
1634
+ "required": false,
1635
+ "related": "Expense",
1636
+ "_meta": {
1637
+ "onDelete": "RESTRICT"
1638
+ }
1639
+ },
1640
+ "refundRecipient": {
1641
+ "type": "text",
1642
+ "required": false,
1643
+ "_meta": {}
1644
+ },
1645
+ "incurredOn": {
1646
+ "type": "text",
1647
+ "required": false,
1648
+ "_meta": {}
1649
+ },
1650
+ "recordedAt": {
1651
+ "type": "datetime",
1652
+ "required": false,
1653
+ "_meta": {}
1654
+ },
1655
+ "recordedByProfileId": {
1656
+ "type": "crossPackageRef",
1657
+ "required": false,
1658
+ "related": "PROFILE"
1659
+ },
1660
+ "paidBy": {
1661
+ "type": "text",
1662
+ "required": false,
1663
+ "_meta": {},
1664
+ "enum": [
1665
+ "company",
1666
+ "person",
1667
+ "third-party"
1668
+ ]
1669
+ },
1670
+ "paidByProfileId": {
1671
+ "type": "crossPackageRef",
1672
+ "required": false,
1673
+ "related": "PROFILE"
1674
+ },
1675
+ "vendorId": {
1676
+ "type": "crossPackageRef",
1677
+ "required": false,
1678
+ "related": "@happyvertical/smrt-commerce:Vendor"
1679
+ },
1680
+ "commitmentId": {
1681
+ "type": "crossPackageRef",
1682
+ "required": false,
1683
+ "related": "@happyvertical/smrt-commerce:PurchaseContract",
1684
+ "_meta": {
1685
+ "validateSubtype": true
1686
+ }
1687
+ },
1688
+ "commitmentLineId": {
1689
+ "type": "crossPackageRef",
1690
+ "required": false,
1691
+ "related": "@happyvertical/smrt-commerce:ContractLineItem"
1692
+ },
1693
+ "reviewStatus": {
1694
+ "type": "text",
1695
+ "required": false,
1696
+ "_meta": {
1697
+ "readonly": true
1698
+ },
1699
+ "enum": [
1700
+ "unreviewed",
1701
+ "reviewed",
1702
+ "rejected"
1703
+ ],
1704
+ "readonly": true
1705
+ },
1706
+ "reviewedByProfileId": {
1707
+ "type": "crossPackageRef",
1708
+ "required": false,
1709
+ "related": "PROFILE"
1710
+ },
1711
+ "reviewedAt": {
1712
+ "type": "datetime",
1713
+ "required": false,
1714
+ "_meta": {
1715
+ "readonly": true
1716
+ },
1717
+ "readonly": true
1718
+ },
1719
+ "reviewNote": {
1720
+ "type": "text",
1721
+ "required": false,
1722
+ "_meta": {
1723
+ "readonly": true
1724
+ },
1725
+ "readonly": true
1726
+ },
1727
+ "duplicateOfId": {
1728
+ "type": "foreignKey",
1729
+ "required": false,
1730
+ "related": "Expense",
1731
+ "_meta": {
1732
+ "onDelete": "SET NULL"
1733
+ }
1734
+ },
1735
+ "reimbursable": {
1736
+ "type": "boolean",
1737
+ "required": false,
1738
+ "_meta": {}
1739
+ },
1740
+ "reimbursedAmount": {
1741
+ "type": "integer",
1742
+ "required": false,
1743
+ "_meta": {
1744
+ "nullable": true,
1745
+ "readonly": true
1746
+ },
1747
+ "readonly": true
1748
+ },
1749
+ "reimbursedAt": {
1750
+ "type": "datetime",
1751
+ "required": false,
1752
+ "_meta": {
1753
+ "readonly": true
1754
+ },
1755
+ "readonly": true
1756
+ },
1757
+ "reimbursementReference": {
1758
+ "type": "text",
1759
+ "required": false,
1760
+ "_meta": {
1111
1761
  "readonly": true
1112
1762
  },
1113
- "readonly": true
1763
+ "readonly": true
1764
+ },
1765
+ "activeAllocationRevisionId": {
1766
+ "type": "foreignKey",
1767
+ "required": false,
1768
+ "related": "ExpenseAllocationRevision",
1769
+ "_meta": {
1770
+ "readonly": true,
1771
+ "nullable": true,
1772
+ "onDelete": "RESTRICT"
1773
+ },
1774
+ "readonly": true
1775
+ }
1776
+ },
1777
+ "methods": {
1778
+ "getFinancialBreakdown": {
1779
+ "name": "getFinancialBreakdown",
1780
+ "async": false,
1781
+ "parameters": [],
1782
+ "returnType": "ExpenseFinancialBreakdown | null",
1783
+ "isStatic": false,
1784
+ "isPublic": true
1785
+ },
1786
+ "setFinancialBreakdown": {
1787
+ "name": "setFinancialBreakdown",
1788
+ "async": false,
1789
+ "parameters": [
1790
+ {
1791
+ "name": "value",
1792
+ "type": "ExpenseFinancialBreakdown | null",
1793
+ "optional": false,
1794
+ "unionBranches": [
1795
+ {
1796
+ "type": "ExpenseFinancialBreakdown"
1797
+ },
1798
+ {
1799
+ "type": "null"
1800
+ }
1801
+ ]
1802
+ }
1803
+ ],
1804
+ "returnType": "void",
1805
+ "isStatic": false,
1806
+ "isPublic": true
1807
+ },
1808
+ "getRefundRecipient": {
1809
+ "name": "getRefundRecipient",
1810
+ "async": false,
1811
+ "parameters": [],
1812
+ "returnType": "ExpenseRefundRecipient | null",
1813
+ "isStatic": false,
1814
+ "isPublic": true
1815
+ },
1816
+ "setRefundRecipient": {
1817
+ "name": "setRefundRecipient",
1818
+ "async": false,
1819
+ "parameters": [
1820
+ {
1821
+ "name": "value",
1822
+ "type": "ExpenseRefundRecipient | null",
1823
+ "optional": false,
1824
+ "unionBranches": [
1825
+ {
1826
+ "type": "ExpenseRefundRecipient"
1827
+ },
1828
+ {
1829
+ "type": "null"
1830
+ }
1831
+ ]
1832
+ }
1833
+ ],
1834
+ "returnType": "void",
1835
+ "isStatic": false,
1836
+ "isPublic": true
1837
+ },
1838
+ "getCostBasis": {
1839
+ "name": "getCostBasis",
1840
+ "async": false,
1841
+ "parameters": [],
1842
+ "returnType": "ExpenseCostBasis | null",
1843
+ "isStatic": false,
1844
+ "isPublic": true
1845
+ },
1846
+ "isReimbursed": {
1847
+ "name": "isReimbursed",
1848
+ "async": false,
1849
+ "parameters": [],
1850
+ "returnType": "boolean",
1851
+ "isStatic": false,
1852
+ "isPublic": true
1853
+ },
1854
+ "isCountable": {
1855
+ "name": "isCountable",
1856
+ "async": false,
1857
+ "parameters": [],
1858
+ "returnType": "boolean",
1859
+ "isStatic": false,
1860
+ "isPublic": true
1861
+ },
1862
+ "review": {
1863
+ "name": "review",
1864
+ "async": true,
1865
+ "parameters": [
1866
+ {
1867
+ "name": "input",
1868
+ "type": "ReviewExpenseInput",
1869
+ "optional": false
1870
+ }
1871
+ ],
1872
+ "returnType": "Promise<this>",
1873
+ "isStatic": false,
1874
+ "isPublic": true
1875
+ },
1876
+ "reject": {
1877
+ "name": "reject",
1878
+ "async": true,
1879
+ "parameters": [
1880
+ {
1881
+ "name": "input",
1882
+ "type": "RejectExpenseInput",
1883
+ "optional": false
1884
+ }
1885
+ ],
1886
+ "returnType": "Promise<this>",
1887
+ "isStatic": false,
1888
+ "isPublic": true
1889
+ },
1890
+ "markDuplicate": {
1891
+ "name": "markDuplicate",
1892
+ "async": true,
1893
+ "parameters": [
1894
+ {
1895
+ "name": "input",
1896
+ "type": "MarkDuplicateExpenseInput",
1897
+ "optional": false
1898
+ }
1899
+ ],
1900
+ "returnType": "Promise<this>",
1901
+ "isStatic": false,
1902
+ "isPublic": true
1903
+ },
1904
+ "reopen": {
1905
+ "name": "reopen",
1906
+ "async": true,
1907
+ "parameters": [
1908
+ {
1909
+ "name": "input",
1910
+ "type": "ReopenExpenseInput",
1911
+ "optional": false
1912
+ }
1913
+ ],
1914
+ "returnType": "Promise<this>",
1915
+ "isStatic": false,
1916
+ "isPublic": true
1917
+ },
1918
+ "markReimbursed": {
1919
+ "name": "markReimbursed",
1920
+ "async": true,
1921
+ "parameters": [
1922
+ {
1923
+ "name": "input",
1924
+ "type": "MarkReimbursedInput",
1925
+ "optional": true
1926
+ }
1927
+ ],
1928
+ "returnType": "Promise<this>",
1929
+ "isStatic": false,
1930
+ "isPublic": true
1931
+ },
1932
+ "getCostObject": {
1933
+ "name": "getCostObject",
1934
+ "async": true,
1935
+ "parameters": [],
1936
+ "returnType": "Promise<T | null>",
1937
+ "isStatic": false,
1938
+ "isPublic": true
1939
+ },
1940
+ "save": {
1941
+ "name": "save",
1942
+ "async": true,
1943
+ "parameters": [
1944
+ {
1945
+ "name": "options",
1946
+ "type": "SmrtSaveOptions",
1947
+ "optional": true
1948
+ }
1949
+ ],
1950
+ "returnType": "Promise<this>",
1951
+ "isStatic": false,
1952
+ "isPublic": true
1953
+ },
1954
+ "recordSupplierPayable": {
1955
+ "name": "recordSupplierPayable",
1956
+ "async": true,
1957
+ "parameters": [
1958
+ {
1959
+ "name": "input",
1960
+ "type": "RecordSupplierPayableInput",
1961
+ "optional": false
1962
+ }
1963
+ ],
1964
+ "returnType": "Promise<SupplierPayablePosition>",
1965
+ "isStatic": false,
1966
+ "isPublic": true
1967
+ },
1968
+ "recordSupplierPayableEvent": {
1969
+ "name": "recordSupplierPayableEvent",
1970
+ "async": true,
1971
+ "parameters": [
1972
+ {
1973
+ "name": "input",
1974
+ "type": "RecordSupplierPayableEventInput",
1975
+ "optional": false
1976
+ }
1977
+ ],
1978
+ "returnType": "Promise<SupplierPayablePosition>",
1979
+ "isStatic": false,
1980
+ "isPublic": true
1981
+ },
1982
+ "completeSupplierPayableBasis": {
1983
+ "name": "completeSupplierPayableBasis",
1984
+ "async": true,
1985
+ "parameters": [
1986
+ {
1987
+ "name": "input",
1988
+ "type": "CompleteSupplierPayableBasisInput",
1989
+ "optional": false
1990
+ }
1991
+ ],
1992
+ "returnType": "Promise<SupplierPayablePosition>",
1993
+ "isStatic": false,
1994
+ "isPublic": true
1995
+ },
1996
+ "getSupplierPayablePosition": {
1997
+ "name": "getSupplierPayablePosition",
1998
+ "async": true,
1999
+ "parameters": [
2000
+ {
2001
+ "name": "input",
2002
+ "type": "object",
2003
+ "optional": true,
2004
+ "memberTypes": [
2005
+ "string"
2006
+ ]
2007
+ }
2008
+ ],
2009
+ "returnType": "Promise<SupplierPayablePosition | null>",
2010
+ "isStatic": false,
2011
+ "isPublic": true
2012
+ },
2013
+ "delete": {
2014
+ "name": "delete",
2015
+ "async": true,
2016
+ "parameters": [
2017
+ {
2018
+ "name": "options",
2019
+ "type": "object",
2020
+ "optional": true,
2021
+ "memberTypes": [
2022
+ "Date | string"
2023
+ ]
2024
+ }
2025
+ ],
2026
+ "returnType": "Promise<void>",
2027
+ "isStatic": false,
2028
+ "isPublic": true
2029
+ },
2030
+ "getReimbursementPosition": {
2031
+ "name": "getReimbursementPosition",
2032
+ "async": true,
2033
+ "parameters": [],
2034
+ "returnType": "Promise<ExpenseReimbursementPosition>",
2035
+ "isStatic": false,
2036
+ "isPublic": true
2037
+ },
2038
+ "getRefundPosition": {
2039
+ "name": "getRefundPosition",
2040
+ "async": true,
2041
+ "parameters": [],
2042
+ "returnType": "Promise<ExpenseRefundPosition>",
2043
+ "isStatic": false,
2044
+ "isPublic": true
2045
+ }
2046
+ },
2047
+ "decoratorConfig": {
2048
+ "tableName": "expenses",
2049
+ "api": {
2050
+ "include": [
2051
+ "record",
2052
+ "attachReceipt",
2053
+ "recordReview",
2054
+ "recordReimbursement"
2055
+ ]
2056
+ },
2057
+ "mcp": {
2058
+ "include": []
2059
+ },
2060
+ "cli": false,
2061
+ "indexes": [
2062
+ {
2063
+ "name": "expenses_cost_object_idx",
2064
+ "columns": [
2065
+ "tenantId",
2066
+ "costObjectType",
2067
+ "costObjectId",
2068
+ "incurredOn"
2069
+ ]
2070
+ },
2071
+ {
2072
+ "name": "expenses_commitment_review_idx",
2073
+ "columns": [
2074
+ "tenantId",
2075
+ "commitmentId",
2076
+ "reviewStatus"
2077
+ ]
2078
+ },
2079
+ {
2080
+ "name": "expenses_review_status_idx",
2081
+ "columns": [
2082
+ "tenantId",
2083
+ "reviewStatus",
2084
+ "incurredOn"
2085
+ ]
2086
+ }
2087
+ ],
2088
+ "tenantScoped": {
2089
+ "mode": "optional"
2090
+ },
2091
+ "conflictColumns": [
2092
+ "tenant_id",
2093
+ "slug",
2094
+ "context"
2095
+ ]
2096
+ },
2097
+ "extends": "SmrtObject",
2098
+ "exportName": "Expense",
2099
+ "collectionExportName": "ExpenseCollection",
2100
+ "schema": {
2101
+ "tableName": "expenses",
2102
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expenses\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"cost_object_type\" TEXT,\n \"cost_object_id\" TEXT,\n \"category\" TEXT,\n \"description\" TEXT,\n \"amount\" INTEGER,\n \"currency\" TEXT,\n \"financial_breakdown\" TEXT,\n \"supplier_payable_json\" TEXT,\n \"paid_by_name\" TEXT,\n \"refund_of_id\" UUID,\n \"refund_recipient\" TEXT,\n \"incurred_on\" TEXT,\n \"recorded_at\" TIMESTAMP,\n \"recorded_by_profile_id\" UUID,\n \"paid_by\" TEXT,\n \"paid_by_profile_id\" UUID,\n \"vendor_id\" UUID,\n \"commitment_id\" UUID,\n \"commitment_line_id\" UUID,\n \"review_status\" TEXT,\n \"reviewed_by_profile_id\" UUID,\n \"reviewed_at\" TIMESTAMP,\n \"review_note\" TEXT,\n \"duplicate_of_id\" UUID,\n \"reimbursable\" BOOLEAN,\n \"reimbursed_amount\" INTEGER,\n \"reimbursed_at\" TIMESTAMP,\n \"reimbursement_reference\" TEXT,\n \"active_allocation_revision_id\" UUID\n);",
2103
+ "columns": {
2104
+ "_sync_origin_device_id": {
2105
+ "type": "TEXT"
2106
+ },
2107
+ "_sync_revision": {
2108
+ "type": "INTEGER"
2109
+ },
2110
+ "id": {
2111
+ "type": "UUID",
2112
+ "primaryKey": true,
2113
+ "referenceKind": "id",
2114
+ "notNull": true
2115
+ },
2116
+ "slug": {
2117
+ "type": "TEXT",
2118
+ "notNull": true
2119
+ },
2120
+ "context": {
2121
+ "type": "TEXT",
2122
+ "notNull": true,
2123
+ "default": ""
2124
+ },
2125
+ "created_at": {
2126
+ "type": "TIMESTAMP",
2127
+ "notNull": true,
2128
+ "default": "current_timestamp"
2129
+ },
2130
+ "updated_at": {
2131
+ "type": "TIMESTAMP",
2132
+ "notNull": true,
2133
+ "default": "current_timestamp"
2134
+ },
2135
+ "tenant_id": {
2136
+ "type": "UUID",
2137
+ "referenceKind": "tenantId",
2138
+ "notNull": false,
2139
+ "unique": false
2140
+ },
2141
+ "cost_object_type": {
2142
+ "type": "TEXT",
2143
+ "notNull": false,
2144
+ "unique": false
2145
+ },
2146
+ "cost_object_id": {
2147
+ "type": "TEXT",
2148
+ "notNull": false,
2149
+ "unique": false
2150
+ },
2151
+ "category": {
2152
+ "type": "TEXT",
2153
+ "notNull": false,
2154
+ "unique": false
2155
+ },
2156
+ "description": {
2157
+ "type": "TEXT",
2158
+ "notNull": false,
2159
+ "unique": false
2160
+ },
2161
+ "amount": {
2162
+ "type": "INTEGER",
2163
+ "notNull": false,
2164
+ "unique": false
2165
+ },
2166
+ "currency": {
2167
+ "type": "TEXT",
2168
+ "notNull": false,
2169
+ "unique": false
2170
+ },
2171
+ "financial_breakdown": {
2172
+ "type": "TEXT",
2173
+ "notNull": false,
2174
+ "unique": false
2175
+ },
2176
+ "supplier_payable_json": {
2177
+ "type": "TEXT",
2178
+ "notNull": false,
2179
+ "unique": false
2180
+ },
2181
+ "paid_by_name": {
2182
+ "type": "TEXT",
2183
+ "notNull": false,
2184
+ "unique": false
2185
+ },
2186
+ "refund_of_id": {
2187
+ "type": "UUID",
2188
+ "referenceKind": "foreignKey",
2189
+ "notNull": false,
2190
+ "unique": false,
2191
+ "foreignKey": {
2192
+ "table": "expenses",
2193
+ "column": "id",
2194
+ "onDelete": "RESTRICT",
2195
+ "onUpdate": "CASCADE"
2196
+ }
2197
+ },
2198
+ "refund_recipient": {
2199
+ "type": "TEXT",
2200
+ "notNull": false,
2201
+ "unique": false
2202
+ },
2203
+ "incurred_on": {
2204
+ "type": "TEXT",
2205
+ "notNull": false,
2206
+ "unique": false
2207
+ },
2208
+ "recorded_at": {
2209
+ "type": "TIMESTAMP",
2210
+ "notNull": false,
2211
+ "unique": false
2212
+ },
2213
+ "recorded_by_profile_id": {
2214
+ "type": "UUID",
2215
+ "referenceKind": "crossPackageRef",
2216
+ "notNull": false,
2217
+ "unique": false
2218
+ },
2219
+ "paid_by": {
2220
+ "type": "TEXT",
2221
+ "notNull": false,
2222
+ "unique": false
2223
+ },
2224
+ "paid_by_profile_id": {
2225
+ "type": "UUID",
2226
+ "referenceKind": "crossPackageRef",
2227
+ "notNull": false,
2228
+ "unique": false
2229
+ },
2230
+ "vendor_id": {
2231
+ "type": "UUID",
2232
+ "referenceKind": "crossPackageRef",
2233
+ "notNull": false,
2234
+ "unique": false
2235
+ },
2236
+ "commitment_id": {
2237
+ "type": "UUID",
2238
+ "referenceKind": "crossPackageRef",
2239
+ "notNull": false,
2240
+ "unique": false
2241
+ },
2242
+ "commitment_line_id": {
2243
+ "type": "UUID",
2244
+ "referenceKind": "crossPackageRef",
2245
+ "notNull": false,
2246
+ "unique": false
2247
+ },
2248
+ "review_status": {
2249
+ "type": "TEXT",
2250
+ "notNull": false,
2251
+ "unique": false
2252
+ },
2253
+ "reviewed_by_profile_id": {
2254
+ "type": "UUID",
2255
+ "referenceKind": "crossPackageRef",
2256
+ "notNull": false,
2257
+ "unique": false
2258
+ },
2259
+ "reviewed_at": {
2260
+ "type": "TIMESTAMP",
2261
+ "notNull": false,
2262
+ "unique": false
2263
+ },
2264
+ "review_note": {
2265
+ "type": "TEXT",
2266
+ "notNull": false,
2267
+ "unique": false
2268
+ },
2269
+ "duplicate_of_id": {
2270
+ "type": "UUID",
2271
+ "referenceKind": "foreignKey",
2272
+ "notNull": false,
2273
+ "unique": false,
2274
+ "foreignKey": {
2275
+ "table": "expenses",
2276
+ "column": "id",
2277
+ "onDelete": "SET NULL",
2278
+ "onUpdate": "CASCADE"
2279
+ }
2280
+ },
2281
+ "reimbursable": {
2282
+ "type": "BOOLEAN",
2283
+ "notNull": false,
2284
+ "unique": false
2285
+ },
2286
+ "reimbursed_amount": {
2287
+ "type": "INTEGER",
2288
+ "notNull": false,
2289
+ "unique": false
2290
+ },
2291
+ "reimbursed_at": {
2292
+ "type": "TIMESTAMP",
2293
+ "notNull": false,
2294
+ "unique": false
2295
+ },
2296
+ "reimbursement_reference": {
2297
+ "type": "TEXT",
2298
+ "notNull": false,
2299
+ "unique": false
2300
+ },
2301
+ "active_allocation_revision_id": {
2302
+ "type": "UUID",
2303
+ "referenceKind": "foreignKey",
2304
+ "notNull": false,
2305
+ "unique": false,
2306
+ "foreignKey": {
2307
+ "table": "expense_allocation_revisions",
2308
+ "column": "id",
2309
+ "onDelete": "RESTRICT",
2310
+ "onUpdate": "CASCADE"
2311
+ }
2312
+ }
2313
+ },
2314
+ "indexes": [
2315
+ {
2316
+ "name": "expenses_slug_context_idx",
2317
+ "columns": [
2318
+ "tenant_id",
2319
+ "slug",
2320
+ "context"
2321
+ ],
2322
+ "unique": true,
2323
+ "nullsNotDistinct": true
2324
+ },
2325
+ {
2326
+ "name": "expenses_cost_object_idx",
2327
+ "columns": [
2328
+ "tenant_id",
2329
+ "cost_object_type",
2330
+ "cost_object_id",
2331
+ "incurred_on"
2332
+ ]
2333
+ },
2334
+ {
2335
+ "name": "expenses_commitment_review_idx",
2336
+ "columns": [
2337
+ "tenant_id",
2338
+ "commitment_id",
2339
+ "review_status"
2340
+ ]
2341
+ },
2342
+ {
2343
+ "name": "expenses_review_status_idx",
2344
+ "columns": [
2345
+ "tenant_id",
2346
+ "review_status",
2347
+ "incurred_on"
2348
+ ]
2349
+ },
2350
+ {
2351
+ "name": "expenses_tenant_id_created_at_idx",
2352
+ "columns": [
2353
+ "tenant_id",
2354
+ "created_at"
2355
+ ]
2356
+ },
2357
+ {
2358
+ "name": "expenses_refund_of_id_idx",
2359
+ "columns": [
2360
+ "refund_of_id"
2361
+ ]
2362
+ },
2363
+ {
2364
+ "name": "expenses_recorded_by_profile_id_idx",
2365
+ "columns": [
2366
+ "recorded_by_profile_id"
2367
+ ]
2368
+ },
2369
+ {
2370
+ "name": "expenses_paid_by_profile_id_idx",
2371
+ "columns": [
2372
+ "paid_by_profile_id"
2373
+ ]
2374
+ },
2375
+ {
2376
+ "name": "expenses_vendor_id_idx",
2377
+ "columns": [
2378
+ "vendor_id"
2379
+ ]
2380
+ },
2381
+ {
2382
+ "name": "expenses_commitment_id_idx",
2383
+ "columns": [
2384
+ "commitment_id"
2385
+ ]
2386
+ },
2387
+ {
2388
+ "name": "expenses_commitment_line_id_idx",
2389
+ "columns": [
2390
+ "commitment_line_id"
2391
+ ]
2392
+ },
2393
+ {
2394
+ "name": "expenses_reviewed_by_profile_id_idx",
2395
+ "columns": [
2396
+ "reviewed_by_profile_id"
2397
+ ]
2398
+ },
2399
+ {
2400
+ "name": "expenses_duplicate_of_id_idx",
2401
+ "columns": [
2402
+ "duplicate_of_id"
2403
+ ]
2404
+ },
2405
+ {
2406
+ "name": "expenses_active_allocation_revision_id_idx",
2407
+ "columns": [
2408
+ "active_allocation_revision_id"
2409
+ ]
2410
+ }
2411
+ ],
2412
+ "version": "f8413307"
2413
+ },
2414
+ "importPath": "@happyvertical/smrt-expenses"
2415
+ },
2416
+ "@happyvertical/smrt-expenses:ExpenseAllocationRevision": {
2417
+ "name": "expenseallocationrevision",
2418
+ "className": "ExpenseAllocationRevision",
2419
+ "qualifiedName": "@happyvertical/smrt-expenses:ExpenseAllocationRevision",
2420
+ "collection": "expenseallocationrevisions",
2421
+ "description": "Persisted command-owned ExpenseAllocationRevision evidence.",
2422
+ "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseAllocation.ts",
2423
+ "packageName": "@happyvertical/smrt-expenses",
2424
+ "fields": {
2425
+ "kind": {
2426
+ "type": "text",
2427
+ "required": false,
2428
+ "default": "allocation",
2429
+ "enum": [
2430
+ "allocation",
2431
+ "withdrawal"
2432
+ ]
2433
+ },
2434
+ "sourceCostObjectType": {
2435
+ "type": "text",
2436
+ "required": false
2437
+ },
2438
+ "sourceCostObjectId": {
2439
+ "type": "text",
2440
+ "required": false
2441
+ },
2442
+ "incurredOn": {
2443
+ "type": "text",
2444
+ "required": false
2445
+ },
2446
+ "paidBy": {
2447
+ "type": "text",
2448
+ "required": false,
2449
+ "default": "company",
2450
+ "enum": [
2451
+ "company",
2452
+ "person",
2453
+ "third-party"
2454
+ ]
2455
+ },
2456
+ "reimbursable": {
2457
+ "type": "boolean",
2458
+ "required": true,
2459
+ "default": false
2460
+ },
2461
+ "hasSupplierTax": {
2462
+ "type": "boolean",
2463
+ "required": false,
2464
+ "_meta": {
2465
+ "nullable": true
2466
+ }
2467
+ },
2468
+ "basisEqualsGross": {
2469
+ "type": "boolean",
2470
+ "required": true,
2471
+ "default": false
2472
+ },
2473
+ "tenantId": {
2474
+ "type": "text",
2475
+ "required": true,
2476
+ "_meta": {
2477
+ "sqlType": "UUID",
2478
+ "__tenancy": {
2479
+ "isTenantIdField": true,
2480
+ "autoFilter": true,
2481
+ "required": true,
2482
+ "autoPopulate": true,
2483
+ "nullable": false,
2484
+ "mode": "required",
2485
+ "field": "tenantId",
2486
+ "allowSuperAdminBypass": false
2487
+ }
2488
+ }
2489
+ },
2490
+ "sourceExpenseId": {
2491
+ "type": "foreignKey",
2492
+ "required": true,
2493
+ "related": "Expense",
2494
+ "_meta": {
2495
+ "required": true,
2496
+ "onDelete": "RESTRICT"
2497
+ }
2498
+ },
2499
+ "previousRevisionId": {
2500
+ "type": "foreignKey",
2501
+ "required": false,
2502
+ "related": "ExpenseAllocationRevision",
2503
+ "_meta": {
2504
+ "nullable": true,
2505
+ "onDelete": "RESTRICT"
2506
+ }
2507
+ },
2508
+ "requestId": {
2509
+ "type": "text",
2510
+ "required": false
2511
+ },
2512
+ "requestFingerprint": {
2513
+ "type": "text",
2514
+ "required": false
2515
+ },
2516
+ "sourceFingerprint": {
2517
+ "type": "text",
2518
+ "required": false
2519
+ },
2520
+ "sourceFingerprintNonce": {
2521
+ "type": "text",
2522
+ "required": false
2523
+ },
2524
+ "sourceRevision": {
2525
+ "type": "text",
2526
+ "required": false
2527
+ },
2528
+ "amountMinor": {
2529
+ "type": "integer",
2530
+ "required": false,
2531
+ "_meta": {}
2532
+ },
2533
+ "currency": {
2534
+ "type": "text",
2535
+ "required": false
2536
+ },
2537
+ "reviewedByProfileId": {
2538
+ "type": "crossPackageRef",
2539
+ "required": true,
2540
+ "related": "@happyvertical/smrt-profiles:Profile"
2541
+ },
2542
+ "reviewedByUserId": {
2543
+ "type": "crossPackageRef",
2544
+ "required": true,
2545
+ "related": "@happyvertical/smrt-users:User"
2546
+ },
2547
+ "reviewEvidence": {
2548
+ "type": "text",
2549
+ "required": false
2550
+ }
2551
+ },
2552
+ "methods": {
2553
+ "save": {
2554
+ "name": "save",
2555
+ "async": true,
2556
+ "parameters": [
2557
+ {
2558
+ "name": "options",
2559
+ "type": "SmrtSaveOptions",
2560
+ "optional": true
2561
+ }
2562
+ ],
2563
+ "returnType": "Promise<this>",
2564
+ "isStatic": false,
2565
+ "isPublic": true
2566
+ },
2567
+ "delete": {
2568
+ "name": "delete",
2569
+ "async": true,
2570
+ "parameters": [],
2571
+ "returnType": "Promise<void>",
2572
+ "isStatic": false,
2573
+ "isPublic": true
2574
+ }
2575
+ },
2576
+ "decoratorConfig": {
2577
+ "tableName": "expense_allocation_revisions",
2578
+ "api": {
2579
+ "include": []
2580
+ },
2581
+ "mcp": {
2582
+ "include": []
2583
+ },
2584
+ "cli": false,
2585
+ "indexes": [
2586
+ {
2587
+ "name": "expense_allocation_request_key",
2588
+ "columns": [
2589
+ "sourceExpenseId",
2590
+ "requestId"
2591
+ ],
2592
+ "unique": true
2593
+ },
2594
+ {
2595
+ "name": "expense_allocation_revision_successor",
2596
+ "columns": [
2597
+ "previousRevisionId"
2598
+ ],
2599
+ "unique": true
2600
+ }
2601
+ ],
2602
+ "tenantScoped": {
2603
+ "mode": "required"
2604
+ },
2605
+ "conflictColumns": [
2606
+ "tenant_id",
2607
+ "slug",
2608
+ "context"
2609
+ ]
2610
+ },
2611
+ "extends": "SmrtObject",
2612
+ "exportName": "ExpenseAllocationRevision",
2613
+ "collectionExportName": "ExpenseAllocationRevisionCollection",
2614
+ "validationRules": [
2615
+ {
2616
+ "field": "reimbursable",
2617
+ "rule": "required",
2618
+ "fieldType": "boolean"
2619
+ },
2620
+ {
2621
+ "field": "basisEqualsGross",
2622
+ "rule": "required",
2623
+ "fieldType": "boolean"
2624
+ },
2625
+ {
2626
+ "field": "sourceExpenseId",
2627
+ "rule": "required",
2628
+ "fieldType": "foreignKey"
2629
+ },
2630
+ {
2631
+ "field": "reviewedByProfileId",
2632
+ "rule": "required",
2633
+ "fieldType": "crossPackageRef"
2634
+ },
2635
+ {
2636
+ "field": "reviewedByUserId",
2637
+ "rule": "required",
2638
+ "fieldType": "crossPackageRef"
2639
+ }
2640
+ ],
2641
+ "schema": {
2642
+ "tableName": "expense_allocation_revisions",
2643
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expense_allocation_revisions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"kind\" TEXT DEFAULT 'allocation',\n \"source_cost_object_type\" TEXT,\n \"source_cost_object_id\" TEXT,\n \"incurred_on\" TEXT,\n \"paid_by\" TEXT DEFAULT 'company',\n \"reimbursable\" BOOLEAN NOT NULL DEFAULT FALSE,\n \"has_supplier_tax\" BOOLEAN,\n \"basis_equals_gross\" BOOLEAN NOT NULL DEFAULT FALSE,\n \"tenant_id\" UUID NOT NULL,\n \"source_expense_id\" UUID NOT NULL,\n \"previous_revision_id\" UUID,\n \"request_id\" TEXT,\n \"request_fingerprint\" TEXT,\n \"source_fingerprint\" TEXT,\n \"source_fingerprint_nonce\" TEXT,\n \"source_revision\" TEXT,\n \"amount_minor\" INTEGER,\n \"currency\" TEXT,\n \"reviewed_by_profile_id\" UUID NOT NULL,\n \"reviewed_by_user_id\" UUID NOT NULL,\n \"review_evidence\" TEXT\n);",
2644
+ "columns": {
2645
+ "_sync_origin_device_id": {
2646
+ "type": "TEXT"
2647
+ },
2648
+ "_sync_revision": {
2649
+ "type": "INTEGER"
2650
+ },
2651
+ "id": {
2652
+ "type": "UUID",
2653
+ "primaryKey": true,
2654
+ "referenceKind": "id",
2655
+ "notNull": true
2656
+ },
2657
+ "slug": {
2658
+ "type": "TEXT",
2659
+ "notNull": true
2660
+ },
2661
+ "context": {
2662
+ "type": "TEXT",
2663
+ "notNull": true,
2664
+ "default": ""
2665
+ },
2666
+ "created_at": {
2667
+ "type": "TIMESTAMP",
2668
+ "notNull": true,
2669
+ "default": "current_timestamp"
2670
+ },
2671
+ "updated_at": {
2672
+ "type": "TIMESTAMP",
2673
+ "notNull": true,
2674
+ "default": "current_timestamp"
2675
+ },
2676
+ "kind": {
2677
+ "type": "TEXT",
2678
+ "notNull": false,
2679
+ "unique": false,
2680
+ "default": "allocation"
2681
+ },
2682
+ "source_cost_object_type": {
2683
+ "type": "TEXT",
2684
+ "notNull": false,
2685
+ "unique": false
2686
+ },
2687
+ "source_cost_object_id": {
2688
+ "type": "TEXT",
2689
+ "notNull": false,
2690
+ "unique": false
2691
+ },
2692
+ "incurred_on": {
2693
+ "type": "TEXT",
2694
+ "notNull": false,
2695
+ "unique": false
2696
+ },
2697
+ "paid_by": {
2698
+ "type": "TEXT",
2699
+ "notNull": false,
2700
+ "unique": false,
2701
+ "default": "company"
2702
+ },
2703
+ "reimbursable": {
2704
+ "type": "BOOLEAN",
2705
+ "notNull": true,
2706
+ "unique": false,
2707
+ "default": false
2708
+ },
2709
+ "has_supplier_tax": {
2710
+ "type": "BOOLEAN",
2711
+ "notNull": false,
2712
+ "unique": false
2713
+ },
2714
+ "basis_equals_gross": {
2715
+ "type": "BOOLEAN",
2716
+ "notNull": true,
2717
+ "unique": false,
2718
+ "default": false
2719
+ },
2720
+ "tenant_id": {
2721
+ "type": "UUID",
2722
+ "referenceKind": "tenantId",
2723
+ "notNull": true,
2724
+ "unique": false
2725
+ },
2726
+ "source_expense_id": {
2727
+ "type": "UUID",
2728
+ "referenceKind": "foreignKey",
2729
+ "notNull": true,
2730
+ "unique": false,
2731
+ "foreignKey": {
2732
+ "table": "expenses",
2733
+ "column": "id",
2734
+ "onDelete": "RESTRICT",
2735
+ "onUpdate": "CASCADE"
2736
+ }
2737
+ },
2738
+ "previous_revision_id": {
2739
+ "type": "UUID",
2740
+ "referenceKind": "foreignKey",
2741
+ "notNull": false,
2742
+ "unique": false,
2743
+ "foreignKey": {
2744
+ "table": "expense_allocation_revisions",
2745
+ "column": "id",
2746
+ "onDelete": "RESTRICT",
2747
+ "onUpdate": "CASCADE"
2748
+ }
2749
+ },
2750
+ "request_id": {
2751
+ "type": "TEXT",
2752
+ "notNull": false,
2753
+ "unique": false
2754
+ },
2755
+ "request_fingerprint": {
2756
+ "type": "TEXT",
2757
+ "notNull": false,
2758
+ "unique": false
2759
+ },
2760
+ "source_fingerprint": {
2761
+ "type": "TEXT",
2762
+ "notNull": false,
2763
+ "unique": false
2764
+ },
2765
+ "source_fingerprint_nonce": {
2766
+ "type": "TEXT",
2767
+ "notNull": false,
2768
+ "unique": false
2769
+ },
2770
+ "source_revision": {
2771
+ "type": "TEXT",
2772
+ "notNull": false,
2773
+ "unique": false
2774
+ },
2775
+ "amount_minor": {
2776
+ "type": "INTEGER",
2777
+ "notNull": false,
2778
+ "unique": false
2779
+ },
2780
+ "currency": {
2781
+ "type": "TEXT",
2782
+ "notNull": false,
2783
+ "unique": false
2784
+ },
2785
+ "reviewed_by_profile_id": {
2786
+ "type": "UUID",
2787
+ "referenceKind": "crossPackageRef",
2788
+ "notNull": true,
2789
+ "unique": false
2790
+ },
2791
+ "reviewed_by_user_id": {
2792
+ "type": "UUID",
2793
+ "referenceKind": "crossPackageRef",
2794
+ "notNull": true,
2795
+ "unique": false
2796
+ },
2797
+ "review_evidence": {
2798
+ "type": "TEXT",
2799
+ "notNull": false,
2800
+ "unique": false
2801
+ }
2802
+ },
2803
+ "indexes": [
2804
+ {
2805
+ "name": "expense_allocation_revisions_slug_context_idx",
2806
+ "columns": [
2807
+ "tenant_id",
2808
+ "slug",
2809
+ "context"
2810
+ ],
2811
+ "unique": true
2812
+ },
2813
+ {
2814
+ "name": "expense_allocation_request_key",
2815
+ "columns": [
2816
+ "source_expense_id",
2817
+ "request_id"
2818
+ ],
2819
+ "unique": true
2820
+ },
2821
+ {
2822
+ "name": "expense_allocation_revision_successor",
2823
+ "columns": [
2824
+ "previous_revision_id"
2825
+ ],
2826
+ "unique": true
2827
+ },
2828
+ {
2829
+ "name": "expense_allocation_revisions_tenant_id_created_at_idx",
2830
+ "columns": [
2831
+ "tenant_id",
2832
+ "created_at"
2833
+ ]
2834
+ },
2835
+ {
2836
+ "name": "expense_allocation_revisions_reviewed_by_profile_id_idx",
2837
+ "columns": [
2838
+ "reviewed_by_profile_id"
2839
+ ]
2840
+ },
2841
+ {
2842
+ "name": "expense_allocation_revisions_reviewed_by_user_id_idx",
2843
+ "columns": [
2844
+ "reviewed_by_user_id"
2845
+ ]
2846
+ }
2847
+ ],
2848
+ "version": "83425a51"
2849
+ },
2850
+ "importPath": "@happyvertical/smrt-expenses"
2851
+ },
2852
+ "@happyvertical/smrt-expenses:ExpenseAllocationPortion": {
2853
+ "name": "expenseallocationportion",
2854
+ "className": "ExpenseAllocationPortion",
2855
+ "qualifiedName": "@happyvertical/smrt-expenses:ExpenseAllocationPortion",
2856
+ "collection": "expenseallocationportions",
2857
+ "description": "Persisted command-owned ExpenseAllocationPortion evidence.",
2858
+ "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseAllocation.ts",
2859
+ "packageName": "@happyvertical/smrt-expenses",
2860
+ "fields": {
2861
+ "tenantId": {
2862
+ "type": "text",
2863
+ "required": true,
2864
+ "_meta": {
2865
+ "sqlType": "UUID",
2866
+ "__tenancy": {
2867
+ "isTenantIdField": true,
2868
+ "autoFilter": true,
2869
+ "required": true,
2870
+ "autoPopulate": true,
2871
+ "nullable": false,
2872
+ "mode": "required",
2873
+ "field": "tenantId",
2874
+ "allowSuperAdminBypass": false
2875
+ }
2876
+ }
1114
2877
  },
1115
- "reimbursementReference": {
2878
+ "sourceExpenseId": {
2879
+ "type": "foreignKey",
2880
+ "required": true,
2881
+ "related": "Expense",
2882
+ "_meta": {
2883
+ "required": true,
2884
+ "onDelete": "RESTRICT"
2885
+ }
2886
+ },
2887
+ "revisionId": {
2888
+ "type": "foreignKey",
2889
+ "required": true,
2890
+ "related": "ExpenseAllocationRevision",
2891
+ "_meta": {
2892
+ "required": true,
2893
+ "onDelete": "RESTRICT"
2894
+ }
2895
+ },
2896
+ "portionKey": {
2897
+ "type": "text",
2898
+ "required": false
2899
+ },
2900
+ "costObjectType": {
2901
+ "type": "text",
2902
+ "required": false
2903
+ },
2904
+ "costObjectId": {
1116
2905
  "type": "text",
2906
+ "required": false
2907
+ },
2908
+ "costCodeRef": {
2909
+ "type": "text",
2910
+ "required": false
2911
+ },
2912
+ "amountMinor": {
2913
+ "type": "integer",
1117
2914
  "required": false,
1118
- "_meta": {
1119
- "readonly": true
1120
- },
1121
- "readonly": true
2915
+ "_meta": {}
2916
+ },
2917
+ "currency": {
2918
+ "type": "text",
2919
+ "required": false
1122
2920
  }
1123
2921
  },
1124
2922
  "methods": {
1125
- "getFinancialBreakdown": {
1126
- "name": "getFinancialBreakdown",
1127
- "async": false,
1128
- "parameters": [],
1129
- "returnType": "ExpenseFinancialBreakdown | null",
1130
- "isStatic": false,
1131
- "isPublic": true
1132
- },
1133
- "setFinancialBreakdown": {
1134
- "name": "setFinancialBreakdown",
1135
- "async": false,
2923
+ "save": {
2924
+ "name": "save",
2925
+ "async": true,
1136
2926
  "parameters": [
1137
2927
  {
1138
- "name": "value",
1139
- "type": "ExpenseFinancialBreakdown | null",
1140
- "optional": false,
1141
- "unionBranches": [
1142
- {
1143
- "type": "ExpenseFinancialBreakdown"
1144
- },
1145
- {
1146
- "type": "null"
1147
- }
1148
- ]
2928
+ "name": "options",
2929
+ "type": "SmrtSaveOptions",
2930
+ "optional": true
1149
2931
  }
1150
2932
  ],
1151
- "returnType": "void",
2933
+ "returnType": "Promise<this>",
1152
2934
  "isStatic": false,
1153
2935
  "isPublic": true
1154
2936
  },
1155
- "getRefundRecipient": {
1156
- "name": "getRefundRecipient",
1157
- "async": false,
2937
+ "delete": {
2938
+ "name": "delete",
2939
+ "async": true,
1158
2940
  "parameters": [],
1159
- "returnType": "ExpenseRefundRecipient | null",
2941
+ "returnType": "Promise<void>",
1160
2942
  "isStatic": false,
1161
2943
  "isPublic": true
2944
+ }
2945
+ },
2946
+ "decoratorConfig": {
2947
+ "tableName": "expense_allocation_portions",
2948
+ "api": {
2949
+ "include": []
1162
2950
  },
1163
- "setRefundRecipient": {
1164
- "name": "setRefundRecipient",
1165
- "async": false,
1166
- "parameters": [
1167
- {
1168
- "name": "value",
1169
- "type": "ExpenseRefundRecipient | null",
1170
- "optional": false,
1171
- "unionBranches": [
1172
- {
1173
- "type": "ExpenseRefundRecipient"
1174
- },
1175
- {
1176
- "type": "null"
1177
- }
1178
- ]
2951
+ "mcp": {
2952
+ "include": []
2953
+ },
2954
+ "cli": false,
2955
+ "indexes": [
2956
+ {
2957
+ "name": "expense_allocation_portion_key",
2958
+ "columns": [
2959
+ "revisionId",
2960
+ "portionKey"
2961
+ ],
2962
+ "unique": true
2963
+ }
2964
+ ],
2965
+ "tenantScoped": {
2966
+ "mode": "required"
2967
+ },
2968
+ "conflictColumns": [
2969
+ "tenant_id",
2970
+ "slug",
2971
+ "context"
2972
+ ]
2973
+ },
2974
+ "extends": "SmrtObject",
2975
+ "exportName": "ExpenseAllocationPortion",
2976
+ "collectionExportName": "ExpenseAllocationPortionCollection",
2977
+ "validationRules": [
2978
+ {
2979
+ "field": "sourceExpenseId",
2980
+ "rule": "required",
2981
+ "fieldType": "foreignKey"
2982
+ },
2983
+ {
2984
+ "field": "revisionId",
2985
+ "rule": "required",
2986
+ "fieldType": "foreignKey"
2987
+ }
2988
+ ],
2989
+ "schema": {
2990
+ "tableName": "expense_allocation_portions",
2991
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expense_allocation_portions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"source_expense_id\" UUID NOT NULL,\n \"revision_id\" UUID NOT NULL,\n \"portion_key\" TEXT,\n \"cost_object_type\" TEXT,\n \"cost_object_id\" TEXT,\n \"cost_code_ref\" TEXT,\n \"amount_minor\" INTEGER,\n \"currency\" TEXT\n);",
2992
+ "columns": {
2993
+ "_sync_origin_device_id": {
2994
+ "type": "TEXT"
2995
+ },
2996
+ "_sync_revision": {
2997
+ "type": "INTEGER"
2998
+ },
2999
+ "id": {
3000
+ "type": "UUID",
3001
+ "primaryKey": true,
3002
+ "referenceKind": "id",
3003
+ "notNull": true
3004
+ },
3005
+ "slug": {
3006
+ "type": "TEXT",
3007
+ "notNull": true
3008
+ },
3009
+ "context": {
3010
+ "type": "TEXT",
3011
+ "notNull": true,
3012
+ "default": ""
3013
+ },
3014
+ "created_at": {
3015
+ "type": "TIMESTAMP",
3016
+ "notNull": true,
3017
+ "default": "current_timestamp"
3018
+ },
3019
+ "updated_at": {
3020
+ "type": "TIMESTAMP",
3021
+ "notNull": true,
3022
+ "default": "current_timestamp"
3023
+ },
3024
+ "tenant_id": {
3025
+ "type": "UUID",
3026
+ "referenceKind": "tenantId",
3027
+ "notNull": true,
3028
+ "unique": false
3029
+ },
3030
+ "source_expense_id": {
3031
+ "type": "UUID",
3032
+ "referenceKind": "foreignKey",
3033
+ "notNull": true,
3034
+ "unique": false,
3035
+ "foreignKey": {
3036
+ "table": "expenses",
3037
+ "column": "id",
3038
+ "onDelete": "RESTRICT",
3039
+ "onUpdate": "CASCADE"
3040
+ }
3041
+ },
3042
+ "revision_id": {
3043
+ "type": "UUID",
3044
+ "referenceKind": "foreignKey",
3045
+ "notNull": true,
3046
+ "unique": false,
3047
+ "foreignKey": {
3048
+ "table": "expense_allocation_revisions",
3049
+ "column": "id",
3050
+ "onDelete": "RESTRICT",
3051
+ "onUpdate": "CASCADE"
3052
+ }
3053
+ },
3054
+ "portion_key": {
3055
+ "type": "TEXT",
3056
+ "notNull": false,
3057
+ "unique": false
3058
+ },
3059
+ "cost_object_type": {
3060
+ "type": "TEXT",
3061
+ "notNull": false,
3062
+ "unique": false
3063
+ },
3064
+ "cost_object_id": {
3065
+ "type": "TEXT",
3066
+ "notNull": false,
3067
+ "unique": false
3068
+ },
3069
+ "cost_code_ref": {
3070
+ "type": "TEXT",
3071
+ "notNull": false,
3072
+ "unique": false
3073
+ },
3074
+ "amount_minor": {
3075
+ "type": "INTEGER",
3076
+ "notNull": false,
3077
+ "unique": false
3078
+ },
3079
+ "currency": {
3080
+ "type": "TEXT",
3081
+ "notNull": false,
3082
+ "unique": false
3083
+ }
3084
+ },
3085
+ "indexes": [
3086
+ {
3087
+ "name": "expense_allocation_portions_slug_context_idx",
3088
+ "columns": [
3089
+ "tenant_id",
3090
+ "slug",
3091
+ "context"
3092
+ ],
3093
+ "unique": true
3094
+ },
3095
+ {
3096
+ "name": "expense_allocation_portion_key",
3097
+ "columns": [
3098
+ "revision_id",
3099
+ "portion_key"
3100
+ ],
3101
+ "unique": true
3102
+ },
3103
+ {
3104
+ "name": "expense_allocation_portions_tenant_id_created_at_idx",
3105
+ "columns": [
3106
+ "tenant_id",
3107
+ "created_at"
3108
+ ]
3109
+ },
3110
+ {
3111
+ "name": "expense_allocation_portions_source_expense_id_idx",
3112
+ "columns": [
3113
+ "source_expense_id"
3114
+ ]
3115
+ }
3116
+ ],
3117
+ "version": "6b0600b1"
3118
+ },
3119
+ "importPath": "@happyvertical/smrt-expenses"
3120
+ },
3121
+ "@happyvertical/smrt-expenses:ExpenseAllocationBilling": {
3122
+ "name": "expenseallocationbilling",
3123
+ "className": "ExpenseAllocationBilling",
3124
+ "qualifiedName": "@happyvertical/smrt-expenses:ExpenseAllocationBilling",
3125
+ "collection": "expenseallocationbillings",
3126
+ "description": "Persisted command-owned ExpenseAllocationBilling evidence.",
3127
+ "filePath": "/home/runner/work/smrt/smrt/packages/expenses/src/models/ExpenseAllocation.ts",
3128
+ "packageName": "@happyvertical/smrt-expenses",
3129
+ "fields": {
3130
+ "tenantId": {
3131
+ "type": "text",
3132
+ "required": true,
3133
+ "_meta": {
3134
+ "sqlType": "UUID",
3135
+ "__tenancy": {
3136
+ "isTenantIdField": true,
3137
+ "autoFilter": true,
3138
+ "required": true,
3139
+ "autoPopulate": true,
3140
+ "nullable": false,
3141
+ "mode": "required",
3142
+ "field": "tenantId",
3143
+ "allowSuperAdminBypass": false
1179
3144
  }
1180
- ],
1181
- "returnType": "void",
1182
- "isStatic": false,
1183
- "isPublic": true
3145
+ }
1184
3146
  },
1185
- "getCostBasis": {
1186
- "name": "getCostBasis",
1187
- "async": false,
1188
- "parameters": [],
1189
- "returnType": "ExpenseCostBasis | null",
1190
- "isStatic": false,
1191
- "isPublic": true
3147
+ "sourceExpenseId": {
3148
+ "type": "foreignKey",
3149
+ "required": true,
3150
+ "related": "Expense",
3151
+ "_meta": {
3152
+ "required": true,
3153
+ "onDelete": "RESTRICT"
3154
+ }
1192
3155
  },
1193
- "isReimbursed": {
1194
- "name": "isReimbursed",
1195
- "async": false,
1196
- "parameters": [],
1197
- "returnType": "boolean",
1198
- "isStatic": false,
1199
- "isPublic": true
3156
+ "portionId": {
3157
+ "type": "foreignKey",
3158
+ "required": true,
3159
+ "related": "ExpenseAllocationPortion",
3160
+ "_meta": {
3161
+ "required": true,
3162
+ "onDelete": "RESTRICT"
3163
+ }
1200
3164
  },
1201
- "isCountable": {
1202
- "name": "isCountable",
1203
- "async": false,
1204
- "parameters": [],
1205
- "returnType": "boolean",
1206
- "isStatic": false,
1207
- "isPublic": true
3165
+ "invoiceId": {
3166
+ "type": "crossPackageRef",
3167
+ "required": false,
3168
+ "related": "@happyvertical/smrt-commerce:Invoice",
3169
+ "_meta": {
3170
+ "nullable": true
3171
+ }
1208
3172
  },
1209
- "review": {
1210
- "name": "review",
1211
- "async": true,
1212
- "parameters": [
1213
- {
1214
- "name": "input",
1215
- "type": "ReviewExpenseInput",
1216
- "optional": false
1217
- }
1218
- ],
1219
- "returnType": "Promise<this>",
1220
- "isStatic": false,
1221
- "isPublic": true
3173
+ "draftType": {
3174
+ "type": "text",
3175
+ "required": false
1222
3176
  },
1223
- "reject": {
1224
- "name": "reject",
1225
- "async": true,
1226
- "parameters": [
1227
- {
1228
- "name": "input",
1229
- "type": "RejectExpenseInput",
1230
- "optional": false
1231
- }
1232
- ],
1233
- "returnType": "Promise<this>",
1234
- "isStatic": false,
1235
- "isPublic": true
3177
+ "draftId": {
3178
+ "type": "text",
3179
+ "required": false
1236
3180
  },
1237
- "markDuplicate": {
1238
- "name": "markDuplicate",
1239
- "async": true,
1240
- "parameters": [
1241
- {
1242
- "name": "input",
1243
- "type": "MarkDuplicateExpenseInput",
1244
- "optional": false
1245
- }
1246
- ],
1247
- "returnType": "Promise<this>",
1248
- "isStatic": false,
1249
- "isPublic": true
3181
+ "invoiceLineId": {
3182
+ "type": "crossPackageRef",
3183
+ "required": false,
3184
+ "related": "@happyvertical/smrt-commerce:InvoiceLineItem",
3185
+ "_meta": {
3186
+ "nullable": true
3187
+ }
1250
3188
  },
1251
- "reopen": {
1252
- "name": "reopen",
1253
- "async": true,
1254
- "parameters": [
1255
- {
1256
- "name": "input",
1257
- "type": "ReopenExpenseInput",
1258
- "optional": false
1259
- }
1260
- ],
1261
- "returnType": "Promise<this>",
1262
- "isStatic": false,
1263
- "isPublic": true
3189
+ "requestId": {
3190
+ "type": "text",
3191
+ "required": false
1264
3192
  },
1265
- "markReimbursed": {
1266
- "name": "markReimbursed",
1267
- "async": true,
1268
- "parameters": [
1269
- {
1270
- "name": "input",
1271
- "type": "MarkReimbursedInput",
1272
- "optional": true
1273
- }
1274
- ],
1275
- "returnType": "Promise<this>",
1276
- "isStatic": false,
1277
- "isPublic": true
3193
+ "requestFingerprint": {
3194
+ "type": "text",
3195
+ "required": false
1278
3196
  },
1279
- "getCostObject": {
1280
- "name": "getCostObject",
1281
- "async": true,
1282
- "parameters": [],
1283
- "returnType": "Promise<T | null>",
1284
- "isStatic": false,
1285
- "isPublic": true
3197
+ "relatedReservationId": {
3198
+ "type": "foreignKey",
3199
+ "required": false,
3200
+ "related": "ExpenseAllocationBilling",
3201
+ "_meta": {
3202
+ "nullable": true,
3203
+ "onDelete": "RESTRICT"
3204
+ }
1286
3205
  },
3206
+ "kind": {
3207
+ "type": "text",
3208
+ "required": false
3209
+ }
3210
+ },
3211
+ "methods": {
1287
3212
  "save": {
1288
3213
  "name": "save",
1289
3214
  "async": true,
@@ -1298,108 +3223,19 @@
1298
3223
  "isStatic": false,
1299
3224
  "isPublic": true
1300
3225
  },
1301
- "recordSupplierPayable": {
1302
- "name": "recordSupplierPayable",
1303
- "async": true,
1304
- "parameters": [
1305
- {
1306
- "name": "input",
1307
- "type": "RecordSupplierPayableInput",
1308
- "optional": false
1309
- }
1310
- ],
1311
- "returnType": "Promise<SupplierPayablePosition>",
1312
- "isStatic": false,
1313
- "isPublic": true
1314
- },
1315
- "recordSupplierPayableEvent": {
1316
- "name": "recordSupplierPayableEvent",
1317
- "async": true,
1318
- "parameters": [
1319
- {
1320
- "name": "input",
1321
- "type": "RecordSupplierPayableEventInput",
1322
- "optional": false
1323
- }
1324
- ],
1325
- "returnType": "Promise<SupplierPayablePosition>",
1326
- "isStatic": false,
1327
- "isPublic": true
1328
- },
1329
- "completeSupplierPayableBasis": {
1330
- "name": "completeSupplierPayableBasis",
1331
- "async": true,
1332
- "parameters": [
1333
- {
1334
- "name": "input",
1335
- "type": "CompleteSupplierPayableBasisInput",
1336
- "optional": false
1337
- }
1338
- ],
1339
- "returnType": "Promise<SupplierPayablePosition>",
1340
- "isStatic": false,
1341
- "isPublic": true
1342
- },
1343
- "getSupplierPayablePosition": {
1344
- "name": "getSupplierPayablePosition",
1345
- "async": true,
1346
- "parameters": [
1347
- {
1348
- "name": "input",
1349
- "type": "object",
1350
- "optional": true,
1351
- "memberTypes": [
1352
- "string"
1353
- ]
1354
- }
1355
- ],
1356
- "returnType": "Promise<SupplierPayablePosition | null>",
1357
- "isStatic": false,
1358
- "isPublic": true
1359
- },
1360
3226
  "delete": {
1361
- "name": "delete",
1362
- "async": true,
1363
- "parameters": [
1364
- {
1365
- "name": "options",
1366
- "type": "object",
1367
- "optional": true,
1368
- "memberTypes": [
1369
- "Date | string"
1370
- ]
1371
- }
1372
- ],
1373
- "returnType": "Promise<void>",
1374
- "isStatic": false,
1375
- "isPublic": true
1376
- },
1377
- "getReimbursementPosition": {
1378
- "name": "getReimbursementPosition",
1379
- "async": true,
1380
- "parameters": [],
1381
- "returnType": "Promise<ExpenseReimbursementPosition>",
1382
- "isStatic": false,
1383
- "isPublic": true
1384
- },
1385
- "getRefundPosition": {
1386
- "name": "getRefundPosition",
3227
+ "name": "delete",
1387
3228
  "async": true,
1388
3229
  "parameters": [],
1389
- "returnType": "Promise<ExpenseRefundPosition>",
3230
+ "returnType": "Promise<void>",
1390
3231
  "isStatic": false,
1391
3232
  "isPublic": true
1392
3233
  }
1393
3234
  },
1394
3235
  "decoratorConfig": {
1395
- "tableName": "expenses",
3236
+ "tableName": "expense_allocation_billings",
1396
3237
  "api": {
1397
- "include": [
1398
- "record",
1399
- "attachReceipt",
1400
- "recordReview",
1401
- "recordReimbursement"
1402
- ]
3238
+ "include": []
1403
3239
  },
1404
3240
  "mcp": {
1405
3241
  "include": []
@@ -1407,33 +3243,24 @@
1407
3243
  "cli": false,
1408
3244
  "indexes": [
1409
3245
  {
1410
- "name": "expenses_cost_object_idx",
1411
- "columns": [
1412
- "tenantId",
1413
- "costObjectType",
1414
- "costObjectId",
1415
- "incurredOn"
1416
- ]
1417
- },
1418
- {
1419
- "name": "expenses_commitment_review_idx",
3246
+ "name": "expense_allocation_billing_request",
1420
3247
  "columns": [
1421
- "tenantId",
1422
- "commitmentId",
1423
- "reviewStatus"
1424
- ]
3248
+ "sourceExpenseId",
3249
+ "requestId"
3250
+ ],
3251
+ "unique": true
1425
3252
  },
1426
3253
  {
1427
- "name": "expenses_review_status_idx",
3254
+ "name": "expense_allocation_billing_release",
1428
3255
  "columns": [
1429
- "tenantId",
1430
- "reviewStatus",
1431
- "incurredOn"
1432
- ]
3256
+ "relatedReservationId",
3257
+ "kind"
3258
+ ],
3259
+ "unique": true
1433
3260
  }
1434
3261
  ],
1435
3262
  "tenantScoped": {
1436
- "mode": "optional"
3263
+ "mode": "required"
1437
3264
  },
1438
3265
  "conflictColumns": [
1439
3266
  "tenant_id",
@@ -1442,11 +3269,23 @@
1442
3269
  ]
1443
3270
  },
1444
3271
  "extends": "SmrtObject",
1445
- "exportName": "Expense",
1446
- "collectionExportName": "ExpenseCollection",
3272
+ "exportName": "ExpenseAllocationBilling",
3273
+ "collectionExportName": "ExpenseAllocationBillingCollection",
3274
+ "validationRules": [
3275
+ {
3276
+ "field": "sourceExpenseId",
3277
+ "rule": "required",
3278
+ "fieldType": "foreignKey"
3279
+ },
3280
+ {
3281
+ "field": "portionId",
3282
+ "rule": "required",
3283
+ "fieldType": "foreignKey"
3284
+ }
3285
+ ],
1447
3286
  "schema": {
1448
- "tableName": "expenses",
1449
- "ddl": "CREATE TABLE IF NOT EXISTS \"expenses\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"cost_object_type\" TEXT,\n \"cost_object_id\" TEXT,\n \"category\" TEXT,\n \"description\" TEXT,\n \"amount\" INTEGER,\n \"currency\" TEXT,\n \"financial_breakdown\" TEXT,\n \"supplier_payable_json\" TEXT,\n \"paid_by_name\" TEXT,\n \"refund_of_id\" UUID,\n \"refund_recipient\" TEXT,\n \"incurred_on\" TEXT,\n \"recorded_at\" TIMESTAMP,\n \"recorded_by_profile_id\" UUID,\n \"paid_by\" TEXT,\n \"paid_by_profile_id\" UUID,\n \"vendor_id\" UUID,\n \"commitment_id\" UUID,\n \"commitment_line_id\" UUID,\n \"review_status\" TEXT,\n \"reviewed_by_profile_id\" UUID,\n \"reviewed_at\" TIMESTAMP,\n \"review_note\" TEXT,\n \"duplicate_of_id\" UUID,\n \"reimbursable\" BOOLEAN,\n \"reimbursed_amount\" INTEGER,\n \"reimbursed_at\" TIMESTAMP,\n \"reimbursement_reference\" TEXT\n);",
3287
+ "tableName": "expense_allocation_billings",
3288
+ "ddl": "CREATE TABLE IF NOT EXISTS \"expense_allocation_billings\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"source_expense_id\" UUID NOT NULL,\n \"portion_id\" UUID NOT NULL,\n \"invoice_id\" UUID,\n \"draft_type\" TEXT,\n \"draft_id\" TEXT,\n \"invoice_line_id\" UUID,\n \"request_id\" TEXT,\n \"request_fingerprint\" TEXT,\n \"related_reservation_id\" UUID,\n \"kind\" TEXT\n);",
1450
3289
  "columns": {
1451
3290
  "_sync_origin_device_id": {
1452
3291
  "type": "TEXT"
@@ -1482,58 +3321,13 @@
1482
3321
  "tenant_id": {
1483
3322
  "type": "UUID",
1484
3323
  "referenceKind": "tenantId",
1485
- "notNull": false,
1486
- "unique": false
1487
- },
1488
- "cost_object_type": {
1489
- "type": "TEXT",
1490
- "notNull": false,
1491
- "unique": false
1492
- },
1493
- "cost_object_id": {
1494
- "type": "TEXT",
1495
- "notNull": false,
1496
- "unique": false
1497
- },
1498
- "category": {
1499
- "type": "TEXT",
1500
- "notNull": false,
1501
- "unique": false
1502
- },
1503
- "description": {
1504
- "type": "TEXT",
1505
- "notNull": false,
1506
- "unique": false
1507
- },
1508
- "amount": {
1509
- "type": "INTEGER",
1510
- "notNull": false,
1511
- "unique": false
1512
- },
1513
- "currency": {
1514
- "type": "TEXT",
1515
- "notNull": false,
1516
- "unique": false
1517
- },
1518
- "financial_breakdown": {
1519
- "type": "TEXT",
1520
- "notNull": false,
1521
- "unique": false
1522
- },
1523
- "supplier_payable_json": {
1524
- "type": "TEXT",
1525
- "notNull": false,
1526
- "unique": false
1527
- },
1528
- "paid_by_name": {
1529
- "type": "TEXT",
1530
- "notNull": false,
3324
+ "notNull": true,
1531
3325
  "unique": false
1532
3326
  },
1533
- "refund_of_id": {
3327
+ "source_expense_id": {
1534
3328
  "type": "UUID",
1535
3329
  "referenceKind": "foreignKey",
1536
- "notNull": false,
3330
+ "notNull": true,
1537
3331
  "unique": false,
1538
3332
  "foreignKey": {
1539
3333
  "table": "expenses",
@@ -1542,105 +3336,63 @@
1542
3336
  "onUpdate": "CASCADE"
1543
3337
  }
1544
3338
  },
1545
- "refund_recipient": {
1546
- "type": "TEXT",
1547
- "notNull": false,
1548
- "unique": false
1549
- },
1550
- "incurred_on": {
1551
- "type": "TEXT",
1552
- "notNull": false,
1553
- "unique": false
1554
- },
1555
- "recorded_at": {
1556
- "type": "TIMESTAMP",
1557
- "notNull": false,
1558
- "unique": false
1559
- },
1560
- "recorded_by_profile_id": {
1561
- "type": "UUID",
1562
- "referenceKind": "crossPackageRef",
1563
- "notNull": false,
1564
- "unique": false
1565
- },
1566
- "paid_by": {
1567
- "type": "TEXT",
1568
- "notNull": false,
1569
- "unique": false
1570
- },
1571
- "paid_by_profile_id": {
1572
- "type": "UUID",
1573
- "referenceKind": "crossPackageRef",
1574
- "notNull": false,
1575
- "unique": false
1576
- },
1577
- "vendor_id": {
3339
+ "portion_id": {
1578
3340
  "type": "UUID",
1579
- "referenceKind": "crossPackageRef",
1580
- "notNull": false,
1581
- "unique": false
3341
+ "referenceKind": "foreignKey",
3342
+ "notNull": true,
3343
+ "unique": false,
3344
+ "foreignKey": {
3345
+ "table": "expense_allocation_portions",
3346
+ "column": "id",
3347
+ "onDelete": "RESTRICT",
3348
+ "onUpdate": "CASCADE"
3349
+ }
1582
3350
  },
1583
- "commitment_id": {
3351
+ "invoice_id": {
1584
3352
  "type": "UUID",
1585
3353
  "referenceKind": "crossPackageRef",
1586
3354
  "notNull": false,
1587
3355
  "unique": false
1588
3356
  },
1589
- "commitment_line_id": {
1590
- "type": "UUID",
1591
- "referenceKind": "crossPackageRef",
3357
+ "draft_type": {
3358
+ "type": "TEXT",
1592
3359
  "notNull": false,
1593
3360
  "unique": false
1594
3361
  },
1595
- "review_status": {
3362
+ "draft_id": {
1596
3363
  "type": "TEXT",
1597
3364
  "notNull": false,
1598
3365
  "unique": false
1599
3366
  },
1600
- "reviewed_by_profile_id": {
3367
+ "invoice_line_id": {
1601
3368
  "type": "UUID",
1602
3369
  "referenceKind": "crossPackageRef",
1603
3370
  "notNull": false,
1604
3371
  "unique": false
1605
3372
  },
1606
- "reviewed_at": {
1607
- "type": "TIMESTAMP",
3373
+ "request_id": {
3374
+ "type": "TEXT",
1608
3375
  "notNull": false,
1609
3376
  "unique": false
1610
3377
  },
1611
- "review_note": {
3378
+ "request_fingerprint": {
1612
3379
  "type": "TEXT",
1613
3380
  "notNull": false,
1614
3381
  "unique": false
1615
3382
  },
1616
- "duplicate_of_id": {
3383
+ "related_reservation_id": {
1617
3384
  "type": "UUID",
1618
3385
  "referenceKind": "foreignKey",
1619
3386
  "notNull": false,
1620
3387
  "unique": false,
1621
3388
  "foreignKey": {
1622
- "table": "expenses",
3389
+ "table": "expense_allocation_billings",
1623
3390
  "column": "id",
1624
- "onDelete": "SET NULL",
3391
+ "onDelete": "RESTRICT",
1625
3392
  "onUpdate": "CASCADE"
1626
3393
  }
1627
3394
  },
1628
- "reimbursable": {
1629
- "type": "BOOLEAN",
1630
- "notNull": false,
1631
- "unique": false
1632
- },
1633
- "reimbursed_amount": {
1634
- "type": "INTEGER",
1635
- "notNull": false,
1636
- "unique": false
1637
- },
1638
- "reimbursed_at": {
1639
- "type": "TIMESTAMP",
1640
- "notNull": false,
1641
- "unique": false
1642
- },
1643
- "reimbursement_reference": {
3395
+ "kind": {
1644
3396
  "type": "TEXT",
1645
3397
  "notNull": false,
1646
3398
  "unique": false
@@ -1648,97 +3400,57 @@
1648
3400
  },
1649
3401
  "indexes": [
1650
3402
  {
1651
- "name": "expenses_slug_context_idx",
3403
+ "name": "expense_allocation_billings_slug_context_idx",
1652
3404
  "columns": [
1653
3405
  "tenant_id",
1654
3406
  "slug",
1655
3407
  "context"
1656
3408
  ],
1657
- "unique": true,
1658
- "nullsNotDistinct": true
1659
- },
1660
- {
1661
- "name": "expenses_cost_object_idx",
1662
- "columns": [
1663
- "tenant_id",
1664
- "cost_object_type",
1665
- "cost_object_id",
1666
- "incurred_on"
1667
- ]
3409
+ "unique": true
1668
3410
  },
1669
3411
  {
1670
- "name": "expenses_commitment_review_idx",
3412
+ "name": "expense_allocation_billing_request",
1671
3413
  "columns": [
1672
- "tenant_id",
1673
- "commitment_id",
1674
- "review_status"
1675
- ]
3414
+ "source_expense_id",
3415
+ "request_id"
3416
+ ],
3417
+ "unique": true
1676
3418
  },
1677
3419
  {
1678
- "name": "expenses_review_status_idx",
3420
+ "name": "expense_allocation_billing_release",
1679
3421
  "columns": [
1680
- "tenant_id",
1681
- "review_status",
1682
- "incurred_on"
1683
- ]
3422
+ "related_reservation_id",
3423
+ "kind"
3424
+ ],
3425
+ "unique": true
1684
3426
  },
1685
3427
  {
1686
- "name": "expenses_tenant_id_created_at_idx",
3428
+ "name": "expense_allocation_billings_tenant_id_created_at_idx",
1687
3429
  "columns": [
1688
3430
  "tenant_id",
1689
3431
  "created_at"
1690
3432
  ]
1691
3433
  },
1692
3434
  {
1693
- "name": "expenses_refund_of_id_idx",
1694
- "columns": [
1695
- "refund_of_id"
1696
- ]
1697
- },
1698
- {
1699
- "name": "expenses_recorded_by_profile_id_idx",
1700
- "columns": [
1701
- "recorded_by_profile_id"
1702
- ]
1703
- },
1704
- {
1705
- "name": "expenses_paid_by_profile_id_idx",
1706
- "columns": [
1707
- "paid_by_profile_id"
1708
- ]
1709
- },
1710
- {
1711
- "name": "expenses_vendor_id_idx",
1712
- "columns": [
1713
- "vendor_id"
1714
- ]
1715
- },
1716
- {
1717
- "name": "expenses_commitment_id_idx",
1718
- "columns": [
1719
- "commitment_id"
1720
- ]
1721
- },
1722
- {
1723
- "name": "expenses_commitment_line_id_idx",
3435
+ "name": "expense_allocation_billings_portion_id_idx",
1724
3436
  "columns": [
1725
- "commitment_line_id"
3437
+ "portion_id"
1726
3438
  ]
1727
3439
  },
1728
3440
  {
1729
- "name": "expenses_reviewed_by_profile_id_idx",
3441
+ "name": "expense_allocation_billings_invoice_id_idx",
1730
3442
  "columns": [
1731
- "reviewed_by_profile_id"
3443
+ "invoice_id"
1732
3444
  ]
1733
3445
  },
1734
3446
  {
1735
- "name": "expenses_duplicate_of_id_idx",
3447
+ "name": "expense_allocation_billings_invoice_line_id_idx",
1736
3448
  "columns": [
1737
- "duplicate_of_id"
3449
+ "invoice_line_id"
1738
3450
  ]
1739
3451
  }
1740
3452
  ],
1741
- "version": "81a9a368"
3453
+ "version": "432aeb1f"
1742
3454
  },
1743
3455
  "importPath": "@happyvertical/smrt-expenses"
1744
3456
  },
@@ -1825,6 +3537,23 @@
1825
3537
  "returnType": "Promise<this>",
1826
3538
  "isStatic": false,
1827
3539
  "isPublic": true
3540
+ },
3541
+ "delete": {
3542
+ "name": "delete",
3543
+ "async": true,
3544
+ "parameters": [
3545
+ {
3546
+ "name": "options",
3547
+ "type": "object",
3548
+ "optional": true,
3549
+ "memberTypes": [
3550
+ "Date | string"
3551
+ ]
3552
+ }
3553
+ ],
3554
+ "returnType": "Promise<void>",
3555
+ "isStatic": false,
3556
+ "isPublic": true
1828
3557
  }
1829
3558
  },
1830
3559
  "decoratorConfig": {
@@ -2099,6 +3828,9 @@
2099
3828
  "costObjectType": {
2100
3829
  "visibility": "hidden"
2101
3830
  },
3831
+ "activeAllocationRevisionId": {
3832
+ "visibility": "hidden"
3833
+ },
2102
3834
  "financialBreakdown": {
2103
3835
  "visibility": "hidden"
2104
3836
  },