forked from Yara724/api
Fixed car body inquiry
This commit is contained in:
@@ -135,6 +135,45 @@ describe("LookupsService.findLastProcessedCarPolicy", () => {
|
||||
expect(lookup.inquiryByVin).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects an expired car-body policy instead of treating it as active coverage", async () => {
|
||||
const lookup = {
|
||||
myPolicies: jest.fn().mockResolvedValue([
|
||||
{
|
||||
PolicyId: 44,
|
||||
InsuranceLineId: 4,
|
||||
BeginDate: "1400/01/01",
|
||||
EndDate: "1401/01/01",
|
||||
},
|
||||
]),
|
||||
inquiryByVin: jest.fn(),
|
||||
bodyPolicyById: jest.fn().mockResolvedValue({
|
||||
PolicyId: 44,
|
||||
VehicleId: 8,
|
||||
BeginDate: "1400/01/01",
|
||||
EndDate: "1401/01/01",
|
||||
}),
|
||||
vehicleById: jest.fn().mockResolvedValue({
|
||||
Id: 8,
|
||||
PlaqueLeftNo: "12",
|
||||
PlaqueMiddleCodeId: 2,
|
||||
PlaqueRightNo: "345",
|
||||
PlaqueSerial: "67",
|
||||
}),
|
||||
getRemoteLookup: jest.fn().mockResolvedValue([]),
|
||||
customerById: jest.fn().mockResolvedValue(null),
|
||||
};
|
||||
|
||||
await expect(
|
||||
createService(lookup).findLastProcessedCarPolicy("car-body", {
|
||||
nationalCode: "0012345678",
|
||||
plaqueLeft: "12",
|
||||
plaqueLetter: "ب",
|
||||
plaqueRight: "345",
|
||||
plaqueSerial: "67",
|
||||
}),
|
||||
).rejects.toBeInstanceOf(NotFoundException);
|
||||
});
|
||||
|
||||
it("accepts the policy when VIN inquiry VehicleId matches and GEN.15 VIN is empty", async () => {
|
||||
const lookup = {
|
||||
myPolicies: jest.fn().mockResolvedValue([
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
filterPoliciesByLine,
|
||||
insuranceLineIdForProduct,
|
||||
insuranceLineLabel,
|
||||
isPolicyActiveOn,
|
||||
parseFanavaranId,
|
||||
parseLastCarPolicyInput,
|
||||
pickVehicleId,
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
type FanavaranCarPolicyProduct,
|
||||
type HydratedFanavaranCarPolicy,
|
||||
} from "./fanavaran-last-car-policy";
|
||||
import { gregorianDateInIran } from "src/helpers/iran-datetime";
|
||||
|
||||
type TejaratAccidentReasonRow = {
|
||||
id: number;
|
||||
@@ -357,6 +359,18 @@ export class LookupsService {
|
||||
);
|
||||
}
|
||||
|
||||
// A CAR_BODY case is payable only with current hull coverage. The generic
|
||||
// selector may intentionally return the latest expired policy for history;
|
||||
// that fallback is not valid for a new CAR_BODY case.
|
||||
if (
|
||||
product === "car-body" &&
|
||||
!isPolicyActiveOn(selected, gregorianDateInIran(new Date()))
|
||||
) {
|
||||
throw new NotFoundException(
|
||||
"No active Fanavaran car-body policy was found for this car.",
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
product,
|
||||
insuranceLine: insuranceLineLabel(insuranceLineId),
|
||||
|
||||
Reference in New Issue
Block a user