update the culprit licenses chnged and ActualPremium

This commit is contained in:
2026-09-19 13:09:28 +03:30
parent 85576e7c5e
commit be06bfe1b5
6 changed files with 36 additions and 6 deletions

View File

@@ -4259,6 +4259,7 @@ export class ClaimRequestManagementService {
/** Blame `Party` row (FIRST party for CAR_BODY); person shape is read via pickPerson* helpers. */
firstParty?: { person?: unknown };
logPrefix: string;
claimCaseId?: string;
}): Promise<void> {
const policyId = parseFanavaranId(input.payload.PolicyId);
if (policyId == null) return;
@@ -4290,6 +4291,13 @@ export class ClaimRequestManagementService {
input.payload.ActualPremium = actualPremium;
}
const vehicleValue = vehicleCurrentValueFromHullPolicyRecord(policyRecord);
if (vehicleValue != null && input.claimCaseId) {
await this.claimCaseDbService.findByIdAndUpdate(input.claimCaseId, {
$set: { "vehicle.carPrice": vehicleValue },
});
}
const person = input.firstParty?.person as
| {
driverIsInsurer?: boolean;
@@ -4522,7 +4530,10 @@ export class ClaimRequestManagementService {
});
let vehicleCurrentValue =
this.parseFanavaranMoney(input.priceDropCarPrice) || null;
this.parseFanavaranMoney(input.claimCase?.vehicle?.carPrice) ||
this.parseFanavaranMoney(input.claimCase?.vehicle?.price) ||
this.parseFanavaranMoney(input.priceDropCarPrice) ||
null;
if (vehicleCurrentValue == null) {
vehicleCurrentValue = vehicleCurrentValueFromHullPolicyRecord(policy);
}
@@ -6132,7 +6143,9 @@ export class ClaimRequestManagementService {
blameCase,
firstParty,
logPrefix,
claimCaseId,
});
delete payload.IsLicenseReplacement;
const hull = toFanavaranHullBaseClaimPayload(payload);
for (const key of Object.keys(payload)) delete payload[key];
Object.assign(payload, hull);

View File

@@ -39,6 +39,10 @@ export class ClaimVehicleSnapshot {
@Prop({ type: String })
price?: string;
/** Vehicle value in Rial from hull policy VehicleValue or expert assessment. */
@Prop({ type: Number })
carPrice?: number;
}
export const ClaimVehicleSnapshotSchema =
SchemaFactory.createForClass(ClaimVehicleSnapshot);

View File

@@ -34,6 +34,14 @@ describe("fanavaran hull base claim", () => {
expect(fanavaranHullNestedClaimId({ ClaimNo: 2268 })).toBeNull();
});
it("keeps IsLicenseReplaced null even when ثالث IsLicenseReplacement is 0", () => {
const hull = toFanavaranHullBaseClaimPayload({
PolicyId: 1,
IsLicenseReplacement: 0,
});
expect(hull.IsLicenseReplaced).toBeNull();
});
it("strips ثالث-only fields from a live hull create echo", () => {
const hull = toFanavaranHullBaseClaimPayload({
AccidentCauseId: 6,

View File

@@ -79,8 +79,8 @@ export function toFanavaranHullBaseClaimPayload(
const next: Record<string, unknown> = {};
for (const key of FANAVARAN_HULL_BASE_CLAIM_KEYS) {
if (key === "IsLicenseReplaced") {
next[key] =
built.IsLicenseReplaced ?? built.IsLicenseReplacement ?? null;
// GEN.03: must be empty/null. Do not map ثالث IsLicenseReplacement (default 0).
next[key] = null;
continue;
}
if (key === "AccidentTypeId") {

View File

@@ -123,6 +123,7 @@ describe("ExpertClaimService expert-reply pricing", () => {
expect(findByIdAndUpdate).toHaveBeenCalledTimes(1);
expect(findByIdAndUpdate.mock.calls[0][1]).toMatchObject({
"vehicle.price": "1250000000",
"vehicle.carPrice": 1250000000,
});
});

View File

@@ -3341,9 +3341,10 @@ export class ExpertClaimService {
const carPriceWasProvided = reply.carPrice != null;
let normalizedCurrentCarPrice: string | undefined;
let parsedCurrentCarPrice: number | undefined;
if (blame.type === BlameRequestType.CAR_BODY) {
const parsedCurrentCarPrice = parseMoneyAmountToman(reply.carPrice);
parsedCurrentCarPrice = parseMoneyAmountToman(reply.carPrice) ?? undefined;
if (
parsedCurrentCarPrice == null ||
!Number.isSafeInteger(parsedCurrentCarPrice) ||
@@ -3600,8 +3601,11 @@ export class ExpertClaimService {
"evaluation.ownerInsurerApproval": "",
"evaluation.ownerPricedPartsApproval": "",
},
...(normalizedCurrentCarPrice
? { "vehicle.price": normalizedCurrentCarPrice }
...(normalizedCurrentCarPrice && parsedCurrentCarPrice != null
? {
"vehicle.price": normalizedCurrentCarPrice,
"vehicle.carPrice": parsedCurrentCarPrice,
}
: {}),
"workflow.currentStep": currentStep,
"workflow.nextStep": nextWorkflowStep,