forked from Yara724/api
Added new data for YARA-1241
This commit is contained in:
@@ -41,7 +41,21 @@ describe("buildInsurerFileReport", () => {
|
|||||||
phoneNumber: "09120000000",
|
phoneNumber: "09120000000",
|
||||||
clientId: "client-guilty",
|
clientId: "client-guilty",
|
||||||
},
|
},
|
||||||
statement: { admitsGuilt: true },
|
statement: {
|
||||||
|
admitsGuilt: true,
|
||||||
|
acceptsExpertOpinion: true,
|
||||||
|
description: "توضیحات مقصر",
|
||||||
|
},
|
||||||
|
vehicle: {
|
||||||
|
carName: "206",
|
||||||
|
carModel: "1401",
|
||||||
|
plate: {
|
||||||
|
leftDigits: 98,
|
||||||
|
centerAlphabet: "ج",
|
||||||
|
centerDigits: 765,
|
||||||
|
ir: 22,
|
||||||
|
},
|
||||||
|
},
|
||||||
insurance: {
|
insurance: {
|
||||||
policyNumber: "TP-GUILTY-001",
|
policyNumber: "TP-GUILTY-001",
|
||||||
company: "بیمه ثالث مقصر",
|
company: "بیمه ثالث مقصر",
|
||||||
@@ -68,6 +82,7 @@ describe("buildInsurerFileReport", () => {
|
|||||||
},
|
},
|
||||||
statement: {
|
statement: {
|
||||||
claimsDamage: true,
|
claimsDamage: true,
|
||||||
|
acceptsExpertOpinion: false,
|
||||||
description: "توضیحات زیاندیده",
|
description: "توضیحات زیاندیده",
|
||||||
accidentDate: "2026-08-10",
|
accidentDate: "2026-08-10",
|
||||||
accidentTime: "13:23",
|
accidentTime: "13:23",
|
||||||
@@ -153,6 +168,32 @@ describe("buildInsurerFileReport", () => {
|
|||||||
"CB-GUILTY-001",
|
"CB-GUILTY-001",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(getFieldValue(report, PR.damagedVehicleSection, "خودرو / نام خودرو")).toBe(
|
||||||
|
"207",
|
||||||
|
);
|
||||||
|
expect(getFieldValue(report, PR.guiltyVehicleSection, "خودرو / نام خودرو")).toBe(
|
||||||
|
"206",
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(getFieldValue(report, PR.damagedStatementSection, PR.partyDescription)).toBe(
|
||||||
|
"توضیحات زیاندیده",
|
||||||
|
);
|
||||||
|
expect(getFieldValue(report, PR.damagedStatementSection, PR.claimsDamage)).toBe(
|
||||||
|
"بله",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
getFieldValue(report, PR.damagedStatementSection, PR.acceptsExpertOpinion),
|
||||||
|
).toBe("خیر");
|
||||||
|
expect(getFieldValue(report, PR.guiltyStatementSection, PR.partyDescription)).toBe(
|
||||||
|
"توضیحات مقصر",
|
||||||
|
);
|
||||||
|
expect(getFieldValue(report, PR.guiltyStatementSection, PR.admitsGuilt)).toBe(
|
||||||
|
"بله",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
getFieldValue(report, PR.guiltyStatementSection, PR.acceptsExpertOpinion),
|
||||||
|
).toBe("بله");
|
||||||
|
|
||||||
expect(getFieldValue(report, PR.fanavaranSection, PR.fanavaranClaimNo)).toBe(
|
expect(getFieldValue(report, PR.fanavaranSection, PR.fanavaranClaimNo)).toBe(
|
||||||
"111",
|
"111",
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -258,6 +258,28 @@ function getPartyRole(party: ReportParty | null | undefined): string | undefined
|
|||||||
return typeof role === "string" ? role : undefined;
|
return typeof role === "string" ? role : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function partyKindLabel(
|
||||||
|
party: ReportParty | null | undefined,
|
||||||
|
damagedParty: ReportParty | null,
|
||||||
|
guiltyParty: ReportParty | null,
|
||||||
|
): string | undefined {
|
||||||
|
if (sameParty(party, damagedParty)) return "damaged";
|
||||||
|
if (sameParty(party, guiltyParty)) return "guilty";
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function partyRoleLabel(role: string | undefined): string | undefined {
|
||||||
|
if (!role) return undefined;
|
||||||
|
if (role === PartyRole.FIRST) return "طرف اول";
|
||||||
|
if (role === PartyRole.SECOND) return "طرف دوم";
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
function statementBoolean(value: unknown): string | undefined {
|
||||||
|
if (typeof value !== "boolean") return undefined;
|
||||||
|
return persianStatus(value);
|
||||||
|
}
|
||||||
|
|
||||||
function sameParty(
|
function sameParty(
|
||||||
first: ReportParty | null | undefined,
|
first: ReportParty | null | undefined,
|
||||||
second: ReportParty | null | undefined,
|
second: ReportParty | null | undefined,
|
||||||
@@ -536,16 +558,60 @@ function buildDriverSection(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildVehicleSection(
|
function buildPartyVehicleSection(
|
||||||
damagedParty: ReportParty | null,
|
title: string,
|
||||||
claim?: Record<string, unknown> | null,
|
party: ReportParty | null | undefined,
|
||||||
): InsurerFileReportSection {
|
claimVehicle?: Record<string, unknown>,
|
||||||
const partyVehicle = damagedParty?.vehicle;
|
): InsurerFileReportSection | undefined {
|
||||||
const claimVehicle = claim?.vehicle as Record<string, unknown> | undefined;
|
if (!party && !claimVehicle) return undefined;
|
||||||
|
|
||||||
return buildSection(PR.vehicleSection, [
|
return buildSection(title, [
|
||||||
...flattenObject(claimVehicle, "claim.vehicle"),
|
...flattenObject(claimVehicle, "claim.vehicle"),
|
||||||
...flattenObject(partyVehicle, "party.vehicle"),
|
...flattenObject(party?.vehicle, "party.vehicle"),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPartyStatementSection(
|
||||||
|
title: string,
|
||||||
|
party: ReportParty | null | undefined,
|
||||||
|
damagedParty: ReportParty | null,
|
||||||
|
guiltyParty: ReportParty | null,
|
||||||
|
): InsurerFileReportSection | undefined {
|
||||||
|
if (!party) return undefined;
|
||||||
|
const statement = (party.statement ?? {}) as ReportRecord;
|
||||||
|
const kind = partyKindLabel(party, damagedParty, guiltyParty);
|
||||||
|
|
||||||
|
return buildSection(title, [
|
||||||
|
{
|
||||||
|
label: PR.partyRole,
|
||||||
|
value: partyRoleLabel(getPartyRole(party)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PR.name,
|
||||||
|
value: firstDefined(party.person?.fullName),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PR.admitsGuilt,
|
||||||
|
value:
|
||||||
|
kind === "damaged"
|
||||||
|
? undefined
|
||||||
|
: statementBoolean(statement.admitsGuilt),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PR.claimsDamage,
|
||||||
|
value:
|
||||||
|
kind === "guilty"
|
||||||
|
? undefined
|
||||||
|
: statementBoolean(statement.claimsDamage),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PR.acceptsExpertOpinion,
|
||||||
|
value: statementBoolean(statement.acceptsExpertOpinion),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PR.partyDescription,
|
||||||
|
value: asString(statement.description),
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,6 +834,8 @@ export function buildInsurerFileReport(file: {
|
|||||||
String((blameContext?.type as string | undefined) ?? "") === "CAR_BODY";
|
String((blameContext?.type as string | undefined) ?? "") === "CAR_BODY";
|
||||||
const includeGuiltySections = !!guiltyParty && !(isCarBody && sameParty(damagedParty, guiltyParty));
|
const includeGuiltySections = !!guiltyParty && !(isCarBody && sameParty(damagedParty, guiltyParty));
|
||||||
|
|
||||||
|
const claimVehicle = claim?.vehicle as Record<string, unknown> | undefined;
|
||||||
|
|
||||||
const sections = filterEmptySections([
|
const sections = filterEmptySections([
|
||||||
buildCaseTimelineSection(overview, claim),
|
buildCaseTimelineSection(overview, claim),
|
||||||
buildOwnerSection(damagedParty, claim),
|
buildOwnerSection(damagedParty, claim),
|
||||||
@@ -792,7 +860,24 @@ export function buildInsurerFileReport(file: {
|
|||||||
buildCarBodyInsuranceFields(guiltyParty, blameContext, claim),
|
buildCarBodyInsuranceFields(guiltyParty, blameContext, claim),
|
||||||
)
|
)
|
||||||
: undefined,
|
: undefined,
|
||||||
buildVehicleSection(damagedParty, claim),
|
buildPartyVehicleSection(PR.damagedVehicleSection, damagedParty, claimVehicle),
|
||||||
|
includeGuiltySections
|
||||||
|
? buildPartyVehicleSection(PR.guiltyVehicleSection, guiltyParty)
|
||||||
|
: undefined,
|
||||||
|
buildPartyStatementSection(
|
||||||
|
PR.damagedStatementSection,
|
||||||
|
damagedParty,
|
||||||
|
damagedParty,
|
||||||
|
guiltyParty,
|
||||||
|
),
|
||||||
|
includeGuiltySections
|
||||||
|
? buildPartyStatementSection(
|
||||||
|
PR.guiltyStatementSection,
|
||||||
|
guiltyParty,
|
||||||
|
damagedParty,
|
||||||
|
guiltyParty,
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
buildFanavaranCodesSection(claim),
|
buildFanavaranCodesSection(claim),
|
||||||
buildEvaluationSection(claim),
|
buildEvaluationSection(claim),
|
||||||
buildAccidentReportSection(blameContext, claim, damagedParty),
|
buildAccidentReportSection(blameContext, claim, damagedParty),
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ export const PR = {
|
|||||||
damagedCarBodyInsuranceSection: "بیمه بدنه زیاندیده",
|
damagedCarBodyInsuranceSection: "بیمه بدنه زیاندیده",
|
||||||
guiltyThirdPartyInsuranceSection: "بیمه شخص ثالث مقصر",
|
guiltyThirdPartyInsuranceSection: "بیمه شخص ثالث مقصر",
|
||||||
guiltyCarBodyInsuranceSection: "بیمه بدنه مقصر",
|
guiltyCarBodyInsuranceSection: "بیمه بدنه مقصر",
|
||||||
|
damagedVehicleSection: "اطلاعات خودروی زیاندیده",
|
||||||
|
guiltyVehicleSection: "اطلاعات خودروی مقصر",
|
||||||
vehicleSection: "اطلاعات خودرو",
|
vehicleSection: "اطلاعات خودرو",
|
||||||
|
damagedStatementSection: "اظهارات و اقرار زیاندیده",
|
||||||
|
guiltyStatementSection: "اظهارات و اقرار مقصر",
|
||||||
timelineSection: "زمانبندی پرونده",
|
timelineSection: "زمانبندی پرونده",
|
||||||
fanavaranSection: "کدهای فناوران",
|
fanavaranSection: "کدهای فناوران",
|
||||||
evaluationSection: "نتیجه ارزیابی",
|
evaluationSection: "نتیجه ارزیابی",
|
||||||
@@ -43,6 +47,10 @@ export const PR = {
|
|||||||
evaluationExpert: "کارشناس ارزیاب",
|
evaluationExpert: "کارشناس ارزیاب",
|
||||||
evaluationSubmittedAt: "تاریخ و ساعت ثبت ارزیابی",
|
evaluationSubmittedAt: "تاریخ و ساعت ثبت ارزیابی",
|
||||||
evaluationResponse: "پاسخ / توضیحات کارشناس",
|
evaluationResponse: "پاسخ / توضیحات کارشناس",
|
||||||
|
admitsGuilt: "اقرار به تقصیر",
|
||||||
|
claimsDamage: "ادعای خسارت",
|
||||||
|
acceptsExpertOpinion: "پذیرش نظر کارشناس",
|
||||||
|
partyRole: "نقش طرف",
|
||||||
data: "اطلاعات",
|
data: "اطلاعات",
|
||||||
date: "تاریخ",
|
date: "تاریخ",
|
||||||
time: "زمان",
|
time: "زمان",
|
||||||
|
|||||||
Reference in New Issue
Block a user