Add invoices page and navigation menu items

Added new navigation menu items in `_Layout.cshtml` for "Rechnungen" (Invoices) and "PDF hochladen" (Upload PDF) with icons, paths, and selection logic.

Created a new Razor Page `Index.cshtml` to display imported invoices using a `DataGrid` with features like filtering, paging, and column formatting. Added a conditional message for when no invoices are available.

Implemented the `IndexModel` class in `Index.cshtml.cs` to handle backend logic, including fetching and sorting invoices from the database using `AppDbContext`.
This commit is contained in:
OlgunR
2026-05-22 14:30:11 +02:00
parent c45e837c2b
commit 5221ee3594
3 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
@page
@model DXApp.TemplateKitProject.Pages.Invoices.IndexModel
@{
ViewData["Title"] = "Rechnungen";
}
<h2>Importierte Rechnungen</h2>
@if (!Model.Invoices.Any())
{
<div class="alert alert-info mt-3">Noch keine Rechnungen importiert.</div>
}
else
{
@(Html.DevExtreme().DataGrid<DXApp.TemplateKitProject.Models.ZugferdInvoice>()
.DataSource(Model.Invoices)
.KeyExpr("Id")
.ShowBorders(true)
.RowAlternationEnabled(true)
.FilterRow(f => f.Visible(true))
.HeaderFilter(h => h.Visible(true))
.Paging(p => p.PageSize(20))
.Pager(p => p
.ShowPageSizeSelector(true)
.AllowedPageSizes(new[] { 10, 20, 50 })
.ShowInfo(true)
)
.Columns(cols =>
{
cols.Add().DataField("Id").Caption("ID").Width(60).AllowEditing(false);
cols.Add().DataField("InvoiceNumber").Caption("Rechnungsnr.");
cols.Add().DataField("InvoiceDate").Caption("Datum")
.DataType(GridColumnDataType.Date)
.Format("dd.MM.yyyy")
.Width(110);
cols.Add().DataField("SellerName").Caption("Verkäufer");
cols.Add().DataField("BuyerName").Caption("Käufer");
cols.Add().DataField("TotalAmount").Caption("Gesamt")
.DataType(GridColumnDataType.Number)
.Format("#,##0.00")
.Width(110);
cols.Add().DataField("TaxAmount").Caption("MwSt.")
.DataType(GridColumnDataType.Number)
.Format("#,##0.00")
.Width(100);
cols.Add().DataField("CurrencyCode").Caption("Währung").Width(80);
cols.Add().DataField("Iban").Caption("IBAN");
cols.Add().DataField("SourceType").Caption("Quelle").Width(90);
cols.Add().DataField("ImportedAt").Caption("Importiert am")
.DataType(GridColumnDataType.DateTime)
.Format("dd.MM.yyyy HH:mm")
.Width(150);
})
)
}

View File

@@ -0,0 +1,18 @@
using DXApp.TemplateKitProject.Data;
using DXApp.TemplateKitProject.Models;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
namespace DXApp.TemplateKitProject.Pages.Invoices;
public class IndexModel(AppDbContext db) : PageModel
{
public List<ZugferdInvoice> Invoices { get; private set; } = [];
public async Task OnGetAsync()
{
Invoices = await db.ZugferdInvoices
.OrderByDescending(i => i.ImportedAt)
.ToListAsync();
}
}