fix(inquiries): route all tenants through ESG and Fanavaran

This commit is contained in:
SepehrYahyaee
2026-11-21 15:27:06 +03:30
parent 61ef4faaf4
commit 1a38b98829
15 changed files with 675 additions and 860 deletions
@@ -33,7 +33,7 @@ describe("car-body coverage when the accident date is collected after inquiry",
it("reselects and stores the earlier renewal for the supplied accident date", async () => {
const { service, party, inquiry } = setup("1401/01/02", "1402/01/02");
inquiry.mockResolvedValue({
source: "ESG_CAR_BODY_INQUIRY",
source: "FANAVARAN_CAR_BODY_INQUIRY",
mapped: {
policyId: 1,
StartDate: "1400/01/01",
@@ -236,7 +236,7 @@ export class InquiryRefreshService {
} else {
await this.waitForRateLimit();
try {
const inquiry = await this.sandHubService.getTejaratBlockInquiry(
const inquiry = await this.sandHubService.getCarByPlateInquiry(
{
plate: {
...plate,
@@ -50,7 +50,7 @@ describe("RequestManagementService policyholder inquiry routing", () => {
it("does not fall back from the current plate for third-party insurance", async () => {
const service = Object.create(RequestManagementService.prototype) as any;
service.sandHubService = {
getTejaratBlockInquiry: jest
getCarByPlateInquiry: jest
.fn()
.mockResolvedValueOnce({ raw: {}, mapped: {} })
.mockResolvedValueOnce({
@@ -67,10 +67,10 @@ describe("RequestManagementService policyholder inquiry routing", () => {
"بیمه‌نامه معتبر و فعالی مطابق مشخصات خودرو و کد ملی واردشده یافت نشد.",
);
expect(service.sandHubService.getTejaratBlockInquiry).toHaveBeenCalledTimes(
expect(service.sandHubService.getCarByPlateInquiry).toHaveBeenCalledTimes(
1,
);
expect(service.sandHubService.getTejaratBlockInquiry).toHaveBeenCalledWith(
expect(service.sandHubService.getCarByPlateInquiry).toHaveBeenCalledWith(
expect.objectContaining({
plate: currentPlate,
nationalCodeOfInsurer: "0022222222",
@@ -82,7 +82,7 @@ describe("RequestManagementService policyholder inquiry routing", () => {
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({
getCarByPlateInquiry: jest.fn().mockResolvedValue({
raw: {
success: false,
error: {
@@ -102,7 +102,7 @@ describe("RequestManagementService policyholder inquiry routing", () => {
await expect(service.getThirdPartyPlateInquiry(submission)).rejects.toThrow(
"بیمه‌نامه شخص ثالثی مطابق پلاک و کد ملی واردشده یافت نشد.",
);
expect(service.sandHubService.getTejaratBlockInquiry).toHaveBeenCalledTimes(
expect(service.sandHubService.getCarByPlateInquiry).toHaveBeenCalledTimes(
1,
);
});
@@ -177,7 +177,7 @@ describe("RequestManagementService policyholder inquiry routing", () => {
});
service.sandHubService = {
getCarBodyInquiry: jest.fn().mockResolvedValue({
source: "ESG_CAR_BODY_VIN_INQUIRY",
source: "FANAVARAN_CAR_BODY_VIN_INQUIRY",
raw: { policyId: 123 },
mapped: {
policyNumber: "BODY-1",
@@ -428,7 +428,7 @@ export class RequestManagementService {
currentPlate: submission.vehicle?.currentPlate ?? submission.dto.plate,
vin: submission.vehicle?.vin,
query: (plate) =>
this.sandHubService.getTejaratBlockInquiry(
this.sandHubService.getCarByPlateInquiry(
{
plate: plate as any,
nationalCodeOfInsurer: subjects.thirdPartyPolicyNationalCode,
@@ -2302,7 +2302,7 @@ export class RequestManagementService {
* 2. Personal identity inquiry (same as the plate path)
*
* The inquiry result is mapped through the same `mapEsgPolicyByPlateToOldFormat`
* normaliser used by `getTejaratBlockInquiry`, so all downstream party/vehicle
* normaliser used by `getCarByPlateInquiry`, so all downstream party/vehicle
* /insurance field assignments are identical.
*/
async initialFormVinV2(
@@ -7608,7 +7608,7 @@ export class RequestManagementService {
/**
* VIN variant of `runInquiriesV3`.
* Identical flow, but calls the two-factor `getCarByChassisInquiry` instead of
* `getTejaratBlockInquiry` for the primary policy lookup.
* `getCarByPlateInquiry` for the primary policy lookup.
*/
async runInquiriesVinV3(
requestId: string,
@@ -7751,7 +7751,7 @@ export class RequestManagementService {
/**
* VIN variant of `runPartyInquiriesV3Internal`.
* Calls `getCarByChassisInquiry` (ESG two-factor chassis lookup) instead of
* `getTejaratBlockInquiry` (plate-based). All other inquiries (personal,
* `getCarByPlateInquiry` (plate-based). All other inquiries (personal,
* driving licence, car-body for CAR_BODY) are unchanged.
*/
private async runPartyInquiriesVinV3Internal(