forked from Yara724/api
warnings are just info warning now
This commit is contained in:
@@ -2738,10 +2738,13 @@ export class ClaimRequestManagementService {
|
||||
priceDropTotal: number;
|
||||
priceDropCarPrice: unknown;
|
||||
warnings: string[];
|
||||
/** Non-blocking notices (factory-bundle fallbacks). Never gates submission. */
|
||||
infoWarnings: string[];
|
||||
replyKey?: string;
|
||||
}): Promise<{
|
||||
payload: Record<string, unknown>;
|
||||
warnings: string[];
|
||||
infoWarnings: string[];
|
||||
replyKey?: string;
|
||||
}> {
|
||||
const policyId = this.parseHullClaimPolicyId(input.claimCase);
|
||||
@@ -2864,14 +2867,19 @@ export class ClaimRequestManagementService {
|
||||
partLabel,
|
||||
);
|
||||
// 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 accessoryKindId: number | string | null | undefined =
|
||||
resolved?.accessoryKindId ?? part?.partId;
|
||||
if (!resolved && factoryBundle) {
|
||||
vehicleHullAccessoryId = factoryBundle.vehicleHullAccessoryId;
|
||||
input.warnings.push(
|
||||
`DmgSections[${index}] (${partLabel || part?.partId || 'part'}): AccessoryKindId=${part?.partId ?? '(missing)'} is not a separate policy dmg-accessories row; using factory bundle 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} («کليه قطعات فابريک»).`,
|
||||
);
|
||||
} else if (!resolved) {
|
||||
input.warnings.push(
|
||||
@@ -2927,6 +2935,7 @@ export class ClaimRequestManagementService {
|
||||
return {
|
||||
replyKey: input.replyKey,
|
||||
warnings: input.warnings,
|
||||
infoWarnings: input.infoWarnings,
|
||||
payload,
|
||||
};
|
||||
}
|
||||
@@ -6123,6 +6132,7 @@ export class ClaimRequestManagementService {
|
||||
}): Promise<{
|
||||
payload: Record<string, unknown>;
|
||||
warnings: string[];
|
||||
infoWarnings: string[];
|
||||
replyKey?: string;
|
||||
}> {
|
||||
const profile = getFanavaranClientProfile(input.clientKey);
|
||||
@@ -6137,6 +6147,7 @@ export class ClaimRequestManagementService {
|
||||
|
||||
// GEN.08 / GEN.06 ClaimExpertId always from assigned assessor staff profile.
|
||||
const warnings: string[] = [];
|
||||
const infoWarnings: string[] = [];
|
||||
let claimExpertId: number | null = null;
|
||||
if (!blameForExpertIds) {
|
||||
const message =
|
||||
@@ -6198,7 +6209,7 @@ export class ClaimRequestManagementService {
|
||||
clientKey: input.clientKey, claimCase: input.claimCase,
|
||||
blame: blameForExpertIds, profile, parts, claimExpertId,
|
||||
submittedAt, priceDropTotal, priceDropCarPrice: priceDrop?.carPrice,
|
||||
warnings, replyKey: active?.replyKey,
|
||||
warnings, infoWarnings, replyKey: active?.replyKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6251,6 +6262,7 @@ export class ClaimRequestManagementService {
|
||||
return {
|
||||
replyKey: active?.replyKey,
|
||||
warnings,
|
||||
infoWarnings,
|
||||
payload,
|
||||
};
|
||||
}
|
||||
@@ -6283,7 +6295,7 @@ export class ClaimRequestManagementService {
|
||||
const claimCase = await this.claimCaseDbService.findById(claimCaseId);
|
||||
if (!claimCase) throw new NotFoundException('Claim case not found');
|
||||
|
||||
const { payload, warnings, replyKey } =
|
||||
const { payload, warnings, infoWarnings, replyKey } =
|
||||
await this.buildFanavaranExpertisePayload({
|
||||
claimCase,
|
||||
clientKey,
|
||||
@@ -6312,6 +6324,7 @@ export class ClaimRequestManagementService {
|
||||
: null,
|
||||
ready: warnings.length === 0 && payload.ClaimExpertId != null,
|
||||
warnings: Array.from(new Set(warnings)),
|
||||
infoWarnings: Array.from(new Set(infoWarnings)),
|
||||
payload,
|
||||
};
|
||||
}
|
||||
@@ -6426,12 +6439,16 @@ export class ClaimRequestManagementService {
|
||||
this.assertFanavaranExpertisePayloadReady(payload, built.warnings, {
|
||||
...hullExpertiseAssertFields(product),
|
||||
});
|
||||
return await this.executeFanavaranExpertiseSubmit(
|
||||
const result = await this.executeFanavaranExpertiseSubmit(
|
||||
claimCaseId,
|
||||
clientKey,
|
||||
payload,
|
||||
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) {
|
||||
if (error instanceof HttpException) throw error;
|
||||
this.logger.error(
|
||||
|
||||
@@ -87,13 +87,32 @@ export type HullFactoryBundleAccessory = {
|
||||
/**
|
||||
* Policy row for «کليه قطعات فابريک» — OEM/factory-fitted coverage bundle.
|
||||
* 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(
|
||||
accessories: FanavaranHullDmgAccessoryRow[],
|
||||
): HullFactoryBundleAccessory | null {
|
||||
// Pass 1: exact match after normalisation (handles ي/ک variants and ZWNJ).
|
||||
for (const row of accessories) {
|
||||
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);
|
||||
if (vehicleHullAccessoryId == null) continue;
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user