feat: company tables, profile, fiscal years and base data (#38, #39, #45)

Adds the company tables of SPEC 11.1 behind one generic service so that every
table gets the same rules, history, cache and CSV import/export, plus the
company profile, fiscal years with monthly lock and the base-data seeder.

- 26 coded tables, exchange rates, company profile, fiscal years and periods:
  entities, maps and migrations 010-014
- TableService + TableCatalog: unique codes, per-table rules (VAT codes are
  checked by the fiscal pack), delete or disable when in use, single default,
  CSV export/import all-or-nothing, cache with cross-instance invalidation
- CompanyProfileService (Italian identifiers through the pack),
  FiscalYearService with the date check used by every dated record
- EcbRatesClient and the ECB rates system task; CsvReader
- ISeeder/SeedRunner with the data version in company settings; base tables
  from the pack (IBaseTablesTemplate) and an embedded ISO country list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 22:33:37 +01:00
1 parent 25f8a7ad30
commit 34e196424f
33 files changed
+6049 -3

No files matched your search

@@ -192,3 +192,51 @@ public interface IIntrastatExporter
/// <returns>A task that completes when the file is written.</returns>
Task WriteAsync(IntrastatReturn intrastatReturn, Stream output, CancellationToken cancellationToken);
}
/// <summary>A payment method of the base data.</summary>
/// <param name="Code">The code.</param>
/// <param name="Description">The description.</param>
/// <param name="EInvoiceCode">The code of the e-invoice format.</param>
/// <param name="NeedsBank">Whether a bank is needed (transfer, bank receipt, direct debit).</param>
public sealed record PaymentMethodTemplate(string Code, string Description, string EInvoiceCode, bool NeedsBank);
/// <summary>An installment of payment terms of the base data.</summary>
/// <param name="Days">Days from the document date.</param>
/// <param name="EndOfMonth">Whether the due date moves to the end of the month.</param>
/// <param name="Percent">Share of the amount, in percent.</param>
public sealed record InstallmentTemplate(int Days, bool EndOfMonth, decimal Percent);
/// <summary>Payment terms of the base data.</summary>
/// <param name="Code">The code.</param>
/// <param name="Description">The description.</param>
/// <param name="PaymentMethodCode">The payment method (a <see cref="PaymentMethodTemplate.Code"/>).</param>
/// <param name="Condition">The condition of the e-invoice format (installments, full, advance).</param>
/// <param name="Installments">The installments.</param>
public sealed record PaymentTermTemplate(string Code, string Description, string PaymentMethodCode, string Condition, IReadOnlyList<InstallmentTemplate> Installments);
/// <summary>A document type of the base data.</summary>
/// <param name="Code">The code.</param>
/// <param name="Description">The description.</param>
/// <param name="Kind">The family.</param>
/// <param name="NumeratorCode">The numerator of the base data (<c>FAT</c>, <c>DDT</c>...), if the document is numbered by the company.</param>
/// <param name="InventoryReasonCode">The warehouse reason of the base data (<c>SCA</c>, <c>CAR</c>...), if the document moves goods.</param>
/// <param name="EInvoiceType">The type of the e-invoice format, if the document is sent electronically.</param>
public sealed record DocumentTypeTemplate(
string Code, string Description, Khaemhat.Core.Tables.NumeratorKind Kind, string? NumeratorCode, string? InventoryReasonCode, string? EInvoiceType);
/// <summary>
/// The rows of the base tables that depend on the country's rules (SPEC §14): payment methods and terms with the codes
/// of the e-invoice format, and document types with their electronic type. The rest of the base data is the same in
/// every country.
/// </summary>
public interface IBaseTablesTemplate
{
/// <summary>The payment methods.</summary>
IReadOnlyList<PaymentMethodTemplate> PaymentMethods { get; }
/// <summary>The payment terms.</summary>
IReadOnlyList<PaymentTermTemplate> PaymentTerms { get; }
/// <summary>The document types.</summary>
IReadOnlyList<DocumentTypeTemplate> DocumentTypes { get; }
}