forked from Yara724/api
badane update is implemented now
This commit is contained in:
@@ -49,6 +49,12 @@ import {
|
||||
pickStoredCarBodyPolicyId,
|
||||
type FanavaranClaimProduct,
|
||||
} from "./fanavaran-claim-product";
|
||||
import {
|
||||
hullExpertiseAssertFields,
|
||||
pickHullVehicleIdentity,
|
||||
toFanavaranHullExpertiseDmgSection,
|
||||
toFanavaranHullExpertisePayload,
|
||||
} from "./fanavaran-hull-expertise";
|
||||
import { BlameRequestDbService } from "src/request-management/entities/db-service/blame-request.db.service";
|
||||
import { CreateClaimFromBlameResponseDto } from "./dto/create-claim-v2.dto";
|
||||
import {
|
||||
@@ -6722,6 +6728,41 @@ export class ClaimRequestManagementService {
|
||||
input.claimCase?._id ? String(input.claimCase._id) : undefined,
|
||||
);
|
||||
|
||||
if (product === "car-body") {
|
||||
const blame = input.claimCase?.blameRequestId
|
||||
? await this.blameRequestDbService.findById(
|
||||
String(input.claimCase.blameRequestId),
|
||||
)
|
||||
: null;
|
||||
const hullSections = parts.map((part: any) =>
|
||||
toFanavaranHullExpertiseDmgSection({
|
||||
partId: part?.partId,
|
||||
desc: this.fanavaranPartLabel(part),
|
||||
wasteValue: this.fanavaranDaghiWasteValue(part?.daghi),
|
||||
amount:
|
||||
this.parseFanavaranMoney(part?.price) +
|
||||
this.parseFanavaranMoney(part?.salary),
|
||||
}),
|
||||
);
|
||||
return {
|
||||
replyKey: active?.replyKey,
|
||||
warnings,
|
||||
payload: toFanavaranHullExpertisePayload({
|
||||
claimExpertId,
|
||||
dmgAssessmentDate: this.convertToPersianDate(submittedAt),
|
||||
inspectionTime: this.getTime24Hour(submittedAt),
|
||||
wage: repairWage,
|
||||
componentReplacementCost,
|
||||
wasteValue,
|
||||
dropAmount: priceDropTotal || 0,
|
||||
vehicleCurrentValue:
|
||||
this.parseFanavaranMoney(priceDrop?.carPrice) || null,
|
||||
vehicle: pickHullVehicleIdentity(blame),
|
||||
dmgSections: hullSections,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
const payload: Record<string, unknown> = {
|
||||
ClaimExpertId: claimExpertId,
|
||||
ComponentReplacementCost: componentReplacementCost,
|
||||
@@ -6738,9 +6779,7 @@ export class ClaimRequestManagementService {
|
||||
this.parseFanavaranMoney(priceDrop?.carPrice) || null,
|
||||
DmgSections: dmgSections,
|
||||
};
|
||||
if (fanavaranHasDamageCaseStage(product)) {
|
||||
payload.DmgCaseId = input.claimCase.dmgCaseId ?? null;
|
||||
}
|
||||
payload.DmgCaseId = input.claimCase.dmgCaseId ?? null;
|
||||
|
||||
return {
|
||||
replyKey: active?.replyKey,
|
||||
@@ -6752,13 +6791,19 @@ export class ClaimRequestManagementService {
|
||||
private assertFanavaranExpertisePayloadReady(
|
||||
payload: Record<string, unknown>,
|
||||
warnings: string[],
|
||||
options?: { requireDmgCaseId?: boolean },
|
||||
options?: { requireDmgCaseId?: boolean; requireThirdPartyLookups?: boolean },
|
||||
): void {
|
||||
const sections = Array.isArray(payload.DmgSections)
|
||||
? payload.DmgSections
|
||||
: [];
|
||||
if (options?.requireDmgCaseId !== false && !payload.DmgCaseId)
|
||||
warnings.push("DmgCaseId is required.");
|
||||
if (options?.requireThirdPartyLookups !== false) {
|
||||
if (!payload.InspectionPlaceId)
|
||||
warnings.push("InspectionPlaceId is required.");
|
||||
if (!payload.DropAmountStatus)
|
||||
warnings.push("DropAmountStatus is required.");
|
||||
}
|
||||
if (!payload.InspectionPlaceId)
|
||||
warnings.push("InspectionPlaceId is required.");
|
||||
if (!payload.DropAmountStatus)
|
||||
@@ -6839,7 +6884,7 @@ export class ClaimRequestManagementService {
|
||||
FANAVARAN_EXPERTISE_MANUAL_OVERRIDE_KEYS,
|
||||
);
|
||||
this.assertFanavaranExpertisePayloadReady(payload, built.warnings, {
|
||||
requireDmgCaseId: fanavaranHasDamageCaseStage(product),
|
||||
...hullExpertiseAssertFields(product),
|
||||
});
|
||||
return await this.executeFanavaranExpertiseSubmit(
|
||||
claimCaseId,
|
||||
@@ -7035,7 +7080,7 @@ export class ClaimRequestManagementService {
|
||||
clientKey,
|
||||
});
|
||||
this.assertFanavaranExpertisePayloadReady(payload, warnings, {
|
||||
requireDmgCaseId: fanavaranHasDamageCaseStage(product),
|
||||
...hullExpertiseAssertFields(product),
|
||||
});
|
||||
|
||||
const fanavaranResponse = await this.executeFanavaranExpertiseSubmit(
|
||||
|
||||
Reference in New Issue
Block a user