forked from Yara724/api
YARA-1217
This commit is contained in:
@@ -20,6 +20,8 @@ export enum ClaimRequiredDocumentType {
|
|||||||
GUILTY_CAR_CARD_FRONT = "guilty_car_card_front",
|
GUILTY_CAR_CARD_FRONT = "guilty_car_card_front",
|
||||||
GUILTY_CAR_CARD_BACK = "guilty_car_card_back",
|
GUILTY_CAR_CARD_BACK = "guilty_car_card_back",
|
||||||
GUILTY_METAL_PLATE = "guilty_metal_plate",
|
GUILTY_METAL_PLATE = "guilty_metal_plate",
|
||||||
|
/** V4 FileMaker flow only: one photo of the guilty party's car. */
|
||||||
|
GUILTY_CAR_PHOTO = "guilty_car_photo",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum CarAngle {
|
export enum CarAngle {
|
||||||
|
|||||||
@@ -460,6 +460,7 @@ export class ClaimRequestManagementService {
|
|||||||
isCarBody: boolean,
|
isCarBody: boolean,
|
||||||
assumeUploadedKey?: string,
|
assumeUploadedKey?: string,
|
||||||
skipMetalPlate?: boolean,
|
skipMetalPlate?: boolean,
|
||||||
|
requiresGuiltyCarPhoto?: boolean,
|
||||||
): boolean {
|
): boolean {
|
||||||
for (const k of this.v3PreCaptureDocumentKeys(isCarBody)) {
|
for (const k of this.v3PreCaptureDocumentKeys(isCarBody)) {
|
||||||
if (skipMetalPlate && OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5.includes(k as any)) continue;
|
if (skipMetalPlate && OPTIONAL_CAPTURE_PHASE_DOC_KEYS_V4V5.includes(k as any)) continue;
|
||||||
@@ -477,6 +478,15 @@ export class ClaimRequestManagementService {
|
|||||||
: this.isRequiredDocumentUploadedOnClaim(claimCase, g);
|
: this.isRequiredDocumentUploadedOnClaim(claimCase, g);
|
||||||
if (!ok) return false;
|
if (!ok) return false;
|
||||||
}
|
}
|
||||||
|
// V4 THIRD_PARTY only: require one photo of the guilty party's car.
|
||||||
|
if (requiresGuiltyCarPhoto && !isCarBody) {
|
||||||
|
const k = ClaimRequiredDocumentType.GUILTY_CAR_PHOTO;
|
||||||
|
const ok =
|
||||||
|
k === assumeUploadedKey
|
||||||
|
? true
|
||||||
|
: this.isRequiredDocumentUploadedOnClaim(claimCase, k);
|
||||||
|
if (!ok) return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,6 +495,7 @@ export class ClaimRequestManagementService {
|
|||||||
isCarBody: boolean,
|
isCarBody: boolean,
|
||||||
assumeUploadedKey?: string,
|
assumeUploadedKey?: string,
|
||||||
skipMetalPlate?: boolean,
|
skipMetalPlate?: boolean,
|
||||||
|
requiresGuiltyCarPhoto?: boolean,
|
||||||
): number {
|
): number {
|
||||||
let n = 0;
|
let n = 0;
|
||||||
for (const k of this.v3PreCaptureDocumentKeys(isCarBody)) {
|
for (const k of this.v3PreCaptureDocumentKeys(isCarBody)) {
|
||||||
@@ -503,6 +514,15 @@ export class ClaimRequestManagementService {
|
|||||||
: this.isRequiredDocumentUploadedOnClaim(claimCase, g);
|
: this.isRequiredDocumentUploadedOnClaim(claimCase, g);
|
||||||
if (!ok) n++;
|
if (!ok) n++;
|
||||||
}
|
}
|
||||||
|
// V4 THIRD_PARTY only: one photo of the guilty party's car.
|
||||||
|
if (requiresGuiltyCarPhoto && !isCarBody) {
|
||||||
|
const k = ClaimRequiredDocumentType.GUILTY_CAR_PHOTO;
|
||||||
|
const ok =
|
||||||
|
k === assumeUploadedKey
|
||||||
|
? true
|
||||||
|
: this.isRequiredDocumentUploadedOnClaim(claimCase, k);
|
||||||
|
if (!ok) n++;
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9073,7 +9093,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; skipMetalPlate?: boolean; requiresFileMakerApproval?: boolean },
|
options?: { v3InPersonFlow?: boolean; skipMetalPlate?: boolean; requiresFileMakerApproval?: boolean; requiresGuiltyCarPhoto?: boolean },
|
||||||
): Promise<UploadRequiredDocumentV2ResponseDto> {
|
): Promise<UploadRequiredDocumentV2ResponseDto> {
|
||||||
try {
|
try {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
@@ -9306,6 +9326,7 @@ export class ClaimRequestManagementService {
|
|||||||
isCarBodyUpload,
|
isCarBodyUpload,
|
||||||
body.documentKey,
|
body.documentKey,
|
||||||
options?.skipMetalPlate,
|
options?.skipMetalPlate,
|
||||||
|
options?.requiresGuiltyCarPhoto,
|
||||||
);
|
);
|
||||||
|
|
||||||
allDocumentsUploaded = options?.v3InPersonFlow
|
allDocumentsUploaded = options?.v3InPersonFlow
|
||||||
@@ -9321,6 +9342,7 @@ export class ClaimRequestManagementService {
|
|||||||
isCarBodyUpload,
|
isCarBodyUpload,
|
||||||
body.documentKey,
|
body.documentKey,
|
||||||
options?.skipMetalPlate,
|
options?.skipMetalPlate,
|
||||||
|
options?.requiresGuiltyCarPhoto,
|
||||||
)
|
)
|
||||||
: this.countRemainingV2OwnerDocuments(
|
: this.countRemainingV2OwnerDocuments(
|
||||||
claimCase,
|
claimCase,
|
||||||
@@ -9417,10 +9439,14 @@ export class ClaimRequestManagementService {
|
|||||||
: null;
|
: null;
|
||||||
const isCarBodyRecheck = blameForRecheck?.type === BlameRequestType.CAR_BODY;
|
const isCarBodyRecheck = blameForRecheck?.type === BlameRequestType.CAR_BODY;
|
||||||
const skipMetalPlateRecheck = !!(blameForRecheck as any)?.isMadeByFileMaker;
|
const skipMetalPlateRecheck = !!(blameForRecheck as any)?.isMadeByFileMaker;
|
||||||
|
// V4 = isMadeByFileMaker + requiresFileMakerApproval is false on the claim.
|
||||||
|
const requiresGuiltyCarPhotoRecheck =
|
||||||
|
!!(blameForRecheck as any)?.isMadeByFileMaker &&
|
||||||
|
!(afterWrite as any).requiresFileMakerApproval;
|
||||||
const allDoneNow =
|
const allDoneNow =
|
||||||
afterWrite.status === ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS &&
|
afterWrite.status === ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS &&
|
||||||
afterWrite.workflow?.currentStep === ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS &&
|
afterWrite.workflow?.currentStep === ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS &&
|
||||||
this.allV3PreCaptureDocumentsComplete(afterWrite, isCarBodyRecheck, undefined, skipMetalPlateRecheck);
|
this.allV3PreCaptureDocumentsComplete(afterWrite, isCarBodyRecheck, undefined, skipMetalPlateRecheck, requiresGuiltyCarPhotoRecheck);
|
||||||
|
|
||||||
if (allDoneNow) {
|
if (allDoneNow) {
|
||||||
// Atomic conditional update: only succeeds when status is still
|
// Atomic conditional update: only succeeds when status is still
|
||||||
@@ -11253,6 +11279,37 @@ export class ClaimRequestManagementService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// V4 only (isMadeByFileMaker + NOT requiresFileMakerApproval) and THIRD_PARTY:
|
||||||
|
// inject one photo of the guilty party's car into the pre-capture document list.
|
||||||
|
const isV4 =
|
||||||
|
!!(blame as any)?.isMadeByFileMaker &&
|
||||||
|
!(claimCase as any)?.requiresFileMakerApproval;
|
||||||
|
const isCarBodyBlame = blame?.type === BlameRequestType.CAR_BODY || (blame as any)?.type === "CAR_BODY";
|
||||||
|
if (isV4 && !isCarBodyBlame) {
|
||||||
|
const guiltyCarPhotoKey = ClaimRequiredDocumentType.GUILTY_CAR_PHOTO;
|
||||||
|
const alreadyPresent = base.requiredDocuments.some(
|
||||||
|
(d) => d.key === guiltyCarPhotoKey,
|
||||||
|
);
|
||||||
|
if (!alreadyPresent) {
|
||||||
|
const docData = (claimCase.requiredDocuments as any)?.get?.(guiltyCarPhotoKey)
|
||||||
|
?? (claimCase.requiredDocuments as any)?.[guiltyCarPhotoKey];
|
||||||
|
base = {
|
||||||
|
...base,
|
||||||
|
requiredDocuments: [
|
||||||
|
...base.requiredDocuments,
|
||||||
|
{
|
||||||
|
key: guiltyCarPhotoKey,
|
||||||
|
label_fa: "عکس خودرو مقصر",
|
||||||
|
label_en: "Guilty Party Car Photo",
|
||||||
|
category: "guilty_party",
|
||||||
|
uploaded: !!docData?.uploaded,
|
||||||
|
preferUploadDuringCapture: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const step = claimCase.workflow?.currentStep;
|
const step = claimCase.workflow?.currentStep;
|
||||||
const capturePartDone = this.claimV3StepCompleted(
|
const capturePartDone = this.claimV3StepCompleted(
|
||||||
claimCase,
|
claimCase,
|
||||||
@@ -11397,13 +11454,23 @@ export class ClaimRequestManagementService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// V4 = isMadeByFileMaker + requiresFileMakerApproval is false.
|
||||||
|
const requiresGuiltyCarPhoto =
|
||||||
|
!!(blame as any).isMadeByFileMaker &&
|
||||||
|
!(claimCase as any).requiresFileMakerApproval;
|
||||||
|
|
||||||
return this.uploadRequiredDocumentV2(
|
return this.uploadRequiredDocumentV2(
|
||||||
claimRequestId,
|
claimRequestId,
|
||||||
body,
|
body,
|
||||||
file,
|
file,
|
||||||
currentUserId,
|
currentUserId,
|
||||||
actor,
|
actor,
|
||||||
{ v3InPersonFlow: true, skipMetalPlate, requiresFileMakerApproval: !!(claimCase as any).requiresFileMakerApproval },
|
{
|
||||||
|
v3InPersonFlow: true,
|
||||||
|
skipMetalPlate,
|
||||||
|
requiresFileMakerApproval: !!(claimCase as any).requiresFileMakerApproval,
|
||||||
|
requiresGuiltyCarPhoto,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user