import { PartyRole } from "src/request-management/entities/schema/partyRole.enum"; import { hullExpertiseAssertFields, collectFanavaranExpertiseReadinessWarnings, pickHullVehicleIdentity, toFanavaranHullExpertiseDmgSection, toFanavaranHullExpertisePayload, } from "./fanavaran-hull-expertise"; describe("fanavaran hull expertise", () => { it("maps car-body inquiry identity onto GEN.06 vehicle fields", () => { const vehicle = pickHullVehicleIdentity({ parties: [ { role: PartyRole.FIRST, insurance: { carBodyInsurance: { chassisNumber: "NAS431100K1050805", motorNumber: "M136251767", vin: "VIN123", }, }, vehicle: { inquiry: { carBody: { mapped: { platePartOne: "29", plateLetterTitle: "د", platePartThree: "782", plateSerialNumber: "60", builtYear: 1398, }, }, }, }, }, ], }); expect(vehicle).toEqual({ motorNo: "M136251767", chassisNo: "NAS431100K1050805", vin: "VIN123", plaqueNo: "29د782", plaqueSerial: "60", builtYear: 1398, }); }); it("builds a GEN.06 payload without ثالث expertise fields", () => { const payload = toFanavaranHullExpertisePayload({ claimExpertId: 29, dmgAssessmentDate: "1405/06/24", inspectionTime: "10:33", wage: 1000, componentReplacementCost: 2000, wasteValue: 0, dropAmount: 12, vehicleCurrentValue: 1900000000, vehicle: { motorNo: "M1", chassisNo: "C1", vin: null, plaqueNo: "695ط61", plaqueSerial: "87", builtYear: 1398, }, dmgSections: [ toFanavaranHullExpertiseDmgSection({ partId: 9, desc: "bumper", wasteValue: 0, amount: 3000, }), ], }); expect(payload.Wage).toBe(1000); expect(payload.RepairWage).toBeUndefined(); expect(payload.DmgCaseId).toBeUndefined(); expect(payload.InspectionPlaceId).toBeUndefined(); expect(payload.DropAmountStatus).toBeUndefined(); expect(payload.DamagedVehicleCurrentPrice).toBeUndefined(); expect(payload.ClaimExpertId).toBe(29); expect(payload.PlaqueNo).toBe("695ط61"); expect(payload.DmgSections).toEqual([ { Count: 1, Desc: "bumper", WasteValue: 0, AccessoryKindId: 9, DmgKindId: null, VehicleHullAccessoryId: null, DmgSectionCosts: [ { Caption: "bumper", Amount: 3000, DmgCostKindId: null }, ], }, ]); }); it("does not require ثالث expertise fields on a GEN.06 hull payload", () => { const payload = toFanavaranHullExpertisePayload({ claimExpertId: 29, dmgAssessmentDate: "1405/06/24", inspectionTime: "10:41", wage: 6000000, componentReplacementCost: 10000000, wasteValue: 0, dropAmount: 10000, vehicleCurrentValue: null, vehicle: { motorNo: "13389030167", chassisNo: "NAAP41FD5BJ301065", vin: "IRFC891V7D2301065", plaqueNo: "56د394", plaqueSerial: "66", builtYear: 1389, }, dmgSections: [ toFanavaranHullExpertiseDmgSection({ partId: 9, desc: "سپر جلو", wasteValue: 0, amount: 11000000, }), toFanavaranHullExpertiseDmgSection({ partId: 11, desc: "آينه سمت راننده", wasteValue: 0, amount: 5000000, }), ], }); expect( collectFanavaranExpertiseReadinessWarnings( payload, hullExpertiseAssertFields("car-body"), ), ).toEqual([]); expect( collectFanavaranExpertiseReadinessWarnings( payload, hullExpertiseAssertFields("third-party"), ), ).toEqual([ "DmgCaseId is required.", "InspectionPlaceId is required.", "DropAmountStatus is required.", "DmgSections[0].DmgSectionId is required.", "DmgSections[0].AccidentLevel is required.", "DmgSections[1].DmgSectionId is required.", "DmgSections[1].AccidentLevel is required.", ]); }); });