forked from Yara724/api
YARA-1119
This commit is contained in:
@@ -161,6 +161,7 @@ import {
|
|||||||
getClaimCaptureProgress,
|
getClaimCaptureProgress,
|
||||||
isCapturePhaseDamagedPartyDocKey,
|
isCapturePhaseDamagedPartyDocKey,
|
||||||
isClaimCaptureStepComplete,
|
isClaimCaptureStepComplete,
|
||||||
|
OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5,
|
||||||
} from "src/helpers/claim-capture-phase";
|
} from "src/helpers/claim-capture-phase";
|
||||||
import { HttpService } from "@nestjs/axios";
|
import { HttpService } from "@nestjs/axios";
|
||||||
import { firstValueFrom } from "rxjs";
|
import { firstValueFrom } from "rxjs";
|
||||||
@@ -8138,7 +8139,7 @@ export class ClaimRequestManagementService {
|
|||||||
file: Express.Multer.File,
|
file: Express.Multer.File,
|
||||||
currentUserId: string,
|
currentUserId: string,
|
||||||
actor?: { sub: string; role?: string },
|
actor?: { sub: string; role?: string },
|
||||||
options?: { v3InPersonFlow?: boolean },
|
options?: { v3InPersonFlow?: boolean; skipMetalPlate?: boolean },
|
||||||
): Promise<UploadRequiredDocumentV2ResponseDto> {
|
): Promise<UploadRequiredDocumentV2ResponseDto> {
|
||||||
try {
|
try {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
@@ -8315,12 +8316,16 @@ export class ClaimRequestManagementService {
|
|||||||
k === body.documentKey ||
|
k === body.documentKey ||
|
||||||
this.isRequiredDocumentUploadedOnClaim(claimCase, k);
|
this.isRequiredDocumentUploadedOnClaim(claimCase, k);
|
||||||
remaining = CAPTURE_PHASE_DAMAGED_PARTY_DOC_KEYS.filter(
|
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;
|
).length;
|
||||||
|
|
||||||
if (remaining === 0) {
|
if (remaining === 0) {
|
||||||
const progressAfterDoc = getClaimCaptureProgress(claimCase, {
|
const progressAfterDoc = getClaimCaptureProgress(claimCase, {
|
||||||
assumeCapturePhaseDocKey: body.documentKey,
|
assumeCapturePhaseDocKey: body.documentKey,
|
||||||
|
skipMetalPlate: options?.skipMetalPlate,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -10196,9 +10201,10 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
private shapeCaptureRequirementsForV3(
|
private shapeCaptureRequirementsForV3(
|
||||||
claimCase: any,
|
claimCase: any,
|
||||||
_blame: any,
|
blame: any,
|
||||||
base: GetCaptureRequirementsV2ResponseDto,
|
base: GetCaptureRequirementsV2ResponseDto,
|
||||||
): GetCaptureRequirementsV2ResponseDto {
|
): GetCaptureRequirementsV2ResponseDto {
|
||||||
|
const skipMetalPlate = !!(blame as any)?.isMadeByFileMaker;
|
||||||
const step = claimCase.workflow?.currentStep;
|
const step = claimCase.workflow?.currentStep;
|
||||||
const capturePartDone = this.claimV3StepCompleted(
|
const capturePartDone = this.claimV3StepCompleted(
|
||||||
claimCase,
|
claimCase,
|
||||||
@@ -10258,7 +10264,9 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
if (step === ClaimWorkflowStep.CAPTURE_PART_DAMAGES) {
|
if (step === ClaimWorkflowStep.CAPTURE_PART_DAMAGES) {
|
||||||
const capturePhaseDocs = base.requiredDocuments.filter(
|
const capturePhaseDocs = base.requiredDocuments.filter(
|
||||||
(d) => d.preferUploadDuringCapture,
|
(d) =>
|
||||||
|
d.preferUploadDuringCapture &&
|
||||||
|
!(skipMetalPlate && OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5.includes(d.key as any)),
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...base,
|
...base,
|
||||||
@@ -10298,6 +10306,7 @@ export class ClaimRequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const blame = await this.assertV3InPersonClaim(claimCase);
|
const blame = await this.assertV3InPersonClaim(claimCase);
|
||||||
|
const skipMetalPlate = !!(blame as any).isMadeByFileMaker;
|
||||||
|
|
||||||
const isCaptureDoc = isCapturePhaseDamagedPartyDocKey(body.documentKey);
|
const isCaptureDoc = isCapturePhaseDamagedPartyDocKey(body.documentKey);
|
||||||
|
|
||||||
@@ -10306,7 +10315,7 @@ export class ClaimRequestManagementService {
|
|||||||
this.assertV3ClaimWorkflowStep(
|
this.assertV3ClaimWorkflowStep(
|
||||||
claimCase,
|
claimCase,
|
||||||
ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
|
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 (
|
if (
|
||||||
!this.claimV3StepCompleted(
|
!this.claimV3StepCompleted(
|
||||||
@@ -10318,15 +10327,15 @@ export class ClaimRequestManagementService {
|
|||||||
"Complete outer and other part selection before capture-phase vehicle documents.",
|
"Complete outer and other part selection before capture-phase vehicle documents.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const captureProgress = getClaimCaptureProgress(claimCase);
|
const captureProgress = getClaimCaptureProgress(claimCase, { skipMetalPlate });
|
||||||
if (!captureProgress.partsComplete) {
|
if (!captureProgress.partsComplete) {
|
||||||
throw new BadRequestException(
|
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) {
|
if (!captureProgress.anglesComplete) {
|
||||||
throw new BadRequestException(
|
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 {
|
} else {
|
||||||
@@ -10346,7 +10355,7 @@ export class ClaimRequestManagementService {
|
|||||||
file,
|
file,
|
||||||
currentUserId,
|
currentUserId,
|
||||||
actor,
|
actor,
|
||||||
{ v3InPersonFlow: true },
|
{ v3InPersonFlow: true, skipMetalPlate },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ export const CAPTURE_PHASE_DAMAGED_PARTY_DOC_KEYS = [
|
|||||||
"damaged_metal_plate",
|
"damaged_metal_plate",
|
||||||
] as const;
|
] 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 =
|
export type CapturePhaseSequence =
|
||||||
| "parts"
|
| "parts"
|
||||||
| "angles"
|
| "angles"
|
||||||
@@ -52,7 +58,7 @@ function isRequiredDocumentUploadedOnClaim(
|
|||||||
|
|
||||||
export function getClaimCaptureProgress(
|
export function getClaimCaptureProgress(
|
||||||
claimCase: any,
|
claimCase: any,
|
||||||
options?: { assumeCapturePhaseDocKey?: string },
|
options?: { assumeCapturePhaseDocKey?: string; skipMetalPlate?: boolean },
|
||||||
): ClaimCaptureProgress {
|
): ClaimCaptureProgress {
|
||||||
const carType = claimCase?.vehicle?.carType as ClaimVehicleTypeV2 | undefined;
|
const carType = claimCase?.vehicle?.carType as ClaimVehicleTypeV2 | undefined;
|
||||||
const selectedNorm = normalizeDamageSelectedParts(
|
const selectedNorm = normalizeDamageSelectedParts(
|
||||||
@@ -83,6 +89,7 @@ export function getClaimCaptureProgress(
|
|||||||
|
|
||||||
const capturePhaseDocsRemaining = CAPTURE_PHASE_DAMAGED_PARTY_DOC_KEYS.filter(
|
const capturePhaseDocsRemaining = CAPTURE_PHASE_DAMAGED_PARTY_DOC_KEYS.filter(
|
||||||
(k) => {
|
(k) => {
|
||||||
|
if (options?.skipMetalPlate && OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5.includes(k as any)) return false;
|
||||||
if (k === options?.assumeCapturePhaseDocKey) return false;
|
if (k === options?.assumeCapturePhaseDocKey) return false;
|
||||||
return !isRequiredDocumentUploadedOnClaim(claimCase, k);
|
return !isRequiredDocumentUploadedOnClaim(claimCase, k);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user