feat: purchase and warehouse documents on the document screens (#55 #56 #58)

The document radars and records now serve /acquisti and /magazzino too:
supplier orders, receipts, supplier invoices and credit notes, self-invoices
and warehouse movements, with the supplier in place of the customer, the
supplier's number and date, the protocol and VAT date of registered invoices,
and reason and warehouses of a movement. Supplier invoices take their
protocol from the purchase numbering, refuse a second document with the same
supplier number in the same year and show price differences against their
order or receipt. The Italian pack advises the self-invoice a received
invoice needs (TD16-TD19, TD28) with its deadline, and the purchase service
drafts it with the ordinary rate. A credit note of an invoice now moves its
goods back instead of being skipped as already moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-12 21:25:25 +01:00
1 parent eeabb12f96
commit f8b72f4d17
21 files changed
+823 -58

No files matched your search

@@ -16,6 +16,7 @@ public sealed class ItalyFiscalPack : FiscalPackBase
{
AddFeature<IEInvoiceFormat>(new FatturaPaFormat());
AddFeature<IIncomingInvoiceReader>(new FatturaPaReader());
AddFeature<ISelfInvoiceRules>(new SelfInvoiceRulesIt());
AddFeature<IWithholdingRules>(new WithholdingRulesIt());
AddFeature<IFixedAssetRules>(new FixedAssetRulesIt());
AddFeature<ITaxPaymentFormExporter>(new F24Exporter());
@@ -0,0 +1,59 @@
using Khaemhat.Fiscal.Abstractions;
namespace Khaemhat.Fiscal.Italy;
/// <summary>
/// Italian self-invoices and integrations (provvedimento AdE 99922/2020, specifiche FatturaPA 1.9): TD16 integrates a
/// domestic reverse charge (natures N6.x), TD17 the purchase of services from abroad, TD18 of goods from another member
/// state, TD19 of goods located in Italy from a non-resident (art. 17 c.2). Integrations go to the exchange system by
/// the 15th of the month after the receipt; regularisations (TD20) and communications (TD29) within 90 days.
/// </summary>
public sealed class SelfInvoiceRulesIt : ISelfInvoiceRules
{
/// <inheritdoc />
public IReadOnlyList<string> DocumentTypeCodes { get; } = ["AF16", "AF17", "AF18", "AF19", "AF20", "AF21", "AF22", "AF23", "AF28", "AF29"];
/// <inheritdoc />
public string OrdinaryTaxCode => "22";
/// <inheritdoc />
public SelfInvoiceAdvice? Advise(SelfInvoiceCase input)
{
ArgumentNullException.ThrowIfNull(input);
var domestic = string.Equals(input.SupplierCountry, "IT", StringComparison.OrdinalIgnoreCase);
if (domestic)
{
if (input.Natures.Any(n => n.StartsWith("N6", StringComparison.Ordinal)))
{
return Advice("AF16", "Inversione contabile interna (art. 17 c.6 e 74 c.7-8 DPR 633/72): integrazione della fattura del fornitore.", input.Received);
}
return null;
}
if (string.Equals(input.SupplierCountry, "SM", StringComparison.OrdinalIgnoreCase))
{
return input.Natures.Count == 0
? Advice("AF28", "Acquisto da San Marino con IVA addebitata in fattura.", input.Received)
: null;
}
if (!input.Goods)
{
return Advice("AF17", "Acquisto di servizi da un fornitore estero (art. 17 c.2 e 7-ter DPR 633/72).", input.Received);
}
return input.SupplierInEu
? Advice("AF18", "Acquisto intracomunitario di beni (art. 46-47 DL 331/93).", input.Received)
: Advice("AF19", "Acquisto di beni già in Italia da un soggetto non residente (art. 17 c.2 DPR 633/72).", input.Received);
}
/// <inheritdoc />
public DateOnly Deadline(string documentTypeCode, DateOnly received) => documentTypeCode switch
{
"AF20" or "AF29" => received.AddDays(90),
_ => new DateOnly(received.Year, received.Month, 15).AddMonths(1),
};
private SelfInvoiceAdvice Advice(string code, string reason, DateOnly received) => new(code, reason, Deadline(code, received));
}