CONTEXT
When a VERI*FACTU integration returns an error, the important decision is not how many times to retry but what status Spain's Tax Agency produced and what happened to the invoice. A technical rejection, a rejected record, a record accepted with errors, and an already-issued invoice that needs correction are different situations. Confusing them can create duplicates, break traceability, or attempt to modify a record that must remain immutable. This guide organizes diagnosis using official AEAT material and Spain's computerized billing regulation. It is intended for teams connecting WooCommerce, PrestaShop, ERP, CRM, spreadsheets, or custom software. It does not replace tax or accounting judgment for a specific transaction; it explains how to classify the incident, preserve evidence, and route the appropriate technical correction.
IN 60 SECONDS
What matters before you start
- Classify the response as rejected, accepted with errors, or accepted before deciding on any retry.
- Do not overwrite an already-generated invoice or record: use the applicable correction, corrective-invoice, or cancellation mechanism and preserve traceability.
- Keep fiscal state separate from commercial state and bound automatic retries to prevent duplicates and loops.
View guide contents
- 011. Diagnose the state before correcting anything
- 022. A rejection requires fixing the cause before resubmitting
- 033. Accepted with errors is not the same as rejected
- 044. Corrective invoice, record correction and cancellation are different mechanisms
- 055. Correcting does not mean rewriting history
- 066. Checklist for recovering from an error without duplicate records
1. Diagnose the state before correcting anything
When an invoice or billing record causes trouble, separate four situations: a technical rejection of the whole submission, a record rejected by a non-admissible validation, a record accepted with errors, and a successfully registered invoice whose content later needs correction. Each situation has different consequences. Spain's Tax Agency technical documentation distinguishes errors that prevent registration from errors that still allow acceptance, while the regulation protects the integrity and traceability of records already generated. The operational question is not how to edit the invoice but what status AEAT returned, which data is wrong, and which mechanism applies. Preserve the code, message, invoice reference, timestamp, payload, and complete response. Do not reduce everything to a sent/not-sent boolean. A detailed fiscal state prevents support staff or an automated queue from treating an admitted record as failed. It also provides evidence for deciding whether to correct and resubmit, perform a permitted record correction, issue a corrective invoice, or create a cancellation followed by a new registration. Before changing data, pause retries for the affected item when the cause is unknown and preserve a snapshot of the original state.
2. A rejection requires fixing the cause before resubmitting
The official web-service description explains that a complete rejection can occur because the submission does not conform to the schema, the header contains a syntax error, or every included record fails syntax or business validations. It also distinguishes non-admissible errors, which reject a record, from admissible errors. In a production integration, that distinction should become explicit internal states. Do not mark an invoice as synchronized merely because an HTTP response arrived; interpret the business result. If the record was rejected, preserve the attempt and response, correct the data or transformation that caused the problem, and prepare a new submission under the applicable procedure. Avoid unlimited automatic loops. A wrong tax identifier, invalid format, impossible date, or inconsistent tax breakdown will not be fixed by repeating the same payload. Classify transport failures separately: temporary network failure may justify a delayed retry, while a deterministic validation error needs a change. Define a retry ceiling and an incident worklist. The integration then stops behaving like a black box and can explain why a record did not advance and which human or automated action should happen next.
3. Accepted with errors is not the same as rejected
VERI*FACTU technical documentation describes admissible errors that do not reject a record and can produce an accepted-with-errors response. That distinction changes the recovery path. If the Tax Agency admitted the record, a naive resend can create an inconsistent or duplicate operation. Preserve the acceptance evidence, warning code, and relationship with the invoice, then open a correction task when appropriate. Business logic should distinguish pending, sent, rejected, accepted with errors, and accepted. In WooCommerce, PrestaShop, ERP, or custom software, also keep fiscal state separate from commercial state. A paid order does not prove fiscal acceptance, and a fiscal warning should not automatically change logistics status. Build an incident view that shows the AEAT outcome, timestamp, affected record, known cause, and next action. If a correction requires human authorization, record who approved it. This traceability reduces improvised decisions and prevents a queue from reprocessing documents that already have an outcome. It also makes reconciliation and support easier because the record's history can be understood without reconstructing it from scattered logs.
4. Corrective invoice, record correction and cancellation are different mechanisms
AEAT explains that certain material errors, legal errors, incorrect tax amounts, or events that modify the taxable base require a corrective invoice. Billing records use R1, R2, R3, and R4 according to the reason, and R5 for a corrective simplified invoice; the correction can be by substitution or by differences. In other situations, AEAT guidance allows certain data to be corrected through a substitute record when invoicing rules do not require a corrective invoice. If an invoice was issued by mistake, such as for a non-existent transaction or certain identification errors, a cancellation record identifying the original registration may apply, followed by a correct new registration when appropriate. This is why a generic edit-invoice button is dangerous: it hides different fiscal decisions behind one action. Software should preserve the original and guide the operator toward the appropriate mechanism. Before automating a code, identify the real reason and check current official documentation or the responsible adviser. Kairoseth can provide integration and technical traceability, but it does not replace the accounting or tax decision about the treatment of a specific transaction. Automation should execute a valid decision, not invent one.
5. Correcting does not mean rewriting history
Royal Decree 1007/2023 requires integrity, preservation, accessibility, readability, traceability, and immutability of billing records. The practical consequence is that an application should not fix an incident by silently overwriting the original record. When an incorrect invoice is cancelled, AEAT guidance states that its numbering remains and both the original registration and cancellation record are retained to preserve the chain. When a corrective invoice or record correction is created, preserve its relationship with the previous item as well. A sound technical design stores the original payload, AEAT response, later version, cross-references, timestamp, and actor that authorized the operation. This evidence supports troubleshooting and reconciliation and reduces contradictory retries. In external systems that allow orders or commercial documents to be edited, the fiscal connector should prevent a retroactive edit from rewriting what was already transmitted. The interface can show a simple current state, but history must not disappear. This separation between operational view and fiscal history matters especially when several people, automated processes, or integrations can act on the same order. Correct recovery adds traceable facts; it does not erase earlier facts to make the result look clean.
6. Checklist for recovering from an error without duplicate records
When an incident occurs, pause retries for the record if the cause is unknown. Capture the response code and text and classify the outcome as rejected, accepted with errors, or accepted. Identify the invoice, payload version, and source commercial event. Check current official documentation for the specific validation. If the issue is structural or concerns data before acceptance, fix the cause and prepare a resubmission under the service rules. If the record was already admitted but requires a permitted correction, do not send it as a brand-new registration. If the problem belongs to the content of an issued invoice, determine whether a corrective invoice, record correction, cancellation followed by a new registration, or another mechanism applies. Record the decision and preserve evidence before and after it. Add idempotency and a stable identifier so one commercial event cannot produce two registrations. Bound retries and route deterministic errors to a review worklist. Finally, reconcile the source state with the stored response and verify that the workflow returned to a coherent state. Kairoseth VeriFactu Software is designed as a connection layer for existing systems: separating commercial source, transport, validation, evidence, and recovery helps resolve incidents without forcing replacement of the ERP, ecommerce platform, or software the business already uses.
KEY TAKEAWAYS
What to remember
- Classify the response as rejected, accepted with errors, or accepted before deciding on any retry.
- Do not overwrite an already-generated invoice or record: use the applicable correction, corrective-invoice, or cancellation mechanism and preserve traceability.
- Keep fiscal state separate from commercial state and bound automatic retries to prevent duplicates and loops.
SOURCES AND TRACEABILITY
Sources used
Agencia Estatal de Administración Tributaria
NEXT STEP
VeriFactu Software
VeriFactu software for connecting WooCommerce, PrestaShop, ERP, CRM, Excel, custom software and local systems to Spain's VeriFactu framework without replacing the source system.