Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mdiago/VeriFactu/llms.txt
Use this file to discover all available pages before exploring further.
Invoice is the core business object representing a Spanish invoice in the VeriFactu system. It holds all invoice data and produces the low-level RegistroAlta and RegistroAnulacion XML objects required by AEAT.
Namespace
VeriFactu.Business
Constructores
Invoice(string invoiceID, DateTime invoiceDate, string sellerID)
Primary constructor. Creates a new invoice from its three required identifiers. Leading/trailing whitespace is trimmed from invoiceID and sellerID; sellerID is also uppercased to match AEAT hash requirements.
Throws ArgumentNullException if either invoiceID or sellerID is null.
Invoice number / series identifier (e.g.
"FAC-2024-001"). Must not be null. Whitespace is trimmed automatically.Issue date of the invoice document.
Seller’s tax identifier (NIF/VAT number). Must not be
null. Whitespace is trimmed and the value is uppercased automatically.Invoice(RegistroAlta registroAlta)
Creates an Invoice instance from an existing low-level RegistroAlta XML object (e.g. one previously deserialized from disk or received from the AEAT). All available fields — type, seller name, buyer details, tax breakdown, and rectification info — are mapped into the Invoice properties automatically.
A
VeriFactu.Xml.Factu.Alta.RegistroAlta instance to reconstruct the invoice from. Throws NotImplementedException if the record has more than one buyer (Destinatarios).Invoice(InvoiceData invoiceData)
Creates an Invoice from a plain data object (InvoiceData). Useful when invoice data is loaded from JSON or constructed programmatically via the InvoiceData DTO. Totals are calculated automatically from the contained TaxItems.
A populated
VeriFactu.Business.InvoiceData plain-data object.Propiedades
Invoice series/number identifier (e.g.
"FAC-2024-001"). Set by the constructor; read-only after construction.Issue date of the invoice document. Set by the constructor; read-only after construction.
Invoice type code (list L2). Common values:
F1 (standard), F2 (simplified), R1–R5 (rectification), F3 (conversion of simplified). Defaults to the enum’s zero value if not set.Seller’s tax identifier (NIF/VAT number). Set by the constructor; read-only after construction.
Seller’s company or personal name (
NombreRazonEmisor). Required before calling Save() on an InvoiceEntry.Buyer’s tax identifier. Use the fiscal identifier if one exists (NIF, EU VAT number, DUNS, etc.).
Buyer’s company or personal name.
ISO 3166-1 alpha-2 country code for the buyer (e.g.
"FR", "DE"). Required when BuyerID is not a valid Spanish identifier and BuyerIDType is not NIF_IVA.Buyer identifier type per list L7. Required for non-Spanish buyers when
BuyerCountryID is set. For EU intra-community buyers set this to IDType.NIF_IVA.Optional operation date (
FechaOperacion) when the taxable event date differs from the invoice issue date.Free-text description of the operation (
DescripcionOperacion). Appears verbatim in the AEAT record.List of tax breakdown lines (
Desglose). Maximum 12 items. Each item defines a tax rate, base, amount, scheme, and optional exemption cause. See TaxItem.Computed total invoice amount:
NetAmount + TotalTaxOutput + TotalTaxOutputSurcharge − TotalTaxWithheld. Recalculated automatically whenever GetRegistroAlta() is called.Sum of output tax amounts (
CuotaRepercutida) across all TaxOutput tax items.Sum of equivalence surcharge amounts (
CuotaRecargoEquivalencia) across all TaxOutput tax items.Sum of withheld tax amounts across all
TaxWithheld tax items.Rectification method (list L3):
S (substitution) or I (differences). Only relevant when InvoiceType is R1–R5. Defaults to I when the invoice is rectificative and this field is left at its default.References to the original invoices being rectified or substituted (
FacturasRectificadas / FacturasSustituidas). Each item holds an InvoiceID and InvoiceDate. Maximum 1 000 items.BaseRectificada for substitution-type (S) rectifications. Only used when RectificationType == S and RectificationTaxBase != 0.CuotaRectificada for substitution-type rectifications.CuotaRecargoRectificado for substitution-type rectifications.The original
RegistroAlta from which this invoice was created, if the Invoice(RegistroAlta) constructor was used. null otherwise. When non-null, GetRegistroAlta() returns this object directly without rebuilding it.REST API access key for the Irene Solutions VeriFactu REST service. Inherited from
JsonSerializable. Set this when using the Irene Solutions hosted REST endpoint. Obtain your key at https://facturae.irenesolutions.com/verifactu/go.Métodos
GetRegistroAlta() → RegistroAlta
Builds and returns the VeriFactu.Xml.Factu.Alta.RegistroAlta low-level XML record. All totals are recalculated, monetary values are rounded to 2 decimal places, and all AEAT-required fields (blockchain hash type, system info, etc.) are populated from global settings.
If the instance was created via Invoice(RegistroAlta), the cached source record is returned directly.
Throws InvalidOperationException if TaxItems is empty or null (no Desglose block can be built).
GetRegistroAnulacion() → RegistroAnulacion
Builds and returns the VeriFactu.Xml.Factu.Anulacion.RegistroAnulacion low-level XML record used to cancel the invoice. Only InvoiceID, InvoiceDate, and SellerID are needed — the full tax breakdown is not required for cancellations.
ToJson() → string
Serializes the invoice data to a JSON string via the underlying InvoiceData object. Useful for logging, persistence, or REST API integration.
ToString() → string
Returns a human-readable identifier in the format "SellerID-InvoiceID-Date" where date is formatted as dd-MM-yyyy (via XmlParser.GetXmlDate), e.g. "B72877814-FAC-2024-001-15-11-2024".