Files
Khaemhat/src/Khaemhat.Fiscal.Italy/ItalianBaseTables.cs
T
Alby96andClaude Opus 5.5 34e196424f 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>
2026-11-11 22:33:37 +01:00

71 lines
4.2 KiB
C#

using Khaemhat.Core.Tables;
using Khaemhat.Fiscal.Abstractions;
namespace Khaemhat.Fiscal.Italy;
/// <summary>
/// The Italian rows of the base tables (SPEC §14): payment methods with the FatturaPA codes MP, the usual payment terms
/// (rimessa diretta, bonifico, RiBa at 30/60/90 days end of month) and the document types with their SDI type TD.
/// </summary>
public sealed class ItalianBaseTables : IBaseTablesTemplate
{
private static readonly InstallmentTemplate Now = new(0, false, 100m);
/// <inheritdoc />
public IReadOnlyList<PaymentMethodTemplate> PaymentMethods { get; } =
[
new("CONT", "Contanti", "MP01", false),
new("ASS", "Assegno", "MP02", false),
new("BON", "Bonifico bancario", "MP05", true),
new("CARTA", "Carta di pagamento", "MP08", false),
new("RIBA", "Ricevuta bancaria (RiBa)", "MP12", true),
new("MAV", "MAV", "MP13", true),
new("DOM", "Domiciliazione bancaria", "MP16", true),
new("SDD", "Addebito diretto SEPA (SDD Core)", "MP20", true),
new("SDDB", "Addebito diretto SEPA B2B", "MP21", true),
new("PAGOPA", "PagoPA", "MP23", false),
];
/// <inheritdoc />
public IReadOnlyList<PaymentTermTemplate> PaymentTerms { get; } =
[
new("RD", "Rimessa diretta", "BON", "TP02", [Now]),
new("CONT", "Contanti alla consegna", "CONT", "TP02", [Now]),
new("ANT", "Pagamento anticipato", "BON", "TP03", [Now]),
new("BB30", "Bonifico 30 gg data fattura", "BON", "TP02", [new(30, false, 100m)]),
new("BB30FM", "Bonifico 30 gg fine mese", "BON", "TP02", [new(30, true, 100m)]),
new("BB60FM", "Bonifico 60 gg fine mese", "BON", "TP02", [new(60, true, 100m)]),
new("BB3060FM", "Bonifico 30-60 gg fine mese", "BON", "TP01", [new(30, true, 50m), new(60, true, 50m)]),
new("RB30FM", "RiBa 30 gg fine mese", "RIBA", "TP02", [new(30, true, 100m)]),
new("RB60FM", "RiBa 60 gg fine mese", "RIBA", "TP02", [new(60, true, 100m)]),
new("RB3060FM", "RiBa 30-60 gg fine mese", "RIBA", "TP01", [new(30, true, 50m), new(60, true, 50m)]),
new("RB306090", "RiBa 30-60-90 gg fine mese", "RIBA", "TP01", [new(30, true, 33.33m), new(60, true, 33.33m), new(90, true, 33.34m)]),
new("SDD30", "Addebito SEPA 30 gg data fattura", "SDD", "TP02", [new(30, false, 100m)]),
];
/// <inheritdoc />
public IReadOnlyList<DocumentTypeTemplate> DocumentTypes { get; } =
[
new("PRE", "Preventivo", NumeratorKind.Quotation, "PRE", null, null),
new("OC", "Ordine cliente", NumeratorKind.SalesOrder, "ORD", null, null),
new("DDT", "Documento di trasporto", NumeratorKind.DeliveryNote, "DDT", "SCA", null),
new("FI", "Fattura immediata", NumeratorKind.SalesInvoice, "FAT", null, "TD01"),
new("FA", "Fattura accompagnatoria", NumeratorKind.SalesInvoice, "FAT", "SCA", "TD01"),
new("FD", "Fattura differita", NumeratorKind.SalesInvoice, "FAT", null, "TD24"),
new("FACC", "Fattura di acconto", NumeratorKind.SalesInvoice, "FAT", null, "TD02"),
new("NC", "Nota di credito", NumeratorKind.SalesInvoice, "FAT", null, "TD04"),
new("ND", "Nota di debito", NumeratorKind.SalesInvoice, "FAT", null, "TD05"),
new("PAR", "Parcella", NumeratorKind.SalesInvoice, "FAT", null, "TD06"),
new("PF", "Fattura pro forma", NumeratorKind.Other, "PRF", null, null),
new("AF16", "Integrazione reverse charge interno", NumeratorKind.SalesInvoice, "AUT", null, "TD16"),
new("AF17", "Integrazione acquisto servizi dall'estero", NumeratorKind.SalesInvoice, "AUT", null, "TD17"),
new("AF18", "Integrazione acquisto beni intracomunitari", NumeratorKind.SalesInvoice, "AUT", null, "TD18"),
new("AF19", "Integrazione acquisto beni art. 17 c.2", NumeratorKind.SalesInvoice, "AUT", null, "TD19"),
new("OF", "Ordine fornitore", NumeratorKind.PurchaseOrder, "ORF", null, null),
new("DDTF", "DDT fornitore (carico)", NumeratorKind.Inventory, null, "CAR", null),
new("FF", "Fattura fornitore", NumeratorKind.PurchaseInvoice, "PRA", null, null),
new("NCF", "Nota di credito fornitore", NumeratorKind.PurchaseInvoice, "PRA", null, null),
new("MM", "Movimento di magazzino", NumeratorKind.Inventory, "MAG", null, null),
];
}