forked from Yara724/api
Merge pull request 'update the culprit licenses chnged and ActualPremium' (#328) from s.hajizadeh/yara724api:main into main
Reviewed-on: Yara724/api#328
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. */
|
/** Blame `Party` row (FIRST party for CAR_BODY); person shape is read via pickPerson* helpers. */
|
||||||
firstParty?: { person?: unknown };
|
firstParty?: { person?: unknown };
|
||||||
logPrefix: string;
|
logPrefix: string;
|
||||||
|
claimCaseId?: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const policyId = parseFanavaranId(input.payload.PolicyId);
|
const policyId = parseFanavaranId(input.payload.PolicyId);
|
||||||
if (policyId == null) return;
|
if (policyId == null) return;
|
||||||
@@ -4290,6 +4291,13 @@ export class ClaimRequestManagementService {
|
|||||||
input.payload.ActualPremium = actualPremium;
|
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
|
const person = input.firstParty?.person as
|
||||||
| {
|
| {
|
||||||
driverIsInsurer?: boolean;
|
driverIsInsurer?: boolean;
|
||||||
@@ -4522,7 +4530,10 @@ export class ClaimRequestManagementService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let vehicleCurrentValue =
|
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) {
|
if (vehicleCurrentValue == null) {
|
||||||
vehicleCurrentValue = vehicleCurrentValueFromHullPolicyRecord(policy);
|
vehicleCurrentValue = vehicleCurrentValueFromHullPolicyRecord(policy);
|
||||||
}
|
}
|
||||||
@@ -6132,7 +6143,9 @@ export class ClaimRequestManagementService {
|
|||||||
blameCase,
|
blameCase,
|
||||||
firstParty,
|
firstParty,
|
||||||
logPrefix,
|
logPrefix,
|
||||||
|
claimCaseId,
|
||||||
});
|
});
|
||||||
|
delete payload.IsLicenseReplacement;
|
||||||
const hull = toFanavaranHullBaseClaimPayload(payload);
|
const hull = toFanavaranHullBaseClaimPayload(payload);
|
||||||
for (const key of Object.keys(payload)) delete payload[key];
|
for (const key of Object.keys(payload)) delete payload[key];
|
||||||
Object.assign(payload, hull);
|
Object.assign(payload, hull);
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ export class ClaimVehicleSnapshot {
|
|||||||
|
|
||||||
@Prop({ type: String })
|
@Prop({ type: String })
|
||||||
price?: string;
|
price?: string;
|
||||||
|
|
||||||
|
/** Vehicle value in Rial from hull policy VehicleValue or expert assessment. */
|
||||||
|
@Prop({ type: Number })
|
||||||
|
carPrice?: number;
|
||||||
}
|
}
|
||||||
export const ClaimVehicleSnapshotSchema =
|
export const ClaimVehicleSnapshotSchema =
|
||||||
SchemaFactory.createForClass(ClaimVehicleSnapshot);
|
SchemaFactory.createForClass(ClaimVehicleSnapshot);
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ describe("fanavaran hull base claim", () => {
|
|||||||
expect(fanavaranHullNestedClaimId({ ClaimNo: 2268 })).toBeNull();
|
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", () => {
|
it("strips ثالث-only fields from a live hull create echo", () => {
|
||||||
const hull = toFanavaranHullBaseClaimPayload({
|
const hull = toFanavaranHullBaseClaimPayload({
|
||||||
AccidentCauseId: 6,
|
AccidentCauseId: 6,
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ export function toFanavaranHullBaseClaimPayload(
|
|||||||
const next: Record<string, unknown> = {};
|
const next: Record<string, unknown> = {};
|
||||||
for (const key of FANAVARAN_HULL_BASE_CLAIM_KEYS) {
|
for (const key of FANAVARAN_HULL_BASE_CLAIM_KEYS) {
|
||||||
if (key === "IsLicenseReplaced") {
|
if (key === "IsLicenseReplaced") {
|
||||||
next[key] =
|
// GEN.03: must be empty/null. Do not map ثالث IsLicenseReplacement (default 0).
|
||||||
built.IsLicenseReplaced ?? built.IsLicenseReplacement ?? null;
|
next[key] = null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key === "AccidentTypeId") {
|
if (key === "AccidentTypeId") {
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ describe("ExpertClaimService expert-reply pricing", () => {
|
|||||||
expect(findByIdAndUpdate).toHaveBeenCalledTimes(1);
|
expect(findByIdAndUpdate).toHaveBeenCalledTimes(1);
|
||||||
expect(findByIdAndUpdate.mock.calls[0][1]).toMatchObject({
|
expect(findByIdAndUpdate.mock.calls[0][1]).toMatchObject({
|
||||||
"vehicle.price": "1250000000",
|
"vehicle.price": "1250000000",
|
||||||
|
"vehicle.carPrice": 1250000000,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3341,9 +3341,10 @@ export class ExpertClaimService {
|
|||||||
|
|
||||||
const carPriceWasProvided = reply.carPrice != null;
|
const carPriceWasProvided = reply.carPrice != null;
|
||||||
let normalizedCurrentCarPrice: string | undefined;
|
let normalizedCurrentCarPrice: string | undefined;
|
||||||
|
let parsedCurrentCarPrice: number | undefined;
|
||||||
|
|
||||||
if (blame.type === BlameRequestType.CAR_BODY) {
|
if (blame.type === BlameRequestType.CAR_BODY) {
|
||||||
const parsedCurrentCarPrice = parseMoneyAmountToman(reply.carPrice);
|
parsedCurrentCarPrice = parseMoneyAmountToman(reply.carPrice) ?? undefined;
|
||||||
if (
|
if (
|
||||||
parsedCurrentCarPrice == null ||
|
parsedCurrentCarPrice == null ||
|
||||||
!Number.isSafeInteger(parsedCurrentCarPrice) ||
|
!Number.isSafeInteger(parsedCurrentCarPrice) ||
|
||||||
@@ -3600,8 +3601,11 @@ export class ExpertClaimService {
|
|||||||
"evaluation.ownerInsurerApproval": "",
|
"evaluation.ownerInsurerApproval": "",
|
||||||
"evaluation.ownerPricedPartsApproval": "",
|
"evaluation.ownerPricedPartsApproval": "",
|
||||||
},
|
},
|
||||||
...(normalizedCurrentCarPrice
|
...(normalizedCurrentCarPrice && parsedCurrentCarPrice != null
|
||||||
? { "vehicle.price": normalizedCurrentCarPrice }
|
? {
|
||||||
|
"vehicle.price": normalizedCurrentCarPrice,
|
||||||
|
"vehicle.carPrice": parsedCurrentCarPrice,
|
||||||
|
}
|
||||||
: {}),
|
: {}),
|
||||||
"workflow.currentStep": currentStep,
|
"workflow.currentStep": currentStep,
|
||||||
"workflow.nextStep": nextWorkflowStep,
|
"workflow.nextStep": nextWorkflowStep,
|
||||||
|
|||||||
Reference in New Issue
Block a user