Files
Khaemhat/src/Khaemhat.Web/Shell/HelpLinks.cs
T
Alby96andClaude Opus 5.5 caa33a2cee feat: guided import and export for parties, items, prices, opening stock and chart of accounts (#44)
Companies starting on Khaemhat need to bring their master data from another
system or a spreadsheet, and the chart of accounts has no Italian exchange
standard, so SPEC 12.12 asks for a guided wizard and an own layout.

- Administration > Import / export: CSV (separator and encoding guessed),
  XLSX (in-house reader, first sheet) and JSON, automatic column mapping with
  aliases, row-by-row check, error report, import confirmation and log entry.
- Rows go through PartyService, ItemService and PriceListService, so the
  import has exactly the rules, error codes and history of the forms; options
  cover existing and missing codes, VIES and city from postal code.
- Export writes the same columns as the import, plus empty templates.
- Opening stock and the chart of accounts (khaemhat-coa layout, natura, tipo,
  flag) are check-only until M6 and M7 add the ledgers to write into.
- PartyService.SaveAsync takes an explicit VIES switch for the import.
- ADR 0031, wiki Import-Export, CHANGELOG and STATUS updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 11:52:59 +01:00

87 lines
3.9 KiB
C#

namespace Khaemhat.Web.Shell;
/// <summary>
/// The wiki page of each part of the application (SPEC §17: F1 and "?" open the page of the screen). The address is
/// the deepest prefix that matches; anything unknown opens the wiki home.
/// </summary>
public static class HelpLinks
{
/// <summary>The wiki of the project, used when no other address is configured.</summary>
public const string DefaultBaseUrl = "https://gitea.encke-hake.ts.net/BalboSoft/Khaemhat/wiki/";
private static readonly (string Prefix, string Page)[] Pages =
[
("/anagrafiche/articoli", "Articoli-e-listini"),
("/anagrafiche/listini", "Articoli-e-listini"),
("/anagrafiche", "Anagrafiche"),
("/crm", "CRM"),
("/vendite", "Vendite"),
("/acquisti", "Acquisti"),
("/magazzino", "Magazzino"),
("/contabilita/liquidazione-iva", "IVA"),
("/contabilita/registri-iva", "IVA"),
("/contabilita", "Contabilita"),
("/scadenzario", "Scadenzario"),
("/fatturazione-elettronica", "Fatturazione-elettronica"),
("/cespiti", "Cespiti"),
("/servizi", "Servizi"),
("/canali", "Canali-e-commerce"),
("/report", "Report"),
("/tabelle", "Tabelle-azienda"),
("/automazioni", "Automazioni"),
("/amministrazione/import-export", "Import-Export"),
("/amministrazione/licenze", "Licenze-e-moduli"),
("/amministrazione/log", "Log"),
("/amministrazione/attivita", "Attivita-programmate"),
("/amministrazione/stato", "Stato-sistema"),
("/amministrazione/utenti", "Utenti-e-permessi"),
("/amministrazione/ruoli", "Utenti-e-permessi"),
("/amministrazione", "Istanza-e-database"),
("/profilo", "Preferenze-utente"),
("/", "Dashboard"),
];
/// <summary>The wiki page of a path.</summary>
/// <param name="path">The path, without query.</param>
/// <returns>The page name, for example <c>Anagrafiche</c>.</returns>
public static string PageFor(string path)
{
var p = TabService.PathOf(path);
foreach (var (prefix, page) in Pages)
{
if (prefix == "/" ? p == "/" : p.Equals(prefix, StringComparison.OrdinalIgnoreCase) || p.StartsWith(prefix + "/", StringComparison.OrdinalIgnoreCase))
{
return page;
}
}
return "Home";
}
/// <summary>The address of the help of a path.</summary>
/// <param name="baseUrl">The wiki address, ending with a slash.</param>
/// <param name="path">The path.</param>
/// <returns>The address.</returns>
public static string UrlFor(string baseUrl, string path) => baseUrl + PageFor(path);
/// <summary>The help page of a path inside the application (F1, mockup 011).</summary>
/// <param name="path">The path.</param>
/// <returns>The relative address, such as <c>aiuto/Anagrafiche</c>.</returns>
public static string LocalFor(string path) => Khaemhat.Web.Help.WikiLibrary.Href(PageFor(path));
/// <summary>The online wiki: <c>KHAEMHAT_HELP_URL</c> or the project wiki, always ending with a slash.</summary>
/// <param name="configured">The configured address, if any.</param>
/// <returns>The address.</returns>
public static string BaseUrl(string? configured) =>
string.IsNullOrWhiteSpace(configured) ? DefaultBaseUrl : configured.EndsWith('/') ? configured : configured + "/";
/// <summary>Where to report a problem: the issues of the repository whose wiki it is (Gitea and GitHub alike).</summary>
/// <param name="baseUrl">The wiki address.</param>
/// <returns>The address of a new issue, or <see langword="null"/> when the wiki is not a repository wiki.</returns>
public static string? IssuesUrl(string baseUrl)
{
ArgumentNullException.ThrowIfNull(baseUrl);
return baseUrl.EndsWith("/wiki/", StringComparison.OrdinalIgnoreCase) ? baseUrl[..^"wiki/".Length] + "issues/new" : null;
}
}