using Khaemhat.Core.Tax; using Khaemhat.Fiscal.Abstractions; namespace Khaemhat.Fiscal.Italy; /// /// The VAT natures of the FatturaPA specifications (Natura, N1-N7). Since 2021 the generic codes N2, N3 and N6 /// are no longer accepted: only their sub-codes. /// public static class VatNatures { /// Every nature, obsolete ones included. 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 StampDutyNatures = new(StringComparer.OrdinalIgnoreCase) { "N1", "N2.1", "N2.2", "N3.5", "N3.6", "N4", "N5", }; /// The kind of operation a nature describes; no nature means a taxable operation. /// The nature code. /// The kind. 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)), }; } /// Whether an amount with this nature counts toward the stamp duty threshold. /// The nature code. /// when the stamp duty rule counts it. public static bool CountsForStampDuty(string? nature) => nature is not null && StampDutyNatures.Contains(nature.Trim()); /// Whether the nature is a reverse charge one (N6.x). /// The nature code. /// for reverse charge. public static bool IsReverseCharge(string? nature) => nature is not null && nature.Trim().StartsWith("N6", StringComparison.OrdinalIgnoreCase); }