--- description: "Implement QuestPDF-based yearly account statement PDF generation with balance summaries" agent: "agent" --- # Step 6: PDF Export Implement `PdfStatementService` in `src/Duempelkas.Infrastructure/Services/`. ## PDF Document Structure Generate one PDF per account/year with the following sections: ### Header - Account name (bold, large) - Year (e.g., "Statement 2026") - Generation date ### Opening Balance Section - "Carryover from previous year: X.XX €" ### Ledger Table - Columns: Date, Title, Type, Amount - Rows sorted chronologically (oldest → newest) - Type column shows "Income", "Expense", or "Transfer" (for linked entries) - Transfer rows should include a note like "→ TargetAccountName" or "← SourceAccountName" - Amount formatted as "1.234,56 €" (German locale) ### Summary Footer 1. "Carryover from previous year: X.XX €" 2. "Current year result: X.XX €" (sum of incomes minus sum of expenses) 3. "Final balance: X.XX €" (carryover + current year result) ## Implementation Details - Use `QuestPDF.Fluent` API with `Document.Create(...)`. - Set `QuestPDF.Settings.License = LicenseType.Community` in startup. - Reuse `IBalanceQueryService.GetYearlySummaryAsync` and `IEntryService.GetEntriesAsync` to get the data — do NOT recalculate balances independently. - Return `byte[]` from `GenerateYearlyStatementAsync`. - Use A4 page size, reasonable margins, and professional typography. ## Conventions - Keep the PDF layout in a single service method or split into private helper methods. - Use `CultureInfo("de-DE")` for number/currency formatting.