fix: harden claim review and inquiry workflows

Preserve damage history and current vehicle price, restore depreciation mapping, normalize inquiry/report output, and support resumable expert review with paginated case retrieval.
This commit is contained in:
2026-09-18 16:04:33 +03:30
parent a84d83a135
commit 7d1a50db7b
38 changed files with 2345 additions and 370 deletions
+36
View File
@@ -110,12 +110,42 @@ for (const [seg, key] of Object.entries(SEGMENT_ALIASES)) {
NORM_TO_PART_KEY.set(seg, key);
}
const PERSIAN_LABEL_ALIASES: Array<[string, string]> = [
["گلگیر عقب", "backFender"],
["درب عقب", "backDoor"],
["درب جلو", "frontDoor"],
["گلگیر جلو", "frontFender"],
["سپر جلو", "frontBumper"],
["سپر عقب", "frontBumper"],
["درب موتور", "Hood"],
["کاپوت", "Hood"],
["درب صندوق", "Trunk"],
["صندوق عقب", "Trunk"],
["سقف", "Roof"],
["کلاف", "coil"],
["ستون", "column"],
["سینی جلو", "frontTray"],
["سینی عقب", "backTray"],
["شاسی جلو", "frontChassis"],
["شاسی عقب", "backChassis"],
["رکاب", "carFootrest"],
["کف اتاق", "carFloor"],
];
export function normalizePriceDropKey(str: string): string {
return String(str ?? "")
.toLowerCase()
.replace(/[^a-z0-9]/g, "");
}
function normalizePersianLabel(str: string): string {
return String(str ?? "")
.replace(/[يى]/g, "ی")
.replace(/ك/g, "ک")
.replace(/[\u200c\s()\-_]/g, "")
.trim();
}
export function parsePriceDropNumber(input: number | string): number {
if (typeof input === "number" && Number.isFinite(input)) return input;
return Number(
@@ -191,6 +221,7 @@ export function buildPriceDropCatalogForApi(): Array<{
export function resolvePriceDropPartKeyFromDamagePart(part: {
name?: string;
catalogKey?: string;
label_fa?: string;
}): string | null {
const candidates: string[] = [];
if (part.catalogKey) {
@@ -205,6 +236,11 @@ export function resolvePriceDropPartKeyFromDamagePart(part: {
const hit = NORM_TO_PART_KEY.get(norm);
if (hit && PRICE_DROP_PART_TABLE[hit]) return hit;
}
const normalizedLabel = normalizePersianLabel(part.label_fa ?? part.name ?? "");
for (const [label, key] of PERSIAN_LABEL_ALIASES) {
if (normalizedLabel.includes(normalizePersianLabel(label))) return key;
}
return null;
}