Fixed car body inquiry

This commit is contained in:
SepehrYahyaee
2026-09-07 13:08:23 +03:30
parent 519967855e
commit 7e3b308572
2 changed files with 53 additions and 0 deletions

View File

@@ -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),