forked from Yara724/api
fix: return inquiry-specific Persian not-found messages
This commit is contained in:
@@ -256,9 +256,7 @@ export class InquiryRefreshService {
|
||||
inquiriesChanged = true;
|
||||
result.thirdParty = {
|
||||
ok: false,
|
||||
message:
|
||||
inquiry.mapped.Error.Message ||
|
||||
getInquiryErrorMessage(inquiry.mapped, "thirdPartyPlate"),
|
||||
message: getInquiryErrorMessage(inquiry.mapped, "thirdPartyPlate"),
|
||||
};
|
||||
} else {
|
||||
nextParty = this.applyThirdPartyToParty(
|
||||
|
||||
@@ -79,7 +79,7 @@ describe("RequestManagementService policyholder inquiry routing", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("propagates the mapped ESG Persian error for third-party insurance", async () => {
|
||||
it("contextualizes the mapped ESG not-found error for third-party insurance", async () => {
|
||||
const service = Object.create(RequestManagementService.prototype) as any;
|
||||
service.sandHubService = {
|
||||
getTejaratBlockInquiry: jest.fn().mockResolvedValue({
|
||||
@@ -99,9 +99,9 @@ describe("RequestManagementService policyholder inquiry routing", () => {
|
||||
participantInput(BlameRequestType.THIRD_PARTY),
|
||||
);
|
||||
|
||||
await expect(
|
||||
service.getThirdPartyPlateInquiry(submission),
|
||||
).rejects.toThrow("رکوردی یافت نشد");
|
||||
await expect(service.getThirdPartyPlateInquiry(submission)).rejects.toThrow(
|
||||
"بیمهنامه شخص ثالثی مطابق پلاک و کد ملی واردشده یافت نشد.",
|
||||
);
|
||||
expect(service.sandHubService.getTejaratBlockInquiry).toHaveBeenCalledTimes(
|
||||
1,
|
||||
);
|
||||
|
||||
@@ -147,10 +147,13 @@ import {
|
||||
sanitizeStoredInquiryParticipants,
|
||||
} from "./inquiry-participant-resolver";
|
||||
|
||||
function mappedInquiryErrorMessage(value: any): string | undefined {
|
||||
function mappedInquiryErrorMessage(
|
||||
value: any,
|
||||
context: "thirdPartyPlate" | "carBodyPlate",
|
||||
): string | undefined {
|
||||
const message = value?.mapped?.Error?.Message;
|
||||
return typeof message === "string" && message.trim()
|
||||
? message.trim()
|
||||
? getInquiryErrorMessage(value.mapped, context)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
@@ -434,7 +437,7 @@ export class RequestManagementService {
|
||||
!value?.mapped?.Error &&
|
||||
!!value?.mapped?.CompanyName &&
|
||||
isMappedPolicyCurrent(value.mapped),
|
||||
errorMessage: mappedInquiryErrorMessage,
|
||||
errorMessage: (value) => mappedInquiryErrorMessage(value, "thirdPartyPlate"),
|
||||
});
|
||||
return {
|
||||
...result.value,
|
||||
@@ -469,7 +472,7 @@ export class RequestManagementService {
|
||||
value.mapped.CompanyName ||
|
||||
value.mapped.companyId
|
||||
),
|
||||
errorMessage: mappedInquiryErrorMessage,
|
||||
errorMessage: (value) => mappedInquiryErrorMessage(value, "carBodyPlate"),
|
||||
});
|
||||
return {
|
||||
...result.value,
|
||||
@@ -1944,8 +1947,7 @@ export class RequestManagementService {
|
||||
});
|
||||
await this.persistBlameInquiryAudit(req);
|
||||
throw new HttpException(
|
||||
inquiryMapped.Error.Message ||
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyPlate"),
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyPlate"),
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
@@ -2369,8 +2371,7 @@ export class RequestManagementService {
|
||||
});
|
||||
await this.persistBlameInquiryAudit(req);
|
||||
throw new HttpException(
|
||||
inquiryMapped.Error.Message ||
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyVin"),
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyVin"),
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
@@ -6771,8 +6772,7 @@ export class RequestManagementService {
|
||||
|
||||
if (inquiryMapped?.Error) {
|
||||
const error = new BadRequestException(
|
||||
inquiryMapped.Error.Message ||
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyPlate"),
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyPlate"),
|
||||
);
|
||||
this.recordPartyCaseInquiryStatus(
|
||||
req,
|
||||
@@ -7693,8 +7693,7 @@ export class RequestManagementService {
|
||||
|
||||
if (inquiryMapped?.Error) {
|
||||
const error = new BadRequestException(
|
||||
inquiryMapped.Error.Message ||
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyVin"),
|
||||
getInquiryErrorMessage(inquiryMapped, "thirdPartyVin"),
|
||||
);
|
||||
this.recordPartyCaseInquiryStatus(
|
||||
req,
|
||||
|
||||
Reference in New Issue
Block a user