feat(usability): explain booking fields and validate decimal input (U06)

This commit is contained in:
2026-11-02 06:32:32 +01:00
parent 33a8abf5cc
commit 76ba79b63e
12 changed files with 205 additions and 42 deletions
@@ -30,15 +30,20 @@ public partial class AddTransferDialog
private List<AccountSummaryDto> accounts = new();
private int targetAccountId;
private DateTime date = DateTime.Today;
private string dateText = DateTime.Today.ToString("yyyy-MM-dd");
private DateTime date => Duempelkas.App.Services.BookingInput.Date(dateText);
private string title = string.Empty;
private decimal amount;
private string amountText = string.Empty;
private bool ValidAmount => Duempelkas.App.Services.BookingInput.TryAmount(amountText, out _);
private decimal amount => Duempelkas.App.Services.BookingInput.TryAmount(amountText, out var value) ? value : 0;
private bool initialized;
private int? initializedEntryId;
#endregion
#region Properties
private bool CanSave => targetAccountId > 0 && !string.IsNullOrWhiteSpace(title) && amount > 0;
private bool CanSave => targetAccountId > 0 && targetAccountId != SourceAccountId && !string.IsNullOrWhiteSpace(title) && ValidAmount && date != default && (!OutsideYear || (confirmDifferentYear && confirmedYear == date.Year));
#endregion
@@ -51,12 +56,15 @@ public partial class AddTransferDialog
accounts = await AccountService.GetAllAccountsAsync();
}
if (initialized && initializedEntryId == EditEntry?.Id) return;
initialized = true;
initializedEntryId = EditEntry?.Id;
if (EditEntry != null)
{
targetAccountId = EditEntry.LinkedAccountId ?? 0;
date = EditEntry.Date;
dateText = EditEntry.Date.ToString("yyyy-MM-dd");
title = EditEntry.Title;
amount = EditEntry.Amount;
amountText = EditEntry.Amount.ToString("0.00", System.Globalization.CultureInfo.GetCultureInfo("de-DE"));
}
}
@@ -66,7 +74,7 @@ public partial class AddTransferDialog
private async Task Save()
{
if (OutsideYear && (!confirmDifferentYear || confirmedYear != date.Year)) return;
if (!CanSave) return;
if (EditEntry != null)
{
await EntryService.UpdateTransferAsync(EditEntry.Id, targetAccountId, date, title.Trim(), amount);