forked from Yara724/api
YARA-1061
This commit is contained in:
@@ -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";
|
||||||
@@ -4431,7 +4429,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 +4465,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 +5103,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 +5454,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 +5681,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 +6338,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 +6356,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 +7922,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 +8003,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 +8027,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 +8075,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 +8091,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 +8131,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 =
|
||||||
Number(cbCompanyCode),
|
await this.clientService.findOrCreateClientByCompanyCode(
|
||||||
String(cbCompanyName),
|
Number(cbCompanyCode),
|
||||||
);
|
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 +8147,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 +8171,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 || "استعلام در دسترس نیست"}`,
|
||||||
);
|
);
|
||||||
@@ -8170,7 +8226,14 @@ 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 || "استعلام در دسترس نیست"}`,
|
||||||
);
|
);
|
||||||
@@ -8265,7 +8328,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 +8379,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 +8443,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 +8526,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 +8543,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 +8607,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 +8663,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 +8716,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 +8899,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 +8922,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 +8983,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 +9181,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