feat: company table screens, profile and fiscal years, seed command (#38, #39, #45)

Gives the company tables of the previous commit their screens, so a company
can be configured from the browser, and makes the base data runnable outside
the web server.

- one generic editor for the 26 coded tables (/tabelle/<slug>), described in
  TableScreens: grid with active/disabled filter, detail with errors and
  warnings, disable instead of delete, CSV export and all-or-nothing import,
  "update from base tables"; index page and menu entries
- company profile in tabs with the fiscal pack checks, fiscal years with
  month lock/unlock, exchange rates with manual rates
- PaymentTermService: installments saved together, percentages must sum to 100
- a new profile proposes the registered company name instead of its code
- seed verb in Khaemhat.Web and scripts/seed.sh --base [--company CODE],
  shipped in the image under /app/scripts
- ADR 0026 (base data only adds missing codes; ISTAT and ABI/CAB lists come
  as separate datasets), wiki, CHANGELOG, STATUS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 23:15:09 +01:00
1 parent 34e196424f
commit 9bcf8c1082
33 files changed
+3272 -43

No files matched your search

@@ -10,7 +10,6 @@
@page "/servizi/{*Rest}"
@page "/canali/{*Rest}"
@page "/report/{*Rest}"
@page "/tabelle/{*Rest}"
@page "/automazioni/{*Rest}"
@page "/amministrazione/{*Rest}"
@attribute [Authorize]
@@ -0,0 +1,173 @@
@page "/tabelle/profilo-azienda"
@attribute [Authorize]
@using Khaemhat.Application.Security
@using Khaemhat.Application.Tables
@using Khaemhat.Core.Common
@using Khaemhat.Core.Tables
@using Khaemhat.Web.Tables
@using Khaemhat.Web.Components.Tables
@inject ShellSession Session
@inject CompanyProfileService Profiles
@inject TableService Tables
@inject CompanyFiscalContext Fiscal
@inject ToastService Toasts
@* The company profile (SPEC §11.1, mockup 075): company data, tax and e-invoice, default bank, print, fiscal year and
VAT, transmitter and intermediary. The country of the profile picks the fiscal pack of the company. *@
<KhPageTitle Text="@T["CompanyTables.Profile.Title"]" Icon="building" />
<TablesGuard>
<div class="phead">
<div>
<div class="crumbs"><a href="@TableScreens.BasePath">@T["Shell.Menu.CompanyTables"]</a> / @T["CompanyTables.Profile.Title"]</div>
<h1>@(_profile?.LegalName is { Length: > 0 } name ? name : T["CompanyTables.Profile.Title"])</h1>
<div class="sub">@T["CompanyTables.Profile.Hint"]</div>
</div>
<div class="grow"></div>
@if (_modified)
{
<KhBadge Tone="KhTone.Warning">@T["CompanyTables.Modified"]</KhBadge>
}
<div class="toolbar">
<button type="button" class="btn" disabled="@(!_modified)" @onclick="UndoAsync"><KhIcon Name="undo" /> @T["CompanyTables.Undo"]</button>
<button type="button" class="btn primary" disabled="@(!_modified || !CanWrite || _busy)" @onclick="SaveAsync"><KhIcon Name="save" /> @T["Common.Save"]</button>
</div>
</div>
@if (_profile is not null)
{
<section class="panel kh-tables-profile">
<KhTabs Items="TabItems" Active="@_tab" ActiveChanged="t => _tab = t" Label="@T["CompanyTables.Profile.Title"]" />
<KhForm Validation="_validation" ReadOnly="!CanWrite" Layout="KhFormLayout.Groups">
@foreach (var group in ProfileLayout.Tabs.First(t => t.Id == _tab).Groups)
{
<KhFieldGroup Title="@T["CompanyTables.Profile.Groups." + group.Key]" Icon="@group.Icon">
@foreach (var field in group.Fields)
{
<KhRowField Row="_profile" Field="field" Options="_options" ReadOnly="!CanWrite" OnChanged="() => _modified = true" />
}
</KhFieldGroup>
}
</KhForm>
@if (_tab == "esercizi")
{
<p class="muted kh-pad"><KhIcon Name="info" /> @T["CompanyTables.Profile.YearsHint"] <a href="/tabelle/esercizi">@T["CompanyTables.FiscalYears.Title"]</a></p>
}
@if (_tab == "stampa")
{
<p class="muted kh-pad"><KhIcon Name="info" /> @T["CompanyTables.Profile.LogoHint"]</p>
}
</section>
}
</TablesGuard>
@code {
private readonly KhValidation _validation = new();
private readonly TableOptions _options = new();
private CompanyProfile? _profile;
private CompanyProfile? _saved;
private string _tab = ProfileLayout.Tabs[0].Id;
private bool _modified;
private bool _busy;
private bool CanWrite => Session.Permissions.Allows(TableService.WritePermission);
private IReadOnlyList<KhTabItem> TabItems =>
[
.. ProfileLayout.Tabs.Select(t => new KhTabItem(t.Id, t.Icon, T["CompanyTables.Profile.Tabs." + t.Id],
_validation.Messages.Count(m => ProfileLayout.TabOf(m.Field) == t) is > 0 and var n ? n : null)),
];
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await Session.EnsureLoadedAsync();
if (Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(TableService.ReadPermission))
{
await _options.LoadAsync(Tables, Fiscal, ProfileLayout.Fields, actor, company);
Show(await Profiles.GetAsync(actor, company));
}
}
private void Show(CompanyProfile profile)
{
_profile = profile;
_saved = Copy(profile);
_modified = false;
_validation.Clear();
}
private Task UndoAsync()
{
if (_saved is { } saved)
{
Show(Copy(saved));
}
return Task.CompletedTask;
}
private async Task SaveAsync()
{
if (_profile is null || Session.Actor is not { } actor || Session.Company?.Code is not { } company)
{
return;
}
_busy = true;
_validation.Clear();
try
{
var problems = Profiles.Validate(_profile);
if (problems.Count > 0)
{
Refuse(problems.Select(p => ((string?)p.Field, p.Code)));
return;
}
Show(await Profiles.SaveAsync(actor, company, _profile));
await _options.LoadAsync(Tables, Fiscal, ProfileLayout.Fields, actor, company);
Toasts.Show(ToastKind.Success, T["CompanyTables.Saved"], _profile.LegalName);
}
catch (ValidationFailedException ex)
{
Refuse(ex.Errors.Select(TableValues.SplitError));
}
catch (ConcurrencyException)
{
Toasts.Show(ToastKind.Error, T["CompanyTables.NotSaved"], T["CompanyTables.Concurrency"]);
}
finally
{
_busy = false;
}
}
private void Refuse(IEnumerable<(string? Field, string Code)> errors)
{
foreach (var (field, code) in errors)
{
_validation.Add(field, T.Contains(code) ? T[code] : T["CompanyTables.UnknownError"]);
}
// Show the tab of the first error, which may not be the one open.
if (_validation.Messages.Select(m => ProfileLayout.TabOf(m.Field)).FirstOrDefault(t => t is not null) is { } tab
&& !_validation.Messages.Any(m => ProfileLayout.TabOf(m.Field)?.Id == _tab))
{
_tab = tab.Id;
}
Toasts.Show(ToastKind.Error, T["CompanyTables.NotSaved"], T["CompanyTables.FixFields"]);
}
private static CompanyProfile Copy(CompanyProfile profile)
{
var copy = new CompanyProfile();
foreach (var property in typeof(CompanyProfile).GetProperties().Where(p => p.CanRead && p.CanWrite))
{
property.SetValue(copy, property.GetValue(profile));
}
return copy;
}
}
@@ -0,0 +1,129 @@
@page "/tabelle/cambi"
@attribute [Authorize]
@using Khaemhat.Application.Security
@using Khaemhat.Application.Tables
@using Khaemhat.Core.Tables
@using Khaemhat.Web.Tables
@inject ShellSession Session
@inject ExchangeRateService Rates
@inject TableService Tables
@inject ToastService Toasts
@inject TimeProvider Clock
@* Exchange rates (SPEC §11.1): the reference rates of the European Central Bank, read every working day by the system
task "Cambi di riferimento BCE", and the rates typed by hand, which the task never overwrites. *@
<KhPageTitle Text="@T["CompanyTables.Rates.Title"]" Icon="euro" />
<TablesGuard>
<div class="phead">
<div>
<div class="crumbs"><a href="@TableScreens.BasePath">@T["Shell.Menu.CompanyTables"]</a> / @T["CompanyTables.Rates.Title"]</div>
<h1>@T["CompanyTables.Rates.Title"]</h1>
<div class="sub">@T["CompanyTables.Rates.Hint"]</div>
</div>
</div>
<div class="kh-tables">
<KhRadar TItem="ExchangeRate" @ref="_radar" Id="tables.exchange-rates" Columns="Columns" Source="ListAsync" KeyOf="r => r.Id" Selectable="false"
QuickFilters="QuickFilters" ShowHints="false" Compact="true" Height="360px" ExportName="cambi" Label="@T["CompanyTables.Rates.Title"]" />
@if (CanWrite)
{
<KhPanel Title="@T["CompanyTables.Rates.Manual"]" Icon="edit">
<KhForm Validation="_validation" Layout="KhFormLayout.Grid">
<KhSelect TValue="string" Label="@T["CompanyTables.Fields.CurrencyCode"]" Name="CurrencyCode" Options="_currencies" @bind-Value="_currency" Required="true" Span="4" />
<KhDateBox Label="@T["CompanyTables.Fields.RateDate"]" Name="RateDate" @bind-Value="_date" Required="true" Span="4" />
<KhNumberBox Label="@T["CompanyTables.Fields.Rate"]" Name="Rate" @bind-Value="_rate" Decimals="6" Min="0" Required="true" Span="4" />
</KhForm>
<div class="kh-pad">
<button type="button" class="btn primary" disabled="@_busy" @onclick="SaveAsync"><KhIcon Name="save" /> @T["CompanyTables.Rates.Save"]</button>
<span class="muted sm">@T["CompanyTables.Rates.ManualHint"]</span>
</div>
</KhPanel>
}
</div>
</TablesGuard>
@code {
private readonly KhValidation _validation = new();
private KhRadar<ExchangeRate>? _radar;
private IReadOnlyList<KhOption<string>> _currencies = [];
private string? _currency;
private DateOnly? _date;
private decimal? _rate;
private bool _busy;
private bool CanWrite => Session.Permissions.Allows(TableService.WritePermission);
private IReadOnlyList<KhColumn<ExchangeRate>> Columns =>
[
new("currency", T["CompanyTables.Fields.CurrencyCode"], r => r.CurrencyCode) { Kind = KhColumnKind.Code, Width = "90px" },
new("date", T["CompanyTables.Fields.RateDate"], r => r.RateDate) { Kind = KhColumnKind.Date, Width = "120px" },
new("rate", T["CompanyTables.Fields.Rate"], r => r.Rate) { Kind = KhColumnKind.Number, Decimals = 6, Width = "140px" },
new("source", T["CompanyTables.Fields.Source"], r => T["CompanyTables.Values.Source." + r.Source]) { Sortable = false },
];
private IReadOnlyList<KhQuickFilter> QuickFilters =>
[
new("source", T["CompanyTables.Fields.Source"],
[
new(string.Empty, T["CompanyTables.Filter.All"]), new(ExchangeRateService.EcbSource, T["CompanyTables.Values.Source.ECB"]),
new(ExchangeRateService.ManualSource, T["CompanyTables.Values.Source.MANUAL"]),
]),
];
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await Session.EnsureLoadedAsync();
_date = DateOnly.FromDateTime(Clock.GetLocalNow().DateTime);
if (Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(TableService.ReadPermission))
{
var currencies = await Tables.ActiveAsync<Currency>(actor, company);
_currencies = [.. currencies.Where(c => c.Code != "EUR").Select(c => new KhOption<string>(c.Code, c.Code + " · " + c.Description))];
}
}
private Task<ListPage<ExchangeRate>> ListAsync(ListQuery query, CancellationToken cancellationToken) =>
Session.Actor is { } actor && Session.Company?.Code is { } company
? Rates.ListAsync(actor, company, query, cancellationToken)
: Task.FromResult(new ListPage<ExchangeRate>([], 0, new Dictionary<string, decimal>()));
private async Task SaveAsync()
{
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
{
return;
}
_validation.Clear();
if (_currency is null || _date is null || _rate is not > 0)
{
_validation.Add(_currency is null ? "CurrencyCode" : _date is null ? "RateDate" : "Rate", T[ExchangeRateService.RateInvalid]);
return;
}
_busy = true;
try
{
await Rates.SetManualAsync(actor, company, _currency, _date.Value, _rate.Value);
Toasts.Show(ToastKind.Success, T["CompanyTables.Saved"], _currency);
_rate = null;
if (_radar is not null)
{
await _radar.ReloadAsync();
}
}
catch (ValidationFailedException ex)
{
foreach (var (field, code) in ex.Errors.Select(TableValues.SplitError))
{
_validation.Add(field ?? "Rate", T.Contains(code) ? T[code] : T["CompanyTables.UnknownError"]);
}
}
finally
{
_busy = false;
}
}
}
@@ -0,0 +1,217 @@
@page "/tabelle/esercizi"
@attribute [Authorize]
@using Khaemhat.Application.Security
@using Khaemhat.Application.Tables
@using Khaemhat.Core.Tables
@using Khaemhat.Web.Tables
@inject ShellSession Session
@inject FiscalYearService Years
@inject ToastService Toasts
@inject DialogService Dialogs
@inject TimeProvider Clock
@* Fiscal years and periods (SPEC §11.1, mockup 052): the years with their state, the months of the chosen year with
the lock that stops new entries and documents on those dates. The VAT settlement (M7) marks a month as settled. *@
<KhPageTitle Text="@T["CompanyTables.FiscalYears.Title"]" Icon="calendar" />
<TablesGuard>
<div class="phead">
<div>
<div class="crumbs"><a href="@TableScreens.BasePath">@T["Shell.Menu.CompanyTables"]</a> / @T["CompanyTables.FiscalYears.Title"]</div>
<h1>@T["CompanyTables.FiscalYears.Heading"]</h1>
<div class="sub">@T["CompanyTables.FiscalYears.Hint"]</div>
</div>
<div class="grow"></div>
<div class="toolbar">
<button type="button" class="btn primary" disabled="@(!CanWrite || _busy)" @onclick="CreateAsync"><KhIcon Name="plus" /> @T["CompanyTables.FiscalYears.New"]</button>
</div>
</div>
<div class="kh-tables">
<KhPanel Title="@T["CompanyTables.FiscalYears.Years"]" Icon="calendar" Tight="true">
@if (_years.Count == 0)
{
<p class="muted kh-pad">@T["CompanyTables.FiscalYears.None"]</p>
}
else
{
<table class="grid" aria-label="@T["CompanyTables.FiscalYears.Years"]">
<thead>
<tr>
<th>@T["CompanyTables.FiscalYears.Year"]</th>
<th>@T["CompanyTables.FiscalYears.Start"]</th>
<th>@T["CompanyTables.FiscalYears.End"]</th>
<th>@T["CompanyTables.FiscalYears.State"]</th>
<th>@T["CompanyTables.FiscalYears.LockedMonths"]</th>
<th>@T["CompanyTables.FiscalYears.LastSettled"]</th>
</tr>
</thead>
<tbody>
@foreach (var view in _years)
{
var year = view.Year;
<tr class="@(year.Id == _selected?.Year.Id ? "sel" : null)" @onclick="() => _selected = view" style="cursor:pointer">
<td><b class="mono">@year.Code</b></td>
<td>@T.Date(year.StartDate)</td>
<td>@T.Date(year.EndDate)</td>
<td><KhBadge Tone="ToneOf(year.Status)">@T[TableScreens.EnumKey(year.Status)]</KhBadge></td>
<td>@view.Periods.Count(p => p.Status != FiscalPeriodStatus.Open) / @view.Periods.Count</td>
<td>@(view.Periods.LastOrDefault(p => p.Status == FiscalPeriodStatus.Settled) is { } last ? MonthName(last) : "-")</td>
</tr>
}
</tbody>
</table>
}
</KhPanel>
@if (_selected is { } selected)
{
<KhPanel Title="@T.Format("CompanyTables.FiscalYears.Periods", selected.Year.Code, T[TableScreens.EnumKey(_periodicity)])" Icon="lock" Tight="true">
<table class="grid" aria-label="@T["CompanyTables.FiscalYears.PeriodsLabel"]">
<thead>
<tr>
<th>@T["CompanyTables.FiscalYears.Period"]</th>
<th>@T["CompanyTables.FiscalYears.From"]</th>
<th>@T["CompanyTables.FiscalYears.To"]</th>
<th>@T["CompanyTables.FiscalYears.State"]</th>
<th>@T["CompanyTables.FiscalYears.Lock"]</th>
</tr>
</thead>
<tbody>
@foreach (var period in selected.Periods)
{
<tr>
<td>@MonthName(period)</td>
<td>@T.Date(period.StartDate)</td>
<td>@T.Date(period.EndDate)</td>
<td><KhBadge Tone="ToneOf(period.Status)">@T[TableScreens.EnumKey(period.Status)]</KhBadge></td>
<td>
@if (period.Status == FiscalPeriodStatus.Settled)
{
<span class="muted">@T["CompanyTables.FiscalYears.SettledLock"]</span>
}
else
{
var locked = period.Status == FiscalPeriodStatus.Locked;
<button type="button" class="btn sm" disabled="@(!CanWrite || _busy || selected.Year.Status != FiscalYearStatus.Open)"
@onclick="() => LockAsync(period, !locked)">
<KhIcon Name="@(locked ? "key" : "lock")" /> @T[locked ? "CompanyTables.FiscalYears.Unlock" : "CompanyTables.FiscalYears.LockMonth"]
</button>
}
</td>
</tr>
}
</tbody>
</table>
</KhPanel>
}
</div>
</TablesGuard>
@code {
private IReadOnlyList<FiscalYearView> _years = [];
private FiscalYearView? _selected;
private Khaemhat.Core.Tax.VatPeriodicity _periodicity;
private bool _busy;
/// <summary>The service of the company profile, for the VAT periodicity shown on the months.</summary>
[Inject]
private CompanyProfileService Profiles { get; set; } = default!;
private bool CanWrite => Session.Permissions.Allows(TableService.WritePermission);
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await Session.EnsureLoadedAsync();
if (Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(TableService.ReadPermission))
{
_periodicity = (await Profiles.GetAsync(actor, company)).VatPeriodicity;
await LoadAsync(actor, company);
}
}
private async Task LoadAsync(Actor actor, string company)
{
var selected = _selected?.Year.Id;
_years = await Years.ListAsync(actor, company);
var today = DateOnly.FromDateTime(Clock.GetLocalNow().DateTime);
_selected = _years.FirstOrDefault(y => y.Year.Id == selected)
?? _years.FirstOrDefault(y => y.Year.StartDate <= today && today <= y.Year.EndDate)
?? _years.FirstOrDefault();
}
private async Task CreateAsync()
{
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
{
return;
}
_busy = true;
try
{
var created = await Years.CreateNextAsync(actor, company, DateOnly.FromDateTime(Clock.GetLocalNow().DateTime));
_selected = created;
await LoadAsync(actor, company);
Toasts.Show(ToastKind.Success, T["CompanyTables.FiscalYears.Created"], created.Year.Code);
}
catch (ValidationFailedException ex)
{
Toasts.Show(ToastKind.Error, T["CompanyTables.NotSaved"], string.Join(" ", ex.Errors.Select(e => T[TableValues.SplitError(e).Code])));
}
finally
{
_busy = false;
}
}
private async Task LockAsync(FiscalPeriod period, bool locked)
{
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
{
return;
}
if (!locked && !await Dialogs.ConfirmAsync(new ConfirmRequest(T["CompanyTables.FiscalYears.Unlock"], T.Format("CompanyTables.FiscalYears.UnlockText", MonthName(period)),
T["CompanyTables.FiscalYears.Unlock"], T["Common.Cancel"])))
{
return;
}
_busy = true;
try
{
await Years.SetLockedAsync(actor, company, period.Id, locked);
await LoadAsync(actor, company);
}
catch (ValidationFailedException ex)
{
Toasts.Show(ToastKind.Error, T["CompanyTables.NotSaved"], string.Join(" ", ex.Errors.Select(e => T[TableValues.SplitError(e).Code])));
}
finally
{
_busy = false;
}
}
private string MonthName(FiscalPeriod period)
{
var text = period.StartDate.ToString("MMMM yyyy", T.Culture);
return char.ToUpper(text[0], T.Culture) + text[1..];
}
private static KhTone ToneOf(FiscalYearStatus status) => status switch
{
FiscalYearStatus.Open => KhTone.Ok,
FiscalYearStatus.Closing => KhTone.Warning,
_ => KhTone.Neutral,
};
private static KhTone ToneOf(FiscalPeriodStatus status) => status switch
{
FiscalPeriodStatus.Open => KhTone.Ok,
FiscalPeriodStatus.Settled => KhTone.Info,
_ => KhTone.Warning,
};
}
@@ -0,0 +1,31 @@
@page "/tabelle/{Slug}"
@attribute [Authorize]
@using Khaemhat.Web.Tables
@using Khaemhat.Web.Components.Tables
@* A company table by address (/tabelle/codici-iva): the generic editor of its entity. *@
<TablesGuard>
@if (TableScreens.Find(Slug) is { } screen)
{
<DynamicComponent @key="screen.Slug" Type="EditorOf(screen)" Parameters="ParametersOf(screen)" />
}
else
{
<KhPageTitle Text="@T["Pages.NotFound.Title"]" Icon="layers" />
<div class="kh-message">
<KhIcon Name="layers" Class="lg" />
<h1>@T["Pages.NotFound.Title"]</h1>
<a class="btn" href="@TableScreens.BasePath">@T["Shell.Menu.CompanyTables"]</a>
</div>
}
</TablesGuard>
@code {
/// <summary>The last part of the address.</summary>
[Parameter]
public string? Slug { get; set; }
private static Type EditorOf(TableScreen screen) => typeof(KhTableEditor<>).MakeGenericType(screen.Entity);
private static Dictionary<string, object?> ParametersOf(TableScreen screen) => new() { ["Screen"] = screen };
}
@@ -0,0 +1,43 @@
@inject ShellSession Session
@* What every page of the company tables checks first: an open company and the permission to read its settings. *@
@if (!_loaded)
{
<p class="muted kh-pad">@T["Common.Loading"]</p>
}
else if (Session.Company is null)
{
<div class="kh-message">
<KhIcon Name="building" Class="lg" />
<h1>@T["CompanyTables.NoCompany.Title"]</h1>
<p class="lead">@T["CompanyTables.NoCompany.Lead"]</p>
</div>
}
else if (!Session.Permissions.Allows(Khaemhat.Application.Tables.TableService.ReadPermission))
{
<div class="kh-message">
<KhIcon Name="lock" Class="lg" />
<h1>@T["Pages.AccessDenied.Title"]</h1>
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
<a class="btn" href="./">@T["Common.BackHome"]</a>
</div>
}
else
{
@ChildContent
}
@code {
private bool _loaded;
/// <summary>The page.</summary>
[Parameter]
public RenderFragment? ChildContent { get; set; }
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await Session.EnsureLoadedAsync();
_loaded = true;
}
}
@@ -0,0 +1,46 @@
@page "/tabelle"
@attribute [Authorize]
@using Khaemhat.Web.Tables
@* The company tables (SPEC §11.1): the profile, the fiscal years and the exchange rates, then every table by group. *@
<KhPageTitle Text="@T["Shell.Menu.CompanyTables"]" Icon="layers" />
<TablesGuard>
<div class="phead">
<div>
<h1>@T["Shell.Menu.CompanyTables"]</h1>
<div class="sub">@T["CompanyTables.Index.Subtitle"]</div>
</div>
</div>
<div class="kh-tables">
<KhPanel Title="@T["CompanyTables.Index.Company"]" Icon="building">
<div class="kh-table-index kh-pad">
@foreach (var (href, icon, title, hint) in Pages)
{
<a href="@href"><KhIcon Name="@icon" /><span><b>@T[title]</b><small>@T[hint]</small></span></a>
}
</div>
</KhPanel>
@foreach (var group in TableScreens.All.GroupBy(s => s.Group))
{
<KhPanel Title="@T["CompanyTables.Groups." + group.Key]" Icon="@group.First().Icon">
<div class="kh-table-index kh-pad">
@foreach (var screen in group)
{
<a href="@screen.Href"><KhIcon Name="@screen.Icon" /><span><b>@T[screen.TitleKey]</b><small>@T[screen.HintKey]</small></span></a>
}
</div>
</KhPanel>
}
</div>
</TablesGuard>
@code {
/// <summary>The pages of the company that are not tables.</summary>
public static readonly IReadOnlyList<(string Href, string Icon, string Title, string Hint)> Pages =
[
("/tabelle/profilo-azienda", "building", "CompanyTables.Profile.Title", "CompanyTables.Profile.Hint"),
("/tabelle/esercizi", "calendar", "CompanyTables.FiscalYears.Title", "CompanyTables.FiscalYears.Hint"),
("/tabelle/cambi", "euro", "CompanyTables.Rates.Title", "CompanyTables.Rates.Hint"),
];
}