forked from Yara724/api
Compare commits
8 Commits
e06178f804
...
9dd0ec0c00
| Author | SHA1 | Date | |
|---|---|---|---|
| 9dd0ec0c00 | |||
| a9adad3c1b | |||
| bbe5b7b77b | |||
| 1e13bb3a3c | |||
| a8d8df574b | |||
| cf07a33951 | |||
| 6f8a6fed69 | |||
| dbf46cfdda |
@@ -66,15 +66,15 @@ import {
|
||||
toFanavaranHullExpertiseDmgSection,
|
||||
toFanavaranHullExpertisePayload,
|
||||
vehicleCurrentValueFromHullPolicyRecord,
|
||||
FANAVARAN_DEFAULT_HULL_REPAIR_DURATION,
|
||||
} from "./fanavaran-hull-expertise";
|
||||
import {
|
||||
asHullDmgAccessoryRows,
|
||||
FANAVARAN_DEFAULT_HULL_DMG_COST_KIND_ID,
|
||||
FANAVARAN_DEFAULT_HULL_DMG_KIND_ID,
|
||||
FANAVARAN_DEFAULT_HULL_VEHICLE_ACCESSORY_ID,
|
||||
FANAVARAN_HULL_DMG_COST_KIND_CAPTION,
|
||||
FANAVARAN_HULL_DMG_KIND_CAPTION,
|
||||
findLookupIdByCaption,
|
||||
resolveVehicleHullAccessoryId,
|
||||
} from "./fanavaran-hull-expertise-lookups";
|
||||
import { BlameRequestDbService } from "src/request-management/entities/db-service/blame-request.db.service";
|
||||
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([
|
||||
this.getFanavaranLookupRows(input.clientKey, "vehicle-hull-dmg-kind"),
|
||||
this.getFanavaranLookupRows(
|
||||
@@ -4494,13 +4494,6 @@ export class ClaimRequestManagementService {
|
||||
contractOptions,
|
||||
)
|
||||
: Promise.resolve(null),
|
||||
policyId != null
|
||||
? this.fanavaranLookupService.vehicleHullDmgAccessoriesByPolicyId(
|
||||
input.clientKey,
|
||||
policyId,
|
||||
contractOptions,
|
||||
)
|
||||
: Promise.resolve([]),
|
||||
]);
|
||||
|
||||
const dmgKindId =
|
||||
@@ -4512,13 +4505,6 @@ export class ClaimRequestManagementService {
|
||||
FANAVARAN_HULL_DMG_COST_KIND_CAPTION,
|
||||
) ?? 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 colorId: number | null = null;
|
||||
const policy = asObjectRecord(policyRecord);
|
||||
@@ -4562,16 +4548,6 @@ export class ClaimRequestManagementService {
|
||||
);
|
||||
|
||||
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({
|
||||
partId: part?.partId,
|
||||
desc: this.fanavaranPartLabel(part),
|
||||
@@ -4581,7 +4557,7 @@ export class ClaimRequestManagementService {
|
||||
this.parseFanavaranMoney(part?.salary),
|
||||
dmgKindId,
|
||||
dmgCostKindId,
|
||||
vehicleHullAccessoryId,
|
||||
vehicleHullAccessoryId: FANAVARAN_DEFAULT_HULL_VEHICLE_ACCESSORY_ID,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4594,10 +4570,7 @@ export class ClaimRequestManagementService {
|
||||
vehicleCurrentValue = vehicleCurrentValueFromHullPolicyRecord(policy);
|
||||
}
|
||||
|
||||
const repairDuration =
|
||||
typeof input.profile.defaults.HullExpertiseRepairDuration === "number"
|
||||
? input.profile.defaults.HullExpertiseRepairDuration
|
||||
: null;
|
||||
const repairDuration = FANAVARAN_DEFAULT_HULL_REPAIR_DURATION;
|
||||
|
||||
return {
|
||||
replyKey: input.replyKey,
|
||||
@@ -7898,7 +7871,18 @@ export class ClaimRequestManagementService {
|
||||
this.logger.log(
|
||||
`[Fanavaran hull sync] PUT ${url} keys=${Object.keys(hull).join(",")}`,
|
||||
);
|
||||
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(
|
||||
|
||||
@@ -7,6 +7,8 @@ export const FANAVARAN_HULL_DMG_COST_KIND_CAPTION = "مجموع لوازم";
|
||||
export const FANAVARAN_DEFAULT_HULL_DMG_KIND_ID = 5485;
|
||||
/** Fallback when lookup fetch fails (`vehicle-hull-dmg-cost-kinds` Id). */
|
||||
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 = {
|
||||
Id?: unknown;
|
||||
|
||||
@@ -78,6 +78,9 @@ export {
|
||||
FANAVARAN_HULL_DMG_KIND_CAPTION,
|
||||
} 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. */
|
||||
export function vehicleCurrentValueFromHullPolicyRecord(
|
||||
policy: Record<string, unknown> | null | undefined,
|
||||
@@ -117,7 +120,8 @@ export function toFanavaranHullExpertisePayload(input: {
|
||||
ComponentReplacementCost: input.componentReplacementCost,
|
||||
WasteValue: input.wasteValue,
|
||||
CarryAndRescueCost: null,
|
||||
RepairDuration: input.repairDuration ?? null,
|
||||
RepairDuration:
|
||||
input.repairDuration ?? FANAVARAN_DEFAULT_HULL_REPAIR_DURATION,
|
||||
VehicleCurrentValue: input.vehicleCurrentValue,
|
||||
WreckHighestValue: null,
|
||||
InspectionDeduction: null,
|
||||
|
||||
Reference in New Issue
Block a user