forked from Yara724/api
YARA-948
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user