Add Blazor application layer with UI components and pages
- Service interfaces and DTO models - Dashboard page with account overview - Account detail page with year/entry management - Reusable components: AccountCard, EntryTable, YearSelector - Dialog components: Add/Edit Account, Entry, Transfer, Year - Main layout and routing configuration
This commit is contained in:
16
src/Duempelkas.App/Components/Accounts/AccountCard.razor
Normal file
16
src/Duempelkas.App/Components/Accounts/AccountCard.razor
Normal file
@@ -0,0 +1,16 @@
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<div class="card account-card h-100" @onclick="Navigate">
|
||||
<div class="card-body d-flex flex-column justify-content-between">
|
||||
<h5 class="card-title mb-3">@Account.Name</h5>
|
||||
<div class="@(Account.TotalBalance >= 0 ? "amount-positive" : "amount-negative") fs-4">
|
||||
@($"{Account.TotalBalance:N2} €")
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public AccountSummaryDto Account { get; set; } = default!;
|
||||
|
||||
private void Navigate() => Navigation.NavigateTo($"/accounts/{Account.Id}");
|
||||
}
|
||||
12
src/Duempelkas.App/Components/Accounts/AccountCardList.razor
Normal file
12
src/Duempelkas.App/Components/Accounts/AccountCardList.razor
Normal file
@@ -0,0 +1,12 @@
|
||||
<div class="row g-3">
|
||||
@foreach (var account in Accounts)
|
||||
{
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<AccountCard Account="account" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public List<AccountSummaryDto> Accounts { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@* AccountHeader is no longer used - header is now inline in AccountDetail.razor *@
|
||||
50
src/Duempelkas.App/Components/Accounts/EntryRow.razor
Normal file
50
src/Duempelkas.App/Components/Accounts/EntryRow.razor
Normal file
@@ -0,0 +1,50 @@
|
||||
<tr class="@GetRowClass()">
|
||||
<td>@Entry.DisplayId</td>
|
||||
<td>@Entry.Date.ToString("dd.MM.yyyy")</td>
|
||||
<td>
|
||||
@Entry.Title
|
||||
@if (Entry.IsTransfer && !string.IsNullOrEmpty(Entry.LinkedAccountName))
|
||||
{
|
||||
<small class="text-muted ms-1">
|
||||
(@(Entry.Type == EntryType.Expense ? "an" : "von") @Entry.LinkedAccountName)
|
||||
</small>
|
||||
}
|
||||
</td>
|
||||
<td class="text-end @(Entry.Type == EntryType.Income ? "amount-positive" : "amount-negative")">
|
||||
@(Entry.Type == EntryType.Income ? "+" : "\u2212")@($"{Entry.Amount:N2} €")
|
||||
</td>
|
||||
<td>
|
||||
@if (Entry.IsDeleted)
|
||||
{
|
||||
<button class="btn btn-outline-success btn-sm" @onclick="() => OnRestore.InvokeAsync(Entry.Id)" title="Wiederherstellen">
|
||||
<i class="bi bi-arrow-counterclockwise"></i>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex gap-1">
|
||||
<button class="btn btn-outline-secondary btn-sm" @onclick="() => OnEdit.InvokeAsync(Entry.Id)" title="Bearbeiten">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="() => OnDelete.InvokeAsync(Entry.Id)" title="Löschen">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@code {
|
||||
[Parameter] public EntryDto Entry { get; set; } = default!;
|
||||
[Parameter] public EventCallback<int> OnDelete { get; set; }
|
||||
[Parameter] public EventCallback<int> OnRestore { get; set; }
|
||||
[Parameter] public EventCallback<int> OnEdit { get; set; }
|
||||
|
||||
private string GetRowClass()
|
||||
{
|
||||
var classes = new List<string>();
|
||||
if (Entry.IsTransfer) classes.Add("entry-row-transfer");
|
||||
if (Entry.IsDeleted) classes.Add("entry-deleted");
|
||||
return string.Join(" ", classes);
|
||||
}
|
||||
}
|
||||
31
src/Duempelkas.App/Components/Accounts/EntryTable.razor
Normal file
31
src/Duempelkas.App/Components/Accounts/EntryTable.razor
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-sm align-middle">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 100px;">LfdNr</th>
|
||||
<th style="width: 120px;">Datum</th>
|
||||
<th>Bezeichnung</th>
|
||||
<th style="width: 140px;" class="text-end">Betrag</th>
|
||||
<th style="width: 80px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var entry in Entries)
|
||||
{
|
||||
<EntryRow Entry="entry" OnDelete="OnDeleteEntry" OnRestore="OnRestoreEntry" OnEdit="OnEditEntry" />
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if (!Entries.Any())
|
||||
{
|
||||
<div class="text-center py-3 text-muted">Keine Einträge vorhanden.</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public List<EntryDto> Entries { get; set; } = new();
|
||||
[Parameter] public EventCallback<int> OnDeleteEntry { get; set; }
|
||||
[Parameter] public EventCallback<int> OnRestoreEntry { get; set; }
|
||||
[Parameter] public EventCallback<int> OnEditEntry { get; set; }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@* ExportButton is no longer used - export is now inline in AccountDetail.razor *@
|
||||
@@ -0,0 +1 @@
|
||||
@* YearSelector is no longer used - year selection has been removed from the data model. *@
|
||||
13
src/Duempelkas.App/Components/App.razor
Normal file
13
src/Duempelkas.App/Components/App.razor
Normal file
@@ -0,0 +1,13 @@
|
||||
<Router AppAssembly="@typeof(App).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<div class="container mt-5">
|
||||
<h3>Seite nicht gefunden</h3>
|
||||
<p>Die angeforderte Seite konnte nicht gefunden werden.</p>
|
||||
</div>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
29
src/Duempelkas.App/Components/Dialogs/AddAccountDialog.razor
Normal file
29
src/Duempelkas.App/Components/Dialogs/AddAccountDialog.razor
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">Neues Konto</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Kontoname</label>
|
||||
<input type="text" class="form-control" @bind="name" @bind:event="oninput"
|
||||
placeholder="z.B. Girokonto" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save" disabled="@string.IsNullOrWhiteSpace(name)"><i class="bi bi-check-lg"></i> Erstellen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public EventCallback<string> OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private string name = string.Empty;
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
await OnSave.InvokeAsync(name.Trim());
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
70
src/Duempelkas.App/Components/Dialogs/AddEntryDialog.razor
Normal file
70
src/Duempelkas.App/Components/Dialogs/AddEntryDialog.razor
Normal file
@@ -0,0 +1,70 @@
|
||||
@inject IEntryService EntryService
|
||||
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5>@(EditEntry != null ? "Eintrag bearbeiten" : "Neuer Eintrag")</h5>
|
||||
@if (EditEntry == null)
|
||||
{
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Art</label>
|
||||
<select class="form-select" @bind="entryType">
|
||||
<option value="@EntryType.Income">Einnahme</option>
|
||||
<option value="@EntryType.Expense">Ausgabe</option>
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Datum</label>
|
||||
<input type="date" class="form-control" @bind="date" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bezeichnung</label>
|
||||
<input type="text" class="form-control" @bind="title" placeholder="Beschreibung" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Betrag (€)</label>
|
||||
<input type="number" class="form-control" @bind="amount" step="0.01" min="0.01" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save"
|
||||
disabled="@(string.IsNullOrWhiteSpace(title) || amount <= 0)">
|
||||
<i class="bi bi-check-lg"></i> @(EditEntry != null ? "Speichern" : "Hinzufügen")
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public int AccountId { get; set; }
|
||||
[Parameter] public EntryDto? EditEntry { get; set; }
|
||||
[Parameter] public EventCallback OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private EntryType entryType = EntryType.Income;
|
||||
private DateTime date = DateTime.Today;
|
||||
private string title = string.Empty;
|
||||
private decimal amount;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (EditEntry != null)
|
||||
{
|
||||
entryType = EditEntry.Type;
|
||||
date = EditEntry.Date;
|
||||
title = EditEntry.Title;
|
||||
amount = EditEntry.Amount;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (EditEntry != null)
|
||||
await EntryService.UpdateEntryAsync(EditEntry.Id, date, title.Trim(), amount);
|
||||
else
|
||||
await EntryService.CreateEntryAsync(AccountId, entryType, date, title.Trim(), amount);
|
||||
await OnSave.InvokeAsync();
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
@inject IEntryService EntryService
|
||||
@inject IAccountService AccountService
|
||||
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">@(EditEntry != null ? "Umbuchung bearbeiten" : "Neue Umbuchung")</h5>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Zielkonto</label>
|
||||
<select class="form-select" @bind="targetAccountId">
|
||||
<option value="0">— Auswählen —</option>
|
||||
@foreach (var acc in accounts.Where(a => a.Id != SourceAccountId))
|
||||
{
|
||||
<option value="@acc.Id">@acc.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Datum</label>
|
||||
<input type="date" class="form-control" @bind="date" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bezeichnung</label>
|
||||
<input type="text" class="form-control" @bind="title" placeholder="Beschreibung der Umbuchung" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Betrag (€)</label>
|
||||
<input type="number" class="form-control" @bind="amount" step="0.01" min="0.01" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save"
|
||||
disabled="@(!CanSave)"><i class="bi bi-arrow-left-right"></i> @(EditEntry != null ? "Speichern" : "Umbuchen")</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public int SourceAccountId { get; set; }
|
||||
[Parameter] public EntryDto? EditEntry { get; set; }
|
||||
[Parameter] public EventCallback OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private List<AccountSummaryDto> accounts = new();
|
||||
private int targetAccountId;
|
||||
private DateTime date = DateTime.Today;
|
||||
private string title = string.Empty;
|
||||
private decimal amount;
|
||||
|
||||
private bool CanSave => targetAccountId > 0 && !string.IsNullOrWhiteSpace(title) && amount > 0;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (!accounts.Any())
|
||||
accounts = await AccountService.GetAllAccountsAsync();
|
||||
|
||||
if (EditEntry != null)
|
||||
{
|
||||
targetAccountId = EditEntry.LinkedAccountId ?? 0;
|
||||
date = EditEntry.Date;
|
||||
title = EditEntry.Title;
|
||||
amount = EditEntry.Amount;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (EditEntry != null)
|
||||
await EntryService.UpdateTransferAsync(EditEntry.Id, targetAccountId, date, title.Trim(), amount);
|
||||
else
|
||||
await EntryService.CreateTransferAsync(SourceAccountId, targetAccountId, date, title.Trim(), amount);
|
||||
await OnSave.InvokeAsync();
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@* AddYearDialog is no longer used - year management has been removed from the data model. *@
|
||||
22
src/Duempelkas.App/Components/Dialogs/ConfirmDialog.razor
Normal file
22
src/Duempelkas.App/Components/Dialogs/ConfirmDialog.razor
Normal file
@@ -0,0 +1,22 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5>@Title</h5>
|
||||
<p>@Message</p>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> @CancelText</button>
|
||||
<button class="btn btn-danger" @onclick="Confirm"><i class="bi bi-trash"></i> @ConfirmText</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public string Title { get; set; } = "Bestätigung";
|
||||
[Parameter] public string Message { get; set; } = "Sind Sie sicher?";
|
||||
[Parameter] public string ConfirmText { get; set; } = "Ja, bestätigen";
|
||||
[Parameter] public string CancelText { get; set; } = "Nein, abbrechen";
|
||||
[Parameter] public EventCallback OnConfirm { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private async Task Confirm() => await OnConfirm.InvokeAsync();
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">Übertrag bearbeiten</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Übertrag (€)</label>
|
||||
<input type="number" class="form-control" step="0.01" @bind="amount" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save"><i class="bi bi-check-lg"></i> Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public decimal CurrentAmount { get; set; }
|
||||
[Parameter] public EventCallback<decimal> OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private decimal amount;
|
||||
|
||||
protected override void OnParametersSet() => amount = CurrentAmount;
|
||||
|
||||
private async Task Save() => await OnSave.InvokeAsync(amount);
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
31
src/Duempelkas.App/Components/Dialogs/EditNameDialog.razor
Normal file
31
src/Duempelkas.App/Components/Dialogs/EditNameDialog.razor
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">Kontoname bearbeiten</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Kontoname</label>
|
||||
<input type="text" class="form-control" @bind="name" @bind:event="oninput" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save" disabled="@string.IsNullOrWhiteSpace(name)"><i class="bi bi-check-lg"></i> Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public string CurrentName { get; set; } = string.Empty;
|
||||
[Parameter] public EventCallback<string> OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private string name = string.Empty;
|
||||
|
||||
protected override void OnParametersSet() => name = CurrentName;
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
await OnSave.InvokeAsync(name.Trim());
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
31
src/Duempelkas.App/Components/Layout/MainLayout.razor
Normal file
31
src/Duempelkas.App/Components/Layout/MainLayout.razor
Normal file
@@ -0,0 +1,31 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="d-flex flex-column vh-100">
|
||||
<nav class="app-navbar d-flex justify-content-between align-items-center">
|
||||
<a class="navbar-brand" href="">
|
||||
<strong>Dümpelkas</strong> <small class="text-muted">Kassenbuch</small>
|
||||
</a>
|
||||
<span class="version-label">v@(AppVersion)</span>
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1 overflow-auto p-3">
|
||||
@Body
|
||||
</main>
|
||||
|
||||
<footer class="app-footer">
|
||||
Dümpelkas © @DateTime.Now.Year · Version @AppVersion
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private static string AppVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var yearShort = now.Year % 100;
|
||||
var dayOfYear = now.DayOfYear;
|
||||
return $"{yearShort}.{dayOfYear}";
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/Duempelkas.App/Components/Routes.razor
Normal file
10
src/Duempelkas.App/Components/Routes.razor
Normal file
@@ -0,0 +1,10 @@
|
||||
<Router AppAssembly="@typeof(Routes).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<p>Seite nicht gefunden.</p>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
15
src/Duempelkas.App/Duempelkas.App.csproj
Normal file
15
src/Duempelkas.App/Duempelkas.App.csproj
Normal file
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Duempelkas.Domain\Duempelkas.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
298
src/Duempelkas.App/Pages/Accounts/AccountDetail.razor
Normal file
298
src/Duempelkas.App/Pages/Accounts/AccountDetail.razor
Normal file
@@ -0,0 +1,298 @@
|
||||
@page "/accounts/{AccountId:int}"
|
||||
@inject IAccountService AccountService
|
||||
@inject IEntryService EntryService
|
||||
@inject IBalanceQueryService BalanceQueryService
|
||||
@inject IPdfStatementService PdfStatementService
|
||||
@inject IFileSaveService FileSaveService
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<div class="container-fluid">
|
||||
@if (account == null)
|
||||
{
|
||||
<div class="text-center py-5">
|
||||
<div class="spinner-border" role="status"></div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex align-items-center gap-2 mb-3">
|
||||
<button class="btn btn-outline-secondary btn-sm flex-shrink-0" @onclick="NavigateBack">
|
||||
<i class="bi bi-arrow-left"></i> Zurück
|
||||
</button>
|
||||
<div class="d-flex align-items-center flex-grow-1" style="min-width: 0;">
|
||||
<h2 class="mb-0" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
||||
@account.Name
|
||||
<button class="btn-edit-pen" @onclick="() => showEditName = true" title="Name bearbeiten"><i class="bi bi-pencil"></i></button>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (balance != null)
|
||||
{
|
||||
<div class="summary-section mb-3">
|
||||
<div class="summary-flex">
|
||||
<div>
|
||||
<small class="text-muted">Saldo</small>
|
||||
<div class="fs-3 fw-bold @(balance.TotalBalance >= 0 ? "amount-positive" : "amount-negative")">
|
||||
@FormatAmount(balance.TotalBalance)
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<small class="text-muted">Einnahmen</small>
|
||||
<div class="amount-positive">@FormatAmount(showCurrentYearOnly ? balance.CurrentYearIncome : balance.TotalIncome)</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<small class="text-muted">Ausgaben</small>
|
||||
<div class="amount-negative">@FormatAmount(showCurrentYearOnly ? balance.CurrentYearExpense : balance.TotalExpense)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (showCurrentYearOnly)
|
||||
{
|
||||
<div class="summary-section mb-3">
|
||||
<div class="summary-flex">
|
||||
<div>
|
||||
<small class="text-muted">Übertrag von @(DateTime.Now.Year - 1)</small>
|
||||
<div class="d-flex align-items-center gap-1">
|
||||
<span class="fw-bold">@FormatAmount(balance.CarryoverBalance)</span>
|
||||
<button class="btn-edit-pen" @onclick="() => showEditCarryover = true" title="Übertrag bearbeiten">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<small class="text-muted">Umsätze @DateTime.Now.Year</small>
|
||||
<div class="fw-bold @(balance.CurrentYearIncome - balance.CurrentYearExpense >= 0 ? "amount-positive" : "amount-negative")">
|
||||
@FormatAmount(balance.CurrentYearIncome - balance.CurrentYearExpense)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<div class="d-flex align-items-center gap-2 mb-3 py-3 flex-wrap">
|
||||
<button class="btn btn-success btn-sm" @onclick="() => showAddEntry = true">
|
||||
<i class="bi bi-plus-lg"></i> Eintrag
|
||||
</button>
|
||||
<button class="btn btn-info btn-sm" @onclick="() => showAddTransfer = true">
|
||||
<i class="bi bi-arrow-left-right"></i> Umbuchung
|
||||
</button>
|
||||
<button class="btn btn-dark btn-sm" @onclick="HandleExport">
|
||||
<i class="bi bi-file-earmark-pdf"></i> PDF
|
||||
</button>
|
||||
<button class="btn btn-sm @(showCurrentYearOnly ? "btn-primary" : "btn-outline-secondary")" @onclick="ToggleYearFilter">
|
||||
<i class="bi bi-funnel"></i> @(showCurrentYearOnly ? $"Nur {DateTime.Now.Year}" : "Alle Einträge")
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (entries != null)
|
||||
{
|
||||
<div class="entries-scroll-wrapper">
|
||||
<EntryTable Entries="entries" OnDeleteEntry="RequestDeleteEntry" OnRestoreEntry="RequestRestoreEntry" OnEditEntry="RequestEditEntry" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (showAddEntry)
|
||||
{
|
||||
<AddEntryDialog AccountId="AccountId"
|
||||
OnSave="HandleEntryCreated"
|
||||
OnCancel="() => showAddEntry = false" />
|
||||
}
|
||||
|
||||
@if (showAddTransfer)
|
||||
{
|
||||
<AddTransferDialog SourceAccountId="AccountId"
|
||||
OnSave="HandleTransferCreated"
|
||||
OnCancel="() => showAddTransfer = false" />
|
||||
}
|
||||
|
||||
@if (showEditName)
|
||||
{
|
||||
<EditNameDialog CurrentName="@(account?.Name ?? "")"
|
||||
OnSave="HandleSaveName"
|
||||
OnCancel="() => showEditName = false" />
|
||||
}
|
||||
|
||||
@if (showEditCarryover)
|
||||
{
|
||||
<EditCarryoverDialog CurrentAmount="@(balance?.CarryoverBalance ?? 0)"
|
||||
OnSave="HandleSaveCarryover"
|
||||
OnCancel="() => showEditCarryover = false" />
|
||||
}
|
||||
|
||||
@if (confirmDeleteEntryId.HasValue)
|
||||
{
|
||||
<ConfirmDialog Title="Eintrag löschen"
|
||||
Message="@($"Soll \"{confirmDeleteEntryTitle}\" wirklich gelöscht werden?")"
|
||||
ConfirmText="Ja, löschen"
|
||||
CancelText="Nein, abbrechen"
|
||||
OnConfirm="HandleConfirmDelete"
|
||||
OnCancel="CancelDeleteConfirm" />
|
||||
}
|
||||
|
||||
@if (confirmRestoreEntryId.HasValue)
|
||||
{
|
||||
<ConfirmDialog Title="Eintrag wiederherstellen"
|
||||
Message="@($"Soll \"{confirmRestoreEntryTitle}\" wiederhergestellt werden?")"
|
||||
ConfirmText="Ja, wiederherstellen"
|
||||
CancelText="Nein, abbrechen"
|
||||
OnConfirm="HandleConfirmRestore"
|
||||
OnCancel="CancelRestoreConfirm" />
|
||||
}
|
||||
|
||||
@if (editingEntry != null)
|
||||
{
|
||||
<AddEntryDialog AccountId="AccountId"
|
||||
EditEntry="editingEntry"
|
||||
OnSave="HandleEntryEdited"
|
||||
OnCancel="() => editingEntry = null" />
|
||||
}
|
||||
|
||||
@if (editingTransferEntry != null)
|
||||
{
|
||||
<AddTransferDialog SourceAccountId="AccountId"
|
||||
EditEntry="editingTransferEntry"
|
||||
OnSave="HandleEntryEdited"
|
||||
OnCancel="() => editingTransferEntry = null" />
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public int AccountId { get; set; }
|
||||
|
||||
private AccountSummaryDto? account;
|
||||
private AccountBalanceDto? balance;
|
||||
private List<EntryDto>? entries;
|
||||
private bool showAddEntry, showAddTransfer;
|
||||
private bool showEditName, showEditCarryover;
|
||||
private bool showCurrentYearOnly = true;
|
||||
|
||||
private int? confirmDeleteEntryId;
|
||||
private string? confirmDeleteEntryTitle;
|
||||
|
||||
private int? confirmRestoreEntryId;
|
||||
private string? confirmRestoreEntryTitle;
|
||||
|
||||
private EntryDto? editingEntry;
|
||||
private EntryDto? editingTransferEntry;
|
||||
|
||||
private void NavigateBack() => Navigation.NavigateTo("/");
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private async Task LoadAll()
|
||||
{
|
||||
account = await AccountService.GetAccountAsync(AccountId);
|
||||
balance = await BalanceQueryService.GetAccountBalanceAsync(AccountId);
|
||||
entries = await EntryService.GetEntriesAsync(AccountId, showCurrentYearOnly);
|
||||
}
|
||||
|
||||
private async Task ToggleYearFilter()
|
||||
{
|
||||
showCurrentYearOnly = !showCurrentYearOnly;
|
||||
entries = await EntryService.GetEntriesAsync(AccountId, showCurrentYearOnly);
|
||||
}
|
||||
|
||||
private async Task HandleSaveName(string newName)
|
||||
{
|
||||
await AccountService.RenameAccountAsync(AccountId, newName);
|
||||
showEditName = false;
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private async Task HandleSaveCarryover(decimal newAmount)
|
||||
{
|
||||
await AccountService.UpdateCarryoverAsync(AccountId, newAmount);
|
||||
showEditCarryover = false;
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private async Task HandleEntryCreated()
|
||||
{
|
||||
showAddEntry = false;
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private async Task HandleTransferCreated()
|
||||
{
|
||||
showAddTransfer = false;
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private void RequestDeleteEntry(int entryId)
|
||||
{
|
||||
confirmDeleteEntryId = entryId;
|
||||
confirmDeleteEntryTitle = entries?.FirstOrDefault(e => e.Id == entryId)?.Title;
|
||||
}
|
||||
|
||||
private void CancelDeleteConfirm()
|
||||
{
|
||||
confirmDeleteEntryId = null;
|
||||
confirmDeleteEntryTitle = null;
|
||||
}
|
||||
|
||||
private async Task HandleConfirmDelete()
|
||||
{
|
||||
if (confirmDeleteEntryId.HasValue)
|
||||
{
|
||||
await EntryService.DeleteEntryAsync(confirmDeleteEntryId.Value);
|
||||
confirmDeleteEntryId = null;
|
||||
confirmDeleteEntryTitle = null;
|
||||
await LoadAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void RequestRestoreEntry(int entryId)
|
||||
{
|
||||
confirmRestoreEntryId = entryId;
|
||||
confirmRestoreEntryTitle = entries?.FirstOrDefault(e => e.Id == entryId)?.Title;
|
||||
}
|
||||
|
||||
private void CancelRestoreConfirm()
|
||||
{
|
||||
confirmRestoreEntryId = null;
|
||||
confirmRestoreEntryTitle = null;
|
||||
}
|
||||
|
||||
private async Task HandleConfirmRestore()
|
||||
{
|
||||
if (confirmRestoreEntryId.HasValue)
|
||||
{
|
||||
await EntryService.RestoreEntryAsync(confirmRestoreEntryId.Value);
|
||||
confirmRestoreEntryId = null;
|
||||
confirmRestoreEntryTitle = null;
|
||||
await LoadAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void RequestEditEntry(int entryId)
|
||||
{
|
||||
var entry = entries?.FirstOrDefault(e => e.Id == entryId);
|
||||
if (entry?.IsTransfer == true)
|
||||
editingTransferEntry = entry;
|
||||
else
|
||||
editingEntry = entry;
|
||||
}
|
||||
|
||||
private async Task HandleEntryEdited()
|
||||
{
|
||||
editingEntry = null;
|
||||
editingTransferEntry = null;
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private async Task HandleExport()
|
||||
{
|
||||
var pdf = await PdfStatementService.GenerateStatementAsync(AccountId, showCurrentYearOnly);
|
||||
var suffix = showCurrentYearOnly ? $"_{DateTime.Now.Year}" : "_Gesamt";
|
||||
await FileSaveService.SaveFileAsync(pdf, $"{account?.Name}{suffix}.pdf");
|
||||
}
|
||||
|
||||
private static string FormatAmount(decimal amount) => $"{amount:N2} €";
|
||||
}
|
||||
56
src/Duempelkas.App/Pages/Dashboard.razor
Normal file
56
src/Duempelkas.App/Pages/Dashboard.razor
Normal file
@@ -0,0 +1,56 @@
|
||||
@page "/"
|
||||
@inject IAccountService AccountService
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>Übersicht</h2>
|
||||
<button class="btn btn-primary" @onclick="() => showAddAccount = true">
|
||||
<i class="bi bi-plus-lg"></i> Neues Konto
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (accounts == null)
|
||||
{
|
||||
<div class="text-center py-5">
|
||||
<div class="spinner-border" role="status"></div>
|
||||
</div>
|
||||
}
|
||||
else if (!accounts.Any())
|
||||
{
|
||||
<div class="text-center py-5 text-muted">
|
||||
<h4>Noch keine Konten vorhanden</h4>
|
||||
<p>Erstelle dein erstes Konto, um loszulegen.</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<AccountCardList Accounts="accounts" />
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (showAddAccount)
|
||||
{
|
||||
<AddAccountDialog OnSave="HandleAccountCreated" OnCancel="() => showAddAccount = false" />
|
||||
}
|
||||
|
||||
@code {
|
||||
private List<AccountSummaryDto>? accounts;
|
||||
private bool showAddAccount;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadAccounts();
|
||||
}
|
||||
|
||||
private async Task LoadAccounts()
|
||||
{
|
||||
accounts = await AccountService.GetAllAccountsAsync();
|
||||
}
|
||||
|
||||
private async Task HandleAccountCreated(string name)
|
||||
{
|
||||
await AccountService.CreateAccountAsync(name);
|
||||
showAddAccount = false;
|
||||
await LoadAccounts();
|
||||
}
|
||||
}
|
||||
13
src/Duempelkas.App/Services/IAccountService.cs
Normal file
13
src/Duempelkas.App/Services/IAccountService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Duempelkas.App.Services.Models;
|
||||
|
||||
namespace Duempelkas.App.Services;
|
||||
|
||||
public interface IAccountService
|
||||
{
|
||||
Task<List<AccountSummaryDto>> GetAllAccountsAsync();
|
||||
Task<AccountSummaryDto> GetAccountAsync(int accountId);
|
||||
Task<AccountSummaryDto> CreateAccountAsync(string name);
|
||||
Task RenameAccountAsync(int accountId, string newName);
|
||||
Task UpdateCarryoverAsync(int accountId, decimal carryoverBalance);
|
||||
Task DeleteAccountAsync(int accountId);
|
||||
}
|
||||
1
src/Duempelkas.App/Services/IAccountYearService.cs
Normal file
1
src/Duempelkas.App/Services/IAccountYearService.cs
Normal file
@@ -0,0 +1 @@
|
||||
// This file is intentionally left empty. AccountYear has been removed from the data model.
|
||||
8
src/Duempelkas.App/Services/IBalanceQueryService.cs
Normal file
8
src/Duempelkas.App/Services/IBalanceQueryService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Duempelkas.App.Services.Models;
|
||||
|
||||
namespace Duempelkas.App.Services;
|
||||
|
||||
public interface IBalanceQueryService
|
||||
{
|
||||
Task<AccountBalanceDto> GetAccountBalanceAsync(int accountId);
|
||||
}
|
||||
15
src/Duempelkas.App/Services/IEntryService.cs
Normal file
15
src/Duempelkas.App/Services/IEntryService.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Duempelkas.App.Services.Models;
|
||||
using Duempelkas.Domain.Enums;
|
||||
|
||||
namespace Duempelkas.App.Services;
|
||||
|
||||
public interface IEntryService
|
||||
{
|
||||
Task<List<EntryDto>> GetEntriesAsync(int accountId, bool currentYearOnly);
|
||||
Task<EntryDto> CreateEntryAsync(int accountId, EntryType type, DateTime date, string title, decimal amount);
|
||||
Task CreateTransferAsync(int sourceAccountId, int targetAccountId, DateTime date, string title, decimal amount);
|
||||
Task DeleteEntryAsync(int entryId);
|
||||
Task RestoreEntryAsync(int entryId);
|
||||
Task UpdateEntryAsync(int entryId, DateTime date, string title, decimal amount);
|
||||
Task UpdateTransferAsync(int entryId, int newLinkedAccountId, DateTime date, string title, decimal amount);
|
||||
}
|
||||
6
src/Duempelkas.App/Services/IFileSaveService.cs
Normal file
6
src/Duempelkas.App/Services/IFileSaveService.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Duempelkas.App.Services;
|
||||
|
||||
public interface IFileSaveService
|
||||
{
|
||||
Task<string?> SaveFileAsync(byte[] content, string suggestedFileName);
|
||||
}
|
||||
6
src/Duempelkas.App/Services/IPdfStatementService.cs
Normal file
6
src/Duempelkas.App/Services/IPdfStatementService.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Duempelkas.App.Services;
|
||||
|
||||
public interface IPdfStatementService
|
||||
{
|
||||
Task<byte[]> GenerateStatementAsync(int accountId, bool currentYearOnly);
|
||||
}
|
||||
3
src/Duempelkas.App/Services/Models/AccountSummaryDto.cs
Normal file
3
src/Duempelkas.App/Services/Models/AccountSummaryDto.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Duempelkas.App.Services.Models;
|
||||
|
||||
public record AccountSummaryDto(int Id, string Name, decimal CarryoverBalance, decimal TotalBalance, DateTime CreatedUtc);
|
||||
1
src/Duempelkas.App/Services/Models/AccountYearDto.cs
Normal file
1
src/Duempelkas.App/Services/Models/AccountYearDto.cs
Normal file
@@ -0,0 +1 @@
|
||||
// This file is intentionally left empty. AccountYear has been removed from the data model.
|
||||
17
src/Duempelkas.App/Services/Models/EntryDto.cs
Normal file
17
src/Duempelkas.App/Services/Models/EntryDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Duempelkas.Domain.Enums;
|
||||
|
||||
namespace Duempelkas.App.Services.Models;
|
||||
|
||||
public record EntryDto(
|
||||
int Id,
|
||||
int AccountId,
|
||||
string DisplayId,
|
||||
EntryType Type,
|
||||
DateTime Date,
|
||||
string Title,
|
||||
decimal Amount,
|
||||
bool IsDeleted,
|
||||
bool IsTransfer,
|
||||
int? TransferLinkId,
|
||||
string? LinkedAccountName,
|
||||
int? LinkedAccountId);
|
||||
9
src/Duempelkas.App/Services/Models/YearlySummaryDto.cs
Normal file
9
src/Duempelkas.App/Services/Models/YearlySummaryDto.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Duempelkas.App.Services.Models;
|
||||
|
||||
public record AccountBalanceDto(
|
||||
decimal CarryoverBalance,
|
||||
decimal TotalIncome,
|
||||
decimal TotalExpense,
|
||||
decimal CurrentYearIncome,
|
||||
decimal CurrentYearExpense,
|
||||
decimal TotalBalance);
|
||||
14
src/Duempelkas.App/_Imports.razor
Normal file
14
src/Duempelkas.App/_Imports.razor
Normal file
@@ -0,0 +1,14 @@
|
||||
@using System.Net.Http
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Microsoft.JSInterop
|
||||
@using Duempelkas.App
|
||||
@using Duempelkas.App.Components
|
||||
@using Duempelkas.App.Components.Layout
|
||||
@using Duempelkas.App.Components.Accounts
|
||||
@using Duempelkas.App.Components.Dialogs
|
||||
@using Duempelkas.App.Services
|
||||
@using Duempelkas.App.Services.Models
|
||||
@using Duempelkas.Domain.Entities
|
||||
@using Duempelkas.Domain.Enums
|
||||
Reference in New Issue
Block a user