forked from Yara724/api
Added new data for YARA-1241
This commit is contained in:
@@ -258,6 +258,28 @@ function getPartyRole(party: ReportParty | null | undefined): string | 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(
|
||||
first: ReportParty | null | undefined,
|
||||
second: ReportParty | null | undefined,
|
||||
@@ -536,16 +558,60 @@ function buildDriverSection(
|
||||
]);
|
||||
}
|
||||
|
||||
function buildVehicleSection(
|
||||
damagedParty: ReportParty | null,
|
||||
claim?: Record<string, unknown> | null,
|
||||
): InsurerFileReportSection {
|
||||
const partyVehicle = damagedParty?.vehicle;
|
||||
const claimVehicle = claim?.vehicle as Record<string, unknown> | undefined;
|
||||
function buildPartyVehicleSection(
|
||||
title: string,
|
||||
party: ReportParty | null | undefined,
|
||||
claimVehicle?: Record<string, unknown>,
|
||||
): InsurerFileReportSection | undefined {
|
||||
if (!party && !claimVehicle) return undefined;
|
||||
|
||||
return buildSection(PR.vehicleSection, [
|
||||
return buildSection(title, [
|
||||
...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";
|
||||
const includeGuiltySections = !!guiltyParty && !(isCarBody && sameParty(damagedParty, guiltyParty));
|
||||
|
||||
const claimVehicle = claim?.vehicle as Record<string, unknown> | undefined;
|
||||
|
||||
const sections = filterEmptySections([
|
||||
buildCaseTimelineSection(overview, claim),
|
||||
buildOwnerSection(damagedParty, claim),
|
||||
@@ -792,7 +860,24 @@ export function buildInsurerFileReport(file: {
|
||||
buildCarBodyInsuranceFields(guiltyParty, blameContext, claim),
|
||||
)
|
||||
: 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),
|
||||
buildEvaluationSection(claim),
|
||||
buildAccidentReportSection(blameContext, claim, damagedParty),
|
||||
|
||||
Reference in New Issue
Block a user