When you need to correct an invoice that has already undergone a previous correction, follow these steps:
Initial Invoice Creation (S1):
You create an invoice, let's refer to it as S1. During the review, you notice there is an error in this invoice, and that a correction is required according to the Invoicing Regulations in Spain.
First Corrective Invoice (R1):
To address the error, you create a corrective invoice, let's refer to it as R1. In the id field of R1, you include the identifier of the original invoice S1.
If you later discover another error in R1, that once again requires a correction by law, proceed to the next step.
Second Corrective Invoice (R2):
Create another corrective invoice, now referred to as R2.
The reference_original_id flag controls how the API interprets the id value of a corrective invoice. In the id field of R2, you can include either:
- the identifier of the first corrective invoice R1, so that each correction is linked to the previous correcting invoice. To do this, set
reference_original_id: false(or omit the field entirely, as it defaults tofalse).
If you are using theSUBSTITUTIONmethod, we recommend always referencing the previous correcting invoice. With this method, each correction fully replaces the previous one, so the latest invoice is the one that reflects the current valid state. Referencing it, rather than the original, keeps the chain of corrections consistent.
- the identifier of the original invoice S1. In that case, remember to set
reference_original_id: true, so the API interprets theidas the original invoice rather than the preceding correction.
In general, this approach tends to fit best with theDIFFERENCESmethod, since each correction can consistently reference the original invoice.