forked from Yara724/api
update the culprit licenses chnged and ActualPremium
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user