feat: render billing usage pdf
Add the immutable PDF renderer for "Nutzungsnachweis" billing reports.
- src/modules/billing/types.ts: BillingReportSnapshot self-contained type
(address, selected positions, repeat downloads, net total in cents,
report/invoice metadata, period, document ID, legal notice).
- src/modules/pdf/document.ts: pdfmake document definition builder with
monochrome invoice layout (black logo, sender/recipient blocks, rounded
black summary panel, repeated black table headers, light-gray rows,
German dates, cents-derived totals, page numbers, document ID, invoice
reference, legal separation notice).
- src/modules/pdf/render.ts: renderBillingPdf → { bytes, sha256 } using
pdfmake 0.3 with IBM Plex Mono (OFL) embedded via the VFS.
- scripts/render-pdf-fixture.ts: stress fixture generator (1 row, 60 rows,
long address, long fields, umlauts, 3-page case) into tmp/pdfs/.
- tests/fixtures/billing-report.ts: deterministic reportFixture (60,00 EUR).
- tsconfig.json: server-only path alias for tsx script execution.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
d37affc80f
commit
89d76e2711
13 files changed
+1265
-1
No files matched your search
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
import type { BillingReportSnapshot } from "@/modules/billing/types";
|
||||
|
||||
/**
|
||||
* Minimal, deterministic snapshot used by the render test. The net total is
|
||||
* 6000 cents so the PDF displays "60,00 EUR" (the value the test asserts on).
|
||||
*/
|
||||
export const reportFixture: BillingReportSnapshot = {
|
||||
address: {
|
||||
companyName: "Redaktion Beispiel GmbH",
|
||||
contactName: "Anna Schmidt",
|
||||
addressLine1: "Musterstraße 12",
|
||||
addressLine2: null,
|
||||
postalCode: "10115",
|
||||
city: "Berlin",
|
||||
countryCode: "DE",
|
||||
},
|
||||
selectedPositions: [
|
||||
{
|
||||
id: "pos-1",
|
||||
assetId: "asset-1",
|
||||
filename: "jubel-eroeffnung.jpg",
|
||||
albumName: "Jubel",
|
||||
purpose: "Print Nutzung",
|
||||
reference: "REF-001",
|
||||
priceCents: 6_000,
|
||||
createdAt: new Date("2026-03-15T10:00:00.000Z"),
|
||||
},
|
||||
],
|
||||
repeatDownloads: [
|
||||
{
|
||||
id: "rdl-1",
|
||||
assetId: "asset-1",
|
||||
usageId: "usage-1",
|
||||
authorizedAt: new Date("2026-03-20T14:00:00.000Z"),
|
||||
repeatDownloadNote: "Zweitverwendung im Web",
|
||||
},
|
||||
],
|
||||
netTotalCents: 6_000,
|
||||
reportNumber: 1,
|
||||
invoiceNumber: "NN-2026-03-001",
|
||||
period: {
|
||||
fromUtc: new Date("2026-03-01T00:00:00.000Z"),
|
||||
toUtcExclusive: new Date("2026-04-01T00:00:00.000Z"),
|
||||
},
|
||||
documentId: "doc-00000000-0000-0000-0000-000000000001",
|
||||
createdAt: new Date("2026-04-02T08:00:00.000Z"),
|
||||
legalSeparationNotice:
|
||||
"Dieser Nutzungsnachweis ist keine Rechnung im Sinne des Umsatzsteuerrechts.",
|
||||
};
|
||||
Reference in new issue
Block a user