@valentine-efagene/qshelter-common 2.0.57 → 2.0.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.57",
3
+ "version": "2.0.60",
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",
@@ -0,0 +1,14 @@
1
+ -- AlterTable
2
+ ALTER TABLE `contract_phase_steps` ADD COLUMN `actionReason` TEXT NULL,
3
+ ADD COLUMN `lastSubmittedAt` DATETIME(3) NULL,
4
+ ADD COLUMN `submissionCount` INTEGER NOT NULL DEFAULT 0,
5
+ MODIFY `status` ENUM('PENDING', 'IN_PROGRESS', 'COMPLETED', 'FAILED', 'SKIPPED', 'NEEDS_RESUBMISSION', 'ACTION_REQUIRED', 'AWAITING_REVIEW') NOT NULL DEFAULT 'PENDING';
6
+
7
+ -- AlterTable
8
+ ALTER TABLE `contract_phases` ADD COLUMN `currentStepId` VARCHAR(191) NULL;
9
+
10
+ -- CreateIndex
11
+ CREATE INDEX `contract_phases_currentStepId_idx` ON `contract_phases`(`currentStepId`);
12
+
13
+ -- AddForeignKey
14
+ ALTER TABLE `contract_phases` ADD CONSTRAINT `contract_phases_currentStepId_fkey` FOREIGN KEY (`currentStepId`) REFERENCES `contract_phase_steps`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
@@ -79,6 +79,9 @@ enum StepStatus {
79
79
  COMPLETED
80
80
  FAILED
81
81
  SKIPPED
82
+ NEEDS_RESUBMISSION // User must re-upload or correct something (after rejection)
83
+ ACTION_REQUIRED // User action needed (generic - check actionReason)
84
+ AWAITING_REVIEW // Submitted, waiting for admin/system review
82
85
  }
83
86
 
84
87
  enum InstallmentStatus {
@@ -965,6 +968,15 @@ model ContractPhase {
965
968
  // FSM state for this phase (DB-enforced enum)
966
969
  status PhaseStatus @default(PENDING)
967
970
 
971
+ // =========================================================================
972
+ // WORKFLOW TRACKING - Current step pointer for UX and orchestration
973
+ // =========================================================================
974
+ // Canonical pointer to the step currently requiring attention.
975
+ // Updated by service when: phase activates (→ first step), step completes (→ next),
976
+ // step rejected (→ same step with NEEDS_RESUBMISSION), or phase completes (→ null).
977
+ currentStepId String?
978
+ currentStep DocumentationStep? @relation("CurrentStep", fields: [currentStepId], references: [id])
979
+
968
980
  // Financial details (for PAYMENT phases)
969
981
  totalAmount Float?
970
982
  paidAmount Float @default(0)
@@ -1012,6 +1024,7 @@ model ContractPhase {
1012
1024
  @@index([phaseCategory])
1013
1025
  @@index([status])
1014
1026
  @@index([order])
1027
+ @@index([currentStepId])
1015
1028
  @@map("contract_phases")
1016
1029
  }
1017
1030
 
@@ -1028,6 +1041,19 @@ model DocumentationStep {
1028
1041
 
1029
1042
  status StepStatus @default(PENDING)
1030
1043
 
1044
+ // =========================================================================
1045
+ // USER ACTION TRACKING - For rejection/resubmission flows
1046
+ // =========================================================================
1047
+ // When status is NEEDS_RESUBMISSION or ACTION_REQUIRED, this explains why.
1048
+ // Populated from DocumentationStepApproval.comment on rejection.
1049
+ actionReason String? @db.Text
1050
+
1051
+ // Number of times this step has been submitted (for tracking resubmissions)
1052
+ submissionCount Int @default(0)
1053
+
1054
+ // Last submission timestamp (for tracking resubmission timing)
1055
+ lastSubmittedAt DateTime?
1056
+
1031
1057
  // Configuration metadata (for GENERATE_DOCUMENT steps, etc.)
1032
1058
  metadata Json?
1033
1059
 
@@ -1054,7 +1080,8 @@ model DocumentationStep {
1054
1080
  createdAt DateTime @default(now())
1055
1081
  updatedAt DateTime @updatedAt
1056
1082
 
1057
- approvals DocumentationStepApproval[]
1083
+ approvals DocumentationStepApproval[]
1084
+ currentForPhase ContractPhase[] @relation("CurrentStep")
1058
1085
 
1059
1086
  @@index([phaseId])
1060
1087
  @@index([status])