Files
Khaemhat/src/Khaemhat.Fiscal.Italy/VatNatures.cs
T
Alby96andClaude Opus 5.5 49d2bb166b feat: fiscal pack abstractions and the Italian pack (#37)
The rest of the product needs tax codes, natures, code lists and VAT rules
without knowing the country. IFiscalPack exposes the parts every country has
(tax code catalog, tax engine, calendar) and optional features by type, so a
module can tell a missing feature from a broken one. FiscalPackCatalog finds
the pack by country; only the composition root names the Italian pack, as an
architecture test now checks.

The Italian pack carries the FatturaPA 1.9.1 code lists, VAT natures and base
tax codes with their rules, summary rounding on the total per rate, the stamp
duty rule, VAT deadlines with the August and holiday shifts, withholding kinds,
basic depreciation rules and F24 codes. ADR 0025 records the design.

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

80 lines
4.4 KiB
C#

using Khaemhat.Core.Tax;
using Khaemhat.Fiscal.Abstractions;
namespace Khaemhat.Fiscal.Italy;
/// <summary>
/// The VAT natures of the FatturaPA specifications (<c>Natura</c>, N1-N7). Since 2021 the generic codes N2, N3 and N6
/// are no longer accepted: only their sub-codes.
/// </summary>
public static class VatNatures
{
/// <summary>Every nature, obsolete ones included.</summary>
public static CodeList All { get; } = new("VatNatures",
[
new("N1", "Escluse ex art. 15 DPR 633/72"),
new("N2", "Non soggette", Obsolete: true),
new("N2.1", "Non soggette ad IVA ai sensi degli artt. da 7 a 7-septies DPR 633/72"),
new("N2.2", "Non soggette - altri casi"),
new("N3", "Non imponibili", Obsolete: true),
new("N3.1", "Non imponibili - esportazioni"),
new("N3.2", "Non imponibili - cessioni intracomunitarie"),
new("N3.3", "Non imponibili - cessioni verso San Marino"),
new("N3.4", "Non imponibili - operazioni assimilate alle cessioni all'esportazione"),
new("N3.5", "Non imponibili - a seguito di dichiarazioni d'intento"),
new("N3.6", "Non imponibili - altre operazioni che non concorrono alla formazione del plafond"),
new("N4", "Esenti"),
new("N5", "Regime del margine / IVA non esposta in fattura"),
new("N6", "Inversione contabile", Obsolete: true),
new("N6.1", "Inversione contabile - cessione di rottami e altri materiali di recupero"),
new("N6.2", "Inversione contabile - cessione di oro e argento ai sensi della L. 7/2000 nonché di oreficeria usata ad OPO"),
new("N6.3", "Inversione contabile - subappalto nel settore edile"),
new("N6.4", "Inversione contabile - cessione di fabbricati"),
new("N6.5", "Inversione contabile - cessione di telefoni cellulari"),
new("N6.6", "Inversione contabile - cessione di prodotti elettronici"),
new("N6.7", "Inversione contabile - prestazioni comparto edile e settori connessi"),
new("N6.8", "Inversione contabile - operazioni settore energetico"),
new("N6.9", "Inversione contabile - altri casi"),
new("N7", "IVA assolta in altro stato UE (art. 7-octies e art. 74-sexies DPR 633/72)"),
]);
// Natures whose amounts count toward the stamp duty threshold: exports (N3.1), intra-EU supplies (N3.2), San Marino
// (N3.3), operations assimilated to exports (N3.4), reverse charge (N6.x) and VAT paid in another EU state (N7) are
// exempt from stamp duty (art. 15 of the table attached to DPR 642/72 and the Agenzia's guidance).
private static readonly HashSet<string> StampDutyNatures = new(StringComparer.OrdinalIgnoreCase)
{
"N1", "N2.1", "N2.2", "N3.5", "N3.6", "N4", "N5",
};
/// <summary>The kind of operation a nature describes; no nature means a taxable operation.</summary>
/// <param name="nature">The nature code.</param>
/// <returns>The kind.</returns>
public static TaxCodeKind KindOf(string? nature)
{
var code = nature?.Trim().ToUpperInvariant() ?? string.Empty;
return code switch
{
"" => TaxCodeKind.Taxable,
"N1" => TaxCodeKind.Excluded,
"N4" => TaxCodeKind.Exempt,
"N5" => TaxCodeKind.Margin,
"N7" => TaxCodeKind.OtherEuVat,
_ when code.StartsWith("N2", StringComparison.Ordinal) => TaxCodeKind.NotSubject,
_ when code.StartsWith("N3", StringComparison.Ordinal) => TaxCodeKind.NonTaxable,
_ when code.StartsWith("N6", StringComparison.Ordinal) => TaxCodeKind.ReverseCharge,
_ => throw new ArgumentException($"Unknown VAT nature '{nature}'.", nameof(nature)),
};
}
/// <summary>Whether an amount with this nature counts toward the stamp duty threshold.</summary>
/// <param name="nature">The nature code.</param>
/// <returns><see langword="true"/> when the stamp duty rule counts it.</returns>
public static bool CountsForStampDuty(string? nature) => nature is not null && StampDutyNatures.Contains(nature.Trim());
/// <summary>Whether the nature is a reverse charge one (N6.x).</summary>
/// <param name="nature">The nature code.</param>
/// <returns><see langword="true"/> for reverse charge.</returns>
public static bool IsReverseCharge(string? nature) =>
nature is not null && nature.Trim().StartsWith("N6", StringComparison.OrdinalIgnoreCase);
}