Files

68 lines
3.2 KiB
C#

using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
namespace General_Ledger_Service.Services.PdfDocuments
{
// Shared header/footer block for every report PDF (05_LKAS_Report_PDF_Templates.md Section 1)
// - satisfies LKAS 1.51's minimum for every statement: entity name, report title, period
// covered, presentation currency. Applied to the non-LKAS reports too, for consistency.
public static class ReportPageHeader
{
public static void Compose(PageDescriptor page, string companyName, string reportTitle, string periodLine, string currencyCode)
{
page.Header().Column(column =>
{
column.Item().Text(companyName).FontSize(14).Bold();
column.Item().Text(reportTitle).FontSize(12).Bold();
column.Item().Text(periodLine).FontSize(10);
column.Item().Text($"(Amounts in {currencyCode})").FontSize(9).Italic();
column.Item().PaddingTop(5).LineHorizontal(1);
});
ComposeFooter(page);
}
// Fuller identity block for the Income Tax Computation report (02_Phase_By_Phase_Development_Plan.md
// Section 1.9) - a corporate tax computation conventionally carries the filer's address
// and tax reference numbers, which the other six reports have no need for.
public static void ComposeWithEntityDetails(PageDescriptor page, string companyName, string address, string tin, string brn, string reportTitle, string periodLine, string currencyCode)
{
page.Header().Column(column =>
{
column.Item().Text(companyName).FontSize(14).Bold();
column.Item().Text(address).FontSize(9);
column.Item().Text($"TIN: {tin} BRN: {brn}").FontSize(9);
column.Item().Text(reportTitle).FontSize(12).Bold();
column.Item().Text(periodLine).FontSize(10);
column.Item().Text($"(Amounts in {currencyCode})").FontSize(9).Italic();
column.Item().PaddingTop(5).LineHorizontal(1);
});
ComposeFooter(page);
}
private static void ComposeFooter(PageDescriptor page)
{
page.Footer().Row(row =>
{
row.RelativeItem().Text(text =>
{
text.Span("Generated ").FontSize(8);
text.Span(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm") + " UTC").FontSize(8);
});
row.RelativeItem().AlignRight().Text(text =>
{
text.Span("Page ").FontSize(8);
text.CurrentPageNumber().FontSize(8);
text.Span(" of ").FontSize(8);
text.TotalPages().FontSize(8);
});
});
}
// Two period-line conventions (Section 1): point-in-time reports vs period reports.
public static string PointInTimePeriodLine(DateOnly asOfDate) => $"As at {asOfDate:yyyy-MM-dd}";
public static string RangePeriodLine(DateOnly periodStart, DateOnly periodEnd) => $"For the period {periodStart:yyyy-MM-dd} to {periodEnd:yyyy-MM-dd}";
}
}