@valentine-efagene/qshelter-common 2.0.77 → 2.0.81

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.
@@ -7,6 +7,7 @@ export * from './ContractEvent';
7
7
  export * from './ContractInstallment';
8
8
  export * from './ContractPayment';
9
9
  export * from './ContractPhase';
10
+ export * from './ContractRefund';
10
11
  export * from './ContractTermination';
11
12
  export * from './DeviceEndpoint';
12
13
  export * from './DocumentRequirementRule';
@@ -7,6 +7,7 @@ export * from './ContractEvent';
7
7
  export * from './ContractInstallment';
8
8
  export * from './ContractPayment';
9
9
  export * from './ContractPhase';
10
+ export * from './ContractRefund';
10
11
  export * from './ContractTermination';
11
12
  export * from './DeviceEndpoint';
12
13
  export * from './DocumentRequirementRule';
@@ -32,6 +32,7 @@ export type * from './models/PaymentMethodPhaseStep.js';
32
32
  export type * from './models/StepEventAttachment.js';
33
33
  export type * from './models/PaymentMethodPhaseDocument.js';
34
34
  export type * from './models/Contract.js';
35
+ export type * from './models/ContractRefund.js';
35
36
  export type * from './models/ContractPhase.js';
36
37
  export type * from './models/ContractEvent.js';
37
38
  export type * from './models/DocumentationStep.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.77",
3
+ "version": "2.0.81",
4
4
  "description": "Shared database schemas and utilities for QShelter services",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -153,16 +153,6 @@ enum TerminationStatus {
153
153
  CANCELLED // Termination request was cancelled
154
154
  }
155
155
 
156
- enum RefundStatus {
157
- NOT_APPLICABLE // No refund needed (no payments made)
158
- PENDING // Refund not yet initiated
159
- INITIATED // Refund request sent to payment gateway
160
- PROCESSING // Gateway processing refund
161
- PARTIAL_COMPLETED // Some refund completed (penalties deducted)
162
- COMPLETED // Full refund completed
163
- FAILED // Refund failed (needs manual intervention)
164
- }
165
-
166
156
  enum TerminationInitiator {
167
157
  BUYER
168
158
  SELLER
@@ -240,6 +230,16 @@ enum EventActorType {
240
230
  ADMIN
241
231
  }
242
232
 
233
+ enum RefundStatus {
234
+ PENDING
235
+ APPROVED
236
+ REJECTED
237
+ PROCESSING
238
+ COMPLETED
239
+ FAILED
240
+ CANCELLED
241
+ }
242
+
243
243
  // =============================================================================
244
244
  // EVENT-DRIVEN WORKFLOW ENUMS
245
245
  // =============================================================================
@@ -347,6 +347,11 @@ model User {
347
347
  approvalRequestsAssigned ApprovalRequest[] @relation("ApprovalAssignee")
348
348
  approvalRequestsReviewed ApprovalRequest[] @relation("ApprovalReviewer")
349
349
 
350
+ // Contract refunds
351
+ requestedRefunds ContractRefund[] @relation("RefundRequester")
352
+ approvedRefunds ContractRefund[] @relation("RefundApprover")
353
+ processedRefunds ContractRefund[] @relation("RefundProcessor")
354
+
350
355
  @@index([email])
351
356
  @@index([tenantId])
352
357
  @@map("users")
@@ -442,6 +447,9 @@ model Tenant {
442
447
  // Unified approval requests
443
448
  approvalRequests ApprovalRequest[]
444
449
 
450
+ // Contract refunds
451
+ contractRefunds ContractRefund[]
452
+
445
453
  @@index([subdomain])
446
454
  @@map("tenants")
447
455
  }
@@ -1159,6 +1167,9 @@ model Contract {
1159
1167
  // Audit trail
1160
1168
  events ContractEvent[]
1161
1169
 
1170
+ // Refund requests
1171
+ refunds ContractRefund[]
1172
+
1162
1173
  @@index([tenantId])
1163
1174
  @@index([propertyUnitId])
1164
1175
  @@index([buyerId])
@@ -1169,6 +1180,61 @@ model Contract {
1169
1180
  @@map("contracts")
1170
1181
  }
1171
1182
 
1183
+ // =============================================================================
1184
+ // CONTRACT REFUNDS - Track refund requests for overpayments or cancellations
1185
+ // =============================================================================
1186
+ model ContractRefund {
1187
+ id String @id @default(cuid())
1188
+ tenantId String
1189
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1190
+
1191
+ contractId String
1192
+ contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
1193
+
1194
+ amount Float
1195
+ reason String @db.Text
1196
+ status RefundStatus @default(PENDING)
1197
+
1198
+ // Who requested the refund
1199
+ requestedById String
1200
+ requestedBy User @relation("RefundRequester", fields: [requestedById], references: [id])
1201
+
1202
+ // Who approved/rejected the refund
1203
+ approvedById String?
1204
+ approvedBy User? @relation("RefundApprover", fields: [approvedById], references: [id])
1205
+
1206
+ // Who processed the refund (finance team)
1207
+ processedById String?
1208
+ processedBy User? @relation("RefundProcessor", fields: [processedById], references: [id])
1209
+
1210
+ // Refund payment details
1211
+ paymentMethod String? // BANK_TRANSFER, CHEQUE, MOBILE_MONEY, etc.
1212
+ referenceNumber String? // Bank/payment reference
1213
+ recipientName String?
1214
+ recipientAccount String?
1215
+ recipientBank String?
1216
+
1217
+ // Timestamps
1218
+ requestedAt DateTime @default(now())
1219
+ approvedAt DateTime?
1220
+ rejectedAt DateTime?
1221
+ processedAt DateTime?
1222
+
1223
+ // Additional notes
1224
+ approvalNotes String? @db.Text
1225
+ rejectionNotes String? @db.Text
1226
+ processingNotes String? @db.Text
1227
+
1228
+ createdAt DateTime @default(now())
1229
+ updatedAt DateTime @updatedAt
1230
+
1231
+ @@index([contractId])
1232
+ @@index([status])
1233
+ @@index([tenantId])
1234
+ @@index([requestedById])
1235
+ @@map("contract_refunds")
1236
+ }
1237
+
1172
1238
  // Phase within a contract - can be DOCUMENTATION or PAYMENT type
1173
1239
  // Admin names phases freely (e.g., "KYC Documents", "Downpayment", "Monthly Mortgage")
1174
1240
  model ContractPhase {
@@ -1624,7 +1690,7 @@ model ContractTermination {
1624
1690
  settlementNotes String? @db.Text
1625
1691
 
1626
1692
  // Refund processing
1627
- refundStatus RefundStatus @default(NOT_APPLICABLE)
1693
+ refundStatus RefundStatus @default(PENDING)
1628
1694
  refundReference String? // Payment gateway reference
1629
1695
  refundMethod String? // ORIGINAL_METHOD, BANK_TRANSFER, CHECK, WALLET
1630
1696
  refundAccountDetails Json? // Encrypted bank details if needed