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.

To cancel a previously submitted invoice, create an Invoice instance with the same InvoiceID, InvoiceDate, and SellerID as the original submission, then wrap it in an InvoiceCancellation and call .Save(). The library generates a RegistroAnulacion XML record, signs it with your certificate, and sends it to the AEAT endpoint.

Ejemplo de anulación

// Create an invoice instance with the identifying data of the record to cancel
var invoice = new Invoice("GIT-EJ-0002", new DateTime(2024, 11, 15), "B72877814")
{
    SellerName = "WEFINZ GANDIA SL",
};

// Create the cancellation
var invoiceCancellation = new InvoiceCancellation(invoice);

// Submit to AEAT
invoiceCancellation.Save();

// Inspect the raw response
Debug.Print($"Respuesta: {invoiceCancellation.Response}");

Comprobar la respuesta

InvoiceCancellation exposes the same response properties as InvoiceEntry:
PropiedadTipoDescripción
StatusstringEstado del resultado. "Correcto" si la anulación fue aceptada.
CSVstringCódigo Seguro de Verificación devuelto por la AEAT.
ErrorCodestringCódigo de error devuelto por la AEAT (cuando Status != "Correcto").
ErrorDescriptionstringDescripción del error devuelto por la AEAT.
ResponsestringRespuesta XML completa de la AEAT.
invoiceCancellation.Save();

if (invoiceCancellation.Status == "Correcto")
{
    Console.WriteLine($"Anulación aceptada. CSV: {invoiceCancellation.CSV}");
}
else
{
    Console.WriteLine($"Error {invoiceCancellation.ErrorCode}: {invoiceCancellation.ErrorDescription}");
}

Diferencias con InvoiceEntry

AspectoInvoiceEntryInvoiceCancellation
Registro XML generadoRegistroAltaRegistroAnulacion
Valor de InvoiceEntryID{blockchainLinkID} (20 dígitos){blockchainLinkID}.DEL
Archivo guardado en disco{InvoiceEntryID}.xml{InvoiceEntryID}.xml (p. ej. 00000000000000000001.DEL.xml)
Archivo de respuesta{InvoiceEntryID}.xml{InvoiceEntryID}.xml (p. ej. 00000000000000000001.DEL.xml)
TaxItems requeridosNo (solo se necesitan InvoiceID, InvoiceDate, SellerID y SellerName)
Contenido del registro XMLDesglose de impuestosSolo identificador de la factura a anular
InvoiceCancellation extends InvoiceEntry, so it inherits the same Save() flow: blockchain post, XML generation, AEAT send, response processing, and automatic rollback on failure.

Consideraciones

La anulación solo es posible si la factura original fue remitida correctamente y la AEAT tiene el registro correspondiente. Si el registro original no existe en el sistema de la AEAT, la anulación será rechazada.
El SellerName debe coincidir exactamente con el que se utilizó en la entrada original. Cualquier diferencia puede provocar errores de validación en la AEAT. Asegúrese de usar el mismo valor de SellerName que en el InvoiceEntry original.

Build docs developers (and LLMs) love