fix(car-body): validate policy coverage on accident date

Validate hull coverage against the accident date, select the covering renewal, and defer validation until that date is collected.
This commit is contained in:
2026-11-21 12:04:09 +03:30
parent 8f15040080
commit 5c6e21dd14
13 changed files with 499 additions and 56 deletions
+18 -1
View File
@@ -1,5 +1,8 @@
import { jalaliToGregorianDate } from "src/helpers/date-jalali";
import { gregorianDateInIran } from "src/helpers/iran-datetime";
import {
gregorianDateInIran,
parseIranLocalDateTime,
} from "src/helpers/iran-datetime";
import { normalizePlateText } from "src/utils/plate-normalizer/plate-normalizer.service";
export const FANAVARAN_THIRD_PARTY_LINE_ID = 5;
@@ -222,6 +225,20 @@ export function toGregorianDate(value: unknown): string | null {
return jalaliToGregorianDate(toEnglishDigits(value).trim() || null);
}
/** Accident calendar date; timestamps are interpreted in Iran, like claim dates. */
export function policyAccidentDate(value: unknown): string | null {
if (value instanceof Date) {
return Number.isNaN(value.getTime()) ? null : gregorianDateInIran(value);
}
const raw = toEnglishDigits(value).trim();
if (!raw) return null;
if (/^\d{4}-\d{2}-\d{2}T/.test(raw)) {
const date = parseIranLocalDateTime(raw);
return date ? gregorianDateInIran(date) : null;
}
return toGregorianDate(raw);
}
export function pickVehicleVin(vehicle: Record<string, unknown> | null): string {
if (!vehicle) return "";
for (const key of ["VIN", "Vin", "VinNo", "vin", "ChassisNo", "chassisNo"]) {