Mark rejected inquiry results as failed

This commit is contained in:
SepehrYahyaee
2026-09-13 12:55:55 +03:30
parent 287978a555
commit 5812637a1e

View File

@@ -9690,20 +9690,50 @@ export class RequestManagementService {
}
if (inquiryMapped?.Error) {
await this.persistBlameInquiryAudit(req);
throw new BadRequestException(
const error = new BadRequestException(
inquiryMapped.Error.Message ||
`${roleLabel} party plate inquiry returned an error`,
);
this.recordPartyCaseInquiryStatus(
req,
"thirdParty",
partyRole,
false,
{
source: inquirySource,
plateKind: inquiryPlateKind,
attempts: inquiryAttempts,
raw: inquiryRaw,
mapped: inquiryMapped,
},
error,
);
await this.persistBlameInquiryAudit(req);
throw error;
}
const clientName = inquiryMapped?.CompanyName;
const companyCode = inquiryMapped?.CompanyCode;
if (!clientName && !policyholderUnknown) {
await this.persistBlameInquiryAudit(req);
throw new BadRequestException(
const error = new BadRequestException(
`CompanyName missing from ${roleLabel} party inquiry response`,
);
this.recordPartyCaseInquiryStatus(
req,
"thirdParty",
partyRole,
false,
{
source: inquirySource,
plateKind: inquiryPlateKind,
attempts: inquiryAttempts,
raw: inquiryRaw,
mapped: inquiryMapped,
},
error,
);
await this.persistBlameInquiryAudit(req);
throw error;
}
const client = clientName
? await this.clientService.findOrCreateClientByCompanyCode(
@@ -9712,10 +9742,25 @@ export class RequestManagementService {
)
: null;
if (clientName && !client) {
await this.persistBlameInquiryAudit(req);
throw new BadRequestException(
const error = new BadRequestException(
`CompanyCode missing or invalid in ${roleLabel} party inquiry response`,
);
this.recordPartyCaseInquiryStatus(
req,
"thirdParty",
partyRole,
false,
{
source: inquirySource,
plateKind: inquiryPlateKind,
attempts: inquiryAttempts,
raw: inquiryRaw,
mapped: inquiryMapped,
},
error,
);
await this.persistBlameInquiryAudit(req);
throw error;
}
const resolvedClientId = (client as any)?._id ?? (client as any)?._doc?._id;
clientId = resolvedClientId ? String(resolvedClientId) : undefined;
@@ -10543,30 +10588,69 @@ export class RequestManagementService {
}
if (inquiryMapped?.Error) {
await this.persistBlameInquiryAudit(req);
throw new BadRequestException(
const error = new BadRequestException(
inquiryMapped.Error.Message ||
`${roleLabel} party VIN inquiry returned an error`,
);
this.recordPartyCaseInquiryStatus(
req,
"thirdParty",
partyRole,
false,
{
source: "ESG_VIN_INQUIRY",
raw: inquiryRaw,
mapped: inquiryMapped,
},
error,
);
await this.persistBlameInquiryAudit(req);
throw error;
}
const clientName = inquiryMapped?.CompanyName;
const companyCode = inquiryMapped?.CompanyCode;
if (!clientName) {
await this.persistBlameInquiryAudit(req);
throw new BadRequestException(
const error = new BadRequestException(
`CompanyName missing from ${roleLabel} party VIN inquiry response`,
);
this.recordPartyCaseInquiryStatus(
req,
"thirdParty",
partyRole,
false,
{
source: "ESG_VIN_INQUIRY",
raw: inquiryRaw,
mapped: inquiryMapped,
},
error,
);
await this.persistBlameInquiryAudit(req);
throw error;
}
const client = await this.clientService.findOrCreateClientByCompanyCode(
companyCode,
clientName,
);
if (!client) {
await this.persistBlameInquiryAudit(req);
throw new BadRequestException(
const error = new BadRequestException(
`CompanyCode missing or invalid in ${roleLabel} party VIN inquiry response`,
);
this.recordPartyCaseInquiryStatus(
req,
"thirdParty",
partyRole,
false,
{
source: "ESG_VIN_INQUIRY",
raw: inquiryRaw,
mapped: inquiryMapped,
},
error,
);
await this.persistBlameInquiryAudit(req);
throw error;
}
const resolvedClientId = (client as any)?._id ?? (client as any)?._doc?._id;
clientId = resolvedClientId ? String(resolvedClientId) : undefined;