-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/change-sentences-in-claim-pdf: change two sentences in pdf (#1507)
* feat/change-sentences-in-claim-pdf: change two sentences in pdf * feat/change-sentences-in-claim-pdf: adapt agreement sentence on video trial depending on user answer Co-authored-by: flo drews <[email protected]> * ref: outsource addDefendantPartyList for simplify createStatement function and for easier testing * ref(fgr pdf): move const margin_right to configuration * ref(fgr pdf): remove width from text * ref(fgr pdf): remove redundant test * ref(fgr pdf): add statementClaimSect into addDefendantPartyList --------- Co-authored-by: flo drews <[email protected]>
- Loading branch information
Showing
9 changed files
with
187 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const MARGIN_BETWEEN_SECTIONS = 1.5; | ||
export const MARGIN_RIGHT = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...strechte/services/pdf/sections/firstPage/claimData/__test__/addDefendantPartyList.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.", | ||
); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
...domains/fluggastrechte/services/pdf/sections/firstPage/claimData/addDefendantPartyList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.