Files
Khaemhat/src/Khaemhat.Fiscal.Italy/ItalyFiscalPack.cs
T
Alby96andClaude Opus 5.5 9a40adecfe feat: read FatturaPA invoices and signed p7m files (#57)
The import of supplier e-invoices needs a reading layer that turns a
received file into plain records, whatever form the file arrives in.

- Fiscal.Abstractions: IIncomingInvoiceReader, an optional pack feature,
  with the IncomingInvoiceFile records and the incoming.* error codes the
  import service and screens build on.
- Infrastructure: CmsSignedData, a minimal CMS SignedData (CAdES .p7m)
  reader on System.Formats.Asn1, since System.Security.Cryptography.Pkcs
  is a separate package. It accepts DER, BER with indefinite lengths and
  chunked content, base64 text and nested envelopes; it checks the
  message digest and the RSA (PKCS#1, PSS) or ECDSA signature with the
  embedded certificate and reports signer, tax code, validity and signing
  time. No trust chain or revocation check: no trusted list offline.
- Fiscal.Italy: FatturaPaReader for FPR12/FPA12 v1.2.x and FSM10, matched
  by local name, DTD prohibited and no resolver, BOM/windows-1252/missing
  declaration tolerated, batches as one invoice per body, attachments
  decoded; registered in ItalyFiscalPack.
- Tests build every sample and signed envelope in code (AsnWriter and
  self-signed certificates), nothing downloaded.

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

48 lines
1.8 KiB
C#

using Khaemhat.Fiscal.Abstractions;
namespace Khaemhat.Fiscal.Italy;
/// <summary>
/// The Italian fiscal pack (SPEC §1.10, ADR 0007, ADR 0025): chosen for companies whose <c>company_profile.country</c>
/// is <c>IT</c>. Registered only by the composition root of <c>Khaemhat.Web</c>.
/// </summary>
public sealed class ItalyFiscalPack : FiscalPackBase
{
/// <summary>The version of the Italian base data and code lists.</summary>
public const string Version = "IT 2026.3";
/// <summary>Creates the pack with every feature this version delivers.</summary>
public ItalyFiscalPack()
{
AddFeature<IEInvoiceFormat>(new FatturaPaFormat());
AddFeature<IIncomingInvoiceReader>(new FatturaPaReader());
AddFeature<IWithholdingRules>(new WithholdingRulesIt());
AddFeature<IFixedAssetRules>(new FixedAssetRulesIt());
AddFeature<ITaxPaymentFormExporter>(new F24Exporter());
AddFeature<ITaxIdentifierRules>(new ItalianTaxIdentifierRules());
AddFeature<IBaseTablesTemplate>(new ItalianBaseTables());
AddFeature<IPlaceDirectory>(new ItalianPlaces());
// ABI and CAB are read from every Italian IBAN; bank names and BICs arrive with the ABI list (ADR 0026).
AddFeature<IBankDirectory>(new ItalianBankDirectory([]));
}
/// <inheritdoc />
public override string CountryCode => "IT";
/// <inheritdoc />
public override string Name => "Italia";
/// <inheritdoc />
public override string DataVersion => Version;
/// <inheritdoc />
public override ITaxCodeCatalog TaxCodes { get; } = new ItalianTaxCodeCatalog();
/// <inheritdoc />
public override ITaxEngine TaxEngine { get; } = new ItalianTaxEngine();
/// <inheritdoc />
public override IFiscalCalendar Calendar { get; } = new ItalianFiscalCalendar();
}