@valentine-efagene/qshelter-common 2.0.94 → 2.0.95
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 +16 -16
- package/dist/generated/client/client.d.ts +16 -16
- package/dist/generated/client/commonInputTypes.d.ts +72 -72
- package/dist/generated/client/enums.d.ts +13 -13
- package/dist/generated/client/enums.js +10 -10
- package/dist/generated/client/internal/class.d.ts +32 -32
- package/dist/generated/client/internal/class.js +2 -2
- package/dist/generated/client/internal/prismaNamespace.d.ts +321 -321
- package/dist/generated/client/internal/prismaNamespace.js +50 -50
- package/dist/generated/client/internal/prismaNamespaceBrowser.d.ts +66 -66
- package/dist/generated/client/internal/prismaNamespaceBrowser.js +50 -50
- package/dist/generated/client/models/Application.d.ts +5439 -0
- package/dist/generated/client/models/Application.js +1 -0
- package/dist/generated/client/models/ApplicationDocument.d.ts +1409 -0
- package/dist/generated/client/models/ApplicationDocument.js +1 -0
- package/dist/generated/client/models/ApplicationEvent.d.ts +1254 -0
- package/dist/generated/client/models/ApplicationEvent.js +1 -0
- package/dist/generated/client/models/ApplicationPayment.d.ts +2030 -0
- package/dist/generated/client/models/ApplicationPayment.js +1 -0
- package/dist/generated/client/models/ApplicationPhase.d.ts +2243 -0
- package/dist/generated/client/models/ApplicationPhase.js +1 -0
- package/dist/generated/client/models/ApplicationRefund.d.ts +2560 -0
- package/dist/generated/client/models/ApplicationRefund.js +1 -0
- package/dist/generated/client/models/ApplicationTermination.d.ts +3446 -0
- package/dist/generated/client/models/ApplicationTermination.js +1 -0
- package/dist/generated/client/models/DocumentationPhase.d.ts +13 -13
- package/dist/generated/client/models/OfferLetter.d.ts +97 -97
- package/dist/generated/client/models/PaymentInstallment.d.ts +1660 -0
- package/dist/generated/client/models/PaymentInstallment.js +1 -0
- package/dist/generated/client/models/PaymentMethodChangeRequest.d.ts +103 -103
- package/dist/generated/client/models/PaymentPhase.d.ts +40 -40
- package/dist/generated/client/models/PropertyPaymentMethod.d.ts +77 -77
- package/dist/generated/client/models/PropertyTransferRequest.d.ts +213 -213
- package/dist/generated/client/models/PropertyUnit.d.ts +53 -53
- package/dist/generated/client/models/QuestionnairePhase.d.ts +11 -11
- package/dist/generated/client/models/Tenant.d.ts +323 -323
- package/dist/generated/client/models/User.d.ts +1329 -1329
- package/dist/generated/client/models/index.d.ts +8 -8
- package/dist/generated/client/models/index.js +8 -8
- package/dist/generated/client/models.d.ts +8 -8
- package/package.json +1 -1
- package/prisma/migrations/20260112080730_rename_contract_to_application/migration.sql +529 -0
- package/prisma/schema.prisma +107 -107
- package/prisma/schema.prisma.backup +2601 -0
package/prisma/schema.prisma
CHANGED
|
@@ -51,14 +51,14 @@ enum PaymentFrequency {
|
|
|
51
51
|
CUSTOM
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
enum
|
|
54
|
+
enum ApplicationStatus {
|
|
55
55
|
DRAFT
|
|
56
56
|
PENDING
|
|
57
57
|
ACTIVE
|
|
58
58
|
COMPLETED
|
|
59
59
|
CANCELLED
|
|
60
60
|
TERMINATED
|
|
61
|
-
TRANSFERRED //
|
|
61
|
+
TRANSFERRED // Application was transferred to a different property
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
enum TransferRequestStatus {
|
|
@@ -213,9 +213,9 @@ enum OfferLetterStatus {
|
|
|
213
213
|
CANCELLED
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
enum
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
enum ApplicationEventType {
|
|
217
|
+
APPLICATION_CREATED
|
|
218
|
+
APPLICATION_STATE_CHANGED
|
|
219
219
|
PHASE_ACTIVATED
|
|
220
220
|
PHASE_COMPLETED
|
|
221
221
|
STEP_COMPLETED
|
|
@@ -227,14 +227,14 @@ enum ContractEventType {
|
|
|
227
227
|
PAYMENT_COMPLETED
|
|
228
228
|
PAYMENT_FAILED
|
|
229
229
|
INSTALLMENTS_GENERATED
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
APPLICATION_SIGNED
|
|
231
|
+
APPLICATION_TERMINATED
|
|
232
|
+
APPLICATION_TRANSFERRED
|
|
233
233
|
UNDERWRITING_COMPLETED
|
|
234
234
|
OFFER_LETTER_GENERATED
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
enum
|
|
237
|
+
enum ApplicationEventGroup {
|
|
238
238
|
STATE_CHANGE
|
|
239
239
|
PAYMENT
|
|
240
240
|
DOCUMENT
|
|
@@ -346,22 +346,22 @@ model User {
|
|
|
346
346
|
|
|
347
347
|
// Relations to other domains
|
|
348
348
|
properties Property[]
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
applications Application[] @relation("ApplicationBuyer")
|
|
350
|
+
soldApplications Application[] @relation("ApplicationSeller")
|
|
351
|
+
applicationPayments ApplicationPayment[] @relation("ApplicationPayer")
|
|
352
352
|
|
|
353
353
|
// Documentation step assignments and approvals
|
|
354
354
|
assignedSteps DocumentationStep[] @relation("DocumentationStepAssignee")
|
|
355
355
|
stepApprovals DocumentationStepApproval[] @relation("DocumentationStepApprover")
|
|
356
|
-
uploadedDocs
|
|
356
|
+
uploadedDocs ApplicationDocument[] @relation("DocumentUploader")
|
|
357
357
|
|
|
358
358
|
// Payment method changes
|
|
359
359
|
paymentMethodChangeRequests PaymentMethodChangeRequest[] @relation("ChangeRequestor")
|
|
360
360
|
reviewedChangeRequests PaymentMethodChangeRequest[] @relation("ChangeReviewer")
|
|
361
361
|
|
|
362
362
|
// Contract terminations
|
|
363
|
-
initiatedTerminations
|
|
364
|
-
reviewedTerminations
|
|
363
|
+
initiatedTerminations ApplicationTermination[] @relation("TerminationInitiator")
|
|
364
|
+
reviewedTerminations ApplicationTermination[] @relation("TerminationReviewer")
|
|
365
365
|
|
|
366
366
|
// Offer letters
|
|
367
367
|
offerLettersGenerated OfferLetter[] @relation("OfferLetterGenerator")
|
|
@@ -377,9 +377,9 @@ model User {
|
|
|
377
377
|
approvalRequestsReviewed ApprovalRequest[] @relation("ApprovalReviewer")
|
|
378
378
|
|
|
379
379
|
// Contract refunds
|
|
380
|
-
requestedRefunds
|
|
381
|
-
approvedRefunds
|
|
382
|
-
processedRefunds
|
|
380
|
+
requestedRefunds ApplicationRefund[] @relation("RefundRequester")
|
|
381
|
+
approvedRefunds ApplicationRefund[] @relation("RefundApprover")
|
|
382
|
+
processedRefunds ApplicationRefund[] @relation("RefundProcessor")
|
|
383
383
|
|
|
384
384
|
@@index([email])
|
|
385
385
|
@@index([tenantId])
|
|
@@ -496,7 +496,7 @@ model Tenant {
|
|
|
496
496
|
properties Property[]
|
|
497
497
|
paymentPlans PaymentPlan[]
|
|
498
498
|
paymentMethods PropertyPaymentMethod[]
|
|
499
|
-
|
|
499
|
+
applications Application[]
|
|
500
500
|
|
|
501
501
|
// RBAC: Tenant-scoped roles and permissions
|
|
502
502
|
roles Role[]
|
|
@@ -509,7 +509,7 @@ model Tenant {
|
|
|
509
509
|
documentRequirementRules DocumentRequirementRule[]
|
|
510
510
|
|
|
511
511
|
// Contract terminations
|
|
512
|
-
contractTerminations
|
|
512
|
+
contractTerminations ApplicationTermination[]
|
|
513
513
|
|
|
514
514
|
// Offer letters and templates
|
|
515
515
|
documentTemplates DocumentTemplate[]
|
|
@@ -531,7 +531,7 @@ model Tenant {
|
|
|
531
531
|
approvalRequests ApprovalRequest[]
|
|
532
532
|
|
|
533
533
|
// Contract refunds
|
|
534
|
-
contractRefunds
|
|
534
|
+
contractRefunds ApplicationRefund[]
|
|
535
535
|
|
|
536
536
|
@@index([subdomain])
|
|
537
537
|
@@map("tenants")
|
|
@@ -929,7 +929,7 @@ model PropertyUnit {
|
|
|
929
929
|
updatedAt DateTime @updatedAt
|
|
930
930
|
|
|
931
931
|
// Relations
|
|
932
|
-
|
|
932
|
+
applications Application[]
|
|
933
933
|
|
|
934
934
|
// Transfer requests targeting this unit
|
|
935
935
|
transferRequests PropertyTransferRequest[]
|
|
@@ -1027,7 +1027,7 @@ model PropertyPaymentMethod {
|
|
|
1027
1027
|
// Phases that make up this method (templates)
|
|
1028
1028
|
phases PropertyPaymentMethodPhase[]
|
|
1029
1029
|
// Contracts using this method
|
|
1030
|
-
|
|
1030
|
+
applications Application[]
|
|
1031
1031
|
|
|
1032
1032
|
// Payment method change tracking
|
|
1033
1033
|
changeRequestsFrom PaymentMethodChangeRequest[] @relation("ChangeFromMethod")
|
|
@@ -1271,12 +1271,12 @@ model PaymentMethodPhaseField {
|
|
|
1271
1271
|
// =============================================================================
|
|
1272
1272
|
// CONTRACT DOMAIN - Unified agreement model (replaces Mortgage, PurchasePlan, etc.)
|
|
1273
1273
|
// =============================================================================
|
|
1274
|
-
//
|
|
1275
|
-
// that creates
|
|
1274
|
+
// Application is the canonical agreement. "Mortgage" is just a product configuration
|
|
1275
|
+
// that creates an Application with specific phases (documentation, downpayment, long-term payment).
|
|
1276
1276
|
// Phases can be QUESTIONNAIRE, DOCUMENTATION, or PAYMENT.
|
|
1277
1277
|
// =============================================================================
|
|
1278
1278
|
|
|
1279
|
-
model
|
|
1279
|
+
model Application {
|
|
1280
1280
|
id String @id @default(cuid())
|
|
1281
1281
|
tenantId String
|
|
1282
1282
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
@@ -1284,25 +1284,25 @@ model Contract {
|
|
|
1284
1284
|
propertyUnitId String
|
|
1285
1285
|
propertyUnit PropertyUnit @relation(fields: [propertyUnitId], references: [id], onDelete: Cascade)
|
|
1286
1286
|
buyerId String
|
|
1287
|
-
buyer User @relation("
|
|
1287
|
+
buyer User @relation("ApplicationBuyer", fields: [buyerId], references: [id], onDelete: Cascade)
|
|
1288
1288
|
sellerId String?
|
|
1289
|
-
seller User? @relation("
|
|
1289
|
+
seller User? @relation("ApplicationSeller", fields: [sellerId], references: [id])
|
|
1290
1290
|
paymentMethodId String? // PropertyPaymentMethod used to create this contract
|
|
1291
1291
|
paymentMethod PropertyPaymentMethod? @relation(fields: [paymentMethodId], references: [id])
|
|
1292
1292
|
|
|
1293
1293
|
// Contract identification
|
|
1294
|
-
|
|
1294
|
+
applicationNumber String @unique
|
|
1295
1295
|
title String
|
|
1296
1296
|
description String? @db.Text
|
|
1297
|
-
|
|
1297
|
+
applicationType String // Admin-defined: MORTGAGE, INSTALLMENT, RENT_TO_OWN, CASH, LEASE, etc.
|
|
1298
1298
|
|
|
1299
1299
|
// Contract value (negotiated from unit price)
|
|
1300
1300
|
totalAmount Float
|
|
1301
1301
|
|
|
1302
1302
|
// FSM state (DB-enforced enum)
|
|
1303
|
-
status
|
|
1303
|
+
status ApplicationStatus @default(DRAFT)
|
|
1304
1304
|
currentPhaseId String?
|
|
1305
|
-
currentPhase
|
|
1305
|
+
currentPhase ApplicationPhase? @relation("CurrentPhase", fields: [currentPhaseId], references: [id])
|
|
1306
1306
|
|
|
1307
1307
|
// Timing
|
|
1308
1308
|
nextPaymentDueDate DateTime?
|
|
@@ -1315,10 +1315,10 @@ model Contract {
|
|
|
1315
1315
|
updatedAt DateTime @updatedAt
|
|
1316
1316
|
|
|
1317
1317
|
// Relations
|
|
1318
|
-
phases
|
|
1319
|
-
documents
|
|
1320
|
-
payments
|
|
1321
|
-
terminations
|
|
1318
|
+
phases ApplicationPhase[]
|
|
1319
|
+
documents ApplicationDocument[]
|
|
1320
|
+
payments ApplicationPayment[]
|
|
1321
|
+
terminations ApplicationTermination[]
|
|
1322
1322
|
offerLetters OfferLetter[]
|
|
1323
1323
|
|
|
1324
1324
|
// Payment method change requests for this contract
|
|
@@ -1326,19 +1326,19 @@ model Contract {
|
|
|
1326
1326
|
|
|
1327
1327
|
// Transfer tracking - when a contract is transferred to a different property
|
|
1328
1328
|
transferredFromId String? @unique // Source contract if this was created via transfer
|
|
1329
|
-
transferredFrom
|
|
1330
|
-
transferredTo
|
|
1329
|
+
transferredFrom Application? @relation("ApplicationTransfer", fields: [transferredFromId], references: [id])
|
|
1330
|
+
transferredTo Application? @relation("ApplicationTransfer")
|
|
1331
1331
|
|
|
1332
1332
|
// Transfer requests where this contract is the source
|
|
1333
|
-
outgoingTransferRequests PropertyTransferRequest[] @relation("
|
|
1333
|
+
outgoingTransferRequests PropertyTransferRequest[] @relation("SourceApplication")
|
|
1334
1334
|
// Transfer requests where this contract is the target (created after approval)
|
|
1335
|
-
incomingTransferRequests PropertyTransferRequest[] @relation("
|
|
1335
|
+
incomingTransferRequests PropertyTransferRequest[] @relation("TargetApplication")
|
|
1336
1336
|
|
|
1337
1337
|
// Audit trail
|
|
1338
|
-
events
|
|
1338
|
+
events ApplicationEvent[]
|
|
1339
1339
|
|
|
1340
1340
|
// Refund requests
|
|
1341
|
-
refunds
|
|
1341
|
+
refunds ApplicationRefund[]
|
|
1342
1342
|
|
|
1343
1343
|
@@index([tenantId])
|
|
1344
1344
|
@@index([propertyUnitId])
|
|
@@ -1347,19 +1347,19 @@ model Contract {
|
|
|
1347
1347
|
@@index([paymentMethodId])
|
|
1348
1348
|
@@index([status])
|
|
1349
1349
|
@@index([currentPhaseId])
|
|
1350
|
-
@@map("
|
|
1350
|
+
@@map("applications")
|
|
1351
1351
|
}
|
|
1352
1352
|
|
|
1353
1353
|
// =============================================================================
|
|
1354
1354
|
// CONTRACT REFUNDS - Track refund requests for overpayments or cancellations
|
|
1355
1355
|
// =============================================================================
|
|
1356
|
-
model
|
|
1356
|
+
model ApplicationRefund {
|
|
1357
1357
|
id String @id @default(cuid())
|
|
1358
1358
|
tenantId String
|
|
1359
1359
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1360
1360
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1361
|
+
applicationId String
|
|
1362
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1363
1363
|
|
|
1364
1364
|
amount Float
|
|
1365
1365
|
reason String @db.Text
|
|
@@ -1398,11 +1398,11 @@ model ContractRefund {
|
|
|
1398
1398
|
createdAt DateTime @default(now())
|
|
1399
1399
|
updatedAt DateTime @updatedAt
|
|
1400
1400
|
|
|
1401
|
-
@@index([
|
|
1401
|
+
@@index([applicationId])
|
|
1402
1402
|
@@index([status])
|
|
1403
1403
|
@@index([tenantId])
|
|
1404
1404
|
@@index([requestedById])
|
|
1405
|
-
@@map("
|
|
1405
|
+
@@map("application_refunds")
|
|
1406
1406
|
}
|
|
1407
1407
|
|
|
1408
1408
|
// Phase within a contract - can be DOCUMENTATION or PAYMENT type
|
|
@@ -1410,7 +1410,7 @@ model ContractRefund {
|
|
|
1410
1410
|
// =============================================================================
|
|
1411
1411
|
// CONTRACT PHASE - Base model with polymorphic extensions
|
|
1412
1412
|
// =============================================================================
|
|
1413
|
-
//
|
|
1413
|
+
// ApplicationPhase is the base table with shared fields only.
|
|
1414
1414
|
// Each phase has exactly ONE extension table based on phaseCategory:
|
|
1415
1415
|
// - QUESTIONNAIRE → QuestionnairePhase
|
|
1416
1416
|
// - DOCUMENTATION → DocumentationPhase
|
|
@@ -1418,10 +1418,10 @@ model ContractRefund {
|
|
|
1418
1418
|
// This eliminates nullable field pollution and makes the schema self-documenting.
|
|
1419
1419
|
// =============================================================================
|
|
1420
1420
|
|
|
1421
|
-
model
|
|
1421
|
+
model ApplicationPhase {
|
|
1422
1422
|
id String @id @default(cuid())
|
|
1423
|
-
|
|
1424
|
-
|
|
1423
|
+
applicationId String
|
|
1424
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1425
1425
|
|
|
1426
1426
|
// Admin-defined naming
|
|
1427
1427
|
name String
|
|
@@ -1454,16 +1454,16 @@ model ContractPhase {
|
|
|
1454
1454
|
paymentPhase PaymentPhase?
|
|
1455
1455
|
|
|
1456
1456
|
// Payments can be linked to any phase type (for tracking)
|
|
1457
|
-
payments
|
|
1457
|
+
payments ApplicationPayment[]
|
|
1458
1458
|
|
|
1459
|
-
// Back-relation for
|
|
1460
|
-
|
|
1459
|
+
// Back-relation for applications where this is the current phase
|
|
1460
|
+
currentForApplications Application[] @relation("CurrentPhase")
|
|
1461
1461
|
|
|
1462
|
-
@@index([
|
|
1462
|
+
@@index([applicationId])
|
|
1463
1463
|
@@index([phaseCategory])
|
|
1464
1464
|
@@index([status])
|
|
1465
1465
|
@@index([order])
|
|
1466
|
-
@@map("
|
|
1466
|
+
@@map("application_phases")
|
|
1467
1467
|
}
|
|
1468
1468
|
|
|
1469
1469
|
// =============================================================================
|
|
@@ -1475,7 +1475,7 @@ model ContractPhase {
|
|
|
1475
1475
|
model QuestionnairePhase {
|
|
1476
1476
|
id String @id @default(cuid())
|
|
1477
1477
|
phaseId String @unique
|
|
1478
|
-
phase
|
|
1478
|
+
phase ApplicationPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1479
1479
|
|
|
1480
1480
|
// Progress tracking
|
|
1481
1481
|
completedFieldsCount Int @default(0)
|
|
@@ -1509,7 +1509,7 @@ model QuestionnairePhase {
|
|
|
1509
1509
|
model DocumentationPhase {
|
|
1510
1510
|
id String @id @default(cuid())
|
|
1511
1511
|
phaseId String @unique
|
|
1512
|
-
phase
|
|
1512
|
+
phase ApplicationPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1513
1513
|
|
|
1514
1514
|
// Current step pointer for UX and orchestration
|
|
1515
1515
|
currentStepId String?
|
|
@@ -1549,7 +1549,7 @@ model DocumentationPhase {
|
|
|
1549
1549
|
model PaymentPhase {
|
|
1550
1550
|
id String @id @default(cuid())
|
|
1551
1551
|
phaseId String @unique
|
|
1552
|
-
phase
|
|
1552
|
+
phase ApplicationPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
|
|
1553
1553
|
|
|
1554
1554
|
// Payment plan reference
|
|
1555
1555
|
paymentPlanId String?
|
|
@@ -1580,7 +1580,7 @@ model PaymentPhase {
|
|
|
1580
1580
|
updatedAt DateTime @updatedAt
|
|
1581
1581
|
|
|
1582
1582
|
// Child records
|
|
1583
|
-
installments
|
|
1583
|
+
installments PaymentInstallment[]
|
|
1584
1584
|
|
|
1585
1585
|
@@index([phaseId])
|
|
1586
1586
|
@@index([paymentPlanId])
|
|
@@ -1643,18 +1643,18 @@ model QuestionnaireField {
|
|
|
1643
1643
|
// =============================================================================
|
|
1644
1644
|
// Tracks all significant events in a contract's lifecycle for audit, compliance,
|
|
1645
1645
|
// and debugging. Unlike DomainEvent (which is for inter-service communication),
|
|
1646
|
-
//
|
|
1646
|
+
// ApplicationEvent is purely for historical tracking and state machine transitions.
|
|
1647
1647
|
// =============================================================================
|
|
1648
|
-
model
|
|
1648
|
+
model ApplicationEvent {
|
|
1649
1649
|
id String @id @default(cuid())
|
|
1650
|
-
|
|
1651
|
-
|
|
1650
|
+
applicationId String
|
|
1651
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1652
1652
|
|
|
1653
1653
|
// Event classification
|
|
1654
|
-
eventType
|
|
1655
|
-
eventGroup
|
|
1654
|
+
eventType ApplicationEventType
|
|
1655
|
+
eventGroup ApplicationEventGroup?
|
|
1656
1656
|
|
|
1657
|
-
// For state transitions (optional - only populated for
|
|
1657
|
+
// For state transitions (optional - only populated for APPLICATION_STATE_CHANGED events)
|
|
1658
1658
|
fromState String?
|
|
1659
1659
|
toState String?
|
|
1660
1660
|
trigger String?
|
|
@@ -1669,11 +1669,11 @@ model ContractEvent {
|
|
|
1669
1669
|
// Timing
|
|
1670
1670
|
occurredAt DateTime @default(now())
|
|
1671
1671
|
|
|
1672
|
-
@@index([
|
|
1672
|
+
@@index([applicationId])
|
|
1673
1673
|
@@index([eventType])
|
|
1674
1674
|
@@index([eventGroup])
|
|
1675
1675
|
@@index([occurredAt])
|
|
1676
|
-
@@map("
|
|
1676
|
+
@@map("application_events")
|
|
1677
1677
|
}
|
|
1678
1678
|
|
|
1679
1679
|
// Steps within a DOCUMENTATION phase (FSM for document collection/approval)
|
|
@@ -1762,7 +1762,7 @@ model DocumentationStepApproval {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
|
|
1764
1764
|
// Installments within a PAYMENT phase
|
|
1765
|
-
model
|
|
1765
|
+
model PaymentInstallment {
|
|
1766
1766
|
id String @id @default(cuid())
|
|
1767
1767
|
paymentPhaseId String
|
|
1768
1768
|
paymentPhase PaymentPhase @relation(fields: [paymentPhaseId], references: [id], onDelete: Cascade)
|
|
@@ -1787,25 +1787,25 @@ model ContractInstallment {
|
|
|
1787
1787
|
createdAt DateTime @default(now())
|
|
1788
1788
|
updatedAt DateTime @updatedAt
|
|
1789
1789
|
|
|
1790
|
-
payments
|
|
1790
|
+
payments ApplicationPayment[]
|
|
1791
1791
|
|
|
1792
1792
|
@@index([paymentPhaseId])
|
|
1793
1793
|
@@index([dueDate])
|
|
1794
1794
|
@@index([status])
|
|
1795
|
-
@@map("
|
|
1795
|
+
@@map("payment_installments")
|
|
1796
1796
|
}
|
|
1797
1797
|
|
|
1798
1798
|
// Unified payment record for contracts
|
|
1799
|
-
model
|
|
1799
|
+
model ApplicationPayment {
|
|
1800
1800
|
id String @id @default(cuid())
|
|
1801
|
-
|
|
1802
|
-
|
|
1801
|
+
applicationId String
|
|
1802
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1803
1803
|
phaseId String?
|
|
1804
|
-
phase
|
|
1804
|
+
phase ApplicationPhase? @relation(fields: [phaseId], references: [id])
|
|
1805
1805
|
installmentId String?
|
|
1806
|
-
installment
|
|
1806
|
+
installment PaymentInstallment? @relation(fields: [installmentId], references: [id])
|
|
1807
1807
|
payerId String?
|
|
1808
|
-
payer User? @relation("
|
|
1808
|
+
payer User? @relation("ApplicationPayer", fields: [payerId], references: [id])
|
|
1809
1809
|
|
|
1810
1810
|
amount Float
|
|
1811
1811
|
principalAmount Float @default(0)
|
|
@@ -1822,20 +1822,20 @@ model ContractPayment {
|
|
|
1822
1822
|
createdAt DateTime @default(now())
|
|
1823
1823
|
updatedAt DateTime @updatedAt
|
|
1824
1824
|
|
|
1825
|
-
@@index([
|
|
1825
|
+
@@index([applicationId])
|
|
1826
1826
|
@@index([phaseId])
|
|
1827
1827
|
@@index([installmentId])
|
|
1828
1828
|
@@index([payerId])
|
|
1829
1829
|
@@index([status])
|
|
1830
1830
|
@@index([reference])
|
|
1831
|
-
@@map("
|
|
1831
|
+
@@map("application_payments")
|
|
1832
1832
|
}
|
|
1833
1833
|
|
|
1834
1834
|
// Contract documents (owned by contract, linked to phases/steps as needed)
|
|
1835
|
-
model
|
|
1835
|
+
model ApplicationDocument {
|
|
1836
1836
|
id String @id @default(cuid())
|
|
1837
|
-
|
|
1838
|
-
|
|
1837
|
+
applicationId String
|
|
1838
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1839
1839
|
phaseId String? // Optional link to specific phase
|
|
1840
1840
|
stepId String? // Optional link to specific step
|
|
1841
1841
|
|
|
@@ -1850,12 +1850,12 @@ model ContractDocument {
|
|
|
1850
1850
|
createdAt DateTime @default(now())
|
|
1851
1851
|
updatedAt DateTime @updatedAt
|
|
1852
1852
|
|
|
1853
|
-
@@index([
|
|
1853
|
+
@@index([applicationId])
|
|
1854
1854
|
@@index([phaseId])
|
|
1855
1855
|
@@index([stepId])
|
|
1856
1856
|
@@index([type])
|
|
1857
1857
|
@@index([status])
|
|
1858
|
-
@@map("
|
|
1858
|
+
@@map("application_documents")
|
|
1859
1859
|
}
|
|
1860
1860
|
|
|
1861
1861
|
// =============================================================================
|
|
@@ -1897,8 +1897,8 @@ model OfferLetter {
|
|
|
1897
1897
|
id String @id @default(cuid())
|
|
1898
1898
|
tenantId String
|
|
1899
1899
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1900
|
-
|
|
1901
|
-
|
|
1900
|
+
applicationId String
|
|
1901
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1902
1902
|
|
|
1903
1903
|
// Template used (optional - documents-service may handle default selection)
|
|
1904
1904
|
templateId String?
|
|
@@ -1940,7 +1940,7 @@ model OfferLetter {
|
|
|
1940
1940
|
updatedAt DateTime @updatedAt
|
|
1941
1941
|
|
|
1942
1942
|
@@index([tenantId])
|
|
1943
|
-
@@index([
|
|
1943
|
+
@@index([applicationId])
|
|
1944
1944
|
@@index([type])
|
|
1945
1945
|
@@index([status])
|
|
1946
1946
|
@@map("offer_letters")
|
|
@@ -1958,10 +1958,10 @@ model OfferLetter {
|
|
|
1958
1958
|
// 5. Contract marked terminated, unit released
|
|
1959
1959
|
// =============================================================================
|
|
1960
1960
|
|
|
1961
|
-
model
|
|
1961
|
+
model ApplicationTermination {
|
|
1962
1962
|
id String @id @default(cuid())
|
|
1963
|
-
|
|
1964
|
-
|
|
1963
|
+
applicationId String
|
|
1964
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
1965
1965
|
tenantId String
|
|
1966
1966
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1967
1967
|
|
|
@@ -1989,8 +1989,8 @@ model ContractTermination {
|
|
|
1989
1989
|
rejectionReason String? @db.Text
|
|
1990
1990
|
|
|
1991
1991
|
// Financial snapshot at time of request
|
|
1992
|
-
|
|
1993
|
-
|
|
1992
|
+
applicationSnapshot Json // Full contract state snapshot
|
|
1993
|
+
totalApplicationAmount Float
|
|
1994
1994
|
totalPaidToDate Float
|
|
1995
1995
|
outstandingBalance Float
|
|
1996
1996
|
|
|
@@ -2029,13 +2029,13 @@ model ContractTermination {
|
|
|
2029
2029
|
createdAt DateTime @default(now())
|
|
2030
2030
|
updatedAt DateTime @updatedAt
|
|
2031
2031
|
|
|
2032
|
-
@@index([
|
|
2032
|
+
@@index([applicationId])
|
|
2033
2033
|
@@index([tenantId])
|
|
2034
2034
|
@@index([status])
|
|
2035
2035
|
@@index([type])
|
|
2036
2036
|
@@index([initiatorId])
|
|
2037
2037
|
@@index([requestedAt])
|
|
2038
|
-
@@map("
|
|
2038
|
+
@@map("application_terminations")
|
|
2039
2039
|
}
|
|
2040
2040
|
|
|
2041
2041
|
// =============================================================================
|
|
@@ -2060,8 +2060,8 @@ model PaymentMethodChangeRequest {
|
|
|
2060
2060
|
id String @id @default(cuid())
|
|
2061
2061
|
tenantId String
|
|
2062
2062
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
2063
|
-
|
|
2064
|
-
|
|
2063
|
+
applicationId String
|
|
2064
|
+
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
2065
2065
|
|
|
2066
2066
|
// The change being requested
|
|
2067
2067
|
fromPaymentMethodId String
|
|
@@ -2102,7 +2102,7 @@ model PaymentMethodChangeRequest {
|
|
|
2102
2102
|
updatedAt DateTime @updatedAt
|
|
2103
2103
|
|
|
2104
2104
|
@@index([tenantId])
|
|
2105
|
-
@@index([
|
|
2105
|
+
@@index([applicationId])
|
|
2106
2106
|
@@index([status])
|
|
2107
2107
|
@@index([requestorId])
|
|
2108
2108
|
@@map("payment_method_change_requests")
|
|
@@ -2119,7 +2119,7 @@ model PaymentMethodChangeRequest {
|
|
|
2119
2119
|
// =============================================================================
|
|
2120
2120
|
|
|
2121
2121
|
enum DocumentRequirementContext {
|
|
2122
|
-
|
|
2122
|
+
APPLICATION_PHASE // During a contract phase
|
|
2123
2123
|
PAYMENT_METHOD_CHANGE // When changing payment method mid-contract
|
|
2124
2124
|
}
|
|
2125
2125
|
|
|
@@ -2133,7 +2133,7 @@ model DocumentRequirementRule {
|
|
|
2133
2133
|
|
|
2134
2134
|
// Scoping (which situations this rule applies to)
|
|
2135
2135
|
// For PREQUALIFICATION: paymentMethodId
|
|
2136
|
-
// For
|
|
2136
|
+
// For APPLICATION_PHASE: phaseType
|
|
2137
2137
|
// For PAYMENT_METHOD_CHANGE: fromMethodId + toMethodId
|
|
2138
2138
|
paymentMethodId String?
|
|
2139
2139
|
paymentMethod PropertyPaymentMethod? @relation("RulePaymentMethod", fields: [paymentMethodId], references: [id])
|
|
@@ -2460,8 +2460,8 @@ model PropertyTransferRequest {
|
|
|
2460
2460
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
2461
2461
|
|
|
2462
2462
|
// Source contract being transferred
|
|
2463
|
-
|
|
2464
|
-
|
|
2463
|
+
sourceApplicationId String
|
|
2464
|
+
sourceApplication Application @relation("SourceApplication", fields: [sourceApplicationId], references: [id], onDelete: Cascade)
|
|
2465
2465
|
|
|
2466
2466
|
// Target property unit
|
|
2467
2467
|
targetPropertyUnitId String
|
|
@@ -2494,8 +2494,8 @@ model PropertyTransferRequest {
|
|
|
2494
2494
|
refundedAt DateTime?
|
|
2495
2495
|
|
|
2496
2496
|
// Result - new contract created after approval
|
|
2497
|
-
|
|
2498
|
-
|
|
2497
|
+
targetApplicationId String?
|
|
2498
|
+
targetApplication Application? @relation("TargetApplication", fields: [targetApplicationId], references: [id])
|
|
2499
2499
|
|
|
2500
2500
|
// Timestamps
|
|
2501
2501
|
createdAt DateTime @default(now())
|
|
@@ -2504,7 +2504,7 @@ model PropertyTransferRequest {
|
|
|
2504
2504
|
updatedAt DateTime @updatedAt
|
|
2505
2505
|
|
|
2506
2506
|
@@index([tenantId])
|
|
2507
|
-
@@index([
|
|
2507
|
+
@@index([sourceApplicationId])
|
|
2508
2508
|
@@index([targetPropertyUnitId])
|
|
2509
2509
|
@@index([requestedById])
|
|
2510
2510
|
@@index([status])
|
|
@@ -2520,7 +2520,7 @@ enum ApprovalRequestType {
|
|
|
2520
2520
|
PROPERTY_UPDATE // Property/unit listing update requiring approval
|
|
2521
2521
|
USER_WORKFLOW // User workflow step approval
|
|
2522
2522
|
CREDIT_CHECK // Credit check result review
|
|
2523
|
-
|
|
2523
|
+
APPLICATION_TERMINATION // Contract termination approval
|
|
2524
2524
|
REFUND_APPROVAL // Refund request approval
|
|
2525
2525
|
}
|
|
2526
2526
|
|