done vehicle hull accessories

This commit is contained in:
2026-11-12 15:05:16 +03:30
parent cbdf4fd2bc
commit 7ab6b4c03d
8 changed files with 154 additions and 33 deletions
@@ -213,7 +213,9 @@ import {
import {
FANAVARAN_HULL_DMG_COST_KIND_CAPTION,
FANAVARAN_HULL_DMG_KIND_CAPTION,
findLookupCaptionById,
findLookupIdByCaption,
findHullFactoryBundleAccessory,
asHullDmgAccessoryRows,
resolveHullDmgSectionAccessory,
} from './fanavaran-hull-expertise-lookups';
@@ -2849,20 +2851,35 @@ export class ClaimRequestManagementService {
0,
);
const factoryBundle = findHullFactoryBundleAccessory(accessories);
const hullSections = input.parts.map((part: any, index: number) => {
const partLabel = this.fanavaranPartLabel(part);
const partKindId = parseFanavaranId(part?.partId);
// Prefer live car-components Caption so Desc matches the frontend catalogue.
const catalogueCaption = findLookupCaptionById(componentRows, partKindId);
const localLabel = this.fanavaranPartLabel(part);
const partLabel = catalogueCaption || localLabel;
const resolved = resolveHullDmgSectionAccessory(
accessories,
parseFanavaranId(part?.partId),
partKindId,
partLabel,
);
if (!resolved) {
// No per-part policy row → cover under «کليه قطعات فابريک» Id (e.g. 3061139).
// Keep the selected car-components AccessoryKindId; Desc stays the specific part.
let vehicleHullAccessoryId = resolved?.vehicleHullAccessoryId ?? null;
let accessoryKindId: number | string | null | undefined =
resolved?.accessoryKindId ?? part?.partId;
if (!resolved && factoryBundle) {
vehicleHullAccessoryId = factoryBundle.vehicleHullAccessoryId;
input.warnings.push(
`DmgSections[${index}] (${partLabel || part?.partId || 'part'}): no matching row in policy ${policyId ?? '(missing)'} dmg-accessories for AccessoryKindId=${part?.partId ?? '(missing)'}. Refusing to invent VehicleHullAccessoryId.`,
`DmgSections[${index}] (${partLabel || part?.partId || 'part'}): AccessoryKindId=${part?.partId ?? '(missing)'} is not a separate policy dmg-accessories row; using factory bundle VehicleHullAccessoryId=${factoryBundle.vehicleHullAccessoryId} («کليه قطعات فابريک»).`,
);
} else if (!resolved) {
input.warnings.push(
`DmgSections[${index}] (${partLabel || part?.partId || 'part'}): no matching row in policy ${policyId ?? '(missing)'} dmg-accessories for AccessoryKindId=${part?.partId ?? '(missing)'}. Leaving VehicleHullAccessoryId null.`,
);
}
return toFanavaranHullExpertiseDmgSection({
partId: resolved?.accessoryKindId ?? part?.partId,
partId: accessoryKindId,
desc: partLabel,
wasteValue: this.fanavaranDaghiWasteValue(part?.daghi),
amount:
@@ -2870,7 +2887,7 @@ export class ClaimRequestManagementService {
this.parseFanavaranMoney(part?.salary),
dmgKindId,
dmgCostKindId,
vehicleHullAccessoryId: resolved?.vehicleHullAccessoryId ?? null,
vehicleHullAccessoryId,
});
});