Merge pull request 'YARA-1267, YARA-1268' (#302) from s.yahyaee/yara724-api:main into main

Reviewed-on: Yara724/api#302
This commit is contained in:
2026-09-08 14:53:15 +03:30
3 changed files with 60 additions and 24 deletions

View File

@@ -481,12 +481,17 @@ export class ClaimRequestManagementController {
);
}
// @ApiOperation({ deprecated: true })
@Get("branches/:insuranceId")
// @ApiParam({ name: "insuranceId" })
async insuranceBranches(@Param("insuranceId") insuranceId: string) {
return await this.claimRequestManagementService.retrieveInsuranceBranches(insuranceId);
}
// Legacy V1 owner branch picker — intentionally disabled.
// A claim is handled by an expert assigned to the insurer branch, so the
// owner must not choose an insurer branch while signing. This does not apply
// to the separate expert-only `daghi.branchId` choice in pricing flows.
//
// @Get("branches/:insuranceId")
// async insuranceBranches(@Param("insuranceId") insuranceId: string) {
// return await this.claimRequestManagementService.retrieveInsuranceBranches(
// insuranceId,
// );
// }
// @ApiOperation({ deprecated: true })
@Get("fanavaran-submit/:claimRequestId")

View File

@@ -184,6 +184,11 @@ describe("SandHubService inquiry mocks", () => {
it("does not accept a policy when CLIENT_ID is not configured", async () => {
delete process.env.CLIENT_ID;
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
jest.spyOn(service, "getTejaratCarBodyInquiry").mockResolvedValue({
raw: { data: { companyId: "15" } },
mapped: { companyId: "15", CompanyCode: "15" },
});
await expect(service.getCarBodyInquiry(userDetail)).rejects.toBeInstanceOf(
ServiceUnavailableException,
@@ -207,6 +212,7 @@ describe("SandHubService inquiry mocks", () => {
it("rejects a CAR_BODY policy from another insurer on the Tejarat lookup route", async () => {
process.env.CLIENT_ID = "15";
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
jest.spyOn(service, "getTejaratCarBodyInquiry").mockResolvedValue({
raw: { data: { companyId: "8" } },
mapped: { companyId: "8", CompanyCode: "8" },
@@ -217,6 +223,24 @@ describe("SandHubService inquiry mocks", () => {
);
});
it("accepts a mocked Parsian CAR_BODY inquiry for the deployment client", async () => {
process.env.CLIENT_ID = "15";
process.env.FANAVARAN_CLIENT = "parsian";
externalInquirySettings.isInquiryLive.mockResolvedValue(false);
externalInquirySettings.getMockCompanyContext.mockResolvedValue({
companyId: "15",
companyName: "بیمه سامان",
});
await expect(service.getCarBodyInquiry(userDetail)).resolves.toEqual(
expect.objectContaining({
source: "ESG_CAR_BODY_INQUIRY",
mapped: expect.objectContaining({ companyId: 15 }),
}),
);
expect(lookupsService.findLastProcessedCarPolicy).not.toHaveBeenCalled();
});
it("uses the processed CAR_BODY lookup when the active Fanavaran client is Parsian", async () => {
process.env.FANAVARAN_CLIENT = "parsian";
externalInquirySettings.isInquiryLive.mockResolvedValue(true);

View File

@@ -931,7 +931,31 @@ export class SandHubService {
raw: any;
mapped: Record<string, unknown>;
}> {
if (!this.shouldUseParsianCarBodyLookup()) {
const useParsianCarBodyLookup = this.shouldUseParsianCarBodyLookup();
const live = await this.isInquiryLive("carBodyPlate", options);
if (!live) {
// Mock results are generated for the active deployment. They must not be
// treated as evidence of a real insurer and therefore do not go through
// the live-policy insurer gate.
const result = await this.getTejaratCarBodyInquiry(
userDetail as SandHubDetailDto,
options,
);
return {
source:
typeof userDetail.plate === "string"
? useParsianCarBodyLookup
? "ESG_CAR_BODY_VIN_INQUIRY"
: "TEJARAT_CAR_BODY_VIN_INQUIRY"
: useParsianCarBodyLookup
? "ESG_CAR_BODY_INQUIRY"
: "TEJARAT_CAR_BODY_INQUIRY",
...result,
};
}
if (!useParsianCarBodyLookup) {
const result = await this.getTejaratCarBodyInquiry(
userDetail as SandHubDetailDto,
options,
@@ -946,23 +970,6 @@ export class SandHubService {
};
}
const live = await this.isInquiryLive("carBodyPlate", options);
if (!live) {
// Reuse the established local mock contract without sending an HTTP request.
const result = await this.getTejaratCarBodyInquiry(
userDetail as SandHubDetailDto,
options,
);
this.assertParsianCarBodyLookupMatchesDeployment();
return {
source:
typeof userDetail.plate === "string"
? "ESG_CAR_BODY_VIN_INQUIRY"
: "ESG_CAR_BODY_INQUIRY",
...result,
};
}
const plateOrVin = userDetail.plate;
const query =
typeof plateOrVin === "string"