Files
Distribution_GL/Services/PdfDocuments/IncomeTaxComputationPdfDocument.cs
T

84 lines
4.1 KiB
C#

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 8, redesigned 2026-07-22 - Accounting_System_Design_LKAS.md
// Section 11.7. A single Profit-Before-Tax-to-Balance-Tax-Payable computation (current tax
// only, no deferred tax) - the standard corporate income tax return shape, replacing the
// 2026-07-21 VAT/WHT/NBT per-tax_code summary entirely. Uses the fuller company identity
// block (address/TIN/BRN) since a tax computation conventionally carries those.
public class IncomeTaxComputationPdfDocument(string companyName, string companyAddress, string companyTin, string companyBrn, string currencyCode, IncomeTaxComputationDto data) : IDocument
{
public DocumentMetadata GetMetadata() => DocumentMetadata.Default;
public void Compose(IDocumentContainer container)
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
ReportPageHeader.ComposeWithEntityDetails(
page, companyName, companyAddress, companyTin, companyBrn,
"Income Tax Computation", ReportPageHeader.RangePeriodLine(data.PeriodStart, data.PeriodEnd), currencyCode);
page.Content().PaddingTop(10).Column(column =>
{
Line(column, "Profit Before Tax", data.ProfitBeforeTax);
Line(column, "Add: Non-Deductible Expenses", data.NonDeductibleExpenses);
Line(column, "Less: Allowable Deductions", -data.AllowableDeductions);
Total(column, "Adjusted Business Profit", data.AdjustedBusinessProfit);
Line(column, "Add: Other Taxable Income", data.OtherTaxableIncome);
Total(column, "Assessable Income", data.AssessableIncome);
Line(column, "Less: Qualifying Payments / Reliefs", -data.QualifyingPaymentsReliefs);
Total(column, "Taxable Income", data.TaxableIncome);
column.Item().PaddingTop(10).Row(r =>
{
r.RelativeItem(4).Text($"Corporate Income Tax @ {data.TaxRatePercent:0.00}%");
r.RelativeItem(1).AlignRight().Text(PdfFormatting.FormatAmount(data.CorporateIncomeTax));
});
Line(column, "Add: Surcharge / Education Levy", data.SurchargeAmount);
Total(column, "Gross Tax Liability", data.GrossTaxLiability);
Line(column, "Less: APIT Credit", -data.ApitCredit);
Line(column, "Less: WHT Credit", -data.WhtCredit);
Line(column, "Less: Quarterly Tax Payments", -data.QuarterlyTaxPayments);
column.Item().PaddingTop(10).LineHorizontal(1.5f);
column.Item().Row(r =>
{
var label = data.BalanceTaxPayable < 0 ? "BALANCE TAX REFUNDABLE" : "BALANCE TAX PAYABLE";
r.RelativeItem(4).Text(label).Bold();
r.RelativeItem(1).AlignRight().Text(PdfFormatting.FormatAmount(data.BalanceTaxPayable)).Bold();
});
});
});
}
private static void Line(ColumnDescriptor column, string label, decimal amount)
{
column.Item().Row(r =>
{
r.RelativeItem(4).Text(label);
r.RelativeItem(1).AlignRight().Text(PdfFormatting.FormatAmount(amount));
});
}
private static void Total(ColumnDescriptor column, string label, decimal amount)
{
column.Item().PaddingTop(3).LineHorizontal(1);
column.Item().Row(r =>
{
r.RelativeItem(4).Text(label).Bold();
r.RelativeItem(1).AlignRight().Text(PdfFormatting.FormatAmount(amount)).Bold();
});
column.Item().PaddingTop(5);
}
}
}