SAFTCheck
Blog

6 min read

AT SAF-T error messages explained: "Ficheiro inválido", "Rejeitado" and cvc- errors

What each message from the Portal das Finanças and AT's SAF-T validator means and how to fix it: "Ficheiro inválido", file statuses, upload errors, and cvc-pattern-valid, cvc-identity-constraint and other validator messages.

AT's messages are short, and most of them don't say which line of the file is wrong. Below are the ones you are likely to see, with what each means and how to fix it. Messages from the Portal das Finanças are quoted in Portuguese, exactly as shown; messages from the validator are technical and in English.

"Ficheiro inválido"

The most common rejection. It means the file breaks the structure defined for SAF-T (PT) (Portaria n.º 302/2016), and AT does not tell you where. Older wording you may still see: "Ficheiro SAF-T (PT) inválido" and "O ficheiro seleccionado não está de acordo com o formato exigido".

Usual causes, in order of how often they happen:

  • Encoding: the file is UTF-8, or its bytes don't match the declaration on the first line. How to fix it.
  • A byte order mark (BOM) before <?xml.
  • A schema error: a missing mandatory field, a value in the wrong format, a reference to a customer or product that isn't listed. The validator messages below say which.

Fix: validate the file to see every problem with its line number, correct it, export again and resubmit.

File status "Rejeitado" or "Integrado parcialmente"

After upload, e-Fatura shows a status for the file. According to AT:

  • Pendente / Em processamento: waiting or being processed.
  • Integrado com sucesso: every document was recorded.
  • Integrado parcialmente: some documents were not recorded. Typically they had already been communicated (by an earlier file or by webservice) and are skipped as duplicates, which is harmless.
  • Rejeitado: a content problem stopped processing, or no document was recorded. This also happens when every document in the file had already been communicated by webservice with no change.

Before resubmitting a rejected file, check whether your software already sends invoices by webservice: you communicate by file or by webservice, not both.

"Ocorreu um erro ao enviar o ficheiro"

The upload itself failed; the file was not checked. Check the internet connection and whether a firewall or proxy blocks the e-Fatura site, then try again.

"Falhou o Envio. O cliente da linha de comandos que está a utilizar não se encontra atualizado"

Your software submits through AT's command-line client (a Java file named FACTEMICLI…jar) and that version is no longer accepted. Download the current one from the e-Fatura site, replace the old file where your software keeps it, and send again. Large files, which the portal upload doesn't accept, go through this client too.

Validator messages: cvc-…

AT's validator reports schema errors with the standard Java (Xerces) messages. The codes are cryptic but precise:

cvc-pattern-valid: Value '…' is not facet-valid with respect to pattern '…'

A value has the wrong shape. Example: InvoiceNo must be the document type, a space, the series, a slash and the number, like FT A/123; FT123 fails.

cvc-minLength-valid: Value with length = '0' is not facet-valid with respect to minLength '1'

A mandatory field is empty: often a product without a description, or a company or customer without a city.

cvc-maxLength-valid: Value '…' with length = '…' is not facet-valid with respect to maxLength '…'

A value is too long, such as a product code over 60 characters or a name over 100.

cvc-enumeration-valid: Value '…' is not facet-valid with respect to enumeration '[…]'

A code isn't in the allowed list, for example a document type or tax code your software invented. If the rejected value is FS (simplified invoice), the validator is outdated: FS is valid in version 1.04_01.

cvc-complex-type.2.4.a: Invalid content was found starting with element '…'. One of '{…}' is expected.

Elements are missing or in the wrong order. The message names the element it found and the one it expected at that position.

cvc-identity-constraint.4.3: Key '…' with value '…' not found for identity constraint

A document points to something that isn't listed. InvoiceCustomerIDConstraint: an invoice uses a CustomerID that has no matching customer in the file. InvoiceProductCodeConstraint: the same for a product. Usually the export filtered the customer or product list differently from the documents.

See every error at once

SAFTCheck validates against AT's current schema and reports these problems in plain language with the line number, plus the checks the schema can't express (encoding, NIF check digits, ATCUD, dates). Validate your SAF-T; the first validation is free and needs no account.

Other posts