forked from Yara724/api
update the lookups list
This commit is contained in:
@@ -233,6 +233,71 @@ export function pickVehicleId(source: unknown): number | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Prefer the inquiry row whose Id matches the policy VehicleId. */
|
||||
export function pickFanavaranVehicleFromInquiry(
|
||||
inquired: unknown,
|
||||
vehicleId?: number | null,
|
||||
): Record<string, unknown> | null {
|
||||
if (Array.isArray(inquired)) {
|
||||
if (vehicleId != null) {
|
||||
const match = inquired.find((row) => pickVehicleId(row) === vehicleId);
|
||||
if (match) return asObjectRecord(match);
|
||||
}
|
||||
return asObjectRecord(inquired[0]);
|
||||
}
|
||||
return asObjectRecord(inquired);
|
||||
}
|
||||
|
||||
export function pickVinFromPartyVehicle(party: {
|
||||
vehicle?: { vin?: unknown; inquiry?: unknown };
|
||||
} | null | undefined): string | null {
|
||||
const direct = normalizeVin(party?.vehicle?.vin);
|
||||
if (direct) return direct;
|
||||
|
||||
const inquiry = party?.vehicle?.inquiry;
|
||||
const nested = asObjectRecord(inquiry);
|
||||
const mapped = pickVehicleVin(asObjectRecord(nested?.mapped));
|
||||
if (mapped) return mapped;
|
||||
const raw = pickVehicleVin(asObjectRecord(nested?.raw ?? inquiry));
|
||||
return raw || null;
|
||||
}
|
||||
|
||||
export type FanavaranPlaqueLookupFields = {
|
||||
kindId: number | null;
|
||||
sampleId: number | null;
|
||||
cityId: number | null;
|
||||
leftNo: string | null;
|
||||
middleCodeId: number | null;
|
||||
rightNo: string | null;
|
||||
serial: string | null;
|
||||
plaqueNo: string | null;
|
||||
};
|
||||
|
||||
function asPlaqueText(value: unknown): string | null {
|
||||
const text = normalizePlaquePart(value);
|
||||
return text || null;
|
||||
}
|
||||
|
||||
/** Plaque lookup-filter fields from VIN inquiry / vehicle GET. */
|
||||
export function pickFanavaranPlaqueLookupFields(
|
||||
vehicle: Record<string, unknown> | null,
|
||||
): FanavaranPlaqueLookupFields {
|
||||
return {
|
||||
kindId: parseFanavaranId(vehicle?.PlaqueKindId ?? vehicle?.plaqueKindId),
|
||||
sampleId: parseFanavaranId(
|
||||
vehicle?.PlaqueSampleId ?? vehicle?.plaqueSampleId,
|
||||
),
|
||||
cityId: parseFanavaranId(vehicle?.PlaqueCityId ?? vehicle?.plaqueCityId),
|
||||
leftNo: asPlaqueText(vehicle?.PlaqueLeftNo ?? vehicle?.plaqueLeftNo),
|
||||
middleCodeId: parseFanavaranId(
|
||||
vehicle?.PlaqueMiddleCodeId ?? vehicle?.plaqueMiddleCodeId,
|
||||
),
|
||||
rightNo: asPlaqueText(vehicle?.PlaqueRightNo ?? vehicle?.plaqueRightNo),
|
||||
serial: asPlaqueText(vehicle?.PlaqueSerial ?? vehicle?.plaqueSerial),
|
||||
plaqueNo: asPlaqueText(vehicle?.PlaqueNo ?? vehicle?.plaqueNo),
|
||||
};
|
||||
}
|
||||
|
||||
function plaqueNumberEquals(left: unknown, right: unknown): boolean {
|
||||
const a = normalizePlaquePart(left);
|
||||
const b = normalizePlaquePart(right);
|
||||
|
||||
Reference in New Issue
Block a user