forked from Yara724/api
fix(fanavaran): preserve assessed part ids in hull expertise
Use each saved expert-reply partId as AccessoryKindId and preserve its label. Resolve policy coverage separately so factory-bundle and caption matches cannot overwrite the selected part identity. Add coverage for the six-part expert reply and document the mapping.
This commit is contained in:
@@ -214,7 +214,6 @@ import {
|
||||
import {
|
||||
FANAVARAN_HULL_DMG_COST_KIND_CAPTION,
|
||||
FANAVARAN_HULL_DMG_KIND_CAPTION,
|
||||
findLookupCaptionById,
|
||||
findLookupIdByCaption,
|
||||
findHullFactoryBundleAccessory,
|
||||
asHullDmgAccessoryRows,
|
||||
@@ -2848,6 +2847,7 @@ export class ClaimRequestManagementService {
|
||||
contractOptions,
|
||||
)
|
||||
: Promise.resolve(null),
|
||||
// Validate saved part IDs against the catalogue without remapping them.
|
||||
input.parts.length ? this.getFanavaranLookupRows(input.clientKey, 'car-components', true) : Promise.resolve([]),
|
||||
]);
|
||||
|
||||
@@ -2936,29 +2936,19 @@ export class ClaimRequestManagementService {
|
||||
const factoryBundle = findHullFactoryBundleAccessory(accessories);
|
||||
const hullSections = input.parts.map((part: any, index: number) => {
|
||||
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;
|
||||
// The saved expert reply already identifies the selected catalogue part.
|
||||
const partLabel = this.fanavaranPartLabel(part);
|
||||
const resolved = resolveHullDmgSectionAccessory(
|
||||
accessories,
|
||||
partKindId,
|
||||
partLabel,
|
||||
);
|
||||
// No per-part policy row → cover under «کليه قطعات فابريک» Id (e.g. 3061139).
|
||||
// Use the bundle's own AccessoryKindId (e.g. 112) so Fanavaran receives a
|
||||
// coherent Id/AccessoryKindId pair from the policy row.
|
||||
// Policy coverage is resolved separately from the assessed part identity.
|
||||
let vehicleHullAccessoryId = resolved?.vehicleHullAccessoryId ?? null;
|
||||
let accessoryKindId: number | string | null | undefined =
|
||||
resolved?.accessoryKindId ?? part?.partId;
|
||||
if (!resolved && factoryBundle) {
|
||||
vehicleHullAccessoryId = factoryBundle.vehicleHullAccessoryId;
|
||||
// Replace the unrecognised per-part AccessoryKindId with the bundle's own
|
||||
// kind (e.g. 112 = «کليه قطعات فابريک»). Fanavaran requires Id and
|
||||
// AccessoryKindId to come from the same policy dmg-accessories row.
|
||||
accessoryKindId = factoryBundle.accessoryKindId ?? accessoryKindId;
|
||||
input.infoWarnings.push(
|
||||
`DmgSections[${index}] (${partLabel || part?.partId || 'part'}): AccessoryKindId=${part?.partId ?? '(missing)'} is a fabrique part (no separate policy row); mapped to factory bundle VehicleHullAccessoryId=${factoryBundle.vehicleHullAccessoryId} AccessoryKindId=${accessoryKindId} («کليه قطعات فابريک»).`,
|
||||
`DmgSections[${index}] (${partLabel || part?.partId || 'part'}): AccessoryKindId=${part?.partId ?? '(missing)'} is a fabrique part (no separate policy row); mapped to factory bundle VehicleHullAccessoryId=${factoryBundle.vehicleHullAccessoryId}; preserving AccessoryKindId=${partKindId} («کليه قطعات فابريک»).`,
|
||||
);
|
||||
} else if (!resolved) {
|
||||
input.warnings.push(
|
||||
@@ -2966,7 +2956,7 @@ export class ClaimRequestManagementService {
|
||||
);
|
||||
}
|
||||
return toFanavaranHullExpertiseDmgSection({
|
||||
partId: accessoryKindId,
|
||||
partId: partKindId,
|
||||
desc: partLabel,
|
||||
wasteValue: this.fanavaranDaghiWasteValue(part?.daghi),
|
||||
amount:
|
||||
|
||||
Reference in New Issue
Block a user