Compare commits

...

8 Commits

3 changed files with 24 additions and 34 deletions

View File

@@ -66,15 +66,15 @@ import {
toFanavaranHullExpertiseDmgSection, toFanavaranHullExpertiseDmgSection,
toFanavaranHullExpertisePayload, toFanavaranHullExpertisePayload,
vehicleCurrentValueFromHullPolicyRecord, vehicleCurrentValueFromHullPolicyRecord,
FANAVARAN_DEFAULT_HULL_REPAIR_DURATION,
} from "./fanavaran-hull-expertise"; } from "./fanavaran-hull-expertise";
import { import {
asHullDmgAccessoryRows,
FANAVARAN_DEFAULT_HULL_DMG_COST_KIND_ID, FANAVARAN_DEFAULT_HULL_DMG_COST_KIND_ID,
FANAVARAN_DEFAULT_HULL_DMG_KIND_ID, FANAVARAN_DEFAULT_HULL_DMG_KIND_ID,
FANAVARAN_DEFAULT_HULL_VEHICLE_ACCESSORY_ID,
FANAVARAN_HULL_DMG_COST_KIND_CAPTION, FANAVARAN_HULL_DMG_COST_KIND_CAPTION,
FANAVARAN_HULL_DMG_KIND_CAPTION, FANAVARAN_HULL_DMG_KIND_CAPTION,
findLookupIdByCaption, findLookupIdByCaption,
resolveVehicleHullAccessoryId,
} from "./fanavaran-hull-expertise-lookups"; } from "./fanavaran-hull-expertise-lookups";
import { BlameRequestDbService } from "src/request-management/entities/db-service/blame-request.db.service"; import { BlameRequestDbService } from "src/request-management/entities/db-service/blame-request.db.service";
import { CreateClaimFromBlameResponseDto } from "./dto/create-claim-v2.dto"; import { CreateClaimFromBlameResponseDto } from "./dto/create-claim-v2.dto";
@@ -4480,7 +4480,7 @@ export class ClaimRequestManagementService {
), ),
}; };
const [dmgKindRows, dmgCostKindRows, policyRecord, accessoriesRaw] = const [dmgKindRows, dmgCostKindRows, policyRecord] =
await Promise.all([ await Promise.all([
this.getFanavaranLookupRows(input.clientKey, "vehicle-hull-dmg-kind"), this.getFanavaranLookupRows(input.clientKey, "vehicle-hull-dmg-kind"),
this.getFanavaranLookupRows( this.getFanavaranLookupRows(
@@ -4494,13 +4494,6 @@ export class ClaimRequestManagementService {
contractOptions, contractOptions,
) )
: Promise.resolve(null), : Promise.resolve(null),
policyId != null
? this.fanavaranLookupService.vehicleHullDmgAccessoriesByPolicyId(
input.clientKey,
policyId,
contractOptions,
)
: Promise.resolve([]),
]); ]);
const dmgKindId = const dmgKindId =
@@ -4512,13 +4505,6 @@ export class ClaimRequestManagementService {
FANAVARAN_HULL_DMG_COST_KIND_CAPTION, FANAVARAN_HULL_DMG_COST_KIND_CAPTION,
) ?? FANAVARAN_DEFAULT_HULL_DMG_COST_KIND_ID; ) ?? FANAVARAN_DEFAULT_HULL_DMG_COST_KIND_ID;
const accessories = asHullDmgAccessoryRows(accessoriesRaw);
if (policyId != null && accessories.length === 0) {
input.warnings.push(
`No hull dmg-accessories for policy ${policyId}; VehicleHullAccessoryId may be missing.`,
);
}
let vehicle = pickHullVehicleIdentity(input.blame); let vehicle = pickHullVehicleIdentity(input.blame);
let colorId: number | null = null; let colorId: number | null = null;
const policy = asObjectRecord(policyRecord); const policy = asObjectRecord(policyRecord);
@@ -4562,16 +4548,6 @@ export class ClaimRequestManagementService {
); );
const hullSections = input.parts.map((part: any) => { const hullSections = input.parts.map((part: any) => {
const accessoryKindId = parseCatalogPartIdInput(part?.partId);
const vehicleHullAccessoryId = resolveVehicleHullAccessoryId(
accessories,
accessoryKindId,
);
if (vehicleHullAccessoryId == null) {
input.warnings.push(
`No VehicleHullAccessoryId for part "${this.fanavaranPartLabel(part)}" (AccessoryKindId=${accessoryKindId ?? "none"}).`,
);
}
return toFanavaranHullExpertiseDmgSection({ return toFanavaranHullExpertiseDmgSection({
partId: part?.partId, partId: part?.partId,
desc: this.fanavaranPartLabel(part), desc: this.fanavaranPartLabel(part),
@@ -4581,7 +4557,7 @@ export class ClaimRequestManagementService {
this.parseFanavaranMoney(part?.salary), this.parseFanavaranMoney(part?.salary),
dmgKindId, dmgKindId,
dmgCostKindId, dmgCostKindId,
vehicleHullAccessoryId, vehicleHullAccessoryId: FANAVARAN_DEFAULT_HULL_VEHICLE_ACCESSORY_ID,
}); });
}); });
@@ -4594,10 +4570,7 @@ export class ClaimRequestManagementService {
vehicleCurrentValue = vehicleCurrentValueFromHullPolicyRecord(policy); vehicleCurrentValue = vehicleCurrentValueFromHullPolicyRecord(policy);
} }
const repairDuration = const repairDuration = FANAVARAN_DEFAULT_HULL_REPAIR_DURATION;
typeof input.profile.defaults.HullExpertiseRepairDuration === "number"
? input.profile.defaults.HullExpertiseRepairDuration
: null;
return { return {
replyKey: input.replyKey, replyKey: input.replyKey,
@@ -7898,7 +7871,18 @@ export class ClaimRequestManagementService {
this.logger.log( this.logger.log(
`[Fanavaran hull sync] PUT ${url} keys=${Object.keys(hull).join(",")}`, `[Fanavaran hull sync] PUT ${url} keys=${Object.keys(hull).join(",")}`,
); );
await this.putFanavaranJson(url, hull, clientKey, undefined, claimCaseId); try {
await this.putFanavaranJson(url, hull, clientKey, undefined, claimCaseId);
} catch (error) {
// Parsian bonyan often has no PUT route on vehicle-hull-claims/{Id}
// ("No HTTP resource was found.../vehicle-hull-claims/{Id}"). Do not
// block GEN.05 files / GEN.06 expertise on that.
this.logger.warn(
`[Fanavaran hull sync] PUT ${url} failed; continuing with nested stages: ${
error instanceof Error ? error.message : error
}`,
);
}
} }
private async postFanavaranMultipart( private async postFanavaranMultipart(

View File

@@ -7,6 +7,8 @@ export const FANAVARAN_HULL_DMG_COST_KIND_CAPTION = "مجموع لوازم";
export const FANAVARAN_DEFAULT_HULL_DMG_KIND_ID = 5485; export const FANAVARAN_DEFAULT_HULL_DMG_KIND_ID = 5485;
/** Fallback when lookup fetch fails (`vehicle-hull-dmg-cost-kinds` Id). */ /** Fallback when lookup fetch fails (`vehicle-hull-dmg-cost-kinds` Id). */
export const FANAVARAN_DEFAULT_HULL_DMG_COST_KIND_ID = 1; export const FANAVARAN_DEFAULT_HULL_DMG_COST_KIND_ID = 1;
/** GEN.06 factory (فابریک) accessory row. Used for every hull DmgSection. */
export const FANAVARAN_DEFAULT_HULL_VEHICLE_ACCESSORY_ID = 3043330;
export type FanavaranHullDmgAccessoryRow = { export type FanavaranHullDmgAccessoryRow = {
Id?: unknown; Id?: unknown;

View File

@@ -78,6 +78,9 @@ export {
FANAVARAN_HULL_DMG_KIND_CAPTION, FANAVARAN_HULL_DMG_KIND_CAPTION,
} from "./fanavaran-hull-expertise-lookups"; } from "./fanavaran-hull-expertise-lookups";
/** GEN.06 RepairDuration in days for every hull expertise. */
export const FANAVARAN_DEFAULT_HULL_REPAIR_DURATION = 3;
/** GEN.06 VehicleCurrentValue from GET car/vehicle-hull-policies/{PolicyId} → VehicleValue. */ /** GEN.06 VehicleCurrentValue from GET car/vehicle-hull-policies/{PolicyId} → VehicleValue. */
export function vehicleCurrentValueFromHullPolicyRecord( export function vehicleCurrentValueFromHullPolicyRecord(
policy: Record<string, unknown> | null | undefined, policy: Record<string, unknown> | null | undefined,
@@ -117,7 +120,8 @@ export function toFanavaranHullExpertisePayload(input: {
ComponentReplacementCost: input.componentReplacementCost, ComponentReplacementCost: input.componentReplacementCost,
WasteValue: input.wasteValue, WasteValue: input.wasteValue,
CarryAndRescueCost: null, CarryAndRescueCost: null,
RepairDuration: input.repairDuration ?? null, RepairDuration:
input.repairDuration ?? FANAVARAN_DEFAULT_HULL_REPAIR_DURATION,
VehicleCurrentValue: input.vehicleCurrentValue, VehicleCurrentValue: input.vehicleCurrentValue,
WreckHighestValue: null, WreckHighestValue: null,
InspectionDeduction: null, InspectionDeduction: null,