NFE-502
Rejeição: Erro na Chave de Acesso - Campo Id não corresponde à concatenação dos campos correspondentes (Id …, campos NFe……).
In English The access key in infNFe/@Id is not "NFe" followed by cUF, the year and month of dhEmi, the issuer's CNPJ or CPF, mod, serie, nNF, tpEmis, cNF and cDV.
Why it fails
- A field of ide (serie, nNF, cNF, tpEmis or dhEmi) changed after the key was built.
- The CPF of an issuer is not padded with three zeros to 14 digits in the key.
How to fix it
Build the key from the fields as they stand: cUF (2), AAMM of dhEmi (4), CNPJ or 000 + CPF (14), mod (2), serie (3), nNF (9), tpEmis (1), cNF (8) and the check digit cDV.
What the rule checks
As the rule set's publisher wrote it. The rule runs on every element the context matches, and fails where the test is false; the validator reports the line of that element.
nfe:infNFe
@Id = concat('NFe', $key43, $ide/nfe:cDV)
Checked with NF-e 4.00, NF-e 4.00 with authorisation protocol