From 64865b70f23301121ccc5b3ca07be1681b8c7957 Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Wed, 22 Jul 2026 15:35:14 +0330 Subject: [PATCH] Fix v2 flow sign of second party --- .../request-management.service.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/request-management/request-management.service.ts b/src/request-management/request-management.service.ts index 4366c3e..4cb1067 100644 --- a/src/request-management/request-management.service.ts +++ b/src/request-management/request-management.service.ts @@ -2119,7 +2119,7 @@ export class RequestManagementService { } req.workflow.completedSteps = completed; req.workflow.currentStep = WorkflowStep.WAITING_FOR_SIGNATURES; - req.workflow.nextStep = undefined; + req.workflow.nextStep = WorkflowStep.WAITING_FOR_SIGNATURES; req.status = CaseStatus.WAITING_FOR_SIGNATURES; closedByMutualAgreement = true; @@ -2205,7 +2205,7 @@ export class RequestManagementService { } req.workflow.completedSteps = completed; req.workflow.currentStep = WorkflowStep.WAITING_FOR_SIGNATURES; - req.workflow.nextStep = undefined; + req.workflow.nextStep = WorkflowStep.WAITING_FOR_SIGNATURES; req.status = CaseStatus.WAITING_FOR_SIGNATURES; } else if (!closedByMutualAgreement) { if (stepKey === WorkflowStep.SECOND_DESCRIPTION) { @@ -6796,17 +6796,16 @@ export class RequestManagementService { ); } await this.verifyExpertAccessForBlameV2(req, expert); - // In the V2 IN_PERSON mirror flow guilt is resolved automatically during - // addDescriptionV2 — accident-fields must only be called once the file has - // reached WAITING_FOR_SIGNATURES (both parties' narrative steps are done). - // Calling it earlier would overwrite the workflow and skip the sign step. + // In the V2 IN_PERSON mirror flow guilt is resolved automatically after both + // parties complete their narrative steps (addDescriptionV2). The sign step for + // both parties must happen BEFORE accident-fields is called — calling it earlier + // would overwrite the workflow and cause the frontend to skip the sign page. if ( req.creationMethod === CreationMethod.IN_PERSON && - req.status !== CaseStatus.WAITING_FOR_SIGNATURES && req.status !== CaseStatus.COMPLETED ) { throw new BadRequestException( - `accident-fields can only be submitted after both parties have completed their narrative steps (current status: ${req.status}). Make sure both parties have gone through location, voice, and description before calling this endpoint.`, + `accident-fields can only be submitted after both parties have signed (current status: ${req.status}). Complete both signatures first.`, ); } @@ -6837,9 +6836,14 @@ export class RequestManagementService { }, }; - // For IN_PERSON expert files: after accident fields are filled, guilt is - // decided and we can go straight to signatures (no separate review needed). - if (req.creationMethod === CreationMethod.IN_PERSON) { + // For IN_PERSON expert files that have not yet reached COMPLETED: after accident + // fields are filled, guilt is decided and we can go straight to signatures. + // When the file is already COMPLETED (both parties signed) we only save the + // supplemental fields without touching the workflow or status. + if ( + req.creationMethod === CreationMethod.IN_PERSON && + req.status !== CaseStatus.COMPLETED + ) { const completed = Array.isArray(req.workflow?.completedSteps) ? req.workflow.completedSteps : [];