From 85d7881b2b71871ac983261fe0b0302fde2dbb63 Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Sun, 16 Aug 2026 10:18:43 +0330 Subject: [PATCH] YARA-1169 --- .../claim-request-management.service.ts | 46 ++++++++++++++++++- .../request-management.service.ts | 4 +- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/claim-request-management/claim-request-management.service.ts b/src/claim-request-management/claim-request-management.service.ts index 67e0d88..5ebbe33 100644 --- a/src/claim-request-management/claim-request-management.service.ts +++ b/src/claim-request-management/claim-request-management.service.ts @@ -11374,6 +11374,7 @@ export class ClaimRequestManagementService { step === ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS && capturePartDone ) { + // car-capture not yet uploaded: next step is the walk-around video. return { ...base, requiredDocuments: [], @@ -11384,6 +11385,22 @@ export class ClaimRequestManagementService { }; } + // V3 FIELD_EXPERT only: car-capture is done (step advanced to USER_SUBMISSION_COMPLETE + // in setVideoCaptureV3). The one remaining action is the blame accident video. + if ( + step === ClaimWorkflowStep.USER_SUBMISSION_COMPLETE && + !(blame as any).isMadeByFileMaker + ) { + return { + ...base, + requiredDocuments: [], + captureSequencePhase: "complete", + captureSequenceHint: + "Walk-around video uploaded. Upload the blame accident video to finalise.", + totalRemaining: 0, + }; + } + return base; } @@ -11721,7 +11738,34 @@ export class ClaimRequestManagementService { // V4/V5 only (isMadeByFileMaker): car-capture is the FINAL FileReviewer step. // For the v3 mirror (FIELD_EXPERT IN_PERSON), car-capture is penultimate — // expertUploadBlameVideoV3 finalises the blame with the accident video next. - if ((blame as any).isMadeByFileMaker) { + // Advance the workflow step so that if the expert exits and reopens the claim + // the system correctly resumes at upload-video rather than replaying car-capture. + if (!(blame as any).isMadeByFileMaker) { + await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, { + $set: { + "workflow.currentStep": ClaimWorkflowStep.USER_SUBMISSION_COMPLETE, + "workflow.nextStep": undefined, + }, + $push: { + "workflow.completedSteps": ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS, + history: { + type: "STEP_COMPLETED", + actor: { + actorId: new Types.ObjectId(currentUserId), + actorName: claimCase.owner?.fullName || "User", + actorType: "field_expert", + }, + timestamp: new Date(), + metadata: { + stepKey: ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS, + description: + "V3 walk-around video uploaded. Upload blame accident video to finalise.", + v3InPersonFlow: true, + }, + }, + }, + }); + } else if ((blame as any).isMadeByFileMaker) { // Both V4 and V5 land at WAITING_FOR_DAMAGE_EXPERT here. // For V5 (requiresFileMakerApproval=true), autoSubmitToFanavaranV2OnClaimCompleted // intercepts COMPLETED → WAITING_FOR_FILE_MAKER_APPROVAL after expert review. diff --git a/src/request-management/request-management.service.ts b/src/request-management/request-management.service.ts index e17b350..f86865e 100644 --- a/src/request-management/request-management.service.ts +++ b/src/request-management/request-management.service.ts @@ -10049,7 +10049,9 @@ export class RequestManagementService { } if ( claim.workflow?.currentStep !== - ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS + ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS && + claim.workflow?.currentStep !== + ClaimWorkflowStep.USER_SUBMISSION_COMPLETE ) { throw new BadRequestException( "Complete capture-part (parts, angles, and capture-phase documents) before the blame accident video.",