Map Fanavaran people and licences by party role; allow unlisted base-info lookups.

Resolve driver, owner, and policyholder from participants when they differ, prefer real licence / driverLicenseDate over dummies, and fall back unknown /lookups/fanavaran/{name} to car/base-info/{name} (including vehicle-groups).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-26 16:42:21 +03:30
parent 4f8fe04380
commit fc1c117b93
9 changed files with 590 additions and 44 deletions

View File

@@ -7,6 +7,7 @@ import {
parseFanavaranId,
type FanavaranCarPolicyProduct,
} from "src/lookups/fanavaran-last-car-policy";
import { resolvePolicyholderFromParty } from "./fanavaran-party-roles";
export type FanavaranClaimProduct = FanavaranCarPolicyProduct;
@@ -101,6 +102,8 @@ export function fanavaranInsuranceLineIdForProduct(
type BlamePartyForCarBodyPolicy = {
role?: string;
person?: { nationalCodeOfInsurer?: unknown };
participants?: Array<Record<string, any>>;
participantRoles?: Record<string, string | undefined>;
insurance?: {
carBodyInsurance?: {
policyId?: unknown;
@@ -168,6 +171,7 @@ export function pickCarBodyPolicyNationalCode(
): string | null {
const party = firstCarBodyParty(blame);
return (
resolvePolicyholderFromParty(party, "car-body").nationalCode ??
nonEmptyText(party?.person?.nationalCodeOfInsurer) ??
nonEmptyText(party?.insurance?.carBodyInsurance?.ownerNationalCode) ??
nonEmptyText(party?.insurance?.carBodyInsurance?.insurerNationalCode)