forked from Yara724/api
Fix PDF return data
This commit is contained in:
@@ -39,6 +39,8 @@ describe("buildInsurerFileReport", () => {
|
|||||||
userId: "guilty-user-id",
|
userId: "guilty-user-id",
|
||||||
fullName: "مقصر نمونه",
|
fullName: "مقصر نمونه",
|
||||||
phoneNumber: "09120000000",
|
phoneNumber: "09120000000",
|
||||||
|
nationalCodeOfInsurer: "0987654321",
|
||||||
|
insurerBirthday: 13650115,
|
||||||
clientId: "client-guilty",
|
clientId: "client-guilty",
|
||||||
},
|
},
|
||||||
statement: {
|
statement: {
|
||||||
@@ -155,6 +157,13 @@ describe("buildInsurerFileReport", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(getFieldValue(report, PR.ownerSection, PR.name)).toBe("زیان دیده نمونه");
|
||||||
|
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.name)).toBe("مقصر نمونه");
|
||||||
|
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.phone)).toBe("09120000000");
|
||||||
|
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.nationalCode)).toBe(
|
||||||
|
"0987654321",
|
||||||
|
);
|
||||||
|
|
||||||
expect(getFieldValue(report, PR.damagedThirdPartyInsuranceSection, PR.policyNumber)).toBe(
|
expect(getFieldValue(report, PR.damagedThirdPartyInsuranceSection, PR.policyNumber)).toBe(
|
||||||
"TP-DAMAGED-001",
|
"TP-DAMAGED-001",
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -477,28 +477,48 @@ function buildCarBodyInsuranceFields(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildOwnerSection(
|
function buildPartyOwnerSection(
|
||||||
damagedParty: ReportParty | null,
|
title: string,
|
||||||
claim?: Record<string, unknown> | null,
|
party: ReportParty | null | undefined,
|
||||||
): InsurerFileReportSection {
|
options?: {
|
||||||
const person = damagedParty?.person as ReportRecord | undefined;
|
claim?: Record<string, unknown> | null;
|
||||||
|
useClaimOwnerFallback?: boolean;
|
||||||
|
includeSheba?: boolean;
|
||||||
|
},
|
||||||
|
): InsurerFileReportSection | undefined {
|
||||||
|
const person = party?.person as ReportRecord | undefined;
|
||||||
|
const claim = options?.claim;
|
||||||
const money = claim?.money as
|
const money = claim?.money as
|
||||||
| { sheba?: string; nationalCodeOfInsurer?: string }
|
| { sheba?: string; nationalCodeOfInsurer?: string }
|
||||||
| undefined;
|
| undefined;
|
||||||
const claimOwner = claim?.owner as { fullName?: string } | undefined;
|
const claimOwner = claim?.owner as { fullName?: string } | undefined;
|
||||||
|
|
||||||
return buildSection(PR.ownerSection, [
|
if (!person && !options?.useClaimOwnerFallback) return undefined;
|
||||||
{ label: PR.name, value: firstDefined(person?.fullName, claimOwner?.fullName) },
|
|
||||||
|
return buildSection(title, [
|
||||||
|
{
|
||||||
|
label: PR.name,
|
||||||
|
value: options?.useClaimOwnerFallback
|
||||||
|
? firstDefined(person?.fullName, claimOwner?.fullName)
|
||||||
|
: firstDefined(person?.fullName),
|
||||||
|
},
|
||||||
{ label: PR.phone, value: asString(person?.phoneNumber) },
|
{ label: PR.phone, value: asString(person?.phoneNumber) },
|
||||||
{
|
{
|
||||||
label: PR.nationalCode,
|
label: PR.nationalCode,
|
||||||
value: firstDefined(person?.nationalCodeOfInsurer, money?.nationalCodeOfInsurer),
|
value: options?.useClaimOwnerFallback
|
||||||
|
? firstDefined(person?.nationalCodeOfInsurer, money?.nationalCodeOfInsurer)
|
||||||
|
: firstDefined(person?.nationalCodeOfInsurer, person?.nationalCode),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: PR.birthDate,
|
label: PR.birthDate,
|
||||||
value: formatBirthDate(person?.insurerBirthday ?? person?.birthday),
|
value: formatBirthDate(
|
||||||
|
person?.insurerBirthday ?? person?.birthday ?? person?.driverBirthday,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PR.sheba,
|
||||||
|
value: options?.includeSheba ? money?.sheba : undefined,
|
||||||
},
|
},
|
||||||
{ label: PR.sheba, value: money?.sheba },
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -838,7 +858,14 @@ export function buildInsurerFileReport(file: {
|
|||||||
|
|
||||||
const sections = filterEmptySections([
|
const sections = filterEmptySections([
|
||||||
buildCaseTimelineSection(overview, claim),
|
buildCaseTimelineSection(overview, claim),
|
||||||
buildOwnerSection(damagedParty, claim),
|
buildPartyOwnerSection(PR.ownerSection, damagedParty, {
|
||||||
|
claim,
|
||||||
|
useClaimOwnerFallback: true,
|
||||||
|
includeSheba: true,
|
||||||
|
}),
|
||||||
|
includeGuiltySections
|
||||||
|
? buildPartyOwnerSection(PR.guiltyOwnerSection, guiltyParty)
|
||||||
|
: undefined,
|
||||||
buildDriverSection(damagedParty, blameContext),
|
buildDriverSection(damagedParty, blameContext),
|
||||||
buildSection(
|
buildSection(
|
||||||
PR.damagedThirdPartyInsuranceSection,
|
PR.damagedThirdPartyInsuranceSection,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export const PR = {
|
|||||||
requestNo: "شماره درخواست",
|
requestNo: "شماره درخواست",
|
||||||
empty: "-",
|
empty: "-",
|
||||||
ownerSection: "مالک خودروی زیان دیده",
|
ownerSection: "مالک خودروی زیان دیده",
|
||||||
|
guiltyOwnerSection: "مالک خودروی مقصر",
|
||||||
driverSection: "راننده خودروی زیان دیده",
|
driverSection: "راننده خودروی زیان دیده",
|
||||||
damagedThirdPartyInsuranceSection: "بیمه شخص ثالث زیاندیده",
|
damagedThirdPartyInsuranceSection: "بیمه شخص ثالث زیاندیده",
|
||||||
damagedCarBodyInsuranceSection: "بیمه بدنه زیاندیده",
|
damagedCarBodyInsuranceSection: "بیمه بدنه زیاندیده",
|
||||||
|
|||||||
Reference in New Issue
Block a user