forked from Yara724/api
Merge pull request 'Removed unncessary data from PDF' (#308) from s.yahyaee/yara724-api:main into main
Reviewed-on: Yara724/api#308
This commit is contained in:
@@ -324,6 +324,61 @@ describe("buildInsurerFileReport", () => {
|
|||||||
).toBe("1405/05/19 16:00");
|
).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", () => {
|
it("uses the stored V4 licence type for a driver who differs from the policyholder", () => {
|
||||||
const report = buildInsurerFileReport({
|
const report = buildInsurerFileReport({
|
||||||
overview: { publicId: "A00011" },
|
overview: { publicId: "A00011" },
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const SKIP_FLATTEN_KEYS = new Set([
|
|||||||
"confirmation",
|
"confirmation",
|
||||||
"inquiries",
|
"inquiries",
|
||||||
"raw",
|
"raw",
|
||||||
|
"source",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
type ReportRecord = Record<string, unknown>;
|
type ReportRecord = Record<string, unknown>;
|
||||||
@@ -39,6 +40,7 @@ type ReportParty = ReportRecord & {
|
|||||||
|
|
||||||
function asString(value: unknown): string | undefined {
|
function asString(value: unknown): string | undefined {
|
||||||
if (value === undefined || value === null || value === "") return undefined;
|
if (value === undefined || value === null || value === "") return undefined;
|
||||||
|
if (typeof value === "boolean") return value ? "بله" : "خیر";
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
const [d, t] = toJalaliDateAndTime(value);
|
const [d, t] = toJalaliDateAndTime(value);
|
||||||
return `${d} ${t}`;
|
return `${d} ${t}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user