forked from Yara724/api
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:
@@ -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"]) {
|
||||
|
||||
Reference in New Issue
Block a user