From 385757c3a0f394d526328da70564d802ed00b972 Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Tue, 14 Jul 2026 14:30:41 +0330 Subject: [PATCH] Fixed file maker retrieving files --- src/expert-claim/dto/claim-detail-v2.dto.ts | 7 +++++++ src/expert-claim/dto/claim-list-v2.dto.ts | 7 +++++++ src/expert-claim/expert-claim.service.ts | 2 ++ .../request-management.service.ts | 19 +++++++++++-------- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/expert-claim/dto/claim-detail-v2.dto.ts b/src/expert-claim/dto/claim-detail-v2.dto.ts index c6b0e59..83e8cf2 100644 --- a/src/expert-claim/dto/claim-detail-v2.dto.ts +++ b/src/expert-claim/dto/claim-detail-v2.dto.ts @@ -131,6 +131,13 @@ export class ClaimDetailV2ResponseDto { }) awaitingFactorValidation?: boolean; + @ApiPropertyOptional({ + description: + "True for V5 files — the FileMaker must approve or reject the claim before it is submitted to fanavaran. False (or absent) for V4 files which go straight through.", + example: true, + }) + requiresFileMakerApproval?: boolean; + @ApiPropertyOptional({ description: "Slice of `claim.evaluation` exposed to the damage expert. " + diff --git a/src/expert-claim/dto/claim-list-v2.dto.ts b/src/expert-claim/dto/claim-list-v2.dto.ts index a64a109..2c34c68 100644 --- a/src/expert-claim/dto/claim-list-v2.dto.ts +++ b/src/expert-claim/dto/claim-list-v2.dto.ts @@ -70,6 +70,13 @@ export class ClaimListItemV2Dto { "True in the expert repair-factor validation queue: `status=EXPERT_VALIDATING_REPAIR_FACTORS` (or legacy `WAITING_FOR_INSURER_APPROVAL`) with `claimStatus=UNDER_REVIEW` and `currentStep=EXPERT_COST_EVALUATION`.", }) awaitingFactorValidation?: boolean; + + @ApiPropertyOptional({ + description: + "True for V5 files — the FileMaker must approve or reject the claim before it is submitted to fanavaran. False (or absent) for V4 files which go straight through.", + example: true, + }) + requiresFileMakerApproval?: boolean; } export class GetClaimListV2ResponseDto { diff --git a/src/expert-claim/expert-claim.service.ts b/src/expert-claim/expert-claim.service.ts index 7542d8c..5fde6c9 100644 --- a/src/expert-claim/expert-claim.service.ts +++ b/src/expert-claim/expert-claim.service.ts @@ -4309,6 +4309,7 @@ export class ExpertClaimService { blameRequestId: c.blameRequestId?.toString(), createdAt: c.createdAt, awaitingFactorValidation: claimIsAwaitingExpertFactorValidationV2(c), + requiresFileMakerApproval: !!(c as any).requiresFileMakerApproval, needsFileReviewerCompletion: String(blame?.status ?? "") === "WAITING_FOR_FILE_REVIEWER" || (!!blame?.isMadeByFileMaker && @@ -5039,6 +5040,7 @@ export class ExpertClaimService { carAngles, damagedParts, awaitingFactorValidation: isFactorValidationPending, + requiresFileMakerApproval: !!(claim as any).requiresFileMakerApproval, evaluation: (evaluationForApi as | ClaimDetailV2ResponseDto["evaluation"] diff --git a/src/request-management/request-management.service.ts b/src/request-management/request-management.service.ts index 68ba407..5efef3c 100644 --- a/src/request-management/request-management.service.ts +++ b/src/request-management/request-management.service.ts @@ -8814,6 +8814,14 @@ export class RequestManagementService { }, } : {}), + // V5 (isMadeByFileMaker): mark approval gate at claim creation so the flag + // is always present regardless of whether upload-video is called. + ...((req as any).isMadeByFileMaker + ? { + requiresFileMakerApproval: true, + fileMakerApprovalActorId: new Types.ObjectId(actor.sub), + } + : {}), history: [ { type: "CLAIM_CREATED", @@ -9816,19 +9824,15 @@ export class RequestManagementService { } await (req as any).save(); - // Advance the claim into the damage-expert queue AND mark FileMaker approval - // required before fanavaran submission. - const fileMakerActorId = req.initiatedByFieldExpertId ?? null; + // Advance the claim into the damage-expert queue. + // requiresFileMakerApproval / fileMakerApprovalActorId were already set at + // claim creation time (createV3ClaimFromBlame) so no need to repeat here. await this.claimCaseDbService.findByIdAndUpdate(String(claim._id), { $set: { status: ClaimCaseStatus.WAITING_FOR_DAMAGE_EXPERT, claimStatus: ClaimStatus.PENDING, "workflow.currentStep": ClaimWorkflowStep.USER_SUBMISSION_COMPLETE, "workflow.nextStep": ClaimWorkflowStep.EXPERT_DAMAGE_ASSESSMENT, - requiresFileMakerApproval: true, - ...(fileMakerActorId - ? { fileMakerApprovalActorId: new Types.ObjectId(String(fileMakerActorId)) } - : {}), }, $push: { "workflow.completedSteps": ClaimWorkflowStep.USER_SUBMISSION_COMPLETE, @@ -9845,7 +9849,6 @@ export class RequestManagementService { description: "V5 field workflow complete. Claim ready for damage expert review (FileMaker approval required before fanavaran).", v5InPersonFlow: true, - fileMakerActorId: fileMakerActorId ? String(fileMakerActorId) : null, }, }, },