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.

InvoiceFix is used when a previously submitted invoice was rejected by the AEAT and needs to be resubmitted as a correction (subsanación). It generates a RegistroAlta with the Subsanacion field set to "S", signalling to the AEAT that this submission corrects an earlier, failed record. InvoiceFix extends InvoiceEntry, so it uses exactly the same constructor signature and .Save() call. The only difference is the internal SetRegistro() override, which sets registroAlta.Subsanacion = "S" before the record is chained and sent.

Ejemplo

Provide the same identifying data (InvoiceID, InvoiceDate, SellerID) as the rejected submission, along with the corrected invoice data:
var invoice = new Invoice("GIT-EJ-0002", new DateTime(2024, 11, 15), "B72877814")
{
    InvoiceType = TipoFactura.F1,
    SellerName = "WEFINZ GANDIA SL",
    BuyerID = "B44531218",
    BuyerName = "WEFINZ SOLUTIONS SL",
    Text = "PRESTACION SERVICIOS DESARROLLO SOFTWARE",
    TaxItems = new List<TaxItem>()
    {
        new TaxItem()
        {
            TaxRate = 4,
            TaxBase = 10,
            TaxAmount = 0.4m
        },
        new TaxItem()
        {
            TaxRate = 21,
            TaxBase = 100,
            TaxAmount = 21
        }
    }
};

var invoiceFix = new InvoiceFix(invoice);
invoiceFix.Save();

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

Archivos generados

InvoiceFix uses timestamped file paths to preserve a history of resubmissions:
ArchivoPath
XML de factura{InvoicePostedPath}{EncodedInvoiceID}.SUB.{timestamp}.xml
Entrada en cadena{InvoiceEntryPath}{InvoiceEntryID}.SUB.{timestamp}.xml
Respuesta AEAT{ResponsesPath}{InvoiceEntryID}.SUB.{timestamp}.xml
The original (errored) invoice file at {InvoicePostedPath}{EncodedInvoiceID}.xml is expected to exist — GetBusErrors() validates this before submission.

Comprobar la respuesta

InvoiceFix inherits all response properties from InvoiceEntry:
PropiedadDescripción
StatusEstado del resultado ("Correcto" si la subsanación fue aceptada).
CSVCódigo Seguro de Verificación devuelto por la AEAT.
ErrorCodeCódigo de error (si Status != "Correcto").
ErrorDescriptionDescripción del error devuelto por la AEAT.
ResponseRespuesta XML completa de la AEAT.

Cuándo usar InvoiceFix

  • ✅ Use InvoiceFix when a previous InvoiceEntry.Save() completed (reached the AEAT) but was rejected with an error code, and you have corrected the data for resubmission.
  • ✅ Use InvoiceFix when the invoice file already exists on disk at the expected path for the given SellerID, year, and InvoiceID.
  • ❌ Do not use InvoiceFix for invoices that were never submitted — use InvoiceEntry for those.
  • ❌ Do not use InvoiceFix to cancel a correctly accepted invoice — use InvoiceCancellation for that.
InvoiceFix.GetBusErrors() checks that the original invoice file already exists on disk. If it does not find it, it adds a validation error: "No existe una entrada con SellerID: ... en el año ... con el número ...". Make sure the failed entry is still present before calling the constructor.

Build docs developers (and LLMs) love