fix(pdf): Überweisungs-QR-Code überdeckt keine Positionen und Summen mehr
Reichen Positionen oder Summen auf der letzten Seite in den Bereich des QR-Codes, wird er auf einer eigenen Folgeseite gedruckt. Die MCP-Vorschau meldet das und schlägt einen früheren Seitenumbruch vor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -77,7 +77,9 @@ test("rendered preview records rows per page and rasterizes pages", { skip: !has
|
||||
const data = buildOutgoingDocumentPdfData(document(rows), context)
|
||||
const layout: InvoicePdfLayout = { pageHeightMm: 0, rows: [], pageCount: 0 }
|
||||
const pdf: any = await createInvoicePDF({} as any, "base64", data, "letterhead.pdf", layout)
|
||||
assert.equal(layout.pageCount, 2)
|
||||
// Rows overflow page 2, so the payment QR code gets an extra third page.
|
||||
assert.equal(layout.pageCount, 3)
|
||||
assert.equal(layout.paymentQr!.page, 3)
|
||||
assert.equal(layout.rows.find((row) => row.index === 13)!.page, 2)
|
||||
assert.ok(layout.endText && layout.totals)
|
||||
const analysis = analyzeOutgoingDocumentLayout(layout)
|
||||
@@ -94,3 +96,30 @@ test("rendered preview records rows per page and rasterizes pages", { skip: !has
|
||||
test("preview tool is read-only for outgoing documents", () => {
|
||||
assert.deepEqual(mcpToolMap.get("accounting.outgoing_documents.preview")!.requiredPermissions, ["accounting.outgoing_documents.read"])
|
||||
})
|
||||
|
||||
test("payment QR code moves to its own page instead of covering amounts", { skip: !hasPdftoppm && "pdftoppm fehlt" }, async (t) => {
|
||||
const letterhead = await PDFDocument.create()
|
||||
letterhead.addPage([595.28, 841.89]).drawText("Briefpapier", { x: 40, y: 40, size: 8 })
|
||||
const background = Buffer.from(await letterhead.save())
|
||||
await initS3()
|
||||
t.mock.method(s3, "send", async () => ({ Body: Readable.from([background]) }))
|
||||
const render = async (count: number) => {
|
||||
const layout: InvoicePdfLayout = { pageHeightMm: 0, rows: [], pageCount: 0 }
|
||||
await createInvoicePDF({} as any, "base64", buildOutgoingDocumentPdfData(document(positions(count)), context), "letterhead.pdf", layout)
|
||||
return layout
|
||||
}
|
||||
|
||||
const short = await render(3)
|
||||
assert.equal(short.pageCount, 1)
|
||||
assert.equal(short.paymentQr!.page, 1)
|
||||
assert.ok(short.totals!.bottomMm < short.paymentQr!.topMm)
|
||||
|
||||
const long = await render(6)
|
||||
assert.equal(long.pageCount, 2)
|
||||
assert.equal(long.paymentQr!.page, 2)
|
||||
assert.ok(long.rows.every((row) => row.page === 1))
|
||||
const analysis = analyzeOutgoingDocumentLayout(long)
|
||||
const warning = analysis.warnings.find((item) => item.type === "paymentQrOwnPage")
|
||||
assert.ok(warning, JSON.stringify(analysis.warnings))
|
||||
assert.ok(!analysis.warnings.some((item) => item.type === "emptyPage"))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user