third party update , optional body is done

This commit is contained in:
2026-09-15 16:36:13 +03:30
parent 073b4dec38
commit 0b0a1dfa13
6 changed files with 386 additions and 182 deletions

View File

@@ -387,6 +387,89 @@ export function canReuseCachedFanavaranVehicleIds(source: unknown): boolean {
return source === "vehicle-inquiry" || source === "vin-inquiry" || source === "vehicle-get";
}
/** Proven Parsian national (چهار تکه) plaque codebook ids. */
export const FANAVARAN_NATIONAL_PLAQUE_KIND_ID = 8;
export const FANAVARAN_NATIONAL_PLAQUE_SAMPLE_ID = 10;
export const FANAVARAN_DAMAGE_MANUAL_OVERRIDE_KEYS = [
"Desc",
"EstimateAmount",
"LicenceNo",
"LicenceIssuDate",
"DriverIsOwner",
] as const;
export const FANAVARAN_EXPERTISE_MANUAL_OVERRIDE_KEYS = [
"RepairWage",
"ComponentReplacementCost",
"WasteValue",
"DmgAssessmentDate",
"InspectionTime",
"DamagedVehicleCurrentPrice",
"DropAmountAdditionsDeductions",
] as const;
export const FANAVARAN_BASE_MANUAL_OVERRIDE_KEYS = [
"EstimateAmount",
"CulpritLicenceNo",
"CulpritLicenceIssuDate",
"AccidentLocationAddress",
"AccidentDate",
"AnnouncementDate",
"DocReceivedDate",
"AccidentTime",
"PoliceReportDesc",
"PoliceReportSeri",
"PoliceReportSerial",
] as const;
/**
* Swagger POST body is optional user-entry tweaks only.
* Inquiry / lookup-filter ids always come from the live rebuilt payload.
*/
export function applyFanavaranManualPayloadOverrides(
built: Record<string, unknown>,
body: Record<string, unknown> | null | undefined,
keys: readonly string[],
): Record<string, unknown> {
if (!body) return built;
const next = { ...built };
for (const key of keys) {
if (!Object.prototype.hasOwnProperty.call(body, key)) continue;
if (body[key] === undefined) continue;
next[key] = body[key];
}
return next;
}
/**
* Plaque kind/sample only from a matched Fanavaran vehicle record.
* CII/ESG inquiry, unsourced cache, and tenant defaults of 15 must not win.
* National 4-part plates fall back to 8/10 (lookup-filter safe on Parsian).
*/
export function resolveDamageCasePlaqueLookupIds(matchedVehicle: Record<
string,
unknown
> | null): {
kindId: number;
sampleId: number;
source: "vehicle-inquiry" | "national-plate-default";
} {
const plaque = pickFanavaranPlaqueLookupFields(matchedVehicle);
if (plaque.kindId != null) {
return {
kindId: plaque.kindId,
sampleId: plaque.sampleId ?? FANAVARAN_NATIONAL_PLAQUE_SAMPLE_ID,
source: "vehicle-inquiry",
};
}
return {
kindId: FANAVARAN_NATIONAL_PLAQUE_KIND_ID,
sampleId: FANAVARAN_NATIONAL_PLAQUE_SAMPLE_ID,
source: "national-plate-default",
};
}
/**
* Pick the VIN-inquiry / vehicle-GET row that is the damaged car.
* Newest VersionNo wins among matches; PlaqueKindId is a tie-break only.