Skip to main content

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.

InvoiceCancellation cancels a previously submitted invoice. It extends InvoiceEntry but generates a RegistroAnulacion XML record (instead of a RegistroAlta) and routes the submission through the AEAT’s cancellation workflow. All response properties, the Save() lifecycle, and blockchain management are inherited from InvoiceEntry.

Namespace

VeriFactu.Business

Herencia

InvoiceCancellation → InvoiceEntry → InvoiceAction → InvoiceActionPost → InvoiceActionMessage → InvoiceActionData

Constructor

InvoiceCancellation(Invoice invoice)

Creates a new cancellation record for the given invoice.
invoice
Invoice
required
The Invoice to cancel. The minimum required data is:
  • InvoiceID — must match the original submitted invoice number exactly.
  • InvoiceDate — must match the original issue date exactly.
  • SellerID — seller’s NIF/VAT number.
  • SellerName — required by the InvoiceAction base-class validation.
The tax breakdown (TaxItems) is not required for cancellations.
Business-rule validation runs in the constructor (inherited from InvoiceAction). Throws InvalidOperationException if validation fails.

Diferencias con InvoiceEntry

AspectInvoiceEntryInvoiceCancellation
XML record typeRegistroAltaRegistroAnulacion
InvoiceEntryID format"00000000000000000042""00000000000000000042.DEL"
Stored file name<encodedID>.xml<encodedID>.DEL.xml
Response file name<entryID>.xml<entryID>.DEL.xml
TaxItems requiredYesNo
The .DEL suffix is appended to both InvoiceEntryID and the physical file paths to distinguish cancellation records from regular submissions in the blockchain and on disk.

Propiedades adicionales

InvoiceEntryID
string
Blockchain link ID with a .DEL suffix appended (e.g. "00000000000000000042.DEL").
InvoiceEntryFilePath
string
Full path to the stored cancellation XML in the outbox directory: {InvoiceEntryPath}{InvoiceEntryID}.xml.
ResponseFilePath
string
Full path to the stored AEAT response XML: {ResponsesPath}{InvoiceEntryID}.xml.
EncodedInvoiceID
string
Hexadecimal encoding of InvoiceID + ".DEL" used as the file name stem on disk.
All other response properties (Status, CSV, ErrorCode, ErrorDescription, Response, Posted, IsSent) are inherited from InvoiceEntry.

Ejemplo

using VeriFactu.Business;

// Only the identifying fields are needed — no TaxItems required
var invoice = new Invoice("FAC-2024-001", new DateTime(2024, 11, 15), "B72877814")
{
    SellerName = "MI EMPRESA SL"
};

var cancellation = new InvoiceCancellation(invoice);
cancellation.Save();

if (cancellation.Status == "Correcto")
    Console.WriteLine($"Cancelled — CSV: {cancellation.CSV}");
else
    Console.WriteLine($"Error — {cancellation.ErrorCode}: {cancellation.ErrorDescription}");
The InvoiceID, InvoiceDate, and SellerID you provide must exactly match the values in the original RegistroAlta submitted to the AEAT. Any mismatch will result in an AEAT rejection.

Build docs developers (and LLMs) love