forked from Yara724/api
Compare commits
9 Commits
7e597db423
...
f3686575ca
| Author | SHA1 | Date | |
|---|---|---|---|
| f3686575ca | |||
|
|
b9fe1bfd52 | ||
| 6eca1f5dad | |||
|
|
6477778835 | ||
|
|
4552450fbc | ||
|
|
f7f7f4548d | ||
|
|
220b39ea5a | ||
| 4a045f564c | |||
|
|
d3249e9854 |
@@ -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
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
@@ -6239,11 +6254,6 @@ export class ClaimRequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (options?.v3InPersonFlow) {
|
if (options?.v3InPersonFlow) {
|
||||||
if (body.documentKey === ClaimRequiredDocumentType.CAR_GREEN_CARD) {
|
|
||||||
throw new BadRequestException(
|
|
||||||
"Car green card must be uploaded during other-parts selection, not in the documents step.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
step === ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS &&
|
step === ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS &&
|
||||||
isCapturePhaseDamagedPartyDocKey(body.documentKey)
|
isCapturePhaseDamagedPartyDocKey(body.documentKey)
|
||||||
@@ -6436,8 +6446,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 +7597,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 +7706,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 +8045,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 +8144,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 +8182,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 +8223,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 +8309,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 +8325,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 +8371,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 +8401,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 +8424,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 +8438,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 +8484,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 +8497,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 +8509,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 +8532,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 +8548,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 +8590,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 +8601,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,
|
||||||
|
|||||||
@@ -378,7 +378,10 @@ export class ExpertClaimService {
|
|||||||
return this.blameRequestDbService.findById(id);
|
return this.blameRequestDbService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async assertExpertActorOnClaim(claim: any, actor: any): Promise<void> {
|
private async assertExpertActorOnClaim(
|
||||||
|
claim: any,
|
||||||
|
actor: any,
|
||||||
|
): Promise<void> {
|
||||||
const blame = await this.loadBlameForClaim(claim);
|
const blame = await this.loadBlameForClaim(claim);
|
||||||
assertClaimCaseForExpertActor(claim, actor, blame);
|
assertClaimCaseForExpertActor(claim, actor, blame);
|
||||||
}
|
}
|
||||||
@@ -2462,9 +2465,15 @@ export class ExpertClaimService {
|
|||||||
*/
|
*/
|
||||||
async assignClaimForReviewV2(
|
async assignClaimForReviewV2(
|
||||||
claimRequestId: string,
|
claimRequestId: string,
|
||||||
actor: { sub: string; fullName?: string; clientKey?: string; role?: string },
|
actor: {
|
||||||
|
sub: string;
|
||||||
|
fullName?: string;
|
||||||
|
clientKey?: string;
|
||||||
|
role?: string;
|
||||||
|
},
|
||||||
): Promise<ExpertFileAssignResultDto> {
|
): Promise<ExpertFileAssignResultDto> {
|
||||||
if ((actor as any).role !== RoleEnum.FIELD_EXPERT) requireActorClientKey(actor);
|
if ((actor as any).role !== RoleEnum.FIELD_EXPERT)
|
||||||
|
requireActorClientKey(actor);
|
||||||
await this.expireClaimWorkflowLockV2IfStale(claimRequestId);
|
await this.expireClaimWorkflowLockV2IfStale(claimRequestId);
|
||||||
|
|
||||||
const claim = await this.claimCaseDbService.findById(claimRequestId);
|
const claim = await this.claimCaseDbService.findById(claimRequestId);
|
||||||
@@ -3003,7 +3012,9 @@ export class ExpertClaimService {
|
|||||||
if (priceCap !== null) {
|
if (priceCap !== null) {
|
||||||
let totalPrice = 0;
|
let totalPrice = 0;
|
||||||
for (const part of reply.parts || []) {
|
for (const part of reply.parts || []) {
|
||||||
const parsed = this.parsePersianNumber(String(part.totalPayment ?? "0"));
|
const parsed = this.parsePersianNumber(
|
||||||
|
String(part.totalPayment ?? "0"),
|
||||||
|
);
|
||||||
if (!isNaN(parsed)) totalPrice += parsed;
|
if (!isNaN(parsed)) totalPrice += parsed;
|
||||||
}
|
}
|
||||||
if (totalPrice > priceCap) {
|
if (totalPrice > priceCap) {
|
||||||
@@ -3492,7 +3503,8 @@ export class ExpertClaimService {
|
|||||||
const clientKey = requireActorClientKey(actor);
|
const clientKey = requireActorClientKey(actor);
|
||||||
const expertId = String(actor.sub);
|
const expertId = String(actor.sub);
|
||||||
const expertOid = new Types.ObjectId(expertId);
|
const expertOid = new Types.ObjectId(expertId);
|
||||||
const activityEvents = await this.expertFileActivityDbService.findByExpert(
|
const activityEvents =
|
||||||
|
await this.expertFileActivityDbService.findByExpert(
|
||||||
expertId,
|
expertId,
|
||||||
ExpertFileKind.CLAIM,
|
ExpertFileKind.CLAIM,
|
||||||
);
|
);
|
||||||
@@ -3511,7 +3523,10 @@ export class ExpertClaimService {
|
|||||||
const rows =
|
const rows =
|
||||||
orClauses.length === 0
|
orClauses.length === 0
|
||||||
? []
|
? []
|
||||||
: await this.claimCaseDbService.find({ $or: orClauses }, { lean: true });
|
: await this.claimCaseDbService.find(
|
||||||
|
{ $or: orClauses },
|
||||||
|
{ lean: true },
|
||||||
|
);
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
for (const doc of rows as Record<string, unknown>[]) {
|
for (const doc of rows as Record<string, unknown>[]) {
|
||||||
const id = String(doc._id ?? "");
|
const id = String(doc._id ?? "");
|
||||||
@@ -4513,9 +4528,10 @@ export class ExpertClaimService {
|
|||||||
carAngles,
|
carAngles,
|
||||||
damagedParts,
|
damagedParts,
|
||||||
awaitingFactorValidation: isFactorValidationPending,
|
awaitingFactorValidation: isFactorValidationPending,
|
||||||
evaluation: evaluationForApi as
|
evaluation:
|
||||||
|
(evaluationForApi as
|
||||||
| ClaimDetailV2ResponseDto["evaluation"]
|
| ClaimDetailV2ResponseDto["evaluation"]
|
||||||
| undefined,
|
| undefined) || (enrichedEvaluation as any),
|
||||||
videoCapture,
|
videoCapture,
|
||||||
blameCase: blameCaseForApi,
|
blameCase: blameCaseForApi,
|
||||||
blameExpertDecision,
|
blameExpertDecision,
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export class BlameRequestDbService {
|
|||||||
return this.blameRequestModel.findOne(filter);
|
return this.blameRequestModel.findOne(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findById(id: string | Types.ObjectId): Promise<BlameRequestDocument | null> {
|
async findById(
|
||||||
|
id: string | Types.ObjectId,
|
||||||
|
): Promise<BlameRequestDocument | null> {
|
||||||
return this.blameRequestModel.findById(id);
|
return this.blameRequestModel.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,5 +74,11 @@ export class BlameRequestDbService {
|
|||||||
: this.blameRequestModel.find(filter);
|
: this.blameRequestModel.find(filter);
|
||||||
return query.exec() as Promise<BlameRequestDocument[]>;
|
return query.exec() as Promise<BlameRequestDocument[]>;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
async deleteMany(
|
||||||
|
filter: FilterQuery<BlameRequest>,
|
||||||
|
): Promise<{ deletedCount: number }> {
|
||||||
|
const result = await this.blameRequestModel.deleteMany(filter);
|
||||||
|
return { deletedCount: result.deletedCount };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ import { ClaimStatus } from "src/Types&Enums/claim-request-management/claimStatu
|
|||||||
import { ClaimWorkflowStep } from "src/Types&Enums/claim-request-management/claim-workflow-steps.enum";
|
import { ClaimWorkflowStep } from "src/Types&Enums/claim-request-management/claim-workflow-steps.enum";
|
||||||
import { resolveClaimOwnerFieldsFromBlame } from "src/helpers/blame-damaged-party";
|
import { resolveClaimOwnerFieldsFromBlame } from "src/helpers/blame-damaged-party";
|
||||||
import { ExpertAccidentFieldsDto } from "./dto/expert-accident-fields.dto";
|
import { ExpertAccidentFieldsDto } from "./dto/expert-accident-fields.dto";
|
||||||
import {
|
import { RunInquiriesV3Dto } from "./dto/run-inquiries-v3.dto";
|
||||||
RunInquiriesV3Dto,
|
|
||||||
} from "./dto/run-inquiries-v3.dto";
|
|
||||||
import { SandHubService } from "src/sand-hub/sand-hub.service";
|
import { SandHubService } from "src/sand-hub/sand-hub.service";
|
||||||
import { ReqBlameStatus } from "src/Types&Enums/blame-request-management/status.enum";
|
import { ReqBlameStatus } from "src/Types&Enums/blame-request-management/status.enum";
|
||||||
import { StepsEnum } from "src/Types&Enums/blame-request-management/steps.enum";
|
import { StepsEnum } from "src/Types&Enums/blame-request-management/steps.enum";
|
||||||
@@ -4369,6 +4367,17 @@ export class RequestManagementService {
|
|||||||
// For IN_PERSON files the phone + userId are stored when verify-party-otp is called.
|
// For IN_PERSON files the phone + userId are stored when verify-party-otp is called.
|
||||||
const parties: any[] = [{ role: PartyRole.FIRST, person: {} }];
|
const parties: any[] = [{ role: PartyRole.FIRST, person: {} }];
|
||||||
|
|
||||||
|
// Before creating, clean up any orphaned IN_PERSON shell from this expert
|
||||||
|
// that never had its first party OTP verified.
|
||||||
|
if (dto.creationMethod === CreationMethod.IN_PERSON) {
|
||||||
|
await this.blameRequestDbService.deleteMany({
|
||||||
|
initiatedByFieldExpertId: expertId,
|
||||||
|
creationMethod: CreationMethod.IN_PERSON,
|
||||||
|
"workflow.currentStep": firstStep.stepKey, // still at CREATED
|
||||||
|
"parties.0.person.userId": { $exists: false }, // no verified party yet
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const created = await this.blameRequestDbService.create({
|
const created = await this.blameRequestDbService.create({
|
||||||
publicId,
|
publicId,
|
||||||
requestNo: publicId,
|
requestNo: publicId,
|
||||||
@@ -4431,7 +4440,12 @@ export class RequestManagementService {
|
|||||||
dto: { phoneNumber: string },
|
dto: { phoneNumber: string },
|
||||||
): Promise<{
|
): Promise<{
|
||||||
sent: boolean;
|
sent: boolean;
|
||||||
sentTo: { role: string; phoneNumber: string; smsSent: boolean; linkUrl: string }[];
|
sentTo: {
|
||||||
|
role: string;
|
||||||
|
phoneNumber: string;
|
||||||
|
smsSent: boolean;
|
||||||
|
linkUrl: string;
|
||||||
|
}[];
|
||||||
}> {
|
}> {
|
||||||
const req = await this.blameRequestDbService.findById(requestId);
|
const req = await this.blameRequestDbService.findById(requestId);
|
||||||
if (!req) throw new NotFoundException("Request not found");
|
if (!req) throw new NotFoundException("Request not found");
|
||||||
@@ -4462,16 +4476,29 @@ export class RequestManagementService {
|
|||||||
req.parties[firstIdx].person.userId = userId;
|
req.parties[firstIdx].person.userId = userId;
|
||||||
|
|
||||||
const expertName = `${expert?.lastName || ""}`.trim() || "کارشناس";
|
const expertName = `${expert?.lastName || ""}`.trim() || "کارشناس";
|
||||||
const sentTo: { role: string; phoneNumber: string; smsSent: boolean; linkUrl: string }[] = [];
|
const sentTo: {
|
||||||
|
role: string;
|
||||||
|
phoneNumber: string;
|
||||||
|
smsSent: boolean;
|
||||||
|
linkUrl: string;
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
const firstLink = this.smsOrchestrationService.buildBlamePartyLink(requestId, "FIRST");
|
const firstLink = this.smsOrchestrationService.buildBlamePartyLink(
|
||||||
|
requestId,
|
||||||
|
"FIRST",
|
||||||
|
);
|
||||||
const smsSent = await this.smsOrchestrationService.sendFieldExpertLink({
|
const smsSent = await this.smsOrchestrationService.sendFieldExpertLink({
|
||||||
receptor: phone,
|
receptor: phone,
|
||||||
type: req.type,
|
type: req.type,
|
||||||
expertLastName: expertName,
|
expertLastName: expertName,
|
||||||
link: firstLink,
|
link: firstLink,
|
||||||
});
|
});
|
||||||
sentTo.push({ role: PartyRole.FIRST, phoneNumber: phone, smsSent, linkUrl: firstLink });
|
sentTo.push({
|
||||||
|
role: PartyRole.FIRST,
|
||||||
|
phoneNumber: phone,
|
||||||
|
smsSent,
|
||||||
|
linkUrl: firstLink,
|
||||||
|
});
|
||||||
|
|
||||||
if (!Array.isArray((req as any).history)) (req as any).history = [];
|
if (!Array.isArray((req as any).history)) (req as any).history = [];
|
||||||
(req as any).history.push({
|
(req as any).history.push({
|
||||||
@@ -5087,7 +5114,9 @@ export class RequestManagementService {
|
|||||||
// Snapshot-party fallback: find blames via claims where this user appears
|
// Snapshot-party fallback: find blames via claims where this user appears
|
||||||
// in claim.snapshot.parties (the most reliable path for IN_PERSON flows).
|
// in claim.snapshot.parties (the most reliable path for IN_PERSON flows).
|
||||||
const idVariants = collectUserIdVariants(
|
const idVariants = collectUserIdVariants(
|
||||||
...(linkedUserIds.length > 0 ? linkedUserIds : [user?.sub].filter(Boolean)),
|
...(linkedUserIds.length > 0
|
||||||
|
? linkedUserIds
|
||||||
|
: [user?.sub].filter(Boolean)),
|
||||||
);
|
);
|
||||||
if (idVariants.length > 0) {
|
if (idVariants.length > 0) {
|
||||||
const snapshotFilter =
|
const snapshotFilter =
|
||||||
@@ -5436,7 +5465,9 @@ export class RequestManagementService {
|
|||||||
const phoneMatch =
|
const phoneMatch =
|
||||||
person.phoneNumber &&
|
person.phoneNumber &&
|
||||||
phoneVariants.some(
|
phoneVariants.some(
|
||||||
(v) => v === person.phoneNumber || v === normalizeIranMobile(person.phoneNumber),
|
(v) =>
|
||||||
|
v === person.phoneNumber ||
|
||||||
|
v === normalizeIranMobile(person.phoneNumber),
|
||||||
);
|
);
|
||||||
if (phoneMatch && !person?.userId) {
|
if (phoneMatch && !person?.userId) {
|
||||||
p.person = p.person || {};
|
p.person = p.person || {};
|
||||||
@@ -5661,7 +5692,8 @@ export class RequestManagementService {
|
|||||||
role: PartyRole.FIRST,
|
role: PartyRole.FIRST,
|
||||||
person: {
|
person: {
|
||||||
userId: firstPartyUserId,
|
userId: firstPartyUserId,
|
||||||
phoneNumber: normalizeIranMobile(formData.firstPartyPhoneNumber) ??
|
phoneNumber:
|
||||||
|
normalizeIranMobile(formData.firstPartyPhoneNumber) ??
|
||||||
formData.firstPartyPhoneNumber,
|
formData.firstPartyPhoneNumber,
|
||||||
clientId: (client as any)?._id ?? (client as any)?._doc?._id,
|
clientId: (client as any)?._id ?? (client as any)?._doc?._id,
|
||||||
nationalCodeOfInsurer: firstPartyPlate.nationalCodeOfInsurer,
|
nationalCodeOfInsurer: firstPartyPlate.nationalCodeOfInsurer,
|
||||||
@@ -6317,10 +6349,7 @@ export class RequestManagementService {
|
|||||||
? req.workflow.completedSteps
|
? req.workflow.completedSteps
|
||||||
: [];
|
: [];
|
||||||
const currentStep = req.workflow?.currentStep as WorkflowStep | undefined;
|
const currentStep = req.workflow?.currentStep as WorkflowStep | undefined;
|
||||||
if (
|
if (currentStep && !completed.includes(currentStep)) {
|
||||||
currentStep &&
|
|
||||||
!completed.includes(currentStep)
|
|
||||||
) {
|
|
||||||
completed.push(currentStep);
|
completed.push(currentStep);
|
||||||
}
|
}
|
||||||
if (!completed.includes(WorkflowStep.WAITING_FOR_GUILT_DECISION)) {
|
if (!completed.includes(WorkflowStep.WAITING_FOR_GUILT_DECISION)) {
|
||||||
@@ -6338,7 +6367,8 @@ export class RequestManagementService {
|
|||||||
type: "ACCIDENT_FIELDS_SAVED_ADVANCED_TO_SIGNATURES",
|
type: "ACCIDENT_FIELDS_SAVED_ADVANCED_TO_SIGNATURES",
|
||||||
actor: {
|
actor: {
|
||||||
actorId: new Types.ObjectId(String(expert.sub)),
|
actorId: new Types.ObjectId(String(expert.sub)),
|
||||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
actorName:
|
||||||
|
`${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||||
actorType: "field_expert",
|
actorType: "field_expert",
|
||||||
},
|
},
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -7903,7 +7933,9 @@ export class RequestManagementService {
|
|||||||
throw new BadRequestException("V3 flow is only for IN_PERSON files.");
|
throw new BadRequestException("V3 flow is only for IN_PERSON files.");
|
||||||
}
|
}
|
||||||
if (!req.expertInitiated) {
|
if (!req.expertInitiated) {
|
||||||
throw new BadRequestException("V3 flow is only for expert-initiated files.");
|
throw new BadRequestException(
|
||||||
|
"V3 flow is only for expert-initiated files.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7982,7 +8014,8 @@ export class RequestManagementService {
|
|||||||
): Promise<{ clientId?: string }> {
|
): Promise<{ clientId?: string }> {
|
||||||
const roleLabel = partyRole === PartyRole.FIRST ? "FIRST" : "SECOND";
|
const roleLabel = partyRole === PartyRole.FIRST ? "FIRST" : "SECOND";
|
||||||
let clientId: string | undefined;
|
let clientId: string | undefined;
|
||||||
const inquiryOptions = (cid?: string) => (cid ? { clientId: cid } : undefined);
|
const inquiryOptions = (cid?: string) =>
|
||||||
|
cid ? { clientId: cid } : undefined;
|
||||||
|
|
||||||
let inquiryRaw: any;
|
let inquiryRaw: any;
|
||||||
let inquiryMapped: any;
|
let inquiryMapped: any;
|
||||||
@@ -8005,7 +8038,14 @@ export class RequestManagementService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`[V3] plate inquiry failed for ${roleLabel} party (request=${req._id}): ${err?.message || err}`,
|
`[V3] plate inquiry failed for ${roleLabel} party (request=${req._id}): ${err?.message || err}`,
|
||||||
);
|
);
|
||||||
this.recordPartyCaseInquiryStatus(req, "thirdParty", partyRole, false, {}, err);
|
this.recordPartyCaseInquiryStatus(
|
||||||
|
req,
|
||||||
|
"thirdParty",
|
||||||
|
partyRole,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
err,
|
||||||
|
);
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`${roleLabel} party plate inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
`${roleLabel} party plate inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
||||||
);
|
);
|
||||||
@@ -8046,8 +8086,10 @@ export class RequestManagementService {
|
|||||||
party.person.driverBirthday =
|
party.person.driverBirthday =
|
||||||
partyData.driverBirthday ??
|
partyData.driverBirthday ??
|
||||||
(partyData.driverIsInsurer ? String(partyData.insurerBirthday) : null);
|
(partyData.driverIsInsurer ? String(partyData.insurerBirthday) : null);
|
||||||
if (partyData.insurerLicense) party.person.insurerLicense = partyData.insurerLicense;
|
if (partyData.insurerLicense)
|
||||||
if (partyData.driverLicense) party.person.driverLicense = partyData.driverLicense;
|
party.person.insurerLicense = partyData.insurerLicense;
|
||||||
|
if (partyData.driverLicense)
|
||||||
|
party.person.driverLicense = partyData.driverLicense;
|
||||||
|
|
||||||
if (!party.vehicle) party.vehicle = {} as any;
|
if (!party.vehicle) party.vehicle = {} as any;
|
||||||
party.vehicle.plateId = this.plateToPlateIdString(partyData.plate);
|
party.vehicle.plateId = this.plateToPlateIdString(partyData.plate);
|
||||||
@@ -8060,13 +8102,16 @@ export class RequestManagementService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!party.insurance) party.insurance = {} as any;
|
if (!party.insurance) party.insurance = {} as any;
|
||||||
party.insurance.policyNumber = inquiryMapped?.LastCompanyDocumentNumber;
|
party.insurance.policyNumber = inquiryMapped?.PrntPlcyCmpDocNo;
|
||||||
party.insurance.company = clientName;
|
party.insurance.company = clientName;
|
||||||
party.insurance.financialCeiling = inquiryMapped?.FinancialCvrCptl;
|
party.insurance.financialCeiling = inquiryMapped?.FinancialCvrCptl;
|
||||||
party.insurance.startDate = inquiryMapped?.IssueDate;
|
party.insurance.startDate = inquiryMapped?.IssueDate;
|
||||||
party.insurance.endDate = inquiryMapped?.EndDate;
|
party.insurance.endDate = inquiryMapped?.EndDate;
|
||||||
|
|
||||||
if (req.type === BlameRequestType.CAR_BODY && partyRole === PartyRole.FIRST) {
|
if (
|
||||||
|
req.type === BlameRequestType.CAR_BODY &&
|
||||||
|
partyRole === PartyRole.FIRST
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
const carBodyInfo = await this.sandHubService.getTejaratCarBodyInquiry(
|
const carBodyInfo = await this.sandHubService.getTejaratCarBodyInquiry(
|
||||||
{
|
{
|
||||||
@@ -8097,11 +8142,13 @@ export class RequestManagementService {
|
|||||||
const cbCompanyCode = m.companyId ?? m.CompanyCode;
|
const cbCompanyCode = m.companyId ?? m.CompanyCode;
|
||||||
const cbCompanyName = m.CompanyName ?? m.companyPersianName;
|
const cbCompanyName = m.CompanyName ?? m.companyPersianName;
|
||||||
if (cbCompanyCode && cbCompanyName) {
|
if (cbCompanyCode && cbCompanyName) {
|
||||||
const cbClient = await this.clientService.findOrCreateClientByCompanyCode(
|
const cbClient =
|
||||||
|
await this.clientService.findOrCreateClientByCompanyCode(
|
||||||
Number(cbCompanyCode),
|
Number(cbCompanyCode),
|
||||||
String(cbCompanyName),
|
String(cbCompanyName),
|
||||||
);
|
);
|
||||||
const cbClientId = (cbClient as any)?._id ?? (cbClient as any)?._doc?._id;
|
const cbClientId =
|
||||||
|
(cbClient as any)?._id ?? (cbClient as any)?._doc?._id;
|
||||||
if (cbClientId) {
|
if (cbClientId) {
|
||||||
party.person.clientId = cbClientId;
|
party.person.clientId = cbClientId;
|
||||||
clientId = String(cbClientId);
|
clientId = String(cbClientId);
|
||||||
@@ -8111,7 +8158,14 @@ export class RequestManagementService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`[V3] car body inquiry failed for request=${req._id}: ${err?.message || err}`,
|
`[V3] car body inquiry failed for request=${req._id}: ${err?.message || err}`,
|
||||||
);
|
);
|
||||||
this.recordPartyCaseInquiryStatus(req, "carBody", partyRole, false, {}, err);
|
this.recordPartyCaseInquiryStatus(
|
||||||
|
req,
|
||||||
|
"carBody",
|
||||||
|
partyRole,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
err,
|
||||||
|
);
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`CAR_BODY inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
`CAR_BODY inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
||||||
);
|
);
|
||||||
@@ -8128,12 +8182,25 @@ export class RequestManagementService {
|
|||||||
birthDate as string | number,
|
birthDate as string | number,
|
||||||
clientId ? { clientId } : undefined,
|
clientId ? { clientId } : undefined,
|
||||||
);
|
);
|
||||||
this.recordPartyCaseInquiryStatus(req, "person", partyRole, true, personalInquiry);
|
this.recordPartyCaseInquiryStatus(
|
||||||
|
req,
|
||||||
|
"person",
|
||||||
|
partyRole,
|
||||||
|
true,
|
||||||
|
personalInquiry,
|
||||||
|
);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
`[V3] personal inquiry failed for ${roleLabel} party request=${req._id}: ${err?.message || err}`,
|
`[V3] personal inquiry failed for ${roleLabel} party request=${req._id}: ${err?.message || err}`,
|
||||||
);
|
);
|
||||||
this.recordPartyCaseInquiryStatus(req, "person", partyRole, false, {}, err);
|
this.recordPartyCaseInquiryStatus(
|
||||||
|
req,
|
||||||
|
"person",
|
||||||
|
partyRole,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
err,
|
||||||
|
);
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`${roleLabel} party personal identity inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
`${roleLabel} party personal identity inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
||||||
);
|
);
|
||||||
@@ -8146,13 +8213,16 @@ export class RequestManagementService {
|
|||||||
const licenseNumber = partyData.driverIsInsurer
|
const licenseNumber = partyData.driverIsInsurer
|
||||||
? partyData.insurerLicense
|
? partyData.insurerLicense
|
||||||
: partyData.driverLicense;
|
: partyData.driverLicense;
|
||||||
if (!licenseNationalCode || !licenseNumber) {
|
|
||||||
throw new BadRequestException(
|
if (!licenseNumber) {
|
||||||
`${roleLabel} party driving license inquiry requires national code and ${
|
this.recordPartyCaseInquiryStatus(
|
||||||
partyData.driverIsInsurer ? "insurerLicense" : "driverLicense"
|
req,
|
||||||
}.`,
|
"drivingLicence",
|
||||||
|
partyRole,
|
||||||
|
false,
|
||||||
|
{ skipped: true, reason: "No license number provided" },
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
try {
|
try {
|
||||||
const licenseInquiry = await this.sandHubService.getDrivingLicenseInfo(
|
const licenseInquiry = await this.sandHubService.getDrivingLicenseInfo(
|
||||||
licenseNationalCode,
|
licenseNationalCode,
|
||||||
@@ -8170,11 +8240,19 @@ export class RequestManagementService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`[V3] driving license inquiry failed for ${roleLabel} party request=${req._id}: ${err?.message || err}`,
|
`[V3] driving license inquiry failed for ${roleLabel} party request=${req._id}: ${err?.message || err}`,
|
||||||
);
|
);
|
||||||
this.recordPartyCaseInquiryStatus(req, "drivingLicence", partyRole, false, {}, err);
|
this.recordPartyCaseInquiryStatus(
|
||||||
|
req,
|
||||||
|
"drivingLicence",
|
||||||
|
partyRole,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
err,
|
||||||
|
);
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`${roleLabel} party driving license inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
`${roleLabel} party driving license inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { clientId };
|
return { clientId };
|
||||||
}
|
}
|
||||||
@@ -8265,7 +8343,9 @@ export class RequestManagementService {
|
|||||||
payingClientId = ownerFields.clientId ?? guiltyClientId?.toString();
|
payingClientId = ownerFields.clientId ?? guiltyClientId?.toString();
|
||||||
} else {
|
} else {
|
||||||
if (!guiltyUserId) {
|
if (!guiltyUserId) {
|
||||||
throw new BadRequestException("First party must be verified before creating claim.");
|
throw new BadRequestException(
|
||||||
|
"First party must be verified before creating claim.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
ownerUserId = String(guiltyUserId);
|
ownerUserId = String(guiltyUserId);
|
||||||
ownerRole = PartyRole.FIRST;
|
ownerRole = PartyRole.FIRST;
|
||||||
@@ -8314,7 +8394,8 @@ export class RequestManagementService {
|
|||||||
type: "CLAIM_CREATED",
|
type: "CLAIM_CREATED",
|
||||||
actor: {
|
actor: {
|
||||||
actorId: new Types.ObjectId(actor.sub),
|
actorId: new Types.ObjectId(actor.sub),
|
||||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
actorName:
|
||||||
|
`${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||||
actorType: "field_expert",
|
actorType: "field_expert",
|
||||||
},
|
},
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
@@ -8377,7 +8458,9 @@ export class RequestManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const payingClientId =
|
const payingClientId =
|
||||||
guiltyPerson?.clientId != null ? String(guiltyPerson.clientId) : undefined;
|
guiltyPerson?.clientId != null
|
||||||
|
? String(guiltyPerson.clientId)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
userId: damagedUserId,
|
userId: damagedUserId,
|
||||||
@@ -8458,7 +8541,8 @@ export class RequestManagementService {
|
|||||||
|
|
||||||
if (partyRole === PartyRole.FIRST) {
|
if (partyRole === PartyRole.FIRST) {
|
||||||
const firstIdx = this.getPartyIndex(req, PartyRole.FIRST);
|
const firstIdx = this.getPartyIndex(req, PartyRole.FIRST);
|
||||||
if (firstIdx === -1) throw new BadRequestException("First party not found");
|
if (firstIdx === -1)
|
||||||
|
throw new BadRequestException("First party not found");
|
||||||
const firstParty = req.parties[firstIdx];
|
const firstParty = req.parties[firstIdx];
|
||||||
if (!firstParty?.person?.userId) {
|
if (!firstParty?.person?.userId) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
@@ -8474,9 +8558,17 @@ export class RequestManagementService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.runPartyInquiriesV3Internal(req, dto, PartyRole.FIRST, firstParty);
|
await this.runPartyInquiriesV3Internal(
|
||||||
|
req,
|
||||||
|
dto,
|
||||||
|
PartyRole.FIRST,
|
||||||
|
firstParty,
|
||||||
|
);
|
||||||
if (req.type === BlameRequestType.CAR_BODY) {
|
if (req.type === BlameRequestType.CAR_BODY) {
|
||||||
await this.validateShebaV3(dto, firstParty.person?.clientId?.toString());
|
await this.validateShebaV3(
|
||||||
|
dto,
|
||||||
|
firstParty.person?.clientId?.toString(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.markPartyInquiriesCompleteOnBlame(req, PartyRole.FIRST, actor);
|
this.markPartyInquiriesCompleteOnBlame(req, PartyRole.FIRST, actor);
|
||||||
@@ -8530,7 +8622,12 @@ export class RequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.runPartyInquiriesV3Internal(req, dto, PartyRole.SECOND, secondParty);
|
await this.runPartyInquiriesV3Internal(
|
||||||
|
req,
|
||||||
|
dto,
|
||||||
|
PartyRole.SECOND,
|
||||||
|
secondParty,
|
||||||
|
);
|
||||||
await this.validateShebaV3(dto, secondParty.person?.clientId?.toString());
|
await this.validateShebaV3(dto, secondParty.person?.clientId?.toString());
|
||||||
|
|
||||||
this.ensureV3GuiltyPartyDecision(req);
|
this.ensureV3GuiltyPartyDecision(req);
|
||||||
@@ -8581,7 +8678,9 @@ export class RequestManagementService {
|
|||||||
private assertBlameV3AccidentFieldsPhase(req: any): void {
|
private assertBlameV3AccidentFieldsPhase(req: any): void {
|
||||||
this.assertBlameV3ExpertInPerson(req);
|
this.assertBlameV3ExpertInPerson(req);
|
||||||
const requiredSigs = req.type === BlameRequestType.CAR_BODY ? 1 : 2;
|
const requiredSigs = req.type === BlameRequestType.CAR_BODY ? 1 : 2;
|
||||||
const signed = (req.parties ?? []).filter((p: any) => p?.confirmation != null);
|
const signed = (req.parties ?? []).filter(
|
||||||
|
(p: any) => p?.confirmation != null,
|
||||||
|
);
|
||||||
if (signed.length < requiredSigs) {
|
if (signed.length < requiredSigs) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"All required party signatures must be collected before accident fields.",
|
"All required party signatures must be collected before accident fields.",
|
||||||
@@ -8632,7 +8731,9 @@ export class RequestManagementService {
|
|||||||
|
|
||||||
const partyIndex = this.getPartyIndex(req, partyRole);
|
const partyIndex = this.getPartyIndex(req, partyRole);
|
||||||
if (partyIndex === -1) {
|
if (partyIndex === -1) {
|
||||||
throw new BadRequestException(`Party ${partyRole} not found on this request`);
|
throw new BadRequestException(
|
||||||
|
`Party ${partyRole} not found on this request`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
req.type === BlameRequestType.CAR_BODY &&
|
req.type === BlameRequestType.CAR_BODY &&
|
||||||
@@ -8813,7 +8914,9 @@ export class RequestManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const requiredSigs = req.type === BlameRequestType.CAR_BODY ? 1 : 2;
|
const requiredSigs = req.type === BlameRequestType.CAR_BODY ? 1 : 2;
|
||||||
const signed = (req.parties ?? []).filter((p: any) => p?.confirmation != null);
|
const signed = (req.parties ?? []).filter(
|
||||||
|
(p: any) => p?.confirmation != null,
|
||||||
|
);
|
||||||
if (signed.length < requiredSigs) {
|
if (signed.length < requiredSigs) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"All required party signatures must be collected before the blame accident video.",
|
"All required party signatures must be collected before the blame accident video.",
|
||||||
@@ -8834,7 +8937,8 @@ export class RequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
claim.workflow?.currentStep !== ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS
|
claim.workflow?.currentStep !==
|
||||||
|
ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS
|
||||||
) {
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"Complete capture-part (parts, angles, and capture-phase documents) before the blame accident video.",
|
"Complete capture-part (parts, angles, and capture-phase documents) before the blame accident video.",
|
||||||
@@ -8894,7 +8998,8 @@ export class RequestManagementService {
|
|||||||
type: "STEP_COMPLETED",
|
type: "STEP_COMPLETED",
|
||||||
actor: {
|
actor: {
|
||||||
actorId: new Types.ObjectId(expert.sub),
|
actorId: new Types.ObjectId(expert.sub),
|
||||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
actorName:
|
||||||
|
`${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||||
actorType: "field_expert",
|
actorType: "field_expert",
|
||||||
},
|
},
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
@@ -9091,7 +9196,9 @@ export class RequestManagementService {
|
|||||||
const req = await this.blameRequestDbService.findById(requestId);
|
const req = await this.blameRequestDbService.findById(requestId);
|
||||||
if (!req) throw new NotFoundException("Request not found");
|
if (!req) throw new NotFoundException("Request not found");
|
||||||
if (req.type !== BlameRequestType.CAR_BODY) {
|
if (req.type !== BlameRequestType.CAR_BODY) {
|
||||||
throw new BadRequestException("CAR_BODY accident type is only for CAR_BODY files.");
|
throw new BadRequestException(
|
||||||
|
"CAR_BODY accident type is only for CAR_BODY files.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this.verifyExpertAccessForBlameV2(req, actor);
|
this.verifyExpertAccessForBlameV2(req, actor);
|
||||||
this.assertBlameV3ExpertInPerson(req);
|
this.assertBlameV3ExpertInPerson(req);
|
||||||
|
|||||||
Reference in New Issue
Block a user