forked from Yara724/api
Fixed car body inquiry
This commit is contained in:
@@ -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