1
0
forked from Yara724/api

Fixed company code error not found

This commit is contained in:
SepehrYahyaee
2026-05-30 15:01:53 +03:30
parent da298a3350
commit d6f1cb9eeb
5 changed files with 60 additions and 5 deletions

View File

@@ -3850,7 +3850,7 @@ export class ExpertClaimService {
};
}
// Build damaged parts list (aligned with normalized selected parts)
// Build damaged parts list (aligned with normalized selected parts and enriched with evaluation context)
const carTypeExpert = claim.vehicle?.carType as
| ClaimVehicleTypeV2
| undefined;
@@ -3860,6 +3860,13 @@ export class ExpertClaimService {
(claim.damage as any)?.selectedOuterParts,
);
const damagedPartsDataExpert = claim.media?.damagedParts as any;
// Extract optimization lookups from the DB document safely
const evaluationBlock = (claim as any).evaluation;
const priceDropLines = evaluationBlock?.priceDrop?.partLines || [];
const objectionParts = evaluationBlock?.objection?.objectionParts || [];
const newObjectionParts = evaluationBlock?.objection?.newParts || [];
const damagedParts = selectedNormExpert.map((sp, index) => {
const ck = sp.catalogKey ?? catalogLikeKeyFromPart(sp);
const cap = getDamagedPartCaptureBlob(
@@ -3867,6 +3874,22 @@ export class ExpertClaimService {
ck,
selectedNormExpert,
) as { url?: string; path?: string } | undefined;
// 1. Cross-reference Price Drop items via partId or name match
const matchingPriceDrop = priceDropLines.find(
(line: any) =>
line.partId === sp.id ||
line.priceDropPartKey?.toLowerCase() === sp.name?.toLowerCase(),
);
// 2. Evaluate if this specific part is flag-linked within an active user objection
const isObjected = objectionParts.some(
(objPart: any) => objPart.id === sp.id || objPart.name === sp.name,
);
const isNewAddedPart = newObjectionParts.some(
(newPart: any) => newPart.id === sp.id || newPart.name === sp.name,
);
return {
index,
partId: catalogPartIdFromSelectedPart(sp),
@@ -3880,6 +3903,15 @@ export class ExpertClaimService {
selectedNormExpert,
),
url: cap?.url || (cap?.path ? buildFileLink(cap.path) : undefined),
// --- Added Consolidated Production Enrichments ---
severity: matchingPriceDrop ? matchingPriceDrop.severity : null,
coefficient: matchingPriceDrop ? matchingPriceDrop.coefficient : null,
objectionStatus: {
hasObjection: isObjected,
isNewlyAddedByObjection: isNewAddedPart,
// You can map extra parameters here if the front-end requires reason texts
},
};
});