@page
@model DXApp.TemplateKitProject.Pages.Invoices.DetailsModel
@{
    ViewData["Title"] = "Rechnungsdetails";
}

<h2>📄 Rechnungsdetails</h2>
<a href="/Invoices" class="btn btn-secondary mb-3">← Zurück zur Liste</a>

@if (Model.Invoice is null)
{
    <div class="alert alert-danger">Rechnung nicht gefunden.</div>
}
else
{
    <table class="table table-sm table-bordered w-auto">
        <tr><th>ID</th><td>@Model.Invoice.Id</td></tr>
        <tr><th>Rechnungsnummer</th><td>@Model.Invoice.InvoiceNumber</td></tr>
        <tr><th>Rechnungsdatum</th><td>@Model.Invoice.InvoiceDate.ToString("dd.MM.yyyy")</td></tr>
        <tr><th>Verkäufer</th><td>@Model.Invoice.SellerName</td></tr>
        <tr><th>USt-ID Verkäufer</th><td>@Model.Invoice.SellerTaxId</td></tr>
        <tr><th>Käufer</th><td>@Model.Invoice.BuyerName</td></tr>
        <tr><th>Währung</th><td>@Model.Invoice.CurrencyCode</td></tr>
        <tr><th>Steuerbetrag</th><td>@Model.Invoice.TaxAmount.ToString("N2")</td></tr>
        <tr><th>Gesamtbetrag</th><td><strong>@Model.Invoice.TotalAmount.ToString("N2")</strong></td></tr>
        <tr><th>IBAN</th><td>@Model.Invoice.Iban</td></tr>
        <tr><th>Quelle</th><td>@Model.Invoice.SourceType</td></tr>
        <tr><th>Guideline-ID</th><td><code>@Model.Invoice.GuidelineId</code></td></tr>
        <tr><th>Importiert am</th><td>@Model.Invoice.ImportedAt.ToString("dd.MM.yyyy HH:mm")</td></tr>
        <tr>
            <th>Result-PDF</th>
            <td>
                @if (!string.IsNullOrEmpty(Model.Invoice.ResultFilePath))
                {
                    <small class="text-muted">@Model.Invoice.ResultFilePath</small>
                }
                else
                {
                    <span class="text-muted">– nicht vorhanden –</span>
                }
            </td>
        </tr>
    </table>
}