Skip to content

Commit 4225fe2

Browse files
committed
refactor(createRenunciantPerson): add missing testator text and acknowledgment details
1 parent 20c8419 commit 4225fe2

2 files changed

Lines changed: 86 additions & 8 deletions

File tree

app/domains/nachlass/erbausschlagung/anfrage/services/pdf/sections/renunciantPerson/__test__/createRenunciantPerson.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,41 @@ describe("createRenunciantPerson", () => {
5757

5858
expect(addRenunciantPersonContactDetails).toHaveBeenCalledTimes(1);
5959
});
60+
61+
it("should add the relationship with testator details", () => {
62+
const mockStruct = mockPdfKitDocumentStructure();
63+
const mockDoc = mockPdfKitDocument(mockStruct);
64+
65+
createRenunciantPerson(mockDoc, mockStruct, {
66+
ausschlagendePersonBeziehungZumErblasser: "mother-father",
67+
});
68+
69+
expect(mockDoc.text).toHaveBeenCalledWith(
70+
"Familienverhältnis zum Erblasser: ",
71+
{ continued: true },
72+
);
73+
expect(mockDoc.text).toHaveBeenCalledWith(
74+
"Erblasser ist mein(e) Mutter/Vater",
75+
);
76+
});
77+
78+
it("should add the acknowledgment details", () => {
79+
const mockStruct = mockPdfKitDocumentStructure();
80+
const mockDoc = mockPdfKitDocument(mockStruct);
81+
82+
createRenunciantPerson(mockDoc, mockStruct, {
83+
dateOfReceipt: { day: "01", month: "01", year: "2020" },
84+
weitereAngaben: "Some additional info",
85+
});
86+
87+
expect(mockDoc.text).toHaveBeenCalledWith(
88+
"Kenntnisnahme der Erbenstellung am: ",
89+
{ continued: true },
90+
);
91+
expect(mockDoc.text).toHaveBeenCalledWith("01.01.2020");
92+
expect(mockDoc.text).toHaveBeenCalledWith("Anmerkung zur Kenntnisnahme: ", {
93+
continued: true,
94+
});
95+
expect(mockDoc.text).toHaveBeenCalledWith("Some additional info");
96+
});
6097
});

app/domains/nachlass/erbausschlagung/anfrage/services/pdf/sections/renunciantPerson/createRenunciantPerson.ts

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,59 @@ import {
77
import { addRenunciantPersonAddress } from "./addRenunciantPersonAddress";
88
import { addRenunciantPersonDetails } from "./addRenunciantPersonDetails";
99
import { addRenunciantPersonContactDetails } from "./addRenunciantPersonContactDetails";
10+
import { toDateString } from "~/services/validation/dateObject";
1011

1112
const TITLE = "II. Ausschlagende Person";
1213

13-
const addAcknowledgmentDetails = (doc: typeof PDFDocument) => {
14+
const addAcknowledgmentDetails = (
15+
doc: typeof PDFDocument,
16+
{ dateOfReceipt, weitereAngaben }: NachlassErbausschlagungAnfrageUserData,
17+
) => {
1418
doc
1519
.moveDown()
1620
.font(FONTS_BUNDESSANS_REGULAR)
1721
.text("Kenntnisnahme der Erbenstellung am: ", { continued: true })
1822
.font(FONTS_BUNDESSANS_BOLD)
19-
.text(" ")
20-
.font(FONTS_BUNDESSANS_REGULAR)
21-
.text("Anmerkung zur Kenntnisnahme: ", { continued: true })
22-
.font(FONTS_BUNDESSANS_BOLD)
23-
.text(" ");
23+
.text(dateOfReceipt ? toDateString(dateOfReceipt) : " ");
24+
25+
if (weitereAngaben && weitereAngaben?.length > 0) {
26+
doc
27+
.font(FONTS_BUNDESSANS_REGULAR)
28+
.text("Anmerkung zur Kenntnisnahme: ", { continued: true })
29+
.font(FONTS_BUNDESSANS_BOLD)
30+
.text(weitereAngaben);
31+
}
32+
};
33+
34+
const testatorText = (
35+
testament: NachlassErbausschlagungAnfrageUserData["ausschlagendePersonBeziehungZumErblasser"],
36+
): string => {
37+
const responses: Record<string, string> = {
38+
"mother-father": "Mutter/Vater",
39+
"daughter-son": "Tochter/Sohn",
40+
"grandmother-grandfather": "Großmutter/Großvater",
41+
"granddaughter-grandson": "Enkelin/Enkel",
42+
"great-grandmother-great-grandfather": "Urgroßmutter/Urgroßvater",
43+
"sister-brother": "Schwester/Bruder",
44+
"half-sister-half-brother": "Halbschwester/Halbbruder",
45+
"niece-nephew": "Nichte/Neffe",
46+
"aunt-uncle": "Tante/Onkel",
47+
cousin: "Cousin/Cousine",
48+
"great-aunt-great-uncle": "Großtante/Großonkel",
49+
"wife-husband": "Ehefrau/Ehemann",
50+
"life-partner": "Lebenspartner*in",
51+
"mother-in-law-father-in-law": "Schwiegermutter/Schwiegervater",
52+
"sister-in-law-brother-in-law": "Schwägerin/Schwager",
53+
"daughter-in-law-son-in-law": "Schwiegertochter/Schwiegersohn",
54+
"stepmother-stepfather": "Stiefmutter/Stiefvater",
55+
"stepdaughter-stepson": "Stieftochter/Stiefsohn",
56+
"stepsister-stepbrother": "Stiefschwester/Stiefbruder",
57+
"foster-child": "Pflegekind",
58+
"adoptive-mother-adoptive-father": "Pflegemutter/Pflegevater",
59+
"godmother-godfather": "Patentante/Patenonkel",
60+
other: "Sonstiges",
61+
};
62+
return responses[testament ?? ""] ?? "";
2463
};
2564

2665
export const createRenunciantPerson = (
@@ -53,9 +92,11 @@ export const createRenunciantPerson = (
5392
.font(FONTS_BUNDESSANS_REGULAR)
5493
.text("Familienverhältnis zum Erblasser: ", { continued: true })
5594
.font(FONTS_BUNDESSANS_BOLD)
56-
.text(userData.ausschlagendePersonBeziehungZumErblasser ?? "");
95+
.text(
96+
`Erblasser ist mein(e) ${testatorText(userData.ausschlagendePersonBeziehungZumErblasser)}`,
97+
);
5798

58-
addAcknowledgmentDetails(doc);
99+
addAcknowledgmentDetails(doc, userData);
59100

60101
addRenunciantPersonAddress(doc, userData);
61102
}),

0 commit comments

Comments
 (0)