diff --git a/app/domains/fluggastrechte/services/pdf/configurations.ts b/app/domains/fluggastrechte/services/pdf/configurations.ts index 1ad74c34f..ce9503880 100644 --- a/app/domains/fluggastrechte/services/pdf/configurations.ts +++ b/app/domains/fluggastrechte/services/pdf/configurations.ts @@ -1 +1,2 @@ export const MARGIN_BETWEEN_SECTIONS = 1.5; +export const MARGIN_RIGHT = 10; diff --git a/app/domains/fluggastrechte/services/pdf/sections/firstPage/__test__/createStatementClaim.test.ts b/app/domains/fluggastrechte/services/pdf/sections/firstPage/__test__/createStatementClaim.test.ts index b2a689736..2be0ff7e3 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/firstPage/__test__/createStatementClaim.test.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/firstPage/__test__/createStatementClaim.test.ts @@ -6,32 +6,25 @@ import type { FluggastrechtContext } from "~/domains/fluggastrechte/formular/con import { getTotalCompensationClaim } from "~/domains/fluggastrechte/formular/services/getTotalCompensationClaim"; import { userDataMock } from "~/domains/fluggastrechte/services/pdf/__test__/userDataMock"; import { PDF_MARGIN_HORIZONTAL } from "~/services/pdf/createPdfKitDocument"; +import { addDefendantPartyList } from "../claimData/addDefendantPartyList"; import { createStatementClaim, - STATEMENT_CLAIM_AGREEMENT_SENTENCE, STATEMENT_CLAIM_COURT_SENTENCE, STATEMENT_CLAIM_SUBTITLE_TEXT, STATEMENT_CLAIM_TITLE_TEXT, - getDefendantPartyList, } from "../createStatementClaim"; -function assertDefendantPartyList( - mockDoc: PDFKit.PDFDocument, - defendantPartyList: Record, -) { - for (const [bullet, claim] of Object.entries(defendantPartyList)) { - expect(mockDoc.text).toHaveBeenCalledWith(bullet, 80, undefined, { - continued: true, - }); - expect(mockDoc.text).toHaveBeenCalledWith(claim, { width: 500 }); - } -} +const STATEMENT_VIDEO_TRIAL_AGREEMENT = + "Ich stimme der Durchführung einer Videoverhandlung (§ 128a ZPO) zu."; +const STATEMENT_VIDEO_TRIAL_NO_AGREEMENT = + "Ich stimme der Durchführung einer Videoverhandlung (§ 128a ZPO) nicht zu."; describe("createStatementClaim", () => { beforeEach(() => { vi.mock( "~/domains/fluggastrechte/formular/services/getTotalCompensationClaim", ); + vi.mock("../claimData/addDefendantPartyList"); vi.mocked(getTotalCompensationClaim).mockReturnValue(600); }); @@ -52,33 +45,12 @@ describe("createStatementClaim", () => { expect(mockDoc.text).toHaveBeenCalledWith(STATEMENT_CLAIM_TITLE_TEXT); expect(mockDoc.text).toHaveBeenCalledWith(STATEMENT_CLAIM_SUBTITLE_TEXT); - const compensation = getTotalCompensationClaim({ - startAirport: userDataMock.startAirport, - endAirport: userDataMock.endAirport, - }); - - const defendantPartyList = getDefendantPartyList( - userDataMock.prozesszinsen, - compensation, - ); - - assertDefendantPartyList(mockDoc, defendantPartyList); - }); - - it("should create a list structure with list items", () => { - const mockStruct = mockPdfKitDocumentStructure(); - const mockDoc = mockPdfKitDocument(mockStruct); - - createStatementClaim(mockDoc, mockStruct, userDataMock); - - expect(mockDoc.struct).toHaveBeenCalledWith("L"); - expect(mockDoc.struct).toHaveBeenCalledWith("LI", {}, expect.any(Function)); - - const defendantPartyList = getDefendantPartyList( + expect(addDefendantPartyList).toHaveBeenCalledWith( + mockDoc, + mockStruct, userDataMock.prozesszinsen, 600, ); - assertDefendantPartyList(mockDoc, defendantPartyList); }); describe("createStatementClaim - versaeumnisurteil logic", () => { @@ -123,15 +95,47 @@ describe("createStatementClaim", () => { PDF_MARGIN_HORIZONTAL, ); }); + }); + + describe("createStatementClaim - videoverhandlung logic", () => { + it("should include videoverhandlung sentence when videoverhandlung is yes", () => { + const mockStruct = mockPdfKitDocumentStructure(); + const mockDoc = mockPdfKitDocument(mockStruct); + + const userDataMockWithVersaeumnisurteil = { + ...userDataMock, + videoverhandlung: "yes", + } satisfies FluggastrechtContext; + + createStatementClaim( + mockDoc, + mockStruct, + userDataMockWithVersaeumnisurteil, + ); + + expect(mockDoc.text).toHaveBeenCalledWith( + STATEMENT_VIDEO_TRIAL_AGREEMENT, + PDF_MARGIN_HORIZONTAL, + ); + }); - it("should include agreement sentence regardless of versaeumnisurteil", () => { + it("should not include videoverhandlung sentence when videoverhandlung is no", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - createStatementClaim(mockDoc, mockStruct, userDataMock); + const userDataMockWithoutVersaeumnisurteil = { + ...userDataMock, + videoverhandlung: "no", + } satisfies FluggastrechtContext; + + createStatementClaim( + mockDoc, + mockStruct, + userDataMockWithoutVersaeumnisurteil, + ); expect(mockDoc.text).toHaveBeenCalledWith( - STATEMENT_CLAIM_AGREEMENT_SENTENCE, + STATEMENT_VIDEO_TRIAL_NO_AGREEMENT, PDF_MARGIN_HORIZONTAL, ); }); diff --git a/app/domains/fluggastrechte/services/pdf/sections/firstPage/claimData/__test__/addDefendantPartyList.test.ts b/app/domains/fluggastrechte/services/pdf/sections/firstPage/claimData/__test__/addDefendantPartyList.test.ts new file mode 100644 index 000000000..411eff769 --- /dev/null +++ b/app/domains/fluggastrechte/services/pdf/sections/firstPage/claimData/__test__/addDefendantPartyList.test.ts @@ -0,0 +1,71 @@ +import { + mockPdfKitDocument, + mockPdfKitDocumentStructure, +} from "tests/factories/mockPdfKit"; +import { MARGIN_RIGHT } from "~/domains/fluggastrechte/services/pdf/configurations"; +import { + FONTS_BUNDESSANS_BOLD, + FONTS_BUNDESSANS_REGULAR, + PDF_MARGIN_HORIZONTAL, +} from "~/services/pdf/createPdfKitDocument"; +import { addDefendantPartyList } from "../addDefendantPartyList"; + +describe("addDefendantPartyList", () => { + it("should create document with defendant party list when litigation interest is requested", () => { + const mockStruct = mockPdfKitDocumentStructure(); + const mockDoc = mockPdfKitDocument(mockStruct); + + addDefendantPartyList(mockDoc, mockStruct, "yes", 600); + + expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_BOLD); + expect(mockDoc.text).toHaveBeenCalledWith( + "1. ", + PDF_MARGIN_HORIZONTAL + MARGIN_RIGHT, + undefined, + { continued: true }, + ); + expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_REGULAR); + expect(mockDoc.text).toHaveBeenCalledWith( + "Die beklagte Partei wird verurteilt, an die klagende Partei 600 € nebst Zinsen in Höhe von 5 Prozentpunkten über dem jeweiligen Basiszinssatz seit Rechtshängigkeit zu zahlen.", + ); + expect(mockDoc.text).toHaveBeenCalledWith( + "2. ", + PDF_MARGIN_HORIZONTAL + MARGIN_RIGHT, + undefined, + { continued: true }, + ); + expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_REGULAR); + expect(mockDoc.text).toHaveBeenCalledWith( + "Die beklagte Partei trägt die Kosten des Rechtsstreits.", + ); + }); + + it("should create document with defendant party list when litigation interest is not requested", () => { + const mockStruct = mockPdfKitDocumentStructure(); + const mockDoc = mockPdfKitDocument(mockStruct); + + addDefendantPartyList(mockDoc, mockStruct, "no", 600); + + expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_BOLD); + expect(mockDoc.text).toHaveBeenCalledWith( + "1. ", + PDF_MARGIN_HORIZONTAL + MARGIN_RIGHT, + undefined, + { continued: true }, + ); + expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_REGULAR); + expect(mockDoc.text).toHaveBeenCalledWith( + "Die beklagte Partei wird verurteilt, an die klagende Partei 600 € zu zahlen.", + ); + expect(mockDoc.text).toHaveBeenCalledWith( + "2. ", + PDF_MARGIN_HORIZONTAL + MARGIN_RIGHT, + undefined, + { continued: true }, + ); + expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_REGULAR); + expect(mockDoc.text).toHaveBeenCalledWith( + "Die beklagte Partei trägt die Kosten des Rechtsstreits.", + ); + }); +}); diff --git a/app/domains/fluggastrechte/services/pdf/sections/firstPage/claimData/addDefendantPartyList.ts b/app/domains/fluggastrechte/services/pdf/sections/firstPage/claimData/addDefendantPartyList.ts new file mode 100644 index 000000000..c4bc3307b --- /dev/null +++ b/app/domains/fluggastrechte/services/pdf/sections/firstPage/claimData/addDefendantPartyList.ts @@ -0,0 +1,43 @@ +import type PDFDocument from "pdfkit"; +import { MARGIN_RIGHT } from "~/domains/fluggastrechte/services/pdf/configurations"; +import { + FONTS_BUNDESSANS_BOLD, + FONTS_BUNDESSANS_REGULAR, + PDF_MARGIN_HORIZONTAL, +} from "~/services/pdf/createPdfKitDocument"; + +export const addDefendantPartyList = ( + doc: typeof PDFDocument, + statementClaimSect: PDFKit.PDFStructureElement, + prozesszinsen: string, + streitwert: number, +) => { + const interestClause = + prozesszinsen === "yes" + ? " nebst Zinsen in Höhe von 5 Prozentpunkten über dem jeweiligen Basiszinssatz seit Rechtshängigkeit" + : ""; + + const defendantPartyList = { + "1. ": `Die beklagte Partei wird verurteilt, an die klagende Partei ${streitwert} €${interestClause} zu zahlen.`, + "2. ": "Die beklagte Partei trägt die Kosten des Rechtsstreits.", + }; + + const statementClaimList = doc.struct("L"); + + for (const [bullet, claim] of Object.entries(defendantPartyList)) { + statementClaimList.add( + doc.struct("LI", {}, () => { + doc + .font(FONTS_BUNDESSANS_BOLD) + .text(bullet, PDF_MARGIN_HORIZONTAL + MARGIN_RIGHT, undefined, { + continued: true, + }) + .font(FONTS_BUNDESSANS_REGULAR) + .text(claim); + doc.moveDown(0.5); + }), + ); + } + + statementClaimSect.add(statementClaimList); +}; diff --git a/app/domains/fluggastrechte/services/pdf/sections/firstPage/createStatementClaim.ts b/app/domains/fluggastrechte/services/pdf/sections/firstPage/createStatementClaim.ts index 8b2f90017..fc0a9c23b 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/firstPage/createStatementClaim.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/firstPage/createStatementClaim.ts @@ -6,43 +6,26 @@ import { FONTS_BUNDESSANS_REGULAR, PDF_MARGIN_HORIZONTAL, } from "~/services/pdf/createPdfKitDocument"; - -export const getDefendantPartyList = ( - prozesszinsen: string, - streitwert: number, -): Record => { - const interestClause = - prozesszinsen === "yes" - ? " nebst Zinsen in Höhe von 5 Prozentpunkten über dem jeweiligen Basiszinssatz seit Rechtshängigkeit" - : ""; - - return { - "1. ": `Die beklagte Partei zu verurteilen, an die klagende Partei ${streitwert} €${interestClause} zu zahlen.`, - "2. ": "Die beklagte Partei trägt die Kosten des Rechtsstreits.", - }; -}; +import { addDefendantPartyList } from "./claimData/addDefendantPartyList"; export const STATEMENT_CLAIM_TITLE_TEXT = "Klageantrag"; -export const STATEMENT_CLAIM_SUBTITLE_TEXT = "Es wird beantragt,"; +export const STATEMENT_CLAIM_SUBTITLE_TEXT = + "Es werden folgende Anträge gestellt:"; export const STATEMENT_CLAIM_COURT_SENTENCE = "Sofern die gesetzlichen Voraussetzungen vorliegen, wird hiermit der Erlass eines Versäumnisurteils gem. § 331 Abs. 1 und Abs. 3 ZPO gestellt."; -export const STATEMENT_CLAIM_AGREEMENT_SENTENCE = - "Mit einer Entscheidung im schriftlichen Verfahren ohne mündliche Verhandlung (§ 128 Abs. 2 ZPO) sowie der Durchführung einer Videoverhandlung (§ 128a ZPO) bin ich einverstanden."; -export const MARGIN_RIGHT = 10; + +const videoTrialAgreement = (videoverhandlung: string | undefined) => { + return `Ich stimme der Durchführung einer Videoverhandlung (§ 128a ZPO) ${videoverhandlung === "yes" ? "" : "nicht "}zu.`; +}; export const createStatementClaim = ( doc: typeof PDFDocument, documentStruct: PDFKit.PDFStructureElement, userData: FluggastrechtContext, ) => { - const { prozesszinsen, versaeumnisurteil } = userData; + const { prozesszinsen, versaeumnisurteil, videoverhandlung } = userData; const compensationByDistance = getTotalCompensationClaim(userData); - const defendantPartyList = getDefendantPartyList( - prozesszinsen ?? "", - compensationByDistance, - ); - const statementClaimSect = doc.struct("Sect"); statementClaimSect.add( doc.struct("H2", {}, () => { @@ -63,33 +46,20 @@ export const createStatementClaim = ( }), ); - const statementClaimList = doc.struct("L"); - - for (const [bullet, claim] of Object.entries(defendantPartyList)) { - statementClaimList.add( - doc.struct("LI", {}, () => { - doc - .font(FONTS_BUNDESSANS_BOLD) - .text(bullet, PDF_MARGIN_HORIZONTAL + MARGIN_RIGHT, undefined, { - continued: true, - }) - .font(FONTS_BUNDESSANS_REGULAR) - .text(claim, { width: 500 }); - doc.moveDown(0.5); - }), - ); - } - - statementClaimSect.add(statementClaimList); + addDefendantPartyList( + doc, + statementClaimSect, + prozesszinsen ?? "", + compensationByDistance, + ); statementClaimSect.add( doc.struct("P", {}, () => { if (versaeumnisurteil === "yes") { doc.text(STATEMENT_CLAIM_COURT_SENTENCE, PDF_MARGIN_HORIZONTAL); } - doc.text(STATEMENT_CLAIM_AGREEMENT_SENTENCE, PDF_MARGIN_HORIZONTAL); + doc.text(videoTrialAgreement(videoverhandlung), PDF_MARGIN_HORIZONTAL); }), ); - documentStruct.add(statementClaimSect); }; diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addMultiplePersonsInfo.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addMultiplePersonsInfo.ts index fcdcbff7a..1b4cd7263 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addMultiplePersonsInfo.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addMultiplePersonsInfo.ts @@ -1,6 +1,9 @@ import type PDFDocument from "pdfkit"; import type { FluggastrechtContext } from "~/domains/fluggastrechte/formular/context"; -import { MARGIN_BETWEEN_SECTIONS } from "~/domains/fluggastrechte/services/pdf/configurations"; +import { + MARGIN_BETWEEN_SECTIONS, + MARGIN_RIGHT, +} from "~/domains/fluggastrechte/services/pdf/configurations"; import { FONTS_BUNDESSANS_BOLD, FONTS_BUNDESSANS_REGULAR, @@ -20,8 +23,6 @@ export const INFORMATION_BOOKING_AND_ASSIGNMENTS_ANNULLIERUNG_TEXT = `Für sämt export const EVIDENCE_QUESTION_WITNESSES_TEXT = "Beweis angeboten durch Vernehmung der folgenden Personen als Zeugen:"; -export const MARGIN_RIGHT = 10; - export const addMultiplePersonsInfo = ( doc: typeof PDFDocument, { diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/__test__/addDetailedReason.test.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/__test__/addDetailedReason.test.ts index 51dbeccb5..7e68cce11 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/__test__/addDetailedReason.test.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/__test__/addDetailedReason.test.ts @@ -3,6 +3,7 @@ import { mockPdfKitDocumentStructure, } from "tests/factories/mockPdfKit"; import { userDataMock } from "~/domains/fluggastrechte/services/pdf/__test__/userDataMock"; +import { MARGIN_RIGHT } from "~/domains/fluggastrechte/services/pdf/configurations"; import { PDF_MARGIN_HORIZONTAL } from "~/services/pdf/createPdfKitDocument"; import { YesNoAnswer } from "~/services/validation/YesNoAnswer"; import { @@ -11,7 +12,6 @@ import { ATTACHMENT_CONFIRM_BOOKING_TEXT, CONFIRM_BOOKING_MULTIPLE_PERSONS_TEXT, CONFIRM_BOOKING_TEXT, - MARGIN_RIGHT, PLAINTIFF_ON_TIME_MULTIPLE_PERSONS_TEXT, PLAINTIFF_ON_TIME_TEXT, } from "../addDetailedReason"; diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addDetailedReason.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addDetailedReason.ts index 3c13a541d..e62d23f07 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addDetailedReason.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addDetailedReason.ts @@ -1,6 +1,9 @@ import type PDFDocument from "pdfkit"; import type { FluggastrechtContext } from "~/domains/fluggastrechte/formular/context"; -import { MARGIN_BETWEEN_SECTIONS } from "~/domains/fluggastrechte/services/pdf/configurations"; +import { + MARGIN_BETWEEN_SECTIONS, + MARGIN_RIGHT, +} from "~/domains/fluggastrechte/services/pdf/configurations"; import { FONTS_BUNDESSANS_BOLD, FONTS_BUNDESSANS_REGULAR, @@ -20,7 +23,6 @@ export const PLAINTIFF_ON_TIME_TEXT = "Die klagende Partei war pünktlich zum Check-in und Boarding."; export const PLAINTIFF_ON_TIME_MULTIPLE_PERSONS_TEXT = "Die klagende Partei und die weiteren Fluggäste waren pünktlich zum Check-in und Boarding."; -export const MARGIN_RIGHT = 10; const getConfirmationBookingTexts = ({ isWeiterePersonen, diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addMultiplePersonsText.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addMultiplePersonsText.ts index 24a933fe6..f22b46eb5 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addMultiplePersonsText.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/detailedReason/addMultiplePersonsText.ts @@ -1,6 +1,9 @@ import type PDFDocument from "pdfkit"; import type { FluggastrechtContext } from "~/domains/fluggastrechte/formular/context"; -import { MARGIN_BETWEEN_SECTIONS } from "~/domains/fluggastrechte/services/pdf/configurations"; +import { + MARGIN_BETWEEN_SECTIONS, + MARGIN_RIGHT, +} from "~/domains/fluggastrechte/services/pdf/configurations"; import type { FluggastrechtBereichType } from "~/domains/fluggastrechte/vorabcheck/context"; import { FONTS_BUNDESSANS_BOLD, @@ -10,8 +13,6 @@ import { import { arrayIsNonEmpty } from "~/util/array"; import { getFullPlaintiffName } from "../../../getFullPlaintiffName"; -export const MARGIN_RIGHT = 10; - const bereichMappingText = { verspaetet: "Verspätung", annullierung: "Annullierung",