@valentine-efagene/qshelter-common 2.0.98 → 2.0.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated/client/browser.d.ts +5 -0
- package/dist/generated/client/client.d.ts +5 -0
- package/dist/generated/client/commonInputTypes.d.ts +90 -0
- package/dist/generated/client/enums.d.ts +26 -0
- package/dist/generated/client/enums.js +23 -0
- package/dist/generated/client/internal/class.d.ts +11 -0
- package/dist/generated/client/internal/class.js +2 -2
- package/dist/generated/client/internal/prismaNamespace.d.ts +176 -1
- package/dist/generated/client/internal/prismaNamespace.js +95 -1
- package/dist/generated/client/internal/prismaNamespaceBrowser.d.ts +96 -0
- package/dist/generated/client/internal/prismaNamespaceBrowser.js +95 -1
- package/dist/generated/client/models/Amenity.d.ts +183 -3
- package/dist/generated/client/models/ApplicationDocument.d.ts +183 -1
- package/dist/generated/client/models/ApplicationEvent.d.ts +190 -14
- package/dist/generated/client/models/ApplicationPayment.d.ts +225 -1
- package/dist/generated/client/models/ApplicationPhase.d.ts +272 -26
- package/dist/generated/client/models/DocumentationPhase.d.ts +224 -24
- package/dist/generated/client/models/DocumentationStep.d.ts +237 -1
- package/dist/generated/client/models/DocumentationStepApproval.d.ts +159 -1
- package/dist/generated/client/models/DocumentationStepDocument.d.ts +150 -10
- package/dist/generated/client/models/EventHandlerExecution.d.ts +208 -14
- package/dist/generated/client/models/PaymentInstallment.d.ts +228 -14
- package/dist/generated/client/models/PaymentMethodPhaseDocument.d.ts +178 -14
- package/dist/generated/client/models/PaymentMethodPhaseField.d.ts +208 -14
- package/dist/generated/client/models/PaymentMethodPhaseStep.d.ts +180 -14
- package/dist/generated/client/models/PaymentPhase.d.ts +214 -14
- package/dist/generated/client/models/PhaseEventAttachment.d.ts +178 -14
- package/dist/generated/client/models/PropertyAmenity.d.ts +145 -11
- package/dist/generated/client/models/PropertyDocument.d.ts +164 -12
- package/dist/generated/client/models/PropertyMedia.d.ts +183 -17
- package/dist/generated/client/models/PropertyPaymentMethodLink.d.ts +159 -13
- package/dist/generated/client/models/PropertyPaymentMethodPhase.d.ts +270 -14
- package/dist/generated/client/models/PropertyUnit.d.ts +230 -14
- package/dist/generated/client/models/PropertyVariant.d.ts +256 -14
- package/dist/generated/client/models/PropertyVariantAmenity.d.ts +145 -11
- package/dist/generated/client/models/PropertyVariantMedia.d.ts +171 -13
- package/dist/generated/client/models/QuestionnaireField.d.ts +232 -14
- package/dist/generated/client/models/QuestionnairePhase.d.ts +207 -1
- package/dist/generated/client/models/StepEventAttachment.d.ts +178 -14
- package/dist/generated/client/models/Tenant.d.ts +11653 -1153
- package/dist/generated/client/models/WorkflowBlocker.d.ts +1432 -0
- package/dist/generated/client/models/WorkflowBlocker.js +1 -0
- package/dist/generated/client/models/index.d.ts +1 -0
- package/dist/generated/client/models/index.js +1 -0
- package/dist/generated/client/models.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/middleware/auth-context.d.ts +63 -6
- package/dist/src/middleware/auth-context.js +132 -13
- package/dist/src/prisma/tenant.js +26 -32
- package/dist/src/types/action-status.d.ts +137 -0
- package/dist/src/types/action-status.js +402 -0
- package/package.json +1 -1
- package/prisma/migrations/20260113000000_remove_workflow_analytics_summary/migration.sql +5 -0
- package/prisma/migrations/20260113110450_add_tenant_id_to_child_models/migration.sql +334 -0
- package/prisma/schema.prisma +273 -60
package/prisma/schema.prisma
CHANGED
|
@@ -345,7 +345,7 @@ model User {
|
|
|
345
345
|
socials Social[]
|
|
346
346
|
|
|
347
347
|
// Relations to other domains
|
|
348
|
-
properties
|
|
348
|
+
properties Property[]
|
|
349
349
|
applications Application[] @relation("ApplicationBuyer")
|
|
350
350
|
soldApplications Application[] @relation("ApplicationSeller")
|
|
351
351
|
applicationPayments ApplicationPayment[] @relation("ApplicationPayer")
|
|
@@ -353,7 +353,7 @@ model User {
|
|
|
353
353
|
// Documentation step assignments and approvals
|
|
354
354
|
assignedSteps DocumentationStep[] @relation("DocumentationStepAssignee")
|
|
355
355
|
stepApprovals DocumentationStepApproval[] @relation("DocumentationStepApprover")
|
|
356
|
-
uploadedDocs ApplicationDocument[]
|
|
356
|
+
uploadedDocs ApplicationDocument[] @relation("DocumentUploader")
|
|
357
357
|
|
|
358
358
|
// Payment method changes
|
|
359
359
|
paymentMethodChangeRequests PaymentMethodChangeRequest[] @relation("ChangeRequestor")
|
|
@@ -496,7 +496,7 @@ model Tenant {
|
|
|
496
496
|
properties Property[]
|
|
497
497
|
paymentPlans PaymentPlan[]
|
|
498
498
|
paymentMethods PropertyPaymentMethod[]
|
|
499
|
-
applications
|
|
499
|
+
applications Application[]
|
|
500
500
|
|
|
501
501
|
// RBAC: Tenant-scoped roles and permissions
|
|
502
502
|
roles Role[]
|
|
@@ -531,7 +531,35 @@ model Tenant {
|
|
|
531
531
|
approvalRequests ApprovalRequest[]
|
|
532
532
|
|
|
533
533
|
// Contract refunds
|
|
534
|
-
contractRefunds
|
|
534
|
+
contractRefunds ApplicationRefund[]
|
|
535
|
+
propertyPaymentMethodLinks PropertyPaymentMethodLink[]
|
|
536
|
+
propertyPaymentMethodPhases PropertyPaymentMethodPhase[]
|
|
537
|
+
phaseEventAttachments PhaseEventAttachment[]
|
|
538
|
+
paymentMethodPhaseSteps PaymentMethodPhaseStep[]
|
|
539
|
+
stepEventAttachments StepEventAttachment[]
|
|
540
|
+
paymentMethodPhaseDocuments PaymentMethodPhaseDocument[]
|
|
541
|
+
paymentMethodPhaseFields PaymentMethodPhaseField[]
|
|
542
|
+
applicationPhases ApplicationPhase[]
|
|
543
|
+
questionnairePhases QuestionnairePhase[]
|
|
544
|
+
documentationPhases DocumentationPhase[]
|
|
545
|
+
paymentPhases PaymentPhase[]
|
|
546
|
+
questionnaireFields QuestionnaireField[]
|
|
547
|
+
applicationEvents ApplicationEvent[]
|
|
548
|
+
documentationSteps DocumentationStep[]
|
|
549
|
+
documentationStepDocuments DocumentationStepDocument[]
|
|
550
|
+
documentationStepApprovals DocumentationStepApproval[]
|
|
551
|
+
paymentInstallments PaymentInstallment[]
|
|
552
|
+
applicationPayments ApplicationPayment[]
|
|
553
|
+
applicationDocuments ApplicationDocument[]
|
|
554
|
+
propertyMedia PropertyMedia[]
|
|
555
|
+
propertyDocuments PropertyDocument[]
|
|
556
|
+
propertyVariants PropertyVariant[]
|
|
557
|
+
propertyVariantAmenities PropertyVariantAmenity[]
|
|
558
|
+
propertyVariantMedia PropertyVariantMedia[]
|
|
559
|
+
propertyUnits PropertyUnit[]
|
|
560
|
+
propertyAmenities PropertyAmenity[]
|
|
561
|
+
eventHandlerExecutions EventHandlerExecution[]
|
|
562
|
+
amenities Amenity[]
|
|
535
563
|
|
|
536
564
|
@@index([subdomain])
|
|
537
565
|
@@map("tenants")
|
|
@@ -779,6 +807,8 @@ model Property {
|
|
|
779
807
|
|
|
780
808
|
model PropertyMedia {
|
|
781
809
|
id String @id @default(cuid())
|
|
810
|
+
tenantId String
|
|
811
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
782
812
|
propertyId String
|
|
783
813
|
property Property @relation("PropertyMedia", fields: [propertyId], references: [id], onDelete: Cascade)
|
|
784
814
|
url String
|
|
@@ -790,12 +820,15 @@ model PropertyMedia {
|
|
|
790
820
|
|
|
791
821
|
displayForProperties Property[] @relation("DisplayImage")
|
|
792
822
|
|
|
823
|
+
@@index([tenantId])
|
|
793
824
|
@@index([propertyId])
|
|
794
825
|
@@map("property_media")
|
|
795
826
|
}
|
|
796
827
|
|
|
797
828
|
model PropertyDocument {
|
|
798
829
|
id String @id @default(cuid())
|
|
830
|
+
tenantId String
|
|
831
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
799
832
|
propertyId String
|
|
800
833
|
property Property @relation(fields: [propertyId], references: [id], onDelete: Cascade)
|
|
801
834
|
name String
|
|
@@ -804,13 +837,16 @@ model PropertyDocument {
|
|
|
804
837
|
createdAt DateTime @default(now())
|
|
805
838
|
updatedAt DateTime @updatedAt
|
|
806
839
|
|
|
840
|
+
@@index([tenantId])
|
|
807
841
|
@@index([propertyId])
|
|
808
842
|
@@map("property_documents")
|
|
809
843
|
}
|
|
810
844
|
|
|
811
845
|
model Amenity {
|
|
812
846
|
id String @id @default(cuid())
|
|
813
|
-
|
|
847
|
+
tenantId String
|
|
848
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
849
|
+
name String
|
|
814
850
|
category String? // PROPERTY, VARIANT, BOTH - helps filter which amenities to show
|
|
815
851
|
icon String? // Icon name/URL for UI
|
|
816
852
|
createdAt DateTime @default(now())
|
|
@@ -818,6 +854,8 @@ model Amenity {
|
|
|
818
854
|
properties PropertyAmenity[]
|
|
819
855
|
variants PropertyVariantAmenity[]
|
|
820
856
|
|
|
857
|
+
@@unique([tenantId, name]) // Unique per tenant
|
|
858
|
+
@@index([tenantId])
|
|
821
859
|
@@index([category])
|
|
822
860
|
@@map("amenities")
|
|
823
861
|
}
|
|
@@ -830,6 +868,8 @@ model Amenity {
|
|
|
830
868
|
// e.g., "3-Bedroom Corner Piece - Fully Finished", "2-Bedroom Standard - Carcass"
|
|
831
869
|
model PropertyVariant {
|
|
832
870
|
id String @id @default(cuid())
|
|
871
|
+
tenantId String
|
|
872
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
833
873
|
propertyId String
|
|
834
874
|
property Property @relation(fields: [propertyId], references: [id], onDelete: Cascade)
|
|
835
875
|
|
|
@@ -863,6 +903,7 @@ model PropertyVariant {
|
|
|
863
903
|
units PropertyUnit[]
|
|
864
904
|
media PropertyVariantMedia[]
|
|
865
905
|
|
|
906
|
+
@@index([tenantId])
|
|
866
907
|
@@index([propertyId])
|
|
867
908
|
@@index([status])
|
|
868
909
|
@@index([price])
|
|
@@ -872,6 +913,8 @@ model PropertyVariant {
|
|
|
872
913
|
// PropertyVariantAmenity = amenities specific to a variant
|
|
873
914
|
// e.g., "Finished Kitchen", "Smart Home System", "Private Garden"
|
|
874
915
|
model PropertyVariantAmenity {
|
|
916
|
+
tenantId String
|
|
917
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
875
918
|
variantId String
|
|
876
919
|
amenityId String
|
|
877
920
|
variant PropertyVariant @relation(fields: [variantId], references: [id], onDelete: Cascade)
|
|
@@ -879,12 +922,15 @@ model PropertyVariantAmenity {
|
|
|
879
922
|
createdAt DateTime @default(now())
|
|
880
923
|
|
|
881
924
|
@@id([variantId, amenityId])
|
|
925
|
+
@@index([tenantId])
|
|
882
926
|
@@map("property_variant_amenities")
|
|
883
927
|
}
|
|
884
928
|
|
|
885
929
|
// PropertyVariantMedia = images/videos specific to a variant
|
|
886
930
|
model PropertyVariantMedia {
|
|
887
931
|
id String @id @default(cuid())
|
|
932
|
+
tenantId String
|
|
933
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
888
934
|
variantId String
|
|
889
935
|
variant PropertyVariant @relation(fields: [variantId], references: [id], onDelete: Cascade)
|
|
890
936
|
url String
|
|
@@ -894,6 +940,7 @@ model PropertyVariantMedia {
|
|
|
894
940
|
createdAt DateTime @default(now())
|
|
895
941
|
updatedAt DateTime @updatedAt
|
|
896
942
|
|
|
943
|
+
@@index([tenantId])
|
|
897
944
|
@@index([variantId])
|
|
898
945
|
@@map("property_variant_media")
|
|
899
946
|
}
|
|
@@ -902,6 +949,8 @@ model PropertyVariantMedia {
|
|
|
902
949
|
// e.g., "Unit A1", "Block B - Flat 3", "Plot 15"
|
|
903
950
|
model PropertyUnit {
|
|
904
951
|
id String @id @default(cuid())
|
|
952
|
+
tenantId String
|
|
953
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
905
954
|
variantId String
|
|
906
955
|
variant PropertyVariant @relation(fields: [variantId], references: [id], onDelete: Cascade)
|
|
907
956
|
|
|
@@ -935,12 +984,15 @@ model PropertyUnit {
|
|
|
935
984
|
transferRequests PropertyTransferRequest[]
|
|
936
985
|
|
|
937
986
|
@@unique([variantId, unitNumber])
|
|
987
|
+
@@index([tenantId])
|
|
938
988
|
@@index([variantId])
|
|
939
989
|
@@index([status])
|
|
940
990
|
@@map("property_units")
|
|
941
991
|
}
|
|
942
992
|
|
|
943
993
|
model PropertyAmenity {
|
|
994
|
+
tenantId String
|
|
995
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
944
996
|
propertyId String
|
|
945
997
|
amenityId String
|
|
946
998
|
property Property @relation(fields: [propertyId], references: [id], onDelete: Cascade)
|
|
@@ -948,6 +1000,7 @@ model PropertyAmenity {
|
|
|
948
1000
|
createdAt DateTime @default(now())
|
|
949
1001
|
|
|
950
1002
|
@@id([propertyId, amenityId])
|
|
1003
|
+
@@index([tenantId])
|
|
951
1004
|
@@map("property_amenities")
|
|
952
1005
|
}
|
|
953
1006
|
|
|
@@ -1023,11 +1076,11 @@ model PropertyPaymentMethod {
|
|
|
1023
1076
|
updatedAt DateTime @updatedAt
|
|
1024
1077
|
|
|
1025
1078
|
// Many-to-many with properties
|
|
1026
|
-
properties
|
|
1079
|
+
properties PropertyPaymentMethodLink[]
|
|
1027
1080
|
// Phases that make up this method (templates)
|
|
1028
|
-
phases
|
|
1081
|
+
phases PropertyPaymentMethodPhase[]
|
|
1029
1082
|
// Contracts using this method
|
|
1030
|
-
applications
|
|
1083
|
+
applications Application[]
|
|
1031
1084
|
|
|
1032
1085
|
// Payment method change tracking
|
|
1033
1086
|
changeRequestsFrom PaymentMethodChangeRequest[] @relation("ChangeFromMethod")
|
|
@@ -1045,6 +1098,8 @@ model PropertyPaymentMethod {
|
|
|
1045
1098
|
|
|
1046
1099
|
// Many-to-many link between Property and PaymentMethod
|
|
1047
1100
|
model PropertyPaymentMethodLink {
|
|
1101
|
+
tenantId String
|
|
1102
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1048
1103
|
propertyId String
|
|
1049
1104
|
property Property @relation(fields: [propertyId], references: [id], onDelete: Cascade)
|
|
1050
1105
|
paymentMethodId String
|
|
@@ -1056,6 +1111,7 @@ model PropertyPaymentMethodLink {
|
|
|
1056
1111
|
createdAt DateTime @default(now())
|
|
1057
1112
|
|
|
1058
1113
|
@@id([propertyId, paymentMethodId])
|
|
1114
|
+
@@index([tenantId])
|
|
1059
1115
|
@@map("property_payment_method_links")
|
|
1060
1116
|
}
|
|
1061
1117
|
|
|
@@ -1063,6 +1119,8 @@ model PropertyPaymentMethodLink {
|
|
|
1063
1119
|
// phaseCategory determines the FSM type: DOCUMENTATION or PAYMENT
|
|
1064
1120
|
model PropertyPaymentMethodPhase {
|
|
1065
1121
|
id String @id @default(cuid())
|
|
1122
|
+
tenantId String
|
|
1123
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1066
1124
|
paymentMethodId String
|
|
1067
1125
|
paymentMethod PropertyPaymentMethod @relation(fields: [paymentMethodId], references: [id], onDelete: Cascade)
|
|
1068
1126
|
paymentPlanId String? // Only for PAYMENT phases
|
|
@@ -1105,6 +1163,7 @@ model PropertyPaymentMethodPhase {
|
|
|
1105
1163
|
// Event attachments - handlers that fire on phase transitions
|
|
1106
1164
|
eventAttachments PhaseEventAttachment[]
|
|
1107
1165
|
|
|
1166
|
+
@@index([tenantId])
|
|
1108
1167
|
@@index([paymentMethodId])
|
|
1109
1168
|
@@index([paymentPlanId])
|
|
1110
1169
|
@@index([phaseCategory])
|
|
@@ -1114,9 +1173,11 @@ model PropertyPaymentMethodPhase {
|
|
|
1114
1173
|
/// Phase Event Attachment - Links event handlers to phase template triggers
|
|
1115
1174
|
/// When a phase transitions (complete, payment received, etc.), attached handlers fire
|
|
1116
1175
|
model PhaseEventAttachment {
|
|
1117
|
-
id
|
|
1118
|
-
|
|
1119
|
-
|
|
1176
|
+
id String @id @default(cuid())
|
|
1177
|
+
tenantId String
|
|
1178
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1179
|
+
phaseId String
|
|
1180
|
+
phase PropertyPaymentMethodPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1120
1181
|
|
|
1121
1182
|
/// When this handler should fire
|
|
1122
1183
|
trigger PhaseTrigger
|
|
@@ -1135,6 +1196,7 @@ model PhaseEventAttachment {
|
|
|
1135
1196
|
updatedAt DateTime @updatedAt
|
|
1136
1197
|
|
|
1137
1198
|
@@unique([phaseId, handlerId, trigger])
|
|
1199
|
+
@@index([tenantId])
|
|
1138
1200
|
@@index([phaseId])
|
|
1139
1201
|
@@index([handlerId])
|
|
1140
1202
|
@@map("phase_event_attachments")
|
|
@@ -1142,9 +1204,11 @@ model PhaseEventAttachment {
|
|
|
1142
1204
|
|
|
1143
1205
|
// Step template within a DOCUMENTATION phase
|
|
1144
1206
|
model PaymentMethodPhaseStep {
|
|
1145
|
-
id
|
|
1146
|
-
|
|
1147
|
-
|
|
1207
|
+
id String @id @default(cuid())
|
|
1208
|
+
tenantId String
|
|
1209
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1210
|
+
phaseId String
|
|
1211
|
+
phase PropertyPaymentMethodPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1148
1212
|
|
|
1149
1213
|
name String
|
|
1150
1214
|
stepType StepType
|
|
@@ -1157,6 +1221,7 @@ model PaymentMethodPhaseStep {
|
|
|
1157
1221
|
// Event attachments - handlers that fire on step transitions
|
|
1158
1222
|
eventAttachments StepEventAttachment[]
|
|
1159
1223
|
|
|
1224
|
+
@@index([tenantId])
|
|
1160
1225
|
@@index([phaseId])
|
|
1161
1226
|
@@map("payment_method_phase_steps")
|
|
1162
1227
|
}
|
|
@@ -1164,9 +1229,11 @@ model PaymentMethodPhaseStep {
|
|
|
1164
1229
|
/// Step Event Attachment - Links event handlers to step template triggers
|
|
1165
1230
|
/// When a step transitions (complete, reject, etc.), attached handlers fire
|
|
1166
1231
|
model StepEventAttachment {
|
|
1167
|
-
id
|
|
1168
|
-
|
|
1169
|
-
|
|
1232
|
+
id String @id @default(cuid())
|
|
1233
|
+
tenantId String
|
|
1234
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1235
|
+
stepId String
|
|
1236
|
+
step PaymentMethodPhaseStep @relation(fields: [stepId], references: [id], onDelete: Cascade)
|
|
1170
1237
|
|
|
1171
1238
|
/// When this handler should fire
|
|
1172
1239
|
trigger StepTrigger
|
|
@@ -1185,6 +1252,7 @@ model StepEventAttachment {
|
|
|
1185
1252
|
updatedAt DateTime @updatedAt
|
|
1186
1253
|
|
|
1187
1254
|
@@unique([stepId, handlerId, trigger])
|
|
1255
|
+
@@index([tenantId])
|
|
1188
1256
|
@@index([stepId])
|
|
1189
1257
|
@@index([handlerId])
|
|
1190
1258
|
@@map("step_event_attachments")
|
|
@@ -1192,9 +1260,11 @@ model StepEventAttachment {
|
|
|
1192
1260
|
|
|
1193
1261
|
// Required document within a DOCUMENTATION phase
|
|
1194
1262
|
model PaymentMethodPhaseDocument {
|
|
1195
|
-
id
|
|
1196
|
-
|
|
1197
|
-
|
|
1263
|
+
id String @id @default(cuid())
|
|
1264
|
+
tenantId String
|
|
1265
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1266
|
+
phaseId String
|
|
1267
|
+
phase PropertyPaymentMethodPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1198
1268
|
|
|
1199
1269
|
documentType String
|
|
1200
1270
|
isRequired Boolean @default(true)
|
|
@@ -1205,6 +1275,7 @@ model PaymentMethodPhaseDocument {
|
|
|
1205
1275
|
metadata Json?
|
|
1206
1276
|
createdAt DateTime @default(now())
|
|
1207
1277
|
|
|
1278
|
+
@@index([tenantId])
|
|
1208
1279
|
@@index([phaseId, documentType])
|
|
1209
1280
|
@@map("payment_method_phase_documents")
|
|
1210
1281
|
}
|
|
@@ -1230,9 +1301,11 @@ enum FieldType {
|
|
|
1230
1301
|
|
|
1231
1302
|
// Questionnaire field template within a QUESTIONNAIRE phase
|
|
1232
1303
|
model PaymentMethodPhaseField {
|
|
1233
|
-
id
|
|
1234
|
-
|
|
1235
|
-
|
|
1304
|
+
id String @id @default(cuid())
|
|
1305
|
+
tenantId String
|
|
1306
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1307
|
+
phaseId String
|
|
1308
|
+
phase PropertyPaymentMethodPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1236
1309
|
|
|
1237
1310
|
// Field identification
|
|
1238
1311
|
name String // Internal field name (e.g., "monthly_income")
|
|
@@ -1264,6 +1337,7 @@ model PaymentMethodPhaseField {
|
|
|
1264
1337
|
updatedAt DateTime @updatedAt
|
|
1265
1338
|
|
|
1266
1339
|
@@unique([phaseId, name])
|
|
1340
|
+
@@index([tenantId])
|
|
1267
1341
|
@@index([phaseId])
|
|
1268
1342
|
@@map("payment_method_phase_fields")
|
|
1269
1343
|
}
|
|
@@ -1292,8 +1366,8 @@ model Application {
|
|
|
1292
1366
|
|
|
1293
1367
|
// Contract identification
|
|
1294
1368
|
applicationNumber String @unique
|
|
1295
|
-
title
|
|
1296
|
-
description
|
|
1369
|
+
title String
|
|
1370
|
+
description String? @db.Text
|
|
1297
1371
|
applicationType String // Admin-defined: MORTGAGE, INSTALLMENT, RENT_TO_OWN, CASH, LEASE, etc.
|
|
1298
1372
|
|
|
1299
1373
|
// Contract value (negotiated from unit price)
|
|
@@ -1325,7 +1399,7 @@ model Application {
|
|
|
1325
1399
|
paymentMethodChangeRequests PaymentMethodChangeRequest[]
|
|
1326
1400
|
|
|
1327
1401
|
// Transfer tracking - when a contract is transferred to a different property
|
|
1328
|
-
transferredFromId String?
|
|
1402
|
+
transferredFromId String? @unique // Source contract if this was created via transfer
|
|
1329
1403
|
transferredFrom Application? @relation("ApplicationTransfer", fields: [transferredFromId], references: [id])
|
|
1330
1404
|
transferredTo Application? @relation("ApplicationTransfer")
|
|
1331
1405
|
|
|
@@ -1419,7 +1493,9 @@ model ApplicationRefund {
|
|
|
1419
1493
|
// =============================================================================
|
|
1420
1494
|
|
|
1421
1495
|
model ApplicationPhase {
|
|
1422
|
-
id
|
|
1496
|
+
id String @id @default(cuid())
|
|
1497
|
+
tenantId String
|
|
1498
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1423
1499
|
applicationId String
|
|
1424
1500
|
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1425
1501
|
|
|
@@ -1459,6 +1535,7 @@ model ApplicationPhase {
|
|
|
1459
1535
|
// Back-relation for applications where this is the current phase
|
|
1460
1536
|
currentForApplications Application[] @relation("CurrentPhase")
|
|
1461
1537
|
|
|
1538
|
+
@@index([tenantId])
|
|
1462
1539
|
@@index([applicationId])
|
|
1463
1540
|
@@index([phaseCategory])
|
|
1464
1541
|
@@index([status])
|
|
@@ -1473,9 +1550,11 @@ model ApplicationPhase {
|
|
|
1473
1550
|
// =============================================================================
|
|
1474
1551
|
|
|
1475
1552
|
model QuestionnairePhase {
|
|
1476
|
-
id
|
|
1477
|
-
|
|
1478
|
-
|
|
1553
|
+
id String @id @default(cuid())
|
|
1554
|
+
tenantId String
|
|
1555
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1556
|
+
phaseId String @unique
|
|
1557
|
+
phase ApplicationPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1479
1558
|
|
|
1480
1559
|
// Progress tracking
|
|
1481
1560
|
completedFieldsCount Int @default(0)
|
|
@@ -1496,6 +1575,7 @@ model QuestionnairePhase {
|
|
|
1496
1575
|
// Child records
|
|
1497
1576
|
fields QuestionnaireField[]
|
|
1498
1577
|
|
|
1578
|
+
@@index([tenantId])
|
|
1499
1579
|
@@index([phaseId])
|
|
1500
1580
|
@@map("questionnaire_phases")
|
|
1501
1581
|
}
|
|
@@ -1507,9 +1587,11 @@ model QuestionnairePhase {
|
|
|
1507
1587
|
// =============================================================================
|
|
1508
1588
|
|
|
1509
1589
|
model DocumentationPhase {
|
|
1510
|
-
id
|
|
1511
|
-
|
|
1512
|
-
|
|
1590
|
+
id String @id @default(cuid())
|
|
1591
|
+
tenantId String
|
|
1592
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1593
|
+
phaseId String @unique
|
|
1594
|
+
phase ApplicationPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1513
1595
|
|
|
1514
1596
|
// Current step pointer for UX and orchestration
|
|
1515
1597
|
currentStepId String?
|
|
@@ -1535,6 +1617,7 @@ model DocumentationPhase {
|
|
|
1535
1617
|
// Child records
|
|
1536
1618
|
steps DocumentationStep[]
|
|
1537
1619
|
|
|
1620
|
+
@@index([tenantId])
|
|
1538
1621
|
@@index([phaseId])
|
|
1539
1622
|
@@index([currentStepId])
|
|
1540
1623
|
@@map("documentation_phases")
|
|
@@ -1547,9 +1630,11 @@ model DocumentationPhase {
|
|
|
1547
1630
|
// =============================================================================
|
|
1548
1631
|
|
|
1549
1632
|
model PaymentPhase {
|
|
1550
|
-
id
|
|
1551
|
-
|
|
1552
|
-
|
|
1633
|
+
id String @id @default(cuid())
|
|
1634
|
+
tenantId String
|
|
1635
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1636
|
+
phaseId String @unique
|
|
1637
|
+
phase ApplicationPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1553
1638
|
|
|
1554
1639
|
// Payment plan reference
|
|
1555
1640
|
paymentPlanId String?
|
|
@@ -1582,6 +1667,7 @@ model PaymentPhase {
|
|
|
1582
1667
|
// Child records
|
|
1583
1668
|
installments PaymentInstallment[]
|
|
1584
1669
|
|
|
1670
|
+
@@index([tenantId])
|
|
1585
1671
|
@@index([phaseId])
|
|
1586
1672
|
@@index([paymentPlanId])
|
|
1587
1673
|
@@map("payment_phases")
|
|
@@ -1596,6 +1682,8 @@ model PaymentPhase {
|
|
|
1596
1682
|
|
|
1597
1683
|
model QuestionnaireField {
|
|
1598
1684
|
id String @id @default(cuid())
|
|
1685
|
+
tenantId String
|
|
1686
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1599
1687
|
questionnairePhaseId String
|
|
1600
1688
|
questionnairePhase QuestionnairePhase @relation(fields: [questionnairePhaseId], references: [id], onDelete: Cascade)
|
|
1601
1689
|
|
|
@@ -1634,6 +1722,7 @@ model QuestionnaireField {
|
|
|
1634
1722
|
updatedAt DateTime @updatedAt
|
|
1635
1723
|
|
|
1636
1724
|
@@unique([questionnairePhaseId, name])
|
|
1725
|
+
@@index([tenantId])
|
|
1637
1726
|
@@index([questionnairePhaseId])
|
|
1638
1727
|
@@map("questionnaire_fields")
|
|
1639
1728
|
}
|
|
@@ -1646,7 +1735,9 @@ model QuestionnaireField {
|
|
|
1646
1735
|
// ApplicationEvent is purely for historical tracking and state machine transitions.
|
|
1647
1736
|
// =============================================================================
|
|
1648
1737
|
model ApplicationEvent {
|
|
1649
|
-
id
|
|
1738
|
+
id String @id @default(cuid())
|
|
1739
|
+
tenantId String
|
|
1740
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1650
1741
|
applicationId String
|
|
1651
1742
|
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1652
1743
|
|
|
@@ -1669,6 +1760,7 @@ model ApplicationEvent {
|
|
|
1669
1760
|
// Timing
|
|
1670
1761
|
occurredAt DateTime @default(now())
|
|
1671
1762
|
|
|
1763
|
+
@@index([tenantId])
|
|
1672
1764
|
@@index([applicationId])
|
|
1673
1765
|
@@index([eventType])
|
|
1674
1766
|
@@index([eventGroup])
|
|
@@ -1679,6 +1771,8 @@ model ApplicationEvent {
|
|
|
1679
1771
|
// Steps within a DOCUMENTATION phase (FSM for document collection/approval)
|
|
1680
1772
|
model DocumentationStep {
|
|
1681
1773
|
id String @id @default(cuid())
|
|
1774
|
+
tenantId String
|
|
1775
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1682
1776
|
documentationPhaseId String
|
|
1683
1777
|
documentationPhase DocumentationPhase @relation(fields: [documentationPhaseId], references: [id], onDelete: Cascade)
|
|
1684
1778
|
|
|
@@ -1722,6 +1816,7 @@ model DocumentationStep {
|
|
|
1722
1816
|
approvals DocumentationStepApproval[]
|
|
1723
1817
|
currentForPhase DocumentationPhase[] @relation("CurrentStep")
|
|
1724
1818
|
|
|
1819
|
+
@@index([tenantId])
|
|
1725
1820
|
@@index([documentationPhaseId])
|
|
1726
1821
|
@@index([status])
|
|
1727
1822
|
@@index([order])
|
|
@@ -1730,15 +1825,18 @@ model DocumentationStep {
|
|
|
1730
1825
|
|
|
1731
1826
|
// Required documents for a step (normalized from CSV)
|
|
1732
1827
|
model DocumentationStepDocument {
|
|
1733
|
-
id
|
|
1734
|
-
|
|
1735
|
-
|
|
1828
|
+
id String @id @default(cuid())
|
|
1829
|
+
tenantId String
|
|
1830
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1831
|
+
stepId String
|
|
1832
|
+
step DocumentationStep @relation(fields: [stepId], references: [id], onDelete: Cascade)
|
|
1736
1833
|
|
|
1737
1834
|
documentType String
|
|
1738
1835
|
isRequired Boolean @default(true)
|
|
1739
1836
|
|
|
1740
1837
|
createdAt DateTime @default(now())
|
|
1741
1838
|
|
|
1839
|
+
@@index([tenantId])
|
|
1742
1840
|
@@index([stepId, documentType])
|
|
1743
1841
|
@@map("documentation_step_documents")
|
|
1744
1842
|
}
|
|
@@ -1746,6 +1844,8 @@ model DocumentationStepDocument {
|
|
|
1746
1844
|
// Approvals for documentation steps
|
|
1747
1845
|
model DocumentationStepApproval {
|
|
1748
1846
|
id String @id @default(cuid())
|
|
1847
|
+
tenantId String
|
|
1848
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1749
1849
|
stepId String
|
|
1750
1850
|
step DocumentationStep @relation(fields: [stepId], references: [id], onDelete: Cascade)
|
|
1751
1851
|
approverId String?
|
|
@@ -1757,6 +1857,7 @@ model DocumentationStepApproval {
|
|
|
1757
1857
|
|
|
1758
1858
|
createdAt DateTime @default(now())
|
|
1759
1859
|
|
|
1860
|
+
@@index([tenantId])
|
|
1760
1861
|
@@index([stepId])
|
|
1761
1862
|
@@map("documentation_step_approvals")
|
|
1762
1863
|
}
|
|
@@ -1764,6 +1865,8 @@ model DocumentationStepApproval {
|
|
|
1764
1865
|
// Installments within a PAYMENT phase
|
|
1765
1866
|
model PaymentInstallment {
|
|
1766
1867
|
id String @id @default(cuid())
|
|
1868
|
+
tenantId String
|
|
1869
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1767
1870
|
paymentPhaseId String
|
|
1768
1871
|
paymentPhase PaymentPhase @relation(fields: [paymentPhaseId], references: [id], onDelete: Cascade)
|
|
1769
1872
|
|
|
@@ -1789,6 +1892,7 @@ model PaymentInstallment {
|
|
|
1789
1892
|
|
|
1790
1893
|
payments ApplicationPayment[]
|
|
1791
1894
|
|
|
1895
|
+
@@index([tenantId])
|
|
1792
1896
|
@@index([paymentPhaseId])
|
|
1793
1897
|
@@index([dueDate])
|
|
1794
1898
|
@@index([status])
|
|
@@ -1797,15 +1901,17 @@ model PaymentInstallment {
|
|
|
1797
1901
|
|
|
1798
1902
|
// Unified payment record for contracts
|
|
1799
1903
|
model ApplicationPayment {
|
|
1800
|
-
id String
|
|
1801
|
-
|
|
1802
|
-
|
|
1904
|
+
id String @id @default(cuid())
|
|
1905
|
+
tenantId String
|
|
1906
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1907
|
+
applicationId String
|
|
1908
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1803
1909
|
phaseId String?
|
|
1804
|
-
phase ApplicationPhase?
|
|
1910
|
+
phase ApplicationPhase? @relation(fields: [phaseId], references: [id])
|
|
1805
1911
|
installmentId String?
|
|
1806
1912
|
installment PaymentInstallment? @relation(fields: [installmentId], references: [id])
|
|
1807
1913
|
payerId String?
|
|
1808
|
-
payer User?
|
|
1914
|
+
payer User? @relation("ApplicationPayer", fields: [payerId], references: [id])
|
|
1809
1915
|
|
|
1810
1916
|
amount Float
|
|
1811
1917
|
principalAmount Float @default(0)
|
|
@@ -1822,6 +1928,7 @@ model ApplicationPayment {
|
|
|
1822
1928
|
createdAt DateTime @default(now())
|
|
1823
1929
|
updatedAt DateTime @updatedAt
|
|
1824
1930
|
|
|
1931
|
+
@@index([tenantId])
|
|
1825
1932
|
@@index([applicationId])
|
|
1826
1933
|
@@index([phaseId])
|
|
1827
1934
|
@@index([installmentId])
|
|
@@ -1833,11 +1940,13 @@ model ApplicationPayment {
|
|
|
1833
1940
|
|
|
1834
1941
|
// Contract documents (owned by contract, linked to phases/steps as needed)
|
|
1835
1942
|
model ApplicationDocument {
|
|
1836
|
-
id
|
|
1943
|
+
id String @id @default(cuid())
|
|
1944
|
+
tenantId String
|
|
1945
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1837
1946
|
applicationId String
|
|
1838
1947
|
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1839
|
-
phaseId
|
|
1840
|
-
stepId
|
|
1948
|
+
phaseId String? // Optional link to specific phase
|
|
1949
|
+
stepId String? // Optional link to specific step
|
|
1841
1950
|
|
|
1842
1951
|
name String
|
|
1843
1952
|
url String
|
|
@@ -1850,6 +1959,7 @@ model ApplicationDocument {
|
|
|
1850
1959
|
createdAt DateTime @default(now())
|
|
1851
1960
|
updatedAt DateTime @updatedAt
|
|
1852
1961
|
|
|
1962
|
+
@@index([tenantId])
|
|
1853
1963
|
@@index([applicationId])
|
|
1854
1964
|
@@index([phaseId])
|
|
1855
1965
|
@@index([stepId])
|
|
@@ -1894,9 +2004,9 @@ model DocumentTemplate {
|
|
|
1894
2004
|
}
|
|
1895
2005
|
|
|
1896
2006
|
model OfferLetter {
|
|
1897
|
-
id
|
|
1898
|
-
tenantId
|
|
1899
|
-
tenant
|
|
2007
|
+
id String @id @default(cuid())
|
|
2008
|
+
tenantId String
|
|
2009
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1900
2010
|
applicationId String
|
|
1901
2011
|
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1902
2012
|
|
|
@@ -1959,11 +2069,11 @@ model OfferLetter {
|
|
|
1959
2069
|
// =============================================================================
|
|
1960
2070
|
|
|
1961
2071
|
model ApplicationTermination {
|
|
1962
|
-
id
|
|
2072
|
+
id String @id @default(cuid())
|
|
1963
2073
|
applicationId String
|
|
1964
2074
|
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1965
|
-
tenantId
|
|
1966
|
-
tenant
|
|
2075
|
+
tenantId String
|
|
2076
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1967
2077
|
|
|
1968
2078
|
// Request identification
|
|
1969
2079
|
requestNumber String @unique // TRM-XXXXXX
|
|
@@ -1991,8 +2101,8 @@ model ApplicationTermination {
|
|
|
1991
2101
|
// Financial snapshot at time of request
|
|
1992
2102
|
applicationSnapshot Json // Full contract state snapshot
|
|
1993
2103
|
totalApplicationAmount Float
|
|
1994
|
-
totalPaidToDate
|
|
1995
|
-
outstandingBalance
|
|
2104
|
+
totalPaidToDate Float
|
|
2105
|
+
outstandingBalance Float
|
|
1996
2106
|
|
|
1997
2107
|
// Settlement calculation
|
|
1998
2108
|
refundableAmount Float @default(0) // Amount eligible for refund
|
|
@@ -2057,9 +2167,9 @@ enum PaymentMethodChangeStatus {
|
|
|
2057
2167
|
}
|
|
2058
2168
|
|
|
2059
2169
|
model PaymentMethodChangeRequest {
|
|
2060
|
-
id
|
|
2061
|
-
tenantId
|
|
2062
|
-
tenant
|
|
2170
|
+
id String @id @default(cuid())
|
|
2171
|
+
tenantId String
|
|
2172
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
2063
2173
|
applicationId String
|
|
2064
2174
|
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
2065
2175
|
|
|
@@ -2358,7 +2468,9 @@ model WorkflowEvent {
|
|
|
2358
2468
|
|
|
2359
2469
|
/// Event Handler Execution - Log of a handler processing an event
|
|
2360
2470
|
model EventHandlerExecution {
|
|
2361
|
-
id
|
|
2471
|
+
id String @id @default(cuid())
|
|
2472
|
+
tenantId String
|
|
2473
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
2362
2474
|
|
|
2363
2475
|
/// The event being processed
|
|
2364
2476
|
eventId String
|
|
@@ -2391,6 +2503,7 @@ model EventHandlerExecution {
|
|
|
2391
2503
|
|
|
2392
2504
|
createdAt DateTime @default(now())
|
|
2393
2505
|
|
|
2506
|
+
@@index([tenantId])
|
|
2394
2507
|
@@index([eventId])
|
|
2395
2508
|
@@index([handlerId])
|
|
2396
2509
|
@@index([status])
|
|
@@ -2599,3 +2712,103 @@ model ApprovalRequest {
|
|
|
2599
2712
|
@@index([type, status]) // Efficient queries for approval dashboard
|
|
2600
2713
|
@@map("approval_requests")
|
|
2601
2714
|
}
|
|
2715
|
+
|
|
2716
|
+
// =============================================================================
|
|
2717
|
+
// WORKFLOW BLOCKER TRACKING - Analytics for workflow delays
|
|
2718
|
+
// =============================================================================
|
|
2719
|
+
// Tracks who is blocking the workflow at any point, enabling analytics like:
|
|
2720
|
+
// - Average time customers take to upload documents
|
|
2721
|
+
// - Average time admins take to review/approve
|
|
2722
|
+
// - Most common bottleneck steps
|
|
2723
|
+
// - SLA compliance tracking
|
|
2724
|
+
// - Customer service intervention triggers
|
|
2725
|
+
// =============================================================================
|
|
2726
|
+
|
|
2727
|
+
/// Who is responsible for the current workflow block
|
|
2728
|
+
enum BlockerActor {
|
|
2729
|
+
CUSTOMER // Customer action required (upload, sign, pay)
|
|
2730
|
+
ADMIN // Admin action required (review, approve, reject)
|
|
2731
|
+
SYSTEM // System processing (auto-generation, external checks)
|
|
2732
|
+
EXTERNAL // External party (bank, government, third-party verification)
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
/// Category of action that is blocking workflow
|
|
2736
|
+
enum BlockerCategory {
|
|
2737
|
+
UPLOAD // Document upload needed
|
|
2738
|
+
RESUBMISSION // Document resubmission after rejection
|
|
2739
|
+
SIGNATURE // Signature required
|
|
2740
|
+
REVIEW // Admin review needed
|
|
2741
|
+
APPROVAL // Admin approval needed
|
|
2742
|
+
PAYMENT // Payment required
|
|
2743
|
+
PROCESSING // System processing
|
|
2744
|
+
EXTERNAL_CHECK // External verification
|
|
2745
|
+
QUESTIONNAIRE // Form/questionnaire completion
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
/// Urgency level for prioritization and SLA tracking
|
|
2749
|
+
enum BlockerUrgency {
|
|
2750
|
+
LOW // No immediate deadline
|
|
2751
|
+
NORMAL // Standard processing
|
|
2752
|
+
HIGH // Approaching deadline or overdue
|
|
2753
|
+
CRITICAL // Significantly overdue or business-critical
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
/// Workflow Blocker - Records who is blocking workflow and for how long
|
|
2757
|
+
model WorkflowBlocker {
|
|
2758
|
+
id String @id @default(cuid())
|
|
2759
|
+
tenantId String
|
|
2760
|
+
|
|
2761
|
+
// Reference to the blocked entity
|
|
2762
|
+
applicationId String
|
|
2763
|
+
phaseId String?
|
|
2764
|
+
stepId String?
|
|
2765
|
+
|
|
2766
|
+
// Actor and action details
|
|
2767
|
+
blockerActor BlockerActor
|
|
2768
|
+
blockerCategory BlockerCategory
|
|
2769
|
+
urgency BlockerUrgency @default(NORMAL)
|
|
2770
|
+
|
|
2771
|
+
// Human-readable descriptions
|
|
2772
|
+
actionRequired String @db.VarChar(500) // What action is needed
|
|
2773
|
+
context String? @db.Text // Additional context
|
|
2774
|
+
|
|
2775
|
+
// SLA tracking
|
|
2776
|
+
expectedByDate DateTime? // When this action should be completed
|
|
2777
|
+
isOverdue Boolean @default(false)
|
|
2778
|
+
overdueAt DateTime? // When it became overdue
|
|
2779
|
+
|
|
2780
|
+
// Duration tracking
|
|
2781
|
+
startedAt DateTime @default(now()) // When this block started
|
|
2782
|
+
resolvedAt DateTime? // When it was resolved
|
|
2783
|
+
durationMs Int? // Calculated duration on resolution
|
|
2784
|
+
|
|
2785
|
+
// Resolution details
|
|
2786
|
+
resolvedByActor String? // Who resolved it (userId or "SYSTEM")
|
|
2787
|
+
resolutionTrigger String? // What action resolved it (e.g., "DOCUMENT_UPLOADED", "STEP_COMPLETED")
|
|
2788
|
+
|
|
2789
|
+
// Reminder tracking (for customer service)
|
|
2790
|
+
reminderCount Int @default(0) // Number of reminders sent
|
|
2791
|
+
lastReminderAt DateTime? // Last reminder timestamp
|
|
2792
|
+
nextReminderAt DateTime? // Scheduled next reminder
|
|
2793
|
+
|
|
2794
|
+
// Metadata for additional analytics
|
|
2795
|
+
metadata Json? // Flexible data: { documentType, stepType, phaseType, etc. }
|
|
2796
|
+
|
|
2797
|
+
createdAt DateTime @default(now())
|
|
2798
|
+
updatedAt DateTime @updatedAt
|
|
2799
|
+
|
|
2800
|
+
@@index([tenantId])
|
|
2801
|
+
@@index([applicationId])
|
|
2802
|
+
@@index([phaseId])
|
|
2803
|
+
@@index([stepId])
|
|
2804
|
+
@@index([blockerActor])
|
|
2805
|
+
@@index([blockerCategory])
|
|
2806
|
+
@@index([urgency])
|
|
2807
|
+
@@index([isOverdue])
|
|
2808
|
+
@@index([startedAt])
|
|
2809
|
+
@@index([resolvedAt])
|
|
2810
|
+
@@index([tenantId, blockerActor, resolvedAt]) // For "open blockers by actor" queries
|
|
2811
|
+
@@index([tenantId, blockerCategory, resolvedAt]) // For "open blockers by category" queries
|
|
2812
|
+
@@index([tenantId, isOverdue, blockerActor]) // For SLA violation queries
|
|
2813
|
+
@@map("workflow_blockers")
|
|
2814
|
+
}
|