The document radars and records now serve /acquisti and /magazzino too: supplier orders, receipts, supplier invoices and credit notes, self-invoices and warehouse movements, with the supplier in place of the customer, the supplier's number and date, the protocol and VAT date of registered invoices, and reason and warehouses of a movement. Supplier invoices take their protocol from the purchase numbering, refuse a second document with the same supplier number in the same year and show price differences against their order or receipt. The Italian pack advises the self-invoice a received invoice needs (TD16-TD19, TD28) with its deadline, and the purchase service drafts it with the ordinary rate. A credit note of an invoice now moves its goods back instead of being skipped as already moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
138 lines
9.8 KiB
C#
138 lines
9.8 KiB
C#
using Khaemhat.Application.Modules;
|
|
|
|
namespace Khaemhat.Web.Shell;
|
|
|
|
/// <summary>Who may see a menu entry besides module and permission.</summary>
|
|
public enum MenuAudience
|
|
{
|
|
/// <summary>Everybody with the module and the permission.</summary>
|
|
Everyone = 0,
|
|
|
|
/// <summary>Only instance accounts (super user and administrators).</summary>
|
|
InstanceAccounts = 1,
|
|
}
|
|
|
|
/// <summary>An entry of the side menu (SPEC §10.2).</summary>
|
|
/// <param name="Key">The text key of the label (<c>Shell.Menu.*</c>) and the identity of the entry.</param>
|
|
/// <param name="Icon">The icon in <c>icons/sprite.svg</c>.</param>
|
|
/// <param name="Href">The address.</param>
|
|
/// <param name="Module">The licence module that must be active.</param>
|
|
/// <param name="Permission">The permission needed, or <see langword="null"/>.</param>
|
|
/// <param name="Milestone">The milestone that delivers the page, shown while it is not there yet (<c>M4</c>...); <see langword="null"/> once delivered.</param>
|
|
/// <param name="Audience">Who may see it.</param>
|
|
public sealed record MenuItem(string Key, string Icon, string Href, string Module, string? Permission, string? Milestone,
|
|
MenuAudience Audience = MenuAudience.Everyone)
|
|
{
|
|
/// <summary>The sub-entries shown under the active module or in the pop-up of the collapsed menu.</summary>
|
|
public IReadOnlyList<MenuItem> Children { get; init; } = [];
|
|
|
|
/// <summary>Whether an address belongs to this entry or to one of its children.</summary>
|
|
/// <param name="path">The path, without query.</param>
|
|
/// <returns><see langword="true"/> when it matches.</returns>
|
|
public bool Matches(string path) =>
|
|
Href == "/" ? path == "/" : path.Equals(Href, StringComparison.OrdinalIgnoreCase) || path.StartsWith(Href + "/", StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>A titled group of the side menu.</summary>
|
|
/// <param name="Key">The text key of the title.</param>
|
|
/// <param name="Items">The entries.</param>
|
|
public sealed record MenuSection(string Key, IReadOnlyList<MenuItem> Items);
|
|
|
|
/// <summary>
|
|
/// The side menu of SPEC §10.2, in its order: Home; Anagrafiche, CRM, Vendite, Acquisti, Magazzino, Contabilità,
|
|
/// Scadenzario, Fatturazione elettronica, Cespiti, Servizi, Canali e-commerce, Report; Tabelle azienda,
|
|
/// Automazioni, Amministrazione. Entries appear only with the licensed module and the permission.
|
|
/// </summary>
|
|
public static class MenuCatalog
|
|
{
|
|
/// <summary>The sections.</summary>
|
|
public static IReadOnlyList<MenuSection> Sections { get; } =
|
|
[
|
|
new("Shell.Menu.Section.Main",
|
|
[
|
|
new("Shell.Menu.Home", "home", "/", ModuleCodes.Core, null, null),
|
|
]),
|
|
new("Shell.Menu.Section.Operations",
|
|
[
|
|
Area("Shell.Menu.Parties", "users", "/anagrafiche", ModuleCodes.Core, "parties.party.read", null,
|
|
("Shell.Menu.Parties.Customers", "clienti"), ("Shell.Menu.Parties.Suppliers", "fornitori"), ("Shell.Menu.Parties.Contacts", "contatti"),
|
|
("Shell.Menu.Parties.Items", "articoli"), ("Shell.Menu.Parties.PriceLists", "listini"), ("Shell.Menu.Parties.Categories", "categorie")),
|
|
Area("Shell.Menu.Crm", "target", "/crm", ModuleCodes.Crm, "crm.lead.read", "M11",
|
|
("Shell.Menu.Crm.Dashboard", "cruscotto"), ("Shell.Menu.Crm.Leads", "lead"), ("Shell.Menu.Crm.Pipeline", "pipeline"),
|
|
("Shell.Menu.Crm.Agenda", "agenda"), ("Shell.Menu.Crm.Tickets", "ticket"), ("Shell.Menu.Crm.Campaigns", "campagne")),
|
|
Area("Shell.Menu.Sales", "cart", "/vendite", ModuleCodes.Core, "sales.invoice.read", null,
|
|
("Shell.Menu.Sales.Quotes", "preventivi"), ("Shell.Menu.Sales.Orders", "ordini"), ("Shell.Menu.Sales.DeliveryNotes", "ddt"),
|
|
("Shell.Menu.Sales.Invoices", "fatture"), ("Shell.Menu.Sales.CreditNotes", "note-credito"), ("Shell.Menu.Sales.DeferredInvoicing", "fatturazione-differita")),
|
|
Area("Shell.Menu.Purchases", "truck", "/acquisti", ModuleCodes.Core, "purchases.order.read", null,
|
|
("Shell.Menu.Purchases.Orders", "ordini"), ("Shell.Menu.Purchases.Receipts", "ricevimenti"), ("Shell.Menu.Purchases.Invoices", "fatture"),
|
|
("Shell.Menu.Purchases.Import", "importa-fatture"), ("Shell.Menu.Purchases.SelfInvoices", "autofatture")),
|
|
Area("Shell.Menu.Inventory", "box", "/magazzino", ModuleCodes.Core, "inventory.stock.read", null,
|
|
("Shell.Menu.Inventory.Stock", "giacenze"), ("Shell.Menu.Inventory.Entries", "movimenti"), ("Shell.Menu.Inventory.StockTake", "inventario"),
|
|
("Shell.Menu.Inventory.Reorder", "riordino")),
|
|
Area("Shell.Menu.Ledger", "book", "/contabilita", ModuleCodes.Accounting, "ledger.entry.read", "M7",
|
|
("Shell.Menu.Ledger.Journal", "prima-nota"), ("Shell.Menu.Ledger.Accounts", "piano-dei-conti"), ("Shell.Menu.Ledger.VatRegisters", "registri-iva"),
|
|
("Shell.Menu.Ledger.VatSettlement", "liquidazione-iva"), ("Shell.Menu.Ledger.Statements", "bilancio")),
|
|
Area("Shell.Menu.Finance", "coins", "/scadenzario", ModuleCodes.Finance, "finance.schedule.read", "M9",
|
|
("Shell.Menu.Finance.OpenItems", "scadenze"), ("Shell.Menu.Finance.Remittances", "distinte"), ("Shell.Menu.Finance.Dunning", "solleciti"),
|
|
("Shell.Menu.Finance.Reconciliation", "riconciliazione")),
|
|
Area("Shell.Menu.EInvoicing", "file-check", "/fatturazione-elettronica", ModuleCodes.EInvoicing, "einvoice.document.read", "M8",
|
|
("Shell.Menu.EInvoicing.Dashboard", "cruscotto"), ("Shell.Menu.EInvoicing.Channels", "canali"), ("Shell.Menu.EInvoicing.StampDuty", "bollo"),
|
|
("Shell.Menu.EInvoicing.IntentDeclarations", "dichiarazioni-intento")),
|
|
Area("Shell.Menu.Assets", "building", "/cespiti", ModuleCodes.Assets, "assets.asset.read", "M10",
|
|
("Shell.Menu.Assets.Register", "registro"), ("Shell.Menu.Assets.Depreciation", "ammortamenti")),
|
|
Area("Shell.Menu.Services", "wrench", "/servizi", ModuleCodes.Services, null, "M12",
|
|
("Shell.Menu.Services.Contracts", "contratti"), ("Shell.Menu.Services.Interventions", "interventi")),
|
|
Area("Shell.Menu.Channels", "globe", "/canali", ModuleCodes.Channels, null, "M12",
|
|
("Shell.Menu.Channels.Orders", "ordini")),
|
|
Area("Shell.Menu.Reports", "chart", "/report", ModuleCodes.Reports, "reports.report.read", "M13"),
|
|
]),
|
|
new("Shell.Menu.Section.System",
|
|
[
|
|
Area("Shell.Menu.CompanyTables", "layers", "/tabelle", ModuleCodes.Core, "company.settings.read", null,
|
|
("Shell.Menu.CompanyTables.Profile", "profilo-azienda"), ("Shell.Menu.CompanyTables.FiscalYears", "esercizi"),
|
|
("Shell.Menu.CompanyTables.Preferences", "preferenze"),
|
|
("Shell.Menu.CompanyTables.TaxCodes", "codici-iva"), ("Shell.Menu.CompanyTables.Payments", "pagamenti"),
|
|
("Shell.Menu.CompanyTables.Numerators", "numeratori"), ("Shell.Menu.CompanyTables.Warehouses", "depositi"),
|
|
("Shell.Menu.CompanyTables.Currencies", "valute"), ("Shell.Menu.CompanyTables.ExchangeRates", "cambi")),
|
|
Area("Shell.Menu.Automation", "zap", "/automazioni", ModuleCodes.Automation, null, "M12",
|
|
("Shell.Menu.Automation.Rules", "regole"), ("Shell.Menu.Automation.Procedures", "procedure")),
|
|
WithChild(
|
|
Area("Shell.Menu.Admin", "shield", "/amministrazione", ModuleCodes.Core, null, "M13",
|
|
MenuAudience.InstanceAccounts,
|
|
("Shell.Menu.Admin.Companies", "aziende"), ("Shell.Menu.Admin.Users", "utenti"), ("Shell.Menu.Admin.Roles", "ruoli"),
|
|
("Shell.Menu.Admin.Licenses", "licenze"), ("Shell.Menu.Admin.Jobs", "attivita"), ("Shell.Menu.Admin.Log", "log"),
|
|
("Shell.Menu.Admin.Status", "stato")),
|
|
new MenuItem("Shell.Menu.Admin.ImportExport", "shield", "/amministrazione/import-export", ModuleCodes.Core, null, null, MenuAudience.InstanceAccounts)),
|
|
]),
|
|
];
|
|
|
|
/// <summary>Every entry with its children, in menu order.</summary>
|
|
public static IEnumerable<MenuItem> All => Sections.SelectMany(s => s.Items).SelectMany(i => i.Children.Prepend(i));
|
|
|
|
/// <summary>The entry that best matches an address: the deepest one whose address is a prefix.</summary>
|
|
/// <param name="path">The path, without query.</param>
|
|
/// <returns>The entry, or <see langword="null"/>.</returns>
|
|
public static MenuItem? Find(string path) =>
|
|
All.Where(i => i.Matches(path)).OrderByDescending(i => i.Href.Length).FirstOrDefault();
|
|
|
|
/// <summary>The top-level entry an address belongs to.</summary>
|
|
/// <param name="path">The path.</param>
|
|
/// <returns>The entry, or <see langword="null"/>.</returns>
|
|
public static MenuItem? FindArea(string path) =>
|
|
Sections.SelectMany(s => s.Items).Where(i => i.Matches(path)).OrderByDescending(i => i.Href.Length).FirstOrDefault();
|
|
|
|
// An entry delivered before the rest of its area (the guided import of M4 under the administration of M13).
|
|
private static MenuItem WithChild(MenuItem area, MenuItem child) => area with { Children = [.. area.Children, child] };
|
|
|
|
private static MenuItem Area(string key, string icon, string href, string module, string? permission, string? milestone,
|
|
params (string Key, string Slug)[] children) =>
|
|
Area(key, icon, href, module, permission, milestone, MenuAudience.Everyone, children);
|
|
|
|
private static MenuItem Area(string key, string icon, string href, string module, string? permission, string? milestone, MenuAudience audience,
|
|
params (string Key, string Slug)[] children) =>
|
|
new(key, icon, href, module, permission, milestone, audience)
|
|
{
|
|
Children = [.. children.Select(c => new MenuItem(c.Key, icon, href + "/" + c.Slug, module, permission, milestone, audience))],
|
|
};
|
|
}
|