@valentine-efagene/qshelter-common 2.0.31 → 2.0.33

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.
@@ -104,37 +104,37 @@ enum ApprovalDecision {
104
104
  // =============================================================================
105
105
 
106
106
  enum TerminationType {
107
- BUYER_WITHDRAWAL // Buyer wants to cancel (voluntary)
108
- SELLER_WITHDRAWAL // Seller/developer cancels
109
- MUTUAL_AGREEMENT // Both parties agree to terminate
110
- PAYMENT_DEFAULT // Buyer failed payment obligations
111
- DOCUMENT_FAILURE // Buyer failed to provide required documents
112
- FRAUD // Fraudulent activity detected
113
- FORCE_MAJEURE // External circumstances (disaster, etc.)
114
- PROPERTY_UNAVAILABLE // Property no longer available
115
- REGULATORY // Regulatory/legal requirement
116
- OTHER // Other reasons (with notes)
107
+ BUYER_WITHDRAWAL // Buyer wants to cancel (voluntary)
108
+ SELLER_WITHDRAWAL // Seller/developer cancels
109
+ MUTUAL_AGREEMENT // Both parties agree to terminate
110
+ PAYMENT_DEFAULT // Buyer failed payment obligations
111
+ DOCUMENT_FAILURE // Buyer failed to provide required documents
112
+ FRAUD // Fraudulent activity detected
113
+ FORCE_MAJEURE // External circumstances (disaster, etc.)
114
+ PROPERTY_UNAVAILABLE // Property no longer available
115
+ REGULATORY // Regulatory/legal requirement
116
+ OTHER // Other reasons (with notes)
117
117
  }
118
118
 
119
119
  enum TerminationStatus {
120
- REQUESTED // Initial request submitted
121
- PENDING_REVIEW // Awaiting admin review
122
- PENDING_REFUND // Approved, awaiting refund processing
123
- REFUND_IN_PROGRESS // Refund being processed
124
- REFUND_COMPLETED // Refund completed
125
- COMPLETED // Termination fully executed (no refund or refund done)
126
- REJECTED // Termination request rejected
127
- CANCELLED // Termination request was cancelled
120
+ REQUESTED // Initial request submitted
121
+ PENDING_REVIEW // Awaiting admin review
122
+ PENDING_REFUND // Approved, awaiting refund processing
123
+ REFUND_IN_PROGRESS // Refund being processed
124
+ REFUND_COMPLETED // Refund completed
125
+ COMPLETED // Termination fully executed (no refund or refund done)
126
+ REJECTED // Termination request rejected
127
+ CANCELLED // Termination request was cancelled
128
128
  }
129
129
 
130
130
  enum RefundStatus {
131
- NOT_APPLICABLE // No refund needed (no payments made)
132
- PENDING // Refund not yet initiated
133
- INITIATED // Refund request sent to payment gateway
134
- PROCESSING // Gateway processing refund
135
- PARTIAL_COMPLETED // Some refund completed (penalties deducted)
136
- COMPLETED // Full refund completed
137
- FAILED // Refund failed (needs manual intervention)
131
+ NOT_APPLICABLE // No refund needed (no payments made)
132
+ PENDING // Refund not yet initiated
133
+ INITIATED // Refund request sent to payment gateway
134
+ PROCESSING // Gateway processing refund
135
+ PARTIAL_COMPLETED // Some refund completed (penalties deducted)
136
+ COMPLETED // Full refund completed
137
+ FAILED // Refund failed (needs manual intervention)
138
138
  }
139
139
 
140
140
  enum TerminationInitiator {
@@ -206,8 +206,8 @@ model User {
206
206
  reviewedChangeRequests PaymentMethodChangeRequest[] @relation("ChangeReviewer")
207
207
 
208
208
  // Contract terminations
209
- initiatedTerminations ContractTermination[] @relation("TerminationInitiator")
210
- reviewedTerminations ContractTermination[] @relation("TerminationReviewer")
209
+ initiatedTerminations ContractTermination[] @relation("TerminationInitiator")
210
+ reviewedTerminations ContractTermination[] @relation("TerminationReviewer")
211
211
 
212
212
  @@index([email])
213
213
  @@index([tenantId])
@@ -284,7 +284,7 @@ model Tenant {
284
284
  documentRequirementRules DocumentRequirementRule[]
285
285
 
286
286
  // Contract terminations
287
- contractTerminations ContractTermination[]
287
+ contractTerminations ContractTermination[]
288
288
 
289
289
  @@index([subdomain])
290
290
  @@map("tenants")
@@ -669,6 +669,11 @@ model PaymentPlan {
669
669
  calculateInterestDaily Boolean @default(false)
670
670
  gracePeriodDays Int @default(0)
671
671
 
672
+ // Fund collection behavior
673
+ // true = we collect funds via wallet/gateway (e.g., downpayment)
674
+ // false = external payment, we only track/reconcile (e.g., bank mortgage)
675
+ collectFunds Boolean @default(true)
676
+
672
677
  createdAt DateTime @default(now())
673
678
  updatedAt DateTime @updatedAt
674
679
 
@@ -765,6 +770,11 @@ model PropertyPaymentMethodPhase {
765
770
  interestRate Float?
766
771
  percentOfPrice Float? // e.g., 10.0 for 10% downpayment
767
772
 
773
+ // Fund collection behavior (inherited from PaymentPlan if not set)
774
+ // true = we collect funds via wallet/gateway (e.g., downpayment)
775
+ // false = external payment, we only track/reconcile (e.g., bank mortgage)
776
+ collectFunds Boolean? // null = inherit from PaymentPlan
777
+
768
778
  // Activation rules
769
779
  requiresPreviousPhaseCompletion Boolean @default(true)
770
780
  minimumCompletionPercentage Float?
@@ -879,11 +889,11 @@ model Contract {
879
889
  updatedAt DateTime @updatedAt
880
890
 
881
891
  // Relations
882
- phases ContractPhase[]
883
- documents ContractDocument[]
884
- payments ContractPayment[]
885
- transitions ContractTransition[]
886
- events ContractEvent[]
892
+ phases ContractPhase[]
893
+ documents ContractDocument[]
894
+ payments ContractPayment[]
895
+ transitions ContractTransition[]
896
+ events ContractEvent[]
887
897
  terminations ContractTermination[]
888
898
 
889
899
  // Prequalification that led to this contract (optional)
@@ -928,6 +938,11 @@ model ContractPhase {
928
938
  remainingAmount Float?
929
939
  interestRate Float?
930
940
 
941
+ // Fund collection behavior (snapshotted from template at contract creation)
942
+ // true = we collect funds via wallet/gateway (e.g., downpayment)
943
+ // false = external payment, we only track/reconcile (e.g., bank mortgage)
944
+ collectFunds Boolean @default(true)
945
+
931
946
  // Progress counters (for efficient activation checks)
932
947
  approvedDocumentsCount Int @default(0)
933
948
  requiredDocumentsCount Int @default(0)
@@ -1183,62 +1198,62 @@ model ContractTermination {
1183
1198
  requestNumber String @unique // TRM-XXXXXX
1184
1199
 
1185
1200
  // Who initiated and why
1186
- initiatedBy TerminationInitiator
1187
- initiatorId String? // userId if BUYER/SELLER/ADMIN
1188
- initiator User? @relation("TerminationInitiator", fields: [initiatorId], references: [id])
1189
- type TerminationType
1190
- reason String? @db.Text
1191
- supportingDocs Json? // [{type, url, uploadedAt}]
1201
+ initiatedBy TerminationInitiator
1202
+ initiatorId String? // userId if BUYER/SELLER/ADMIN
1203
+ initiator User? @relation("TerminationInitiator", fields: [initiatorId], references: [id])
1204
+ type TerminationType
1205
+ reason String? @db.Text
1206
+ supportingDocs Json? // [{type, url, uploadedAt}]
1192
1207
 
1193
1208
  // Workflow status
1194
- status TerminationStatus @default(REQUESTED)
1195
- requiresApproval Boolean @default(true)
1196
- autoApproveEligible Boolean @default(false) // Pre-signature, no payments
1209
+ status TerminationStatus @default(REQUESTED)
1210
+ requiresApproval Boolean @default(true)
1211
+ autoApproveEligible Boolean @default(false) // Pre-signature, no payments
1197
1212
 
1198
1213
  // Admin review
1199
- reviewedBy String?
1200
- reviewer User? @relation("TerminationReviewer", fields: [reviewedBy], references: [id])
1201
- reviewedAt DateTime?
1202
- reviewNotes String? @db.Text
1203
- rejectionReason String? @db.Text
1214
+ reviewedBy String?
1215
+ reviewer User? @relation("TerminationReviewer", fields: [reviewedBy], references: [id])
1216
+ reviewedAt DateTime?
1217
+ reviewNotes String? @db.Text
1218
+ rejectionReason String? @db.Text
1204
1219
 
1205
1220
  // Financial snapshot at time of request
1206
- contractSnapshot Json // Full contract state snapshot
1221
+ contractSnapshot Json // Full contract state snapshot
1207
1222
  totalContractAmount Float
1208
1223
  totalPaidToDate Float
1209
1224
  outstandingBalance Float
1210
1225
 
1211
1226
  // Settlement calculation
1212
- refundableAmount Float @default(0) // Amount eligible for refund
1213
- penaltyAmount Float @default(0) // Penalties/fees to deduct
1214
- forfeitedAmount Float @default(0) // Amount forfeited (non-refundable deposits)
1215
- adminFeeAmount Float @default(0) // Processing fees
1216
- netRefundAmount Float @default(0) // refundableAmount - penaltyAmount - adminFeeAmount
1217
- settlementNotes String? @db.Text
1227
+ refundableAmount Float @default(0) // Amount eligible for refund
1228
+ penaltyAmount Float @default(0) // Penalties/fees to deduct
1229
+ forfeitedAmount Float @default(0) // Amount forfeited (non-refundable deposits)
1230
+ adminFeeAmount Float @default(0) // Processing fees
1231
+ netRefundAmount Float @default(0) // refundableAmount - penaltyAmount - adminFeeAmount
1232
+ settlementNotes String? @db.Text
1218
1233
 
1219
1234
  // Refund processing
1220
- refundStatus RefundStatus @default(NOT_APPLICABLE)
1221
- refundReference String? // Payment gateway reference
1222
- refundMethod String? // ORIGINAL_METHOD, BANK_TRANSFER, CHECK, WALLET
1223
- refundAccountDetails Json? // Encrypted bank details if needed
1224
- refundInitiatedAt DateTime?
1225
- refundCompletedAt DateTime?
1226
- refundFailureReason String? @db.Text
1235
+ refundStatus RefundStatus @default(NOT_APPLICABLE)
1236
+ refundReference String? // Payment gateway reference
1237
+ refundMethod String? // ORIGINAL_METHOD, BANK_TRANSFER, CHECK, WALLET
1238
+ refundAccountDetails Json? // Encrypted bank details if needed
1239
+ refundInitiatedAt DateTime?
1240
+ refundCompletedAt DateTime?
1241
+ refundFailureReason String? @db.Text
1227
1242
 
1228
1243
  // Property unit handling
1229
1244
  unitReleasedAt DateTime?
1230
- unitReservedForId String? // If unit being held for another buyer
1245
+ unitReservedForId String? // If unit being held for another buyer
1231
1246
 
1232
1247
  // Timing
1233
- requestedAt DateTime @default(now())
1234
- approvedAt DateTime?
1235
- executedAt DateTime?
1236
- completedAt DateTime?
1237
- cancelledAt DateTime?
1248
+ requestedAt DateTime @default(now())
1249
+ approvedAt DateTime?
1250
+ executedAt DateTime?
1251
+ completedAt DateTime?
1252
+ cancelledAt DateTime?
1238
1253
 
1239
1254
  // Idempotency and audit
1240
- idempotencyKey String? @unique
1241
- metadata Json?
1255
+ idempotencyKey String? @unique
1256
+ metadata Json?
1242
1257
 
1243
1258
  createdAt DateTime @default(now())
1244
1259
  updatedAt DateTime @updatedAt