@valentine-efagene/qshelter-common 2.0.78 → 2.0.82
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 +120 -30
- package/dist/generated/client/enums.d.ts +10 -10
- package/dist/generated/client/enums.js +9 -9
- 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 +129 -8
- package/dist/generated/client/internal/prismaNamespace.js +44 -4
- package/dist/generated/client/internal/prismaNamespaceBrowser.d.ts +45 -3
- package/dist/generated/client/internal/prismaNamespaceBrowser.js +44 -4
- package/dist/generated/client/models/Contract.d.ts +323 -0
- package/dist/generated/client/models/ContractEvent.d.ts +76 -66
- package/dist/generated/client/models/ContractRefund.d.ts +2560 -0
- package/dist/generated/client/models/ContractRefund.js +1 -0
- package/dist/generated/client/models/ContractTermination.d.ts +0 -3
- package/dist/generated/client/models/Tenant.d.ts +235 -0
- package/dist/generated/client/models/User.d.ts +1103 -22
- 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/package.json +1 -1
- package/prisma/migrations/20260107214834_add_contract_refund_model/migration.sql +64 -0
- package/prisma/schema.prisma +77 -11
|
@@ -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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to alter the column `actorType` on the `contract_events` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `Enum(EnumId(15))`.
|
|
5
|
+
- You are about to alter the column `eventGroup` on the `contract_events` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `Enum(EnumId(14))`.
|
|
6
|
+
- You are about to alter the column `eventType` on the `contract_events` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `Enum(EnumId(13))`.
|
|
7
|
+
- You are about to alter the column `refundStatus` on the `contract_terminations` table. The data in that column could be lost. The data in that column will be cast from `Enum(EnumId(34))` to `Enum(EnumId(27))`.
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
-- AlterTable
|
|
11
|
+
ALTER TABLE `contract_events` MODIFY `actorType` ENUM('USER', 'SYSTEM', 'WEBHOOK', 'ADMIN') NULL,
|
|
12
|
+
MODIFY `eventGroup` ENUM('STATE_CHANGE', 'PAYMENT', 'DOCUMENT', 'NOTIFICATION', 'WORKFLOW') NULL,
|
|
13
|
+
MODIFY `eventType` ENUM('CONTRACT_CREATED', 'CONTRACT_STATE_CHANGED', 'PHASE_ACTIVATED', 'PHASE_COMPLETED', 'STEP_COMPLETED', 'STEP_REJECTED', 'DOCUMENT_SUBMITTED', 'DOCUMENT_APPROVED', 'DOCUMENT_REJECTED', 'PAYMENT_INITIATED', 'PAYMENT_COMPLETED', 'PAYMENT_FAILED', 'INSTALLMENTS_GENERATED', 'CONTRACT_SIGNED', 'CONTRACT_TERMINATED', 'CONTRACT_TRANSFERRED', 'UNDERWRITING_COMPLETED', 'OFFER_LETTER_GENERATED') NOT NULL;
|
|
14
|
+
|
|
15
|
+
-- AlterTable
|
|
16
|
+
ALTER TABLE `contract_terminations` MODIFY `refundStatus` ENUM('PENDING', 'APPROVED', 'REJECTED', 'PROCESSING', 'COMPLETED', 'FAILED', 'CANCELLED') NOT NULL DEFAULT 'PENDING';
|
|
17
|
+
|
|
18
|
+
-- CreateTable
|
|
19
|
+
CREATE TABLE `contract_refunds` (
|
|
20
|
+
`id` VARCHAR(191) NOT NULL,
|
|
21
|
+
`tenantId` VARCHAR(191) NOT NULL,
|
|
22
|
+
`contractId` VARCHAR(191) NOT NULL,
|
|
23
|
+
`amount` DOUBLE NOT NULL,
|
|
24
|
+
`reason` TEXT NOT NULL,
|
|
25
|
+
`status` ENUM('PENDING', 'APPROVED', 'REJECTED', 'PROCESSING', 'COMPLETED', 'FAILED', 'CANCELLED') NOT NULL DEFAULT 'PENDING',
|
|
26
|
+
`requestedById` VARCHAR(191) NOT NULL,
|
|
27
|
+
`approvedById` VARCHAR(191) NULL,
|
|
28
|
+
`processedById` VARCHAR(191) NULL,
|
|
29
|
+
`paymentMethod` VARCHAR(191) NULL,
|
|
30
|
+
`referenceNumber` VARCHAR(191) NULL,
|
|
31
|
+
`recipientName` VARCHAR(191) NULL,
|
|
32
|
+
`recipientAccount` VARCHAR(191) NULL,
|
|
33
|
+
`recipientBank` VARCHAR(191) NULL,
|
|
34
|
+
`requestedAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
35
|
+
`approvedAt` DATETIME(3) NULL,
|
|
36
|
+
`rejectedAt` DATETIME(3) NULL,
|
|
37
|
+
`processedAt` DATETIME(3) NULL,
|
|
38
|
+
`approvalNotes` TEXT NULL,
|
|
39
|
+
`rejectionNotes` TEXT NULL,
|
|
40
|
+
`processingNotes` TEXT NULL,
|
|
41
|
+
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
42
|
+
`updatedAt` DATETIME(3) NOT NULL,
|
|
43
|
+
|
|
44
|
+
INDEX `contract_refunds_contractId_idx`(`contractId`),
|
|
45
|
+
INDEX `contract_refunds_status_idx`(`status`),
|
|
46
|
+
INDEX `contract_refunds_tenantId_idx`(`tenantId`),
|
|
47
|
+
INDEX `contract_refunds_requestedById_idx`(`requestedById`),
|
|
48
|
+
PRIMARY KEY (`id`)
|
|
49
|
+
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
50
|
+
|
|
51
|
+
-- AddForeignKey
|
|
52
|
+
ALTER TABLE `contract_refunds` ADD CONSTRAINT `contract_refunds_tenantId_fkey` FOREIGN KEY (`tenantId`) REFERENCES `tenants`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
53
|
+
|
|
54
|
+
-- AddForeignKey
|
|
55
|
+
ALTER TABLE `contract_refunds` ADD CONSTRAINT `contract_refunds_contractId_fkey` FOREIGN KEY (`contractId`) REFERENCES `contracts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
56
|
+
|
|
57
|
+
-- AddForeignKey
|
|
58
|
+
ALTER TABLE `contract_refunds` ADD CONSTRAINT `contract_refunds_requestedById_fkey` FOREIGN KEY (`requestedById`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
59
|
+
|
|
60
|
+
-- AddForeignKey
|
|
61
|
+
ALTER TABLE `contract_refunds` ADD CONSTRAINT `contract_refunds_approvedById_fkey` FOREIGN KEY (`approvedById`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
|
62
|
+
|
|
63
|
+
-- AddForeignKey
|
|
64
|
+
ALTER TABLE `contract_refunds` ADD CONSTRAINT `contract_refunds_processedById_fkey` FOREIGN KEY (`processedById`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -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(
|
|
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
|