using General_Ledger_Service.DTOs.Reports; using QuestPDF.Fluent; using QuestPDF.Helpers; using QuestPDF.Infrastructure; namespace General_Ledger_Service.Services.PdfDocuments { // 05_LKAS_Report_PDF_Templates.md Section 2 - not an LKAS statement, a working paper. // Retrofit 2026-07-22: flat list (no depth/indentation) - portrait, matching the // reference template's plain Account name | Debit | Credit table. public class TrialBalancePdfDocument(string companyName, string currencyCode, DateOnly asOfDate, List rows) : IDocument { public DocumentMetadata GetMetadata() => DocumentMetadata.Default; public void Compose(IDocumentContainer container) { container.Page(page => { page.Size(PageSizes.A4); page.Margin(2, Unit.Centimetre); ReportPageHeader.Compose(page, companyName, "Trial Balance", ReportPageHeader.PointInTimePeriodLine(asOfDate), currencyCode); page.Content().PaddingTop(10).Table(table => { table.ColumnsDefinition(columns => { columns.RelativeColumn(2); columns.RelativeColumn(5); columns.RelativeColumn(2); columns.RelativeColumn(2); }); table.Header(header => { header.Cell().Text("Account Code").Bold(); header.Cell().Text("Account Name").Bold(); header.Cell().AlignRight().Text("Debit").Bold(); header.Cell().AlignRight().Text("Credit").Bold(); header.Cell().ColumnSpan(4).PaddingTop(3).LineHorizontal(1); }); foreach (var row in rows) { table.Cell().Text(row.AccountCode); table.Cell().Text(row.AccountName); table.Cell().AlignRight().Text(PdfFormatting.FormatAmountOrBlank(row.Debit)); table.Cell().AlignRight().Text(PdfFormatting.FormatAmountOrBlank(row.Credit)); } var totalDebit = rows.Sum(r => r.Debit); var totalCredit = rows.Sum(r => r.Credit); table.Cell().ColumnSpan(4).PaddingTop(3).LineHorizontal(1); table.Cell().Text(""); table.Cell().Text("TOTAL").Bold(); table.Cell().AlignRight().Text(PdfFormatting.FormatAmount(totalDebit)).Bold(); table.Cell().AlignRight().Text(PdfFormatting.FormatAmount(totalCredit)).Bold(); }); }); } } }