einvoice_data_invalid
HTTP 422 · code: "einvoice_data_invalid" · type: https://docs.formfeed.dev/errors/einvoice-data-invalid
The render makes an e-invoice, and its invoice data cannot make a valid one. The answer comes from one of two places:
- Before anything is rendered. The
_invoiceblock ofdatais missing, a field is missing, a code is not in its list, or a total does not add up.errorslists every finding with itspath, itsmessageand, where one applies, theruleof EN 16931 or of the French specifications it breaks;detailrepeats the first. Nothing is rendered, counted or charged. In a batch,indexnames the first item that failed, and nothing is queued. - After rendering. The block passed that check, and the validator still refused the finished file. The problem then carries
einvoice, the report of the validator, andrender_id. The render isfailedand keeps the report. No file is stored, and no plain PDF is delivered instead. A failed render costs nothing.
Example
Refused before rendering:
{
"type": "https://docs.formfeed.dev/errors/einvoice-data-invalid",
"title": "E-invoice data invalid",
"status": 422,
"detail": "_invoice.totals.grand is 1142.41, but tax_basis plus tax_total is 1142.40 (BR-CO-15) (and 1 more)",
"code": "einvoice_data_invalid",
"errors": [
{
"path": "data._invoice.totals.grand",
"message": "_invoice.totals.grand is 1142.41, but tax_basis plus tax_total is 1142.40 (BR-CO-15)",
"rule": "BR-CO-15"
},
{
"path": "data._invoice.totals.due",
"message": "_invoice.totals.due is 1142.40, but grand less prepaid plus rounding is 1142.41 (BR-CO-16)",
"rule": "BR-CO-16"
}
],
"request_id": "req_4b7c1e9a2f3d4c5b8a6e7f9012"
}
Refused by the validator after rendering:
{
"type": "https://docs.formfeed.dev/errors/einvoice-data-invalid",
"title": "E-invoice data invalid",
"status": 422,
"detail": "The e-invoice breaks 1 rule of EN 16931",
"code": "einvoice_data_invalid",
"location": null,
"render_id": "rnd_7da09ab6cd9946b798c187c2a9350852",
"einvoice": {
"profile": "en16931",
"flavour": "factur-x",
"spec_version": "1.09",
"xml_url": null,
"validation": {
"valid": false,
"schematron": "Factur-X 1.09.2 (Mustang 2.26.0)",
"pdfa": null,
"messages": [
{
"part": "xml",
"severity": "error",
"rule": "…",
"message": "…",
"location": "/rsm:CrossIndustryInvoice/…"
}
]
},
"display": null
},
"request_id": "req_4b7c1e9a2f3d4c5b8a6e7f9012"
}
Common causes
- The data has no
_invoiceblock. A template whose settings declare an e-invoice needs one in every PDF render (pathisdata._invoice). - A total that does not add up to the cent (
BR-CO-10toBR-CO-16), or a VAT breakdown that does not match the lines. Formfeed computes and rounds nothing for you. - An amount with more than two decimals, such as a line total that was never rounded.
- A code that is not in its list: a unit written as
hoursinstead ofHUR(BR-CL-23), a country, a currency. - A field the standard asks for is missing: the due date or the payment terms of an invoice with an amount due (
BR-CO-25), the IBAN of a credit transfer (BR-61), an identifier of the seller (BR-CO-26). - An invoice between two French businesses without the fields France asks for, or in the profile
basic, which France's reform does not accept. - The profile
basicwith atotals.roundingother than 0, which that profile cannot carry.
How to fix it
- Fix the fields
errorsnames. Paths start atdata._invoice, and list items count from 0, sodata._invoice.lines[0].unit_codeis the unit of the first line. The field reference says what each field takes. - Find the findings before you send the request: the E-invoice section of the editor's Page setup lists them for the data set on screen, and
formfeed validatechecks every data set of a template offline. Both run the check the API runs. - When the problem carries
einvoice, readeinvoice.validation.messages: each finding has itsruleand itslocation, an XPath into the XML. The failed render keeps the same report, inGET /v1/renders/{id}and in the render log. If the data looks right to you, send therender_idto support@formfeed.dev. - Which VAT category and rate apply to a sale is a question for your tax adviser. Formfeed checks only that the block is consistent with what you state.
- If this request should produce a plain PDF from a template that declares an e-invoice, send
"post": { "einvoice": false }.
Retry?
No. Retrying the same request gives the same answer; change the data first. Send the corrected request with a new Idempotency-Key or without one: a 4xx answer is stored under its key for 24 hours, so the old key returns this problem again. See retrying.