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:
55
DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml
Normal file
55
DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml
Normal 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);
|
||||
})
|
||||
)
|
||||
}
|
||||
18
DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml.cs
Normal file
18
DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user