@valentine-efagene/qshelter-common 2.0.84 → 2.0.87
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 +25 -0
- package/dist/generated/client/client.d.ts +25 -0
- package/dist/generated/client/commonInputTypes.d.ts +30 -0
- package/dist/generated/client/enums.d.ts +18 -0
- package/dist/generated/client/enums.js +17 -0
- package/dist/generated/client/internal/class.d.ts +55 -0
- package/dist/generated/client/internal/class.js +2 -2
- package/dist/generated/client/internal/prismaNamespace.d.ts +469 -42
- package/dist/generated/client/internal/prismaNamespace.js +118 -40
- package/dist/generated/client/internal/prismaNamespaceBrowser.d.ts +129 -41
- package/dist/generated/client/internal/prismaNamespaceBrowser.js +118 -40
- package/dist/generated/client/models/Contract.d.ts +303 -1574
- package/dist/generated/client/models/ContractInstallment.d.ts +77 -77
- package/dist/generated/client/models/ContractPhase.d.ts +339 -1376
- package/dist/generated/client/models/DocumentationPhase.d.ts +1649 -0
- package/dist/generated/client/models/DocumentationPhase.js +1 -0
- package/dist/generated/client/models/DocumentationStep.d.ts +126 -387
- package/dist/generated/client/models/PaymentMethodPhaseField.d.ts +1378 -0
- package/dist/generated/client/models/PaymentMethodPhaseField.js +1 -0
- package/dist/generated/client/models/PaymentPhase.d.ts +1566 -0
- package/dist/generated/client/models/PaymentPhase.js +1 -0
- package/dist/generated/client/models/PaymentPlan.d.ts +53 -53
- package/dist/generated/client/models/PropertyPaymentMethodPhase.d.ts +171 -0
- package/dist/generated/client/models/PropertyTransferRequest.d.ts +196 -70
- package/dist/generated/client/models/QuestionnaireField.d.ts +1495 -0
- package/dist/generated/client/models/QuestionnaireField.js +1 -0
- package/dist/generated/client/models/QuestionnairePhase.d.ts +1383 -0
- package/dist/generated/client/models/QuestionnairePhase.js +1 -0
- package/dist/generated/client/models.d.ts +5 -0
- package/package.json +1 -1
- package/prisma/migrations/20260109132751_update_transfer_flow/migration.sql +343 -0
- package/prisma/schema.prisma +304 -98
package/prisma/schema.prisma
CHANGED
|
@@ -20,16 +20,26 @@ datasource db {
|
|
|
20
20
|
// =============================================================================
|
|
21
21
|
|
|
22
22
|
enum PhaseCategory {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
QUESTIONNAIRE // Configurable form fields with validation
|
|
24
|
+
DOCUMENTATION // Document upload and approval workflow
|
|
25
|
+
PAYMENT // Installment-based payment collection
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
enum PhaseType {
|
|
29
|
+
// QUESTIONNAIRE phases
|
|
30
|
+
PRE_APPROVAL // Eligibility questionnaire (income, employment, etc.)
|
|
31
|
+
UNDERWRITING // System evaluation of eligibility
|
|
32
|
+
|
|
33
|
+
// DOCUMENTATION phases
|
|
28
34
|
KYC
|
|
29
35
|
VERIFICATION
|
|
36
|
+
|
|
37
|
+
// PAYMENT phases
|
|
30
38
|
DOWNPAYMENT
|
|
31
39
|
MORTGAGE
|
|
32
40
|
BALLOON
|
|
41
|
+
|
|
42
|
+
// Generic
|
|
33
43
|
CUSTOM
|
|
34
44
|
}
|
|
35
45
|
|
|
@@ -898,9 +908,9 @@ model PaymentPlan {
|
|
|
898
908
|
updatedAt DateTime @updatedAt
|
|
899
909
|
|
|
900
910
|
// Used by property payment method phases (templates)
|
|
901
|
-
methodPhases
|
|
902
|
-
// Used by instantiated
|
|
903
|
-
|
|
911
|
+
methodPhases PropertyPaymentMethodPhase[]
|
|
912
|
+
// Used by instantiated payment phases
|
|
913
|
+
paymentPhases PaymentPhase[]
|
|
904
914
|
|
|
905
915
|
@@unique([tenantId, name]) // Unique per tenant, or globally if tenantId is null
|
|
906
916
|
@@index([tenantId])
|
|
@@ -1005,8 +1015,10 @@ model PropertyPaymentMethodPhase {
|
|
|
1005
1015
|
updatedAt DateTime @updatedAt
|
|
1006
1016
|
|
|
1007
1017
|
// Normalized child tables (for DOCUMENTATION phases)
|
|
1008
|
-
steps
|
|
1009
|
-
requiredDocuments
|
|
1018
|
+
steps PaymentMethodPhaseStep[]
|
|
1019
|
+
requiredDocuments PaymentMethodPhaseDocument[]
|
|
1020
|
+
// Normalized child tables (for QUESTIONNAIRE phases)
|
|
1021
|
+
questionnaireFields PaymentMethodPhaseField[]
|
|
1010
1022
|
|
|
1011
1023
|
@@index([paymentMethodId])
|
|
1012
1024
|
@@index([paymentPlanId])
|
|
@@ -1083,12 +1095,71 @@ model PaymentMethodPhaseDocument {
|
|
|
1083
1095
|
@@map("payment_method_phase_documents")
|
|
1084
1096
|
}
|
|
1085
1097
|
|
|
1098
|
+
// =============================================================================
|
|
1099
|
+
// QUESTIONNAIRE FIELD TYPES - For QUESTIONNAIRE phases
|
|
1100
|
+
// =============================================================================
|
|
1101
|
+
|
|
1102
|
+
enum FieldType {
|
|
1103
|
+
TEXT // Short text input
|
|
1104
|
+
TEXTAREA // Long text input
|
|
1105
|
+
NUMBER // Numeric input (with optional min/max)
|
|
1106
|
+
CURRENCY // Currency input (validated as money)
|
|
1107
|
+
EMAIL // Email validation
|
|
1108
|
+
PHONE // Phone number validation
|
|
1109
|
+
DATE // Date picker
|
|
1110
|
+
SELECT // Dropdown/single select
|
|
1111
|
+
MULTI_SELECT // Multiple selection
|
|
1112
|
+
CHECKBOX // Boolean yes/no
|
|
1113
|
+
RADIO // Radio button group
|
|
1114
|
+
FILE // File upload (single)
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// Questionnaire field template within a QUESTIONNAIRE phase
|
|
1118
|
+
model PaymentMethodPhaseField {
|
|
1119
|
+
id String @id @default(cuid())
|
|
1120
|
+
phaseId String
|
|
1121
|
+
phase PropertyPaymentMethodPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1122
|
+
|
|
1123
|
+
// Field identification
|
|
1124
|
+
name String // Internal field name (e.g., "monthly_income")
|
|
1125
|
+
label String // Display label (e.g., "Monthly Income")
|
|
1126
|
+
description String? @db.Text // Help text for the field
|
|
1127
|
+
placeholder String? // Placeholder text
|
|
1128
|
+
|
|
1129
|
+
// Field configuration
|
|
1130
|
+
fieldType FieldType
|
|
1131
|
+
isRequired Boolean @default(true)
|
|
1132
|
+
order Int
|
|
1133
|
+
|
|
1134
|
+
// Validation rules (JSON schema-like)
|
|
1135
|
+
// Examples:
|
|
1136
|
+
// NUMBER: { "min": 0, "max": 1000000 }
|
|
1137
|
+
// TEXT: { "minLength": 2, "maxLength": 100, "pattern": "^[A-Za-z]+$" }
|
|
1138
|
+
// SELECT: { "options": [{"value": "employed", "label": "Employed"}, ...] }
|
|
1139
|
+
// DATE: { "minDate": "now", "maxDate": "+30d" }
|
|
1140
|
+
validation Json?
|
|
1141
|
+
|
|
1142
|
+
// For conditional display (e.g., show if another field has a certain value)
|
|
1143
|
+
// { "field": "employment_status", "operator": "equals", "value": "employed" }
|
|
1144
|
+
displayCondition Json?
|
|
1145
|
+
|
|
1146
|
+
// Default value (JSON to support any type)
|
|
1147
|
+
defaultValue Json?
|
|
1148
|
+
|
|
1149
|
+
createdAt DateTime @default(now())
|
|
1150
|
+
updatedAt DateTime @updatedAt
|
|
1151
|
+
|
|
1152
|
+
@@unique([phaseId, name])
|
|
1153
|
+
@@index([phaseId])
|
|
1154
|
+
@@map("payment_method_phase_fields")
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1086
1157
|
// =============================================================================
|
|
1087
1158
|
// CONTRACT DOMAIN - Unified agreement model (replaces Mortgage, PurchasePlan, etc.)
|
|
1088
1159
|
// =============================================================================
|
|
1089
1160
|
// Contract is the canonical agreement. "Mortgage" is just a product configuration
|
|
1090
1161
|
// that creates a Contract with specific phases (documentation, downpayment, long-term payment).
|
|
1091
|
-
// Phases can be DOCUMENTATION
|
|
1162
|
+
// Phases can be QUESTIONNAIRE, DOCUMENTATION, or PAYMENT.
|
|
1092
1163
|
// =============================================================================
|
|
1093
1164
|
|
|
1094
1165
|
model Contract {
|
|
@@ -1111,28 +1182,13 @@ model Contract {
|
|
|
1111
1182
|
description String? @db.Text
|
|
1112
1183
|
contractType String // Admin-defined: MORTGAGE, INSTALLMENT, RENT_TO_OWN, CASH, LEASE, etc.
|
|
1113
1184
|
|
|
1114
|
-
//
|
|
1115
|
-
totalAmount
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
principal Float? // Financed amount (if applicable)
|
|
1119
|
-
interestRate Float? // Overall interest rate (if applicable)
|
|
1120
|
-
termMonths Int? // Total term (if applicable)
|
|
1121
|
-
periodicPayment Float? // Computed periodic payment (if applicable)
|
|
1122
|
-
totalPaidToDate Float @default(0)
|
|
1123
|
-
totalInterestPaid Float @default(0)
|
|
1124
|
-
|
|
1125
|
-
// Pre-approval and underwriting data (moved from prequalification)
|
|
1126
|
-
monthlyIncome Float? // Buyer's monthly income
|
|
1127
|
-
monthlyExpenses Float? // Buyer's monthly expenses
|
|
1128
|
-
preApprovalAnswers Json? // Questionnaire answers from PRE_APPROVAL step
|
|
1129
|
-
underwritingScore Float? // Aggregate score from underwriting evaluation
|
|
1130
|
-
debtToIncomeRatio Float? // Calculated DTI ratio
|
|
1131
|
-
|
|
1132
|
-
// FSM state (DB-enforced enums)
|
|
1185
|
+
// Contract value (negotiated from unit price)
|
|
1186
|
+
totalAmount Float
|
|
1187
|
+
|
|
1188
|
+
// FSM state (DB-enforced enum)
|
|
1133
1189
|
status ContractStatus @default(DRAFT)
|
|
1134
|
-
state ContractStatus @default(DRAFT) // FSM state for workflow
|
|
1135
1190
|
currentPhaseId String?
|
|
1191
|
+
currentPhase ContractPhase? @relation("CurrentPhase", fields: [currentPhaseId], references: [id])
|
|
1136
1192
|
|
|
1137
1193
|
// Timing
|
|
1138
1194
|
nextPaymentDueDate DateTime?
|
|
@@ -1176,7 +1232,7 @@ model Contract {
|
|
|
1176
1232
|
@@index([sellerId])
|
|
1177
1233
|
@@index([paymentMethodId])
|
|
1178
1234
|
@@index([status])
|
|
1179
|
-
@@index([
|
|
1235
|
+
@@index([currentPhaseId])
|
|
1180
1236
|
@@map("contracts")
|
|
1181
1237
|
}
|
|
1182
1238
|
|
|
@@ -1237,12 +1293,21 @@ model ContractRefund {
|
|
|
1237
1293
|
|
|
1238
1294
|
// Phase within a contract - can be DOCUMENTATION or PAYMENT type
|
|
1239
1295
|
// Admin names phases freely (e.g., "KYC Documents", "Downpayment", "Monthly Mortgage")
|
|
1296
|
+
// =============================================================================
|
|
1297
|
+
// CONTRACT PHASE - Base model with polymorphic extensions
|
|
1298
|
+
// =============================================================================
|
|
1299
|
+
// ContractPhase is the base table with shared fields only.
|
|
1300
|
+
// Each phase has exactly ONE extension table based on phaseCategory:
|
|
1301
|
+
// - QUESTIONNAIRE → QuestionnairePhase
|
|
1302
|
+
// - DOCUMENTATION → DocumentationPhase
|
|
1303
|
+
// - PAYMENT → PaymentPhase
|
|
1304
|
+
// This eliminates nullable field pollution and makes the schema self-documenting.
|
|
1305
|
+
// =============================================================================
|
|
1306
|
+
|
|
1240
1307
|
model ContractPhase {
|
|
1241
|
-
id
|
|
1242
|
-
contractId
|
|
1243
|
-
contract
|
|
1244
|
-
paymentPlanId String? // Only for PAYMENT phases
|
|
1245
|
-
paymentPlan PaymentPlan? @relation(fields: [paymentPlanId], references: [id])
|
|
1308
|
+
id String @id @default(cuid())
|
|
1309
|
+
contractId String
|
|
1310
|
+
contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
|
|
1246
1311
|
|
|
1247
1312
|
// Admin-defined naming
|
|
1248
1313
|
name String
|
|
@@ -1256,64 +1321,202 @@ model ContractPhase {
|
|
|
1256
1321
|
// FSM state for this phase (DB-enforced enum)
|
|
1257
1322
|
status PhaseStatus @default(PENDING)
|
|
1258
1323
|
|
|
1259
|
-
//
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
currentStepId String?
|
|
1266
|
-
currentStep DocumentationStep? @relation("CurrentStep", fields: [currentStepId], references: [id])
|
|
1324
|
+
// Timing (shared across all phase types)
|
|
1325
|
+
dueDate DateTime?
|
|
1326
|
+
startDate DateTime?
|
|
1327
|
+
endDate DateTime?
|
|
1328
|
+
activatedAt DateTime?
|
|
1329
|
+
completedAt DateTime?
|
|
1267
1330
|
|
|
1268
|
-
//
|
|
1269
|
-
|
|
1270
|
-
paidAmount Float @default(0)
|
|
1271
|
-
remainingAmount Float?
|
|
1272
|
-
interestRate Float?
|
|
1331
|
+
// Activation rules (shared)
|
|
1332
|
+
requiresPreviousPhaseCompletion Boolean @default(true)
|
|
1273
1333
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1334
|
+
createdAt DateTime @default(now())
|
|
1335
|
+
updatedAt DateTime @updatedAt
|
|
1336
|
+
|
|
1337
|
+
// Polymorphic extensions (exactly one will be populated based on phaseCategory)
|
|
1338
|
+
questionnairePhase QuestionnairePhase?
|
|
1339
|
+
documentationPhase DocumentationPhase?
|
|
1340
|
+
paymentPhase PaymentPhase?
|
|
1341
|
+
|
|
1342
|
+
// Payments can be linked to any phase type (for tracking)
|
|
1343
|
+
payments ContractPayment[]
|
|
1344
|
+
|
|
1345
|
+
// Back-relation for contracts where this is the current phase
|
|
1346
|
+
currentForContracts Contract[] @relation("CurrentPhase")
|
|
1347
|
+
|
|
1348
|
+
@@index([contractId])
|
|
1349
|
+
@@index([phaseCategory])
|
|
1350
|
+
@@index([status])
|
|
1351
|
+
@@index([order])
|
|
1352
|
+
@@map("contract_phases")
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// =============================================================================
|
|
1356
|
+
// QUESTIONNAIRE PHASE DATA - Extension for QUESTIONNAIRE phases
|
|
1357
|
+
// =============================================================================
|
|
1358
|
+
// Collects form data from users (eligibility, pre-approval, underwriting inputs)
|
|
1359
|
+
// =============================================================================
|
|
1360
|
+
|
|
1361
|
+
model QuestionnairePhase {
|
|
1362
|
+
id String @id @default(cuid())
|
|
1363
|
+
phaseId String @unique
|
|
1364
|
+
phase ContractPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1365
|
+
|
|
1366
|
+
// Progress tracking
|
|
1367
|
+
completedFieldsCount Int @default(0)
|
|
1368
|
+
totalFieldsCount Int @default(0)
|
|
1369
|
+
|
|
1370
|
+
// Computed results (for UNDERWRITING phases)
|
|
1371
|
+
underwritingScore Float?
|
|
1372
|
+
debtToIncomeRatio Float?
|
|
1373
|
+
underwritingDecision String? // APPROVED, CONDITIONAL, DECLINED
|
|
1374
|
+
underwritingNotes String? @db.Text
|
|
1375
|
+
|
|
1376
|
+
// Snapshot of field definitions at creation
|
|
1377
|
+
fieldsSnapshot Json?
|
|
1378
|
+
|
|
1379
|
+
createdAt DateTime @default(now())
|
|
1380
|
+
updatedAt DateTime @updatedAt
|
|
1381
|
+
|
|
1382
|
+
// Child records
|
|
1383
|
+
fields QuestionnaireField[]
|
|
1384
|
+
|
|
1385
|
+
@@index([phaseId])
|
|
1386
|
+
@@map("questionnaire_phases")
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// =============================================================================
|
|
1390
|
+
// DOCUMENTATION PHASE DATA - Extension for DOCUMENTATION phases
|
|
1391
|
+
// =============================================================================
|
|
1392
|
+
// Manages document upload/approval workflow with FSM steps
|
|
1393
|
+
// =============================================================================
|
|
1394
|
+
|
|
1395
|
+
model DocumentationPhase {
|
|
1396
|
+
id String @id @default(cuid())
|
|
1397
|
+
phaseId String @unique
|
|
1398
|
+
phase ContractPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1278
1399
|
|
|
1279
|
-
//
|
|
1400
|
+
// Current step pointer for UX and orchestration
|
|
1401
|
+
currentStepId String?
|
|
1402
|
+
currentStep DocumentationStep? @relation("CurrentStep", fields: [currentStepId], references: [id])
|
|
1403
|
+
|
|
1404
|
+
// Progress counters
|
|
1280
1405
|
approvedDocumentsCount Int @default(0)
|
|
1281
1406
|
requiredDocumentsCount Int @default(0)
|
|
1282
1407
|
completedStepsCount Int @default(0)
|
|
1283
1408
|
totalStepsCount Int @default(0)
|
|
1284
1409
|
|
|
1285
|
-
//
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
endDate DateTime?
|
|
1289
|
-
activatedAt DateTime?
|
|
1290
|
-
completedAt DateTime?
|
|
1291
|
-
|
|
1292
|
-
// Activation rules
|
|
1293
|
-
requiresPreviousPhaseCompletion Boolean @default(true)
|
|
1294
|
-
minimumCompletionPercentage Float?
|
|
1295
|
-
completionCriterion CompletionCriterion?
|
|
1410
|
+
// Completion criteria
|
|
1411
|
+
minimumCompletionPercentage Float?
|
|
1412
|
+
completionCriterion CompletionCriterion?
|
|
1296
1413
|
|
|
1297
|
-
// Snapshots for audit
|
|
1298
|
-
paymentPlanSnapshot Json?
|
|
1414
|
+
// Snapshots for audit
|
|
1299
1415
|
stepDefinitionsSnapshot Json?
|
|
1300
1416
|
requiredDocumentSnapshot Json?
|
|
1301
1417
|
|
|
1302
1418
|
createdAt DateTime @default(now())
|
|
1303
1419
|
updatedAt DateTime @updatedAt
|
|
1304
1420
|
|
|
1305
|
-
//
|
|
1421
|
+
// Child records
|
|
1422
|
+
steps DocumentationStep[]
|
|
1423
|
+
|
|
1424
|
+
@@index([phaseId])
|
|
1425
|
+
@@index([currentStepId])
|
|
1426
|
+
@@map("documentation_phases")
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// =============================================================================
|
|
1430
|
+
// PAYMENT PHASE DATA - Extension for PAYMENT phases
|
|
1431
|
+
// =============================================================================
|
|
1432
|
+
// Manages installment-based payment collection
|
|
1433
|
+
// =============================================================================
|
|
1434
|
+
|
|
1435
|
+
model PaymentPhase {
|
|
1436
|
+
id String @id @default(cuid())
|
|
1437
|
+
phaseId String @unique
|
|
1438
|
+
phase ContractPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1439
|
+
|
|
1440
|
+
// Payment plan reference
|
|
1441
|
+
paymentPlanId String?
|
|
1442
|
+
paymentPlan PaymentPlan? @relation(fields: [paymentPlanId], references: [id])
|
|
1443
|
+
|
|
1444
|
+
// Financial details
|
|
1445
|
+
totalAmount Float
|
|
1446
|
+
paidAmount Float @default(0)
|
|
1447
|
+
interestRate Float @default(0)
|
|
1448
|
+
|
|
1449
|
+
// Fund collection behavior
|
|
1450
|
+
// true = we collect funds via wallet/gateway (e.g., downpayment)
|
|
1451
|
+
// false = external payment, we only track/reconcile (e.g., bank mortgage)
|
|
1452
|
+
collectFunds Boolean @default(true)
|
|
1453
|
+
|
|
1454
|
+
// Completion criteria
|
|
1455
|
+
minimumCompletionPercentage Float?
|
|
1456
|
+
|
|
1457
|
+
// Snapshot for audit
|
|
1458
|
+
paymentPlanSnapshot Json?
|
|
1459
|
+
|
|
1460
|
+
createdAt DateTime @default(now())
|
|
1461
|
+
updatedAt DateTime @updatedAt
|
|
1462
|
+
|
|
1463
|
+
// Child records
|
|
1306
1464
|
installments ContractInstallment[]
|
|
1307
|
-
payments ContractPayment[]
|
|
1308
|
-
steps DocumentationStep[] // For DOCUMENTATION phases (FSM steps)
|
|
1309
1465
|
|
|
1310
|
-
@@index([
|
|
1466
|
+
@@index([phaseId])
|
|
1311
1467
|
@@index([paymentPlanId])
|
|
1312
|
-
@@
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1468
|
+
@@map("payment_phases")
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// =============================================================================
|
|
1472
|
+
// QUESTIONNAIRE FIELDS - Instantiated fields within QUESTIONNAIRE phases
|
|
1473
|
+
// =============================================================================
|
|
1474
|
+
// When a contract is created from a payment method template, questionnaire field
|
|
1475
|
+
// templates are copied to QuestionnaireField records. Users submit answers here.
|
|
1476
|
+
// =============================================================================
|
|
1477
|
+
|
|
1478
|
+
model QuestionnaireField {
|
|
1479
|
+
id String @id @default(cuid())
|
|
1480
|
+
questionnairePhaseId String
|
|
1481
|
+
questionnairePhase QuestionnairePhase @relation(fields: [questionnairePhaseId], references: [id], onDelete: Cascade)
|
|
1482
|
+
|
|
1483
|
+
// Field identification (copied from template)
|
|
1484
|
+
name String // Internal field name (e.g., "monthly_income")
|
|
1485
|
+
label String // Display label (e.g., "Monthly Income")
|
|
1486
|
+
description String? @db.Text
|
|
1487
|
+
placeholder String?
|
|
1488
|
+
|
|
1489
|
+
// Field configuration (copied from template)
|
|
1490
|
+
fieldType FieldType
|
|
1491
|
+
isRequired Boolean @default(true)
|
|
1492
|
+
order Int
|
|
1493
|
+
|
|
1494
|
+
// Validation rules (copied from template)
|
|
1495
|
+
validation Json?
|
|
1496
|
+
displayCondition Json?
|
|
1497
|
+
defaultValue Json?
|
|
1498
|
+
|
|
1499
|
+
// User's submitted answer (JSON to support any type)
|
|
1500
|
+
// TEXT: "John Doe"
|
|
1501
|
+
// NUMBER/CURRENCY: 500000
|
|
1502
|
+
// SELECT: "employed"
|
|
1503
|
+
// MULTI_SELECT: ["option1", "option2"]
|
|
1504
|
+
// CHECKBOX: true
|
|
1505
|
+
// DATE: "2024-01-15"
|
|
1506
|
+
answer Json?
|
|
1507
|
+
|
|
1508
|
+
// Validation status
|
|
1509
|
+
isValid Boolean @default(false)
|
|
1510
|
+
validationErrors Json? // Array of error messages if invalid
|
|
1511
|
+
|
|
1512
|
+
// Timestamps
|
|
1513
|
+
submittedAt DateTime?
|
|
1514
|
+
createdAt DateTime @default(now())
|
|
1515
|
+
updatedAt DateTime @updatedAt
|
|
1516
|
+
|
|
1517
|
+
@@unique([questionnairePhaseId, name])
|
|
1518
|
+
@@index([questionnairePhaseId])
|
|
1519
|
+
@@map("questionnaire_fields")
|
|
1317
1520
|
}
|
|
1318
1521
|
|
|
1319
1522
|
// =============================================================================
|
|
@@ -1356,9 +1559,9 @@ model ContractEvent {
|
|
|
1356
1559
|
|
|
1357
1560
|
// Steps within a DOCUMENTATION phase (FSM for document collection/approval)
|
|
1358
1561
|
model DocumentationStep {
|
|
1359
|
-
id
|
|
1360
|
-
|
|
1361
|
-
|
|
1562
|
+
id String @id @default(cuid())
|
|
1563
|
+
documentationPhaseId String
|
|
1564
|
+
documentationPhase DocumentationPhase @relation(fields: [documentationPhaseId], references: [id], onDelete: Cascade)
|
|
1362
1565
|
|
|
1363
1566
|
name String
|
|
1364
1567
|
description String? @db.Text
|
|
@@ -1383,15 +1586,6 @@ model DocumentationStep {
|
|
|
1383
1586
|
// Configuration metadata (for GENERATE_DOCUMENT steps, etc.)
|
|
1384
1587
|
metadata Json?
|
|
1385
1588
|
|
|
1386
|
-
// For PRE_APPROVAL steps: store questionnaire answers
|
|
1387
|
-
preApprovalAnswers Json?
|
|
1388
|
-
|
|
1389
|
-
// For UNDERWRITING steps: store evaluation results
|
|
1390
|
-
underwritingScore Float?
|
|
1391
|
-
debtToIncomeRatio Float?
|
|
1392
|
-
underwritingDecision String? // APPROVED, CONDITIONAL, DECLINED
|
|
1393
|
-
underwritingNotes String? @db.Text
|
|
1394
|
-
|
|
1395
1589
|
// Assignment
|
|
1396
1590
|
assigneeId String?
|
|
1397
1591
|
assignee User? @relation("DocumentationStepAssignee", fields: [assigneeId], references: [id])
|
|
@@ -1407,12 +1601,12 @@ model DocumentationStep {
|
|
|
1407
1601
|
updatedAt DateTime @updatedAt
|
|
1408
1602
|
|
|
1409
1603
|
approvals DocumentationStepApproval[]
|
|
1410
|
-
currentForPhase
|
|
1604
|
+
currentForPhase DocumentationPhase[] @relation("CurrentStep")
|
|
1411
1605
|
|
|
1412
|
-
@@index([
|
|
1606
|
+
@@index([documentationPhaseId])
|
|
1413
1607
|
@@index([status])
|
|
1414
1608
|
@@index([order])
|
|
1415
|
-
@@map("
|
|
1609
|
+
@@map("documentation_steps")
|
|
1416
1610
|
}
|
|
1417
1611
|
|
|
1418
1612
|
// Required documents for a step (normalized from CSV)
|
|
@@ -1427,7 +1621,7 @@ model DocumentationStepDocument {
|
|
|
1427
1621
|
createdAt DateTime @default(now())
|
|
1428
1622
|
|
|
1429
1623
|
@@index([stepId, documentType])
|
|
1430
|
-
@@map("
|
|
1624
|
+
@@map("documentation_step_documents")
|
|
1431
1625
|
}
|
|
1432
1626
|
|
|
1433
1627
|
// Approvals for documentation steps
|
|
@@ -1445,14 +1639,14 @@ model DocumentationStepApproval {
|
|
|
1445
1639
|
createdAt DateTime @default(now())
|
|
1446
1640
|
|
|
1447
1641
|
@@index([stepId])
|
|
1448
|
-
@@map("
|
|
1642
|
+
@@map("documentation_step_approvals")
|
|
1449
1643
|
}
|
|
1450
1644
|
|
|
1451
1645
|
// Installments within a PAYMENT phase
|
|
1452
1646
|
model ContractInstallment {
|
|
1453
|
-
id
|
|
1454
|
-
|
|
1455
|
-
|
|
1647
|
+
id String @id @default(cuid())
|
|
1648
|
+
paymentPhaseId String
|
|
1649
|
+
paymentPhase PaymentPhase @relation(fields: [paymentPhaseId], references: [id], onDelete: Cascade)
|
|
1456
1650
|
|
|
1457
1651
|
installmentNumber Int
|
|
1458
1652
|
|
|
@@ -1476,7 +1670,7 @@ model ContractInstallment {
|
|
|
1476
1670
|
|
|
1477
1671
|
payments ContractPayment[]
|
|
1478
1672
|
|
|
1479
|
-
@@index([
|
|
1673
|
+
@@index([paymentPhaseId])
|
|
1480
1674
|
@@index([dueDate])
|
|
1481
1675
|
@@index([status])
|
|
1482
1676
|
@@map("contract_installments")
|
|
@@ -2126,8 +2320,16 @@ model DomainEvent {
|
|
|
2126
2320
|
// =============================================================================
|
|
2127
2321
|
// Property Transfer Request
|
|
2128
2322
|
// =============================================================================
|
|
2129
|
-
// Allows a buyer to request transferring their contract to a different property
|
|
2130
|
-
//
|
|
2323
|
+
// Allows a buyer to request transferring their contract to a different property.
|
|
2324
|
+
//
|
|
2325
|
+
// TRANSFER PAYMENT FLOW:
|
|
2326
|
+
// 1. All payments from source contract are refunded to buyer's wallet (single credit transaction)
|
|
2327
|
+
// 2. Source contract marked TRANSFERRED, unit released
|
|
2328
|
+
// 3. New contract created for target unit with zero payments
|
|
2329
|
+
// 4. Buyer can optionally apply wallet balance as equity during new mortgage application
|
|
2330
|
+
//
|
|
2331
|
+
// This ensures clean accounting: each contract has isolated payment history,
|
|
2332
|
+
// wallet serves as intermediary, and buyer retains full credit.
|
|
2131
2333
|
// =============================================================================
|
|
2132
2334
|
|
|
2133
2335
|
model PropertyTransferRequest {
|
|
@@ -2163,7 +2365,11 @@ model PropertyTransferRequest {
|
|
|
2163
2365
|
sourceTotalAmount Float? // Original contract total
|
|
2164
2366
|
targetTotalAmount Float? // New contract total (based on target property)
|
|
2165
2367
|
priceAdjustment Float? // Difference (positive = buyer owes more)
|
|
2166
|
-
|
|
2368
|
+
|
|
2369
|
+
// Wallet refund tracking (payments refunded to wallet, NOT carried over)
|
|
2370
|
+
refundedAmount Float? // Total amount refunded to wallet
|
|
2371
|
+
refundTransactionId String? // Reference to wallet Transaction record
|
|
2372
|
+
refundedAt DateTime?
|
|
2167
2373
|
|
|
2168
2374
|
// Result - new contract created after approval
|
|
2169
2375
|
targetContractId String?
|