forked from Yara724/api
fix(fanavaran): resolve hull expertise policy from stored inquiry
Reuse the insured vehicle hull inquiry policy when saved base-claim policy metadata is absent. This lets expertise resolve policy accessories and factory coverage before stage 1 has been persisted. Add a regression test for the missing-cache case.
This commit is contained in:
@@ -2842,7 +2842,11 @@ export class ClaimRequestManagementService {
|
|||||||
infoWarnings: string[];
|
infoWarnings: string[];
|
||||||
replyKey?: string;
|
replyKey?: string;
|
||||||
}> {
|
}> {
|
||||||
const policyId = this.parseHullClaimPolicyId(input.claimCase);
|
// Expertise preview may run before a base-claim payload has been saved.
|
||||||
|
// Reuse the insured vehicle's hull inquiry policy, as stage 1 does.
|
||||||
|
const policyId =
|
||||||
|
this.parseHullClaimPolicyId(input.claimCase) ??
|
||||||
|
pickStoredCarBodyPolicyId(input.blame);
|
||||||
const contractOptions = {
|
const contractOptions = {
|
||||||
contractIdOverride: resolveFanavaranProductContractId(
|
contractIdOverride: resolveFanavaranProductContractId(
|
||||||
input.clientKey,
|
input.clientKey,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function setup(accessories: unknown) {
|
|||||||
"vehicle-hull-dmg-cost-kinds": [
|
"vehicle-hull-dmg-cost-kinds": [
|
||||||
{ Id: 8002, Caption: "مجموع لوازم", IsActive: 1 },
|
{ Id: 8002, Caption: "مجموع لوازم", IsActive: 1 },
|
||||||
],
|
],
|
||||||
"car-components": [9, 13, 112, 10, 48, 76, 29, 100, 37].map(Id => ({ Id })),
|
"car-components": [1, 9, 13, 112, 10, 48, 76, 29, 100, 37].map(Id => ({ Id })),
|
||||||
})[name] ?? [],
|
})[name] ?? [],
|
||||||
);
|
);
|
||||||
service.fanavaranLookupService = {
|
service.fanavaranLookupService = {
|
||||||
@@ -25,11 +25,12 @@ function setup(accessories: unknown) {
|
|||||||
{ partId: 9, partName: "سپر جلو", price: 50000000, salary: 25000000 },
|
{ partId: 9, partName: "سپر جلو", price: 50000000, salary: 25000000 },
|
||||||
{ partId: 13, partName: "چراغ جلو چپ", price: 0, salary: 2000000 },
|
{ partId: 13, partName: "چراغ جلو چپ", price: 0, salary: 2000000 },
|
||||||
],
|
],
|
||||||
|
context: { claimCase?: any; blame?: any } = {},
|
||||||
) =>
|
) =>
|
||||||
service.buildCarBodyFanavaranExpertisePayload({
|
service.buildCarBodyFanavaranExpertisePayload({
|
||||||
clientKey: "parsian",
|
clientKey: "parsian",
|
||||||
claimCase: { fanavaranSync: { baseClaim: { policyId } } },
|
claimCase: context.claimCase ?? { fanavaranSync: { baseClaim: { policyId } } },
|
||||||
blame: { parties: [] },
|
blame: context.blame ?? { parties: [] },
|
||||||
profile: {},
|
profile: {},
|
||||||
parts,
|
parts,
|
||||||
claimExpertId: 4044,
|
claimExpertId: 4044,
|
||||||
@@ -43,6 +44,30 @@ function setup(accessories: unknown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("hull expertise policy accessory mapping", () => {
|
describe("hull expertise policy accessory mapping", () => {
|
||||||
|
it("uses the hull inquiry policy when stage-1 policy metadata is absent", async () => {
|
||||||
|
const { service, build } = setup([
|
||||||
|
{ Id: 2598601, AccessoryKindId: 92, AccessoryDesc: "پايونير 1650" },
|
||||||
|
{ Id: 2598602, AccessoryKindId: 93, AccessoryDesc: "غير فابريک" },
|
||||||
|
{ Id: 3043330, AccessoryKindId: 112, AccessoryDesc: "کليه قطعات فابريک" },
|
||||||
|
]);
|
||||||
|
const { payload, warnings } = await build(null, [
|
||||||
|
{ partId: 1, partName: "جلو کامل", salary: 10000000 },
|
||||||
|
], {
|
||||||
|
claimCase: {},
|
||||||
|
blame: {
|
||||||
|
parties: [{ role: "FIRST", insurance: { carBodyInsurance: { policyId: 13764610 } } }],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(payload.DmgSections[0]).toMatchObject({
|
||||||
|
AccessoryKindId: 1,
|
||||||
|
VehicleHullAccessoryId: 3043330,
|
||||||
|
});
|
||||||
|
expect(warnings).toEqual([]);
|
||||||
|
expect(service.fanavaranLookupService.vehicleHullDmgAccessoriesByPolicyId)
|
||||||
|
.toHaveBeenCalledWith("parsian", 13764610, expect.any(Object));
|
||||||
|
});
|
||||||
|
|
||||||
it("uses the current policy accessory IDs for the bumper and headlamp", async () => {
|
it("uses the current policy accessory IDs for the bumper and headlamp", async () => {
|
||||||
const { service, build } = setup([
|
const { service, build } = setup([
|
||||||
{ Id: 900001, AccessoryKindId: 9, AccessoryDesc: "سپر جلو" },
|
{ Id: 900001, AccessoryKindId: 9, AccessoryDesc: "سپر جلو" },
|
||||||
|
|||||||
Reference in New Issue
Block a user