forked from Yara724/api
Merge pull request 'Fix CAR_GREEN_CARD place to upload for v3' (#159) from s.yahyaee/yara724-api:main into main
Reviewed-on: Yara724/api#159
This commit is contained in:
@@ -3411,8 +3411,7 @@ export class ClaimRequestManagementService {
|
|||||||
CulpritTypeId: number;
|
CulpritTypeId: number;
|
||||||
};
|
};
|
||||||
}): Promise<Record<string, unknown>> {
|
}): Promise<Record<string, unknown>> {
|
||||||
const lookupDefaults =
|
const lookupDefaults = input.defaults ?? this.TEJARATNO_FANAVARAN_DEFAULTS;
|
||||||
input.defaults ?? this.TEJARATNO_FANAVARAN_DEFAULTS;
|
|
||||||
const result: Record<string, unknown> = {
|
const result: Record<string, unknown> = {
|
||||||
...lookupDefaults,
|
...lookupDefaults,
|
||||||
AccidentCauseId: FANAVARAN_DEFAULT_ACCIDENT_CAUSE_ID,
|
AccidentCauseId: FANAVARAN_DEFAULT_ACCIDENT_CAUSE_ID,
|
||||||
@@ -3844,7 +3843,11 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const appToken = await this.getAppToken(config, auditSession);
|
const appToken = await this.getAppToken(config, auditSession);
|
||||||
const authenticationToken = await this.login(appToken, config, auditSession);
|
const authenticationToken = await this.login(
|
||||||
|
appToken,
|
||||||
|
config,
|
||||||
|
auditSession,
|
||||||
|
);
|
||||||
|
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
`${logPrefix} Calling policy inquiry API for nationalCode: ${nationalCodeOfInsurer}`,
|
`${logPrefix} Calling policy inquiry API for nationalCode: ${nationalCodeOfInsurer}`,
|
||||||
@@ -3866,7 +3869,8 @@ export class ClaimRequestManagementService {
|
|||||||
const policyCount = Array.isArray(response.data)
|
const policyCount = Array.isArray(response.data)
|
||||||
? response.data.length
|
? response.data.length
|
||||||
: 0;
|
: 0;
|
||||||
const lastPolicy = policyCount > 0 ? response.data[policyCount - 1] : null;
|
const lastPolicy =
|
||||||
|
policyCount > 0 ? response.data[policyCount - 1] : null;
|
||||||
|
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
`${logPrefix} Policy inquiry response status=${response.status} count=${policyCount}`,
|
`${logPrefix} Policy inquiry response status=${response.status} count=${policyCount}`,
|
||||||
@@ -3920,7 +3924,9 @@ export class ClaimRequestManagementService {
|
|||||||
httpStatus: response.status,
|
httpStatus: response.status,
|
||||||
responseMeta: {
|
responseMeta: {
|
||||||
policyId: null,
|
policyId: null,
|
||||||
policyCount: Array.isArray(response.data) ? response.data.length : 0,
|
policyCount: Array.isArray(response.data)
|
||||||
|
? response.data.length
|
||||||
|
: 0,
|
||||||
},
|
},
|
||||||
durationMs: Date.now() - startedAt,
|
durationMs: Date.now() - startedAt,
|
||||||
});
|
});
|
||||||
@@ -4234,7 +4240,10 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(`Error in previewFanavaranSubmitV2 (${clientKey})`, error);
|
this.logger.error(
|
||||||
|
`Error in previewFanavaranSubmitV2 (${clientKey})`,
|
||||||
|
error,
|
||||||
|
);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4986,9 +4995,7 @@ export class ClaimRequestManagementService {
|
|||||||
const parties: any[] = claim?.snapshot?.parties ?? [];
|
const parties: any[] = claim?.snapshot?.parties ?? [];
|
||||||
if (!parties.length) return false;
|
if (!parties.length) return false;
|
||||||
|
|
||||||
const ownerIdStr = claim?.owner?.userId
|
const ownerIdStr = claim?.owner?.userId ? String(claim.owner.userId) : null;
|
||||||
? String(claim.owner.userId)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
for (const party of parties) {
|
for (const party of parties) {
|
||||||
const partyUserId = party?.person?.userId;
|
const partyUserId = party?.person?.userId;
|
||||||
@@ -5012,10 +5019,10 @@ export class ClaimRequestManagementService {
|
|||||||
actor?: { username?: string },
|
actor?: { username?: string },
|
||||||
message = "Only the damaged party can perform this action on the claim",
|
message = "Only the damaged party can perform this action on the claim",
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const linkedUserIds = await resolveLinkedUserIdStrings(
|
const linkedUserIds = await resolveLinkedUserIdStrings(this.userDbService, {
|
||||||
this.userDbService,
|
sub: effectiveUserId,
|
||||||
{ sub: effectiveUserId, username: actor?.username },
|
username: actor?.username,
|
||||||
);
|
});
|
||||||
const actorCtx = { sub: effectiveUserId, username: actor?.username };
|
const actorCtx = { sub: effectiveUserId, username: actor?.username };
|
||||||
|
|
||||||
// 0. damagedPartyUserId stored directly on the claim (fastest, most reliable)
|
// 0. damagedPartyUserId stored directly on the claim (fastest, most reliable)
|
||||||
@@ -5044,7 +5051,9 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
// 3. Snapshot-party fallback: claim.snapshot.parties is written at creation
|
// 3. Snapshot-party fallback: claim.snapshot.parties is written at creation
|
||||||
// and is reliable even when blame lookup fails or userId mapping differs.
|
// and is reliable even when blame lookup fails or userId mapping differs.
|
||||||
if (this.claimSnapshotPartyMatchesAsDamagedParty(claimCase, linkedUserIds)) {
|
if (
|
||||||
|
this.claimSnapshotPartyMatchesAsDamagedParty(claimCase, linkedUserIds)
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5056,10 +5065,10 @@ export class ClaimRequestManagementService {
|
|||||||
currentUserId: string,
|
currentUserId: string,
|
||||||
actor?: { sub: string; role?: string; username?: string },
|
actor?: { sub: string; role?: string; username?: string },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const linkedUserIds = await resolveLinkedUserIdStrings(
|
const linkedUserIds = await resolveLinkedUserIdStrings(this.userDbService, {
|
||||||
this.userDbService,
|
sub: currentUserId,
|
||||||
{ sub: currentUserId, username: actor?.username },
|
username: actor?.username,
|
||||||
);
|
});
|
||||||
|
|
||||||
if (ownerUserIdMatchesActor(claim.owner?.userId, linkedUserIds)) {
|
if (ownerUserIdMatchesActor(claim.owner?.userId, linkedUserIds)) {
|
||||||
return;
|
return;
|
||||||
@@ -5898,6 +5907,12 @@ export class ClaimRequestManagementService {
|
|||||||
label_en: "Damaged Metal Plate",
|
label_en: "Damaged Metal Plate",
|
||||||
category: "damaged_party",
|
category: "damaged_party",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "car_green_card",
|
||||||
|
label_fa: "کارت سبز خودرو",
|
||||||
|
label_en: "Car Green Card",
|
||||||
|
category: "damaged_party",
|
||||||
|
},
|
||||||
...(isCarBody
|
...(isCarBody
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
@@ -6436,8 +6451,7 @@ export class ClaimRequestManagementService {
|
|||||||
$set["status"] = ClaimCaseStatus.SELECTING_OUTER_PARTS;
|
$set["status"] = ClaimCaseStatus.SELECTING_OUTER_PARTS;
|
||||||
$set["workflow.currentStep"] =
|
$set["workflow.currentStep"] =
|
||||||
ClaimWorkflowStep.SELECT_OUTER_PARTS;
|
ClaimWorkflowStep.SELECT_OUTER_PARTS;
|
||||||
$set["workflow.nextStep"] =
|
$set["workflow.nextStep"] = ClaimWorkflowStep.SELECT_OTHER_PARTS;
|
||||||
ClaimWorkflowStep.SELECT_OTHER_PARTS;
|
|
||||||
|
|
||||||
completedStepsEntries.push(
|
completedStepsEntries.push(
|
||||||
ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS,
|
ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS,
|
||||||
@@ -7588,8 +7602,7 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
let message = "Your signature has been recorded. The claim is completed.";
|
let message = "Your signature has been recorded. The claim is completed.";
|
||||||
if (fanavaran.submitted) {
|
if (fanavaran.submitted) {
|
||||||
message +=
|
message += " The claim was sent to Fanavaran successfully.";
|
||||||
" The claim was sent to Fanavaran successfully.";
|
|
||||||
} else if (fanavaran.warning) {
|
} else if (fanavaran.warning) {
|
||||||
message += ` ${fanavaran.warning}`;
|
message += ` ${fanavaran.warning}`;
|
||||||
}
|
}
|
||||||
@@ -7698,8 +7711,12 @@ export class ClaimRequestManagementService {
|
|||||||
? { "snapshot.parties.person.userId": { $in: idVariants } }
|
? { "snapshot.parties.person.userId": { $in: idVariants } }
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const [ownerClaims, damagedDirectClaims, snapshotClaims, candidateBlames] =
|
const [
|
||||||
await Promise.all([
|
ownerClaims,
|
||||||
|
damagedDirectClaims,
|
||||||
|
snapshotClaims,
|
||||||
|
candidateBlames,
|
||||||
|
] = await Promise.all([
|
||||||
ownerOr
|
ownerOr
|
||||||
? this.claimCaseDbService.find(ownerOr as any, { lean: true })
|
? this.claimCaseDbService.find(ownerOr as any, { lean: true })
|
||||||
: Promise.resolve([]),
|
: Promise.resolve([]),
|
||||||
@@ -8033,7 +8050,10 @@ export class ClaimRequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private hasPartyInquiriesOnBlame(blame: any, role: "FIRST" | "SECOND"): boolean {
|
private hasPartyInquiriesOnBlame(
|
||||||
|
blame: any,
|
||||||
|
role: "FIRST" | "SECOND",
|
||||||
|
): boolean {
|
||||||
const step =
|
const step =
|
||||||
role === "FIRST"
|
role === "FIRST"
|
||||||
? WorkflowStep.FIRST_INITIAL_FORM
|
? WorkflowStep.FIRST_INITIAL_FORM
|
||||||
@@ -8129,7 +8149,9 @@ export class ClaimRequestManagementService {
|
|||||||
claimCase: any,
|
claimCase: any,
|
||||||
blame: any,
|
blame: any,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (claimCase.workflow?.currentStep === ClaimWorkflowStep.SELECT_OUTER_PARTS) {
|
if (
|
||||||
|
claimCase.workflow?.currentStep === ClaimWorkflowStep.SELECT_OUTER_PARTS
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8165,13 +8187,19 @@ export class ClaimRequestManagementService {
|
|||||||
private async assertV3InPersonClaim(claimCase: any) {
|
private async assertV3InPersonClaim(claimCase: any) {
|
||||||
const blame = await this.loadBlameForV3Claim(claimCase);
|
const blame = await this.loadBlameForV3Claim(claimCase);
|
||||||
if (!blame) {
|
if (!blame) {
|
||||||
throw new BadRequestException("V3 claim flow requires a linked blame file.");
|
throw new BadRequestException(
|
||||||
|
"V3 claim flow requires a linked blame file.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (blame.creationMethod !== CreationMethod.IN_PERSON) {
|
if (blame.creationMethod !== CreationMethod.IN_PERSON) {
|
||||||
throw new BadRequestException("V3 claim flow is only for IN_PERSON blame files.");
|
throw new BadRequestException(
|
||||||
|
"V3 claim flow is only for IN_PERSON blame files.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!blame.expertInitiated) {
|
if (!blame.expertInitiated) {
|
||||||
throw new BadRequestException("V3 claim flow requires an expert-initiated blame file.");
|
throw new BadRequestException(
|
||||||
|
"V3 claim flow requires an expert-initiated blame file.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return blame;
|
return blame;
|
||||||
}
|
}
|
||||||
@@ -8200,9 +8228,7 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
if (this.isV3InitialDocumentsPhase(claimCase)) {
|
if (this.isV3InitialDocumentsPhase(claimCase)) {
|
||||||
const preCaptureDocs = base.requiredDocuments.filter(
|
const preCaptureDocs = base.requiredDocuments.filter(
|
||||||
(d) =>
|
(d) => !d.preferUploadDuringCapture,
|
||||||
!d.preferUploadDuringCapture &&
|
|
||||||
d.key !== ClaimRequiredDocumentType.CAR_GREEN_CARD,
|
|
||||||
);
|
);
|
||||||
const remaining = preCaptureDocs.filter((d) => !d.uploaded).length;
|
const remaining = preCaptureDocs.filter((d) => !d.uploaded).length;
|
||||||
return {
|
return {
|
||||||
@@ -8288,15 +8314,11 @@ export class ClaimRequestManagementService {
|
|||||||
): Promise<UploadRequiredDocumentV2ResponseDto> {
|
): Promise<UploadRequiredDocumentV2ResponseDto> {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
if (!claimCase) {
|
if (!claimCase) {
|
||||||
throw new NotFoundException(`Claim case with ID ${claimRequestId} not found`);
|
throw new NotFoundException(
|
||||||
}
|
`Claim case with ID ${claimRequestId} not found`,
|
||||||
const blame = await this.assertV3InPersonClaim(claimCase);
|
|
||||||
|
|
||||||
if (body.documentKey === ClaimRequiredDocumentType.CAR_GREEN_CARD) {
|
|
||||||
throw new BadRequestException(
|
|
||||||
"Car green card must be uploaded during other-parts selection, not here.",
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const blame = await this.assertV3InPersonClaim(claimCase);
|
||||||
|
|
||||||
const isCaptureDoc = isCapturePhaseDamagedPartyDocKey(body.documentKey);
|
const isCaptureDoc = isCapturePhaseDamagedPartyDocKey(body.documentKey);
|
||||||
|
|
||||||
@@ -8308,7 +8330,10 @@ export class ClaimRequestManagementService {
|
|||||||
"Upload chassis, engine, and metal plate photos during capture after damaged-part photos and car angles.",
|
"Upload chassis, engine, and metal plate photos during capture after damaged-part photos and car angles.",
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
!this.claimV3StepCompleted(claimCase, ClaimWorkflowStep.SELECT_OTHER_PARTS)
|
!this.claimV3StepCompleted(
|
||||||
|
claimCase,
|
||||||
|
ClaimWorkflowStep.SELECT_OTHER_PARTS,
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"Complete outer and other part selection before capture-phase vehicle documents.",
|
"Complete outer and other part selection before capture-phase vehicle documents.",
|
||||||
@@ -8351,7 +8376,9 @@ export class ClaimRequestManagementService {
|
|||||||
): Promise<GetCaptureRequirementsV2ResponseDto> {
|
): Promise<GetCaptureRequirementsV2ResponseDto> {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
if (!claimCase) {
|
if (!claimCase) {
|
||||||
throw new NotFoundException(`Claim case with ID ${claimRequestId} not found`);
|
throw new NotFoundException(
|
||||||
|
`Claim case with ID ${claimRequestId} not found`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const blame = await this.assertV3InPersonClaim(claimCase);
|
const blame = await this.assertV3InPersonClaim(claimCase);
|
||||||
|
|
||||||
@@ -8379,7 +8406,9 @@ export class ClaimRequestManagementService {
|
|||||||
): Promise<SelectOuterPartsV2ResponseDto> {
|
): Promise<SelectOuterPartsV2ResponseDto> {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
if (!claimCase) {
|
if (!claimCase) {
|
||||||
throw new NotFoundException(`Claim case with ID ${claimRequestId} not found`);
|
throw new NotFoundException(
|
||||||
|
`Claim case with ID ${claimRequestId} not found`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const blame = await this.assertV3InPersonClaim(claimCase);
|
const blame = await this.assertV3InPersonClaim(claimCase);
|
||||||
this.assertV3ClaimPartsPhase(blame);
|
this.assertV3ClaimPartsPhase(blame);
|
||||||
@@ -8400,11 +8429,12 @@ export class ClaimRequestManagementService {
|
|||||||
body: SelectOtherPartsV3Dto,
|
body: SelectOtherPartsV3Dto,
|
||||||
currentUserId: string,
|
currentUserId: string,
|
||||||
actor?: { sub: string; role?: string },
|
actor?: { sub: string; role?: string },
|
||||||
file?: Express.Multer.File,
|
|
||||||
): Promise<SelectOtherPartsV2ResponseDto> {
|
): Promise<SelectOtherPartsV2ResponseDto> {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
if (!claimCase) {
|
if (!claimCase) {
|
||||||
throw new NotFoundException(`Claim case with ID ${claimRequestId} not found`);
|
throw new NotFoundException(
|
||||||
|
`Claim case with ID ${claimRequestId} not found`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const blame = await this.assertV3InPersonClaim(claimCase);
|
const blame = await this.assertV3InPersonClaim(claimCase);
|
||||||
this.assertV3ClaimPartsPhase(blame);
|
this.assertV3ClaimPartsPhase(blame);
|
||||||
@@ -8413,7 +8443,12 @@ export class ClaimRequestManagementService {
|
|||||||
ClaimWorkflowStep.SELECT_OTHER_PARTS,
|
ClaimWorkflowStep.SELECT_OTHER_PARTS,
|
||||||
"Select outer parts before other parts.",
|
"Select outer parts before other parts.",
|
||||||
);
|
);
|
||||||
if (!this.claimV3StepCompleted(claimCase, ClaimWorkflowStep.SELECT_OUTER_PARTS)) {
|
if (
|
||||||
|
!this.claimV3StepCompleted(
|
||||||
|
claimCase,
|
||||||
|
ClaimWorkflowStep.SELECT_OUTER_PARTS,
|
||||||
|
)
|
||||||
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"Complete outer part selection before selecting other parts.",
|
"Complete outer part selection before selecting other parts.",
|
||||||
);
|
);
|
||||||
@@ -8454,7 +8489,8 @@ export class ClaimRequestManagementService {
|
|||||||
actor: {
|
actor: {
|
||||||
actorId: new Types.ObjectId(currentUserId),
|
actorId: new Types.ObjectId(currentUserId),
|
||||||
actorName: claimCase.owner?.fullName || "Actor",
|
actorName: claimCase.owner?.fullName || "Actor",
|
||||||
actorType: actor?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
actorType:
|
||||||
|
actor?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
||||||
},
|
},
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -8466,23 +8502,6 @@ export class ClaimRequestManagementService {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (file) {
|
|
||||||
const docRef = await this.claimRequiredDocumentDbService.create({
|
|
||||||
path: file.path,
|
|
||||||
fileName: file.filename,
|
|
||||||
claimId: new Types.ObjectId(claimRequestId),
|
|
||||||
documentType: ClaimRequiredDocumentType.CAR_GREEN_CARD,
|
|
||||||
uploadedAt: new Date(),
|
|
||||||
});
|
|
||||||
updatePayload[`requiredDocuments.${ClaimRequiredDocumentType.CAR_GREEN_CARD}`] = {
|
|
||||||
fileId: docRef._id,
|
|
||||||
filePath: file.path,
|
|
||||||
fileName: file.filename,
|
|
||||||
uploaded: true,
|
|
||||||
uploadedAt: new Date(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedClaim = await this.claimCaseDbService.findByIdAndUpdate(
|
const updatedClaim = await this.claimCaseDbService.findByIdAndUpdate(
|
||||||
claimRequestId,
|
claimRequestId,
|
||||||
updatePayload,
|
updatePayload,
|
||||||
@@ -8495,8 +8514,14 @@ export class ClaimRequestManagementService {
|
|||||||
claimRequestId: updatedClaim._id.toString(),
|
claimRequestId: updatedClaim._id.toString(),
|
||||||
publicId: updatedClaim.publicId,
|
publicId: updatedClaim.publicId,
|
||||||
otherParts,
|
otherParts,
|
||||||
shebaNumber: String(shebaNumber).replace(/^(.{4})(.*)(.{4})$/, "IR$1************$3"),
|
shebaNumber: String(shebaNumber).replace(
|
||||||
nationalCodeOfOwner: String(nationalCode).replace(/^(.{2})(.*)(.{2})$/, "$1******$3"),
|
/^(.{4})(.*)(.{4})$/,
|
||||||
|
"IR$1************$3",
|
||||||
|
),
|
||||||
|
nationalCodeOfOwner: String(nationalCode).replace(
|
||||||
|
/^(.{2})(.*)(.{2})$/,
|
||||||
|
"$1******$3",
|
||||||
|
),
|
||||||
currentStep: ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
|
currentStep: ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
|
||||||
nextStep: ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS,
|
nextStep: ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS,
|
||||||
message:
|
message:
|
||||||
@@ -8512,7 +8537,9 @@ export class ClaimRequestManagementService {
|
|||||||
): Promise<VideoCaptureV2ResponseDto> {
|
): Promise<VideoCaptureV2ResponseDto> {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
if (!claimCase) {
|
if (!claimCase) {
|
||||||
throw new NotFoundException(`Claim case with ID ${claimRequestId} not found`);
|
throw new NotFoundException(
|
||||||
|
`Claim case with ID ${claimRequestId} not found`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.assertV3InPersonClaim(claimCase);
|
await this.assertV3InPersonClaim(claimCase);
|
||||||
|
|
||||||
@@ -8526,7 +8553,8 @@ export class ClaimRequestManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
claimCase.workflow?.currentStep !== ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS
|
claimCase.workflow?.currentStep !==
|
||||||
|
ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS
|
||||||
) {
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`Complete all part/angle captures first. Expected ${ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS}, but current step is ${claimCase.workflow?.currentStep}`,
|
`Complete all part/angle captures first. Expected ${ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS}, but current step is ${claimCase.workflow?.currentStep}`,
|
||||||
@@ -8567,7 +8595,9 @@ export class ClaimRequestManagementService {
|
|||||||
): Promise<CapturePartV2ResponseDto> {
|
): Promise<CapturePartV2ResponseDto> {
|
||||||
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
const claimCase = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
if (!claimCase) {
|
if (!claimCase) {
|
||||||
throw new NotFoundException(`Claim case with ID ${claimRequestId} not found`);
|
throw new NotFoundException(
|
||||||
|
`Claim case with ID ${claimRequestId} not found`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const blame = await this.assertV3InPersonClaim(claimCase);
|
const blame = await this.assertV3InPersonClaim(claimCase);
|
||||||
this.assertV3ClaimPartsPhase(blame);
|
this.assertV3ClaimPartsPhase(blame);
|
||||||
@@ -8576,18 +8606,17 @@ export class ClaimRequestManagementService {
|
|||||||
ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
|
ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
|
||||||
"Select other parts before capturing damaged parts and angles.",
|
"Select other parts before capturing damaged parts and angles.",
|
||||||
);
|
);
|
||||||
if (!this.claimV3StepCompleted(claimCase, ClaimWorkflowStep.SELECT_OTHER_PARTS)) {
|
if (
|
||||||
|
!this.claimV3StepCompleted(
|
||||||
|
claimCase,
|
||||||
|
ClaimWorkflowStep.SELECT_OTHER_PARTS,
|
||||||
|
)
|
||||||
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"Complete other part selection before capture.",
|
"Complete other part selection before capture.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.capturePartV2(
|
return this.capturePartV2(claimRequestId, body, file, currentUserId, actor);
|
||||||
claimRequestId,
|
|
||||||
body,
|
|
||||||
file,
|
|
||||||
currentUserId,
|
|
||||||
actor,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ import {
|
|||||||
IsBooleanString,
|
IsBooleanString,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsNumberString,
|
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsPositive,
|
IsPositive,
|
||||||
IsString,
|
IsString,
|
||||||
IsUrl,
|
IsUrl,
|
||||||
Length,
|
|
||||||
Matches,
|
Matches,
|
||||||
Max,
|
Max,
|
||||||
Min,
|
Min,
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ import {
|
|||||||
SelectOuterPartsV2Dto,
|
SelectOuterPartsV2Dto,
|
||||||
SelectOuterPartsV2ResponseDto,
|
SelectOuterPartsV2ResponseDto,
|
||||||
} from "src/claim-request-management/dto/select-outer-parts-v2.dto";
|
} from "src/claim-request-management/dto/select-outer-parts-v2.dto";
|
||||||
import {
|
import { SelectOtherPartsV2ResponseDto } from "src/claim-request-management/dto/select-other-parts-v2.dto";
|
||||||
SelectOtherPartsV2ResponseDto,
|
|
||||||
} from "src/claim-request-management/dto/select-other-parts-v2.dto";
|
|
||||||
import { SelectOtherPartsV3Dto } from "src/claim-request-management/dto/select-other-parts-v3.dto";
|
import { SelectOtherPartsV3Dto } from "src/claim-request-management/dto/select-other-parts-v3.dto";
|
||||||
import {
|
import {
|
||||||
UploadRequiredDocumentV2Dto,
|
UploadRequiredDocumentV2Dto,
|
||||||
@@ -117,7 +115,8 @@ export class ExpertInitiatedBlameV3MirrorController {
|
|||||||
@ApiBody({ type: SendPartyOtpDto })
|
@ApiBody({ type: SendPartyOtpDto })
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: "Send OTP to one party",
|
summary: "Send OTP to one party",
|
||||||
description: "Guilty party first; damaged party after guilty party has signed (THIRD_PARTY).",
|
description:
|
||||||
|
"Guilty party first; damaged party after guilty party has signed (THIRD_PARTY).",
|
||||||
})
|
})
|
||||||
async sendPartyOtp(
|
async sendPartyOtp(
|
||||||
@CurrentUser() expert: any,
|
@CurrentUser() expert: any,
|
||||||
@@ -139,7 +138,11 @@ export class ExpertInitiatedBlameV3MirrorController {
|
|||||||
@Param("requestId") requestId: string,
|
@Param("requestId") requestId: string,
|
||||||
@Body() dto: VerifyPartyOtpDto,
|
@Body() dto: VerifyPartyOtpDto,
|
||||||
) {
|
) {
|
||||||
return this.requestManagementService.verifyPartyOtpV2(expert, requestId, dto);
|
return this.requestManagementService.verifyPartyOtpV2(
|
||||||
|
expert,
|
||||||
|
requestId,
|
||||||
|
dto,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post("car-body-form/:requestId")
|
@Post("car-body-form/:requestId")
|
||||||
@@ -181,7 +184,9 @@ export class ExpertInitiatedBlameV3MirrorController {
|
|||||||
@Post("add-detail-location/:requestId")
|
@Post("add-detail-location/:requestId")
|
||||||
@ApiParam({ name: "requestId" })
|
@ApiParam({ name: "requestId" })
|
||||||
@ApiBody({ type: LocationDto })
|
@ApiBody({ type: LocationDto })
|
||||||
@ApiOperation({ summary: "Add location for current party (partyRole FIRST or SECOND)" })
|
@ApiOperation({
|
||||||
|
summary: "Add location for current party (partyRole FIRST or SECOND)",
|
||||||
|
})
|
||||||
async addLocation(
|
async addLocation(
|
||||||
@Param("requestId") requestId: string,
|
@Param("requestId") requestId: string,
|
||||||
@Body() body: LocationDto,
|
@Body() body: LocationDto,
|
||||||
@@ -400,38 +405,42 @@ export class ExpertInitiatedBlameV3MirrorController {
|
|||||||
|
|
||||||
@Patch("select-other-parts/:claimRequestId")
|
@Patch("select-other-parts/:claimRequestId")
|
||||||
@ApiParam({ name: "claimRequestId", example: "507f1f77bcf86cd799439011" })
|
@ApiParam({ name: "claimRequestId", example: "507f1f77bcf86cd799439011" })
|
||||||
@ApiConsumes("multipart/form-data")
|
|
||||||
@UseInterceptors(
|
|
||||||
FileInterceptor("file", {
|
|
||||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
|
||||||
storage: diskStorage({
|
|
||||||
destination: "./files/claim-required-document",
|
|
||||||
filename: (req, file, callback) => {
|
|
||||||
const unique = Date.now();
|
|
||||||
const ex = extname(file.originalname);
|
|
||||||
callback(null, `v3-other-parts-${unique}${ex}`);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: "Select other damaged parts (V3)",
|
summary: "Select other damaged parts (V3)",
|
||||||
description:
|
description:
|
||||||
"Other parts only — sheba and national code were collected during run-inquiries. Optional car green card file.",
|
"Other parts only — sheba and national code were collected during run-inquiries. Optional car green card file.",
|
||||||
})
|
})
|
||||||
@ApiBody({
|
@ApiBody({
|
||||||
description: "Other parts selection. Bank info is already on the claim from run-inquiries.",
|
description:
|
||||||
|
"Other parts selection. Bank info is already on the claim from run-inquiries.",
|
||||||
schema: {
|
schema: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
otherParts: {
|
otherParts: {
|
||||||
oneOf: [
|
oneOf: [
|
||||||
{ type: "array", items: { type: "string", enum: ["engine", "suspension", "brake_system", "electrical", "radiator", "transmission", "exhaust", "headlight", "taillight", "mirror", "glass"] } },
|
{
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "string",
|
||||||
|
enum: [
|
||||||
|
"engine",
|
||||||
|
"suspension",
|
||||||
|
"brake_system",
|
||||||
|
"electrical",
|
||||||
|
"radiator",
|
||||||
|
"transmission",
|
||||||
|
"exhaust",
|
||||||
|
"headlight",
|
||||||
|
"taillight",
|
||||||
|
"mirror",
|
||||||
|
"glass",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
{ type: "string", description: "JSON string array for multipart" },
|
{ type: "string", description: "JSON string array for multipart" },
|
||||||
],
|
],
|
||||||
example: ["engine", "suspension"],
|
example: ["engine", "suspension"],
|
||||||
},
|
},
|
||||||
file: { type: "string", format: "binary", description: "Optional car green card" },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -439,17 +448,12 @@ export class ExpertInitiatedBlameV3MirrorController {
|
|||||||
@Param("claimRequestId") claimRequestId: string,
|
@Param("claimRequestId") claimRequestId: string,
|
||||||
@Body() body: SelectOtherPartsV3Dto,
|
@Body() body: SelectOtherPartsV3Dto,
|
||||||
@CurrentUser() expert: any,
|
@CurrentUser() expert: any,
|
||||||
@UploadedFile() file?: Express.Multer.File,
|
|
||||||
): Promise<SelectOtherPartsV2ResponseDto> {
|
): Promise<SelectOtherPartsV2ResponseDto> {
|
||||||
if (file) {
|
|
||||||
await this.mediaPolicyService.assertForClaim(file, claimRequestId, "image");
|
|
||||||
}
|
|
||||||
return this.claimRequestManagementService.selectOtherPartsV3(
|
return this.claimRequestManagementService.selectOtherPartsV3(
|
||||||
claimRequestId,
|
claimRequestId,
|
||||||
body,
|
body,
|
||||||
expert.sub,
|
expert.sub,
|
||||||
expert,
|
expert,
|
||||||
file,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user