1
0
forked from Yara724/api
This commit is contained in:
SepehrYahyaee
2026-06-03 12:05:19 +03:30
parent 077bae429e
commit 2c810afcb6
4 changed files with 121 additions and 25 deletions

View File

@@ -4226,6 +4226,49 @@ export class ExpertClaimService {
}
this.assertExpertCanEditClaimDuringReviewV2(claim, actor);
const vehicleSet: Record<string, string> = {};
if (body.carName != null && String(body.carName).trim()) {
vehicleSet["vehicle.carName"] = String(body.carName).trim();
}
if (body.carModel != null && String(body.carModel).trim()) {
vehicleSet["vehicle.carModel"] = String(body.carModel).trim();
}
// Manual override path — expert knows the number, skip calculation entirely
if (body.manualPriceDrop != null) {
if (!Number.isFinite(body.manualPriceDrop) || body.manualPriceDrop < 0) {
throw new BadRequestException(
"manualPriceDrop must be a non-negative finite number.",
);
}
const manualPayload = {
manualOverride: true,
totalPriceDrop: body.manualPriceDrop,
partLines: [],
};
await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, {
$set: {
...vehicleSet,
"evaluation.priceDrop": manualPayload,
},
});
const updated = await this.claimCaseDbService.findById(claimRequestId);
return {
claimRequestId,
vehicle: {
carName: updated?.vehicle?.carName,
carModel: updated?.vehicle?.carModel,
carType: updated?.vehicle?.carType,
},
priceDrop: manualPayload,
partLines: [],
};
}
// Calculated path — existing logic unchanged
const carType = claim.vehicle?.carType as ClaimVehicleTypeV2 | undefined;
const selectedNorm = normalizeDamageSelectedParts(
claim.damage?.selectedParts,
@@ -4235,7 +4278,7 @@ export class ExpertClaimService {
if (!body.partSeverities?.length) {
throw new BadRequestException(
"Provide at least one partSeverities line for a damaged part.",
"Provide at least one partSeverities line, or use manualPriceDrop for a direct override.",
);
}
@@ -4290,14 +4333,6 @@ export class ExpertClaimService {
partLines: lines,
};
const vehicleSet: Record<string, string> = {};
if (body.carName != null && String(body.carName).trim()) {
vehicleSet["vehicle.carName"] = String(body.carName).trim();
}
if (body.carModel != null && String(body.carModel).trim()) {
vehicleSet["vehicle.carModel"] = String(body.carModel).trim();
}
await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, {
$set: {
...vehicleSet,
@@ -4306,7 +4341,6 @@ export class ExpertClaimService {
});
const updated = await this.claimCaseDbService.findById(claimRequestId);
return {
claimRequestId,
vehicle: {