warnings are just info warning now

This commit is contained in:
2026-11-12 16:24:53 +03:30
parent 7ab6b4c03d
commit 457fd0b174
2 changed files with 43 additions and 7 deletions
@@ -2738,10 +2738,13 @@ export class ClaimRequestManagementService {
priceDropTotal: number; priceDropTotal: number;
priceDropCarPrice: unknown; priceDropCarPrice: unknown;
warnings: string[]; warnings: string[];
/** Non-blocking notices (factory-bundle fallbacks). Never gates submission. */
infoWarnings: string[];
replyKey?: string; replyKey?: string;
}): Promise<{ }): Promise<{
payload: Record<string, unknown>; payload: Record<string, unknown>;
warnings: string[]; warnings: string[];
infoWarnings: string[];
replyKey?: string; replyKey?: string;
}> { }> {
const policyId = this.parseHullClaimPolicyId(input.claimCase); const policyId = this.parseHullClaimPolicyId(input.claimCase);
@@ -2864,14 +2867,19 @@ export class ClaimRequestManagementService {
partLabel, partLabel,
); );
// No per-part policy row → cover under «کليه قطعات فابريک» Id (e.g. 3061139). // No per-part policy row → cover under «کليه قطعات فابريک» Id (e.g. 3061139).
// Keep the selected car-components AccessoryKindId; Desc stays the specific part. // Use the bundle's own AccessoryKindId (e.g. 112) so Fanavaran receives a
// coherent Id/AccessoryKindId pair from the policy row.
let vehicleHullAccessoryId = resolved?.vehicleHullAccessoryId ?? null; let vehicleHullAccessoryId = resolved?.vehicleHullAccessoryId ?? null;
let accessoryKindId: number | string | null | undefined = let accessoryKindId: number | string | null | undefined =
resolved?.accessoryKindId ?? part?.partId; resolved?.accessoryKindId ?? part?.partId;
if (!resolved && factoryBundle) { if (!resolved && factoryBundle) {
vehicleHullAccessoryId = factoryBundle.vehicleHullAccessoryId; vehicleHullAccessoryId = factoryBundle.vehicleHullAccessoryId;
input.warnings.push( // Replace the unrecognised per-part AccessoryKindId with the bundle's own
`DmgSections[${index}] (${partLabel || part?.partId || 'part'}): AccessoryKindId=${part?.partId ?? '(missing)'} is not a separate policy dmg-accessories row; using factory bundle VehicleHullAccessoryId=${factoryBundle.vehicleHullAccessoryId} («کليه قطعات فابريک»).`, // 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} («کليه قطعات فابريک»).`,
); );
} else if (!resolved) { } else if (!resolved) {
input.warnings.push( input.warnings.push(
@@ -2927,6 +2935,7 @@ export class ClaimRequestManagementService {
return { return {
replyKey: input.replyKey, replyKey: input.replyKey,
warnings: input.warnings, warnings: input.warnings,
infoWarnings: input.infoWarnings,
payload, payload,
}; };
} }
@@ -6123,6 +6132,7 @@ export class ClaimRequestManagementService {
}): Promise<{ }): Promise<{
payload: Record<string, unknown>; payload: Record<string, unknown>;
warnings: string[]; warnings: string[];
infoWarnings: string[];
replyKey?: string; replyKey?: string;
}> { }> {
const profile = getFanavaranClientProfile(input.clientKey); const profile = getFanavaranClientProfile(input.clientKey);
@@ -6137,6 +6147,7 @@ export class ClaimRequestManagementService {
// GEN.08 / GEN.06 ClaimExpertId always from assigned assessor staff profile. // GEN.08 / GEN.06 ClaimExpertId always from assigned assessor staff profile.
const warnings: string[] = []; const warnings: string[] = [];
const infoWarnings: string[] = [];
let claimExpertId: number | null = null; let claimExpertId: number | null = null;
if (!blameForExpertIds) { if (!blameForExpertIds) {
const message = const message =
@@ -6198,7 +6209,7 @@ export class ClaimRequestManagementService {
clientKey: input.clientKey, claimCase: input.claimCase, clientKey: input.clientKey, claimCase: input.claimCase,
blame: blameForExpertIds, profile, parts, claimExpertId, blame: blameForExpertIds, profile, parts, claimExpertId,
submittedAt, priceDropTotal, priceDropCarPrice: priceDrop?.carPrice, submittedAt, priceDropTotal, priceDropCarPrice: priceDrop?.carPrice,
warnings, replyKey: active?.replyKey, warnings, infoWarnings, replyKey: active?.replyKey,
}); });
} }
@@ -6251,6 +6262,7 @@ export class ClaimRequestManagementService {
return { return {
replyKey: active?.replyKey, replyKey: active?.replyKey,
warnings, warnings,
infoWarnings,
payload, payload,
}; };
} }
@@ -6283,7 +6295,7 @@ export class ClaimRequestManagementService {
const claimCase = await this.claimCaseDbService.findById(claimCaseId); const claimCase = await this.claimCaseDbService.findById(claimCaseId);
if (!claimCase) throw new NotFoundException('Claim case not found'); if (!claimCase) throw new NotFoundException('Claim case not found');
const { payload, warnings, replyKey } = const { payload, warnings, infoWarnings, replyKey } =
await this.buildFanavaranExpertisePayload({ await this.buildFanavaranExpertisePayload({
claimCase, claimCase,
clientKey, clientKey,
@@ -6312,6 +6324,7 @@ export class ClaimRequestManagementService {
: null, : null,
ready: warnings.length === 0 && payload.ClaimExpertId != null, ready: warnings.length === 0 && payload.ClaimExpertId != null,
warnings: Array.from(new Set(warnings)), warnings: Array.from(new Set(warnings)),
infoWarnings: Array.from(new Set(infoWarnings)),
payload, payload,
}; };
} }
@@ -6426,12 +6439,16 @@ export class ClaimRequestManagementService {
this.assertFanavaranExpertisePayloadReady(payload, built.warnings, { this.assertFanavaranExpertisePayloadReady(payload, built.warnings, {
...hullExpertiseAssertFields(product), ...hullExpertiseAssertFields(product),
}); });
return await this.executeFanavaranExpertiseSubmit( const result = await this.executeFanavaranExpertiseSubmit(
claimCaseId, claimCaseId,
clientKey, clientKey,
payload, payload,
FanavaranAuditSource.SUBMIT, FanavaranAuditSource.SUBMIT,
); );
// Surface infoWarnings (e.g. factory-bundle fallbacks) on the success
// response so callers are informed, without ever blocking the submit.
const infoWarnings = Array.from(new Set(built.infoWarnings));
return infoWarnings.length > 0 ? { ...result, infoWarnings } : result;
} catch (error) { } catch (error) {
if (error instanceof HttpException) throw error; if (error instanceof HttpException) throw error;
this.logger.error( this.logger.error(
@@ -87,13 +87,32 @@ export type HullFactoryBundleAccessory = {
/** /**
* Policy row for «کليه قطعات فابريک» — OEM/factory-fitted coverage bundle. * Policy row for «کليه قطعات فابريک» — OEM/factory-fitted coverage bundle.
* Many hull policies list only this row instead of every car-components part. * Many hull policies list only this row instead of every car-components part.
*
* Uses exact match first to avoid selecting «غير فابريک» which also contains
* «فابریک» as a substring but is specifically the NON-factory accessory row.
*/ */
export function findHullFactoryBundleAccessory( export function findHullFactoryBundleAccessory(
accessories: FanavaranHullDmgAccessoryRow[], accessories: FanavaranHullDmgAccessoryRow[],
): HullFactoryBundleAccessory | null { ): HullFactoryBundleAccessory | null {
// Pass 1: exact match after normalisation (handles ي/ک variants and ZWNJ).
for (const row of accessories) { for (const row of accessories) {
const desc = normalizeAccessoryCaption(row.AccessoryDesc); const desc = normalizeAccessoryCaption(row.AccessoryDesc);
if (!desc.includes("فابریک")) continue; if (desc !== "کليه قطعات فابریک") continue;
const vehicleHullAccessoryId = parseFanavaranId(row.Id);
if (vehicleHullAccessoryId == null) continue;
return {
vehicleHullAccessoryId,
accessoryKindId: parseFanavaranId(row.AccessoryKindId),
};
}
// Pass 2: starts-with fallback for minor suffix variations.
// «غير فابريک» starts with «غير» so it will never match here.
for (const row of accessories) {
const desc = normalizeAccessoryCaption(row.AccessoryDesc);
if (
!desc.startsWith("کليه قطعات فابریک") &&
!desc.startsWith("کلیه قطعات فابریک")
) continue;
const vehicleHullAccessoryId = parseFanavaranId(row.Id); const vehicleHullAccessoryId = parseFanavaranId(row.Id);
if (vehicleHullAccessoryId == null) continue; if (vehicleHullAccessoryId == null) continue;
return { return {