Removed unncessary data from PDF

This commit is contained in:
SepehrYahyaee
2026-09-12 14:35:01 +03:30
parent 7fd60df1d6
commit bc9c217d8a
2 changed files with 57 additions and 0 deletions

View File

@@ -324,6 +324,61 @@ describe("buildInsurerFileReport", () => {
).toBe("1405/05/19 16:00");
});
it("localizes every boolean value", () => {
const report = buildInsurerFileReport({
overview: { publicId: "A00015" },
blame: {
type: "CAR_BODY",
parties: [
{
role: "FIRST",
person: { userId: "damaged", fullName: "بیمه‌گذار" },
vehicle: {
isNew: true,
hasEndorsement: false,
source: "ESG_CAR_BODY_INQUIRY",
inquiry: { source: "TEJARAT_BLOCK_INQUIRY" },
},
},
],
},
});
const fields = report.sections.flatMap((section) => section.fields);
expect(fields.find((field) => field.label === "خودرو / خودرو نو")?.value).toBe(
"بله",
);
expect(fields.some((field) => field.value === "خیر")).toBe(true);
expect(fields.some((field) => field.value === "true")).toBe(false);
expect(fields.some((field) => field.value === "false")).toBe(false);
});
it("hides ESG and TEJARAT inquiry source details", () => {
const report = buildInsurerFileReport({
overview: { publicId: "A00016" },
blame: {
type: "CAR_BODY",
parties: [
{
role: "FIRST",
person: { userId: "damaged", fullName: "بیمه‌گذار" },
vehicle: {
source: "ESG_CAR_BODY_INQUIRY",
inquiry: { source: "TEJARAT_BLOCK_INQUIRY" },
},
},
],
},
});
const fields = report.sections.flatMap((section) => section.fields);
expect(fields.some((field) => String(field.value).includes("ESG"))).toBe(false);
expect(fields.some((field) => String(field.value).includes("TEJARAT"))).toBe(
false,
);
expect(fields.some((field) => field.label.includes("منبع"))).toBe(false);
});
it("uses the stored V4 licence type for a driver who differs from the policyholder", () => {
const report = buildInsurerFileReport({
overview: { publicId: "A00011" },

View File

@@ -25,6 +25,7 @@ const SKIP_FLATTEN_KEYS = new Set([
"confirmation",
"inquiries",
"raw",
"source",
]);
type ReportRecord = Record<string, unknown>;
@@ -39,6 +40,7 @@ type ReportParty = ReportRecord & {
function asString(value: unknown): string | undefined {
if (value === undefined || value === null || value === "") return undefined;
if (typeof value === "boolean") return value ? "بله" : "خیر";
if (value instanceof Date) {
const [d, t] = toJalaliDateAndTime(value);
return `${d} ${t}`;