From 4aa6e03afb86c821188ebfb9b1f418903f80e7ec Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Tue, 14 Jul 2026 11:32:03 +0330 Subject: [PATCH] YARA-1119 --- .../claim-request-management.service.ts | 27 ++++++++++++------- src/helpers/claim-capture-phase.ts | 9 ++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/claim-request-management/claim-request-management.service.ts b/src/claim-request-management/claim-request-management.service.ts index cec1b6a..4df7092 100644 --- a/src/claim-request-management/claim-request-management.service.ts +++ b/src/claim-request-management/claim-request-management.service.ts @@ -161,6 +161,7 @@ import { getClaimCaptureProgress, isCapturePhaseDamagedPartyDocKey, isClaimCaptureStepComplete, + OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5, } from "src/helpers/claim-capture-phase"; import { HttpService } from "@nestjs/axios"; import { firstValueFrom } from "rxjs"; @@ -8138,7 +8139,7 @@ export class ClaimRequestManagementService { file: Express.Multer.File, currentUserId: string, actor?: { sub: string; role?: string }, - options?: { v3InPersonFlow?: boolean }, + options?: { v3InPersonFlow?: boolean; skipMetalPlate?: boolean }, ): Promise { try { const claimCase = await this.claimCaseDbService.findById(claimRequestId); @@ -8315,12 +8316,16 @@ export class ClaimRequestManagementService { k === body.documentKey || this.isRequiredDocumentUploadedOnClaim(claimCase, k); remaining = CAPTURE_PHASE_DAMAGED_PARTY_DOC_KEYS.filter( - (k) => !afterThis(k), + (k) => { + if (options?.skipMetalPlate && OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5.includes(k as any)) return false; + return !afterThis(k); + }, ).length; if (remaining === 0) { const progressAfterDoc = getClaimCaptureProgress(claimCase, { assumeCapturePhaseDocKey: body.documentKey, + skipMetalPlate: options?.skipMetalPlate, }); if ( @@ -10196,9 +10201,10 @@ export class ClaimRequestManagementService { private shapeCaptureRequirementsForV3( claimCase: any, - _blame: any, + blame: any, base: GetCaptureRequirementsV2ResponseDto, ): GetCaptureRequirementsV2ResponseDto { + const skipMetalPlate = !!(blame as any)?.isMadeByFileMaker; const step = claimCase.workflow?.currentStep; const capturePartDone = this.claimV3StepCompleted( claimCase, @@ -10258,7 +10264,9 @@ export class ClaimRequestManagementService { if (step === ClaimWorkflowStep.CAPTURE_PART_DAMAGES) { const capturePhaseDocs = base.requiredDocuments.filter( - (d) => d.preferUploadDuringCapture, + (d) => + d.preferUploadDuringCapture && + !(skipMetalPlate && OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5.includes(d.key as any)), ); return { ...base, @@ -10298,6 +10306,7 @@ export class ClaimRequestManagementService { ); } const blame = await this.assertV3InPersonClaim(claimCase); + const skipMetalPlate = !!(blame as any).isMadeByFileMaker; const isCaptureDoc = isCapturePhaseDamagedPartyDocKey(body.documentKey); @@ -10306,7 +10315,7 @@ export class ClaimRequestManagementService { this.assertV3ClaimWorkflowStep( claimCase, ClaimWorkflowStep.CAPTURE_PART_DAMAGES, - "Upload chassis, engine, and metal plate photos during capture after damaged-part photos and car angles.", + "Upload chassis and engine photos during capture after damaged-part photos and car angles.", ); if ( !this.claimV3StepCompleted( @@ -10318,15 +10327,15 @@ export class ClaimRequestManagementService { "Complete outer and other part selection before capture-phase vehicle documents.", ); } - const captureProgress = getClaimCaptureProgress(claimCase); + const captureProgress = getClaimCaptureProgress(claimCase, { skipMetalPlate }); if (!captureProgress.partsComplete) { throw new BadRequestException( - "Upload photos for all selected damaged parts before chassis, engine, or metal plate photos.", + "Upload photos for all selected damaged parts before chassis or engine photos.", ); } if (!captureProgress.anglesComplete) { throw new BadRequestException( - "Capture all four car angles before chassis, engine, or metal plate photos.", + "Capture all four car angles before chassis or engine photos.", ); } } else { @@ -10346,7 +10355,7 @@ export class ClaimRequestManagementService { file, currentUserId, actor, - { v3InPersonFlow: true }, + { v3InPersonFlow: true, skipMetalPlate }, ); } diff --git a/src/helpers/claim-capture-phase.ts b/src/helpers/claim-capture-phase.ts index 1c458f8..5f30598 100644 --- a/src/helpers/claim-capture-phase.ts +++ b/src/helpers/claim-capture-phase.ts @@ -16,6 +16,12 @@ export const CAPTURE_PHASE_DAMAGED_PARTY_DOC_KEYS = [ "damaged_metal_plate", ] as const; +/** Metal-plate keys that are optional in the V4/V5 FileMaker flow. */ +export const OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5 = [ + "damaged_metal_plate", + "guilty_metal_plate", +] as const; + export type CapturePhaseSequence = | "parts" | "angles" @@ -52,7 +58,7 @@ function isRequiredDocumentUploadedOnClaim( export function getClaimCaptureProgress( claimCase: any, - options?: { assumeCapturePhaseDocKey?: string }, + options?: { assumeCapturePhaseDocKey?: string; skipMetalPlate?: boolean }, ): ClaimCaptureProgress { const carType = claimCase?.vehicle?.carType as ClaimVehicleTypeV2 | undefined; const selectedNorm = normalizeDamageSelectedParts( @@ -83,6 +89,7 @@ export function getClaimCaptureProgress( const capturePhaseDocsRemaining = CAPTURE_PHASE_DAMAGED_PARTY_DOC_KEYS.filter( (k) => { + if (options?.skipMetalPlate && OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5.includes(k as any)) return false; if (k === options?.assumeCapturePhaseDocKey) return false; return !isRequiredDocumentUploadedOnClaim(claimCase, k); },