diff --git a/src/claim-request-management/claim-request-management.service.ts b/src/claim-request-management/claim-request-management.service.ts index db02286..2cb8729 100644 --- a/src/claim-request-management/claim-request-management.service.ts +++ b/src/claim-request-management/claim-request-management.service.ts @@ -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 { 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); diff --git a/src/claim-request-management/entites/schema/claim-case.identity.schema.ts b/src/claim-request-management/entites/schema/claim-case.identity.schema.ts index 3daf41b..18cd5f4 100644 --- a/src/claim-request-management/entites/schema/claim-case.identity.schema.ts +++ b/src/claim-request-management/entites/schema/claim-case.identity.schema.ts @@ -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); diff --git a/src/claim-request-management/fanavaran-hull-base-claim.spec.ts b/src/claim-request-management/fanavaran-hull-base-claim.spec.ts index 7be8206..fbd4f36 100644 --- a/src/claim-request-management/fanavaran-hull-base-claim.spec.ts +++ b/src/claim-request-management/fanavaran-hull-base-claim.spec.ts @@ -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, diff --git a/src/claim-request-management/fanavaran-hull-base-claim.ts b/src/claim-request-management/fanavaran-hull-base-claim.ts index 8ef1c93..136a0a8 100644 --- a/src/claim-request-management/fanavaran-hull-base-claim.ts +++ b/src/claim-request-management/fanavaran-hull-base-claim.ts @@ -79,8 +79,8 @@ export function toFanavaranHullBaseClaimPayload( const next: Record = {}; 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") { diff --git a/src/expert-claim/expert-claim.service.spec.ts b/src/expert-claim/expert-claim.service.spec.ts index 8ab91c8..1341126 100644 --- a/src/expert-claim/expert-claim.service.spec.ts +++ b/src/expert-claim/expert-claim.service.spec.ts @@ -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, }); }); diff --git a/src/expert-claim/expert-claim.service.ts b/src/expert-claim/expert-claim.service.ts index 40e6753..ef99a9d 100644 --- a/src/expert-claim/expert-claim.service.ts +++ b/src/expert-claim/expert-claim.service.ts @@ -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,