Last active
March 1, 2019 17:05
-
-
Save tporto/1fae4082669de13745c69d47af880b68 to your computer and use it in GitHub Desktop.
Função para obter a chave nfe - rejeição 539, 613, 217
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class function TNfController.get_chaveacesso_rejeicao539(mensagem: string | |
): string; | |
var | |
s: TStringList; | |
i: integer; | |
str_value: string; | |
begin | |
result := ''; | |
s := TStringList.Create; | |
try | |
s.Delimiter := ' '; | |
str_value := StringReplace(mensagem, ']', ' ', [rfReplaceAll]); | |
str_value := StringReplace(str_value, ':', ' ', [rfReplaceAll]); | |
s.DelimitedText := str_value; | |
for i := 0 to s.Count - 1 do | |
begin | |
if length(trim(s[i])) = 44 then | |
result := trim(s[i]); | |
end; | |
finally | |
s.Free; | |
end; | |
end; | |
---- USO | |
nf.CHAVE_ACESSO := get_chaveacesso_rejeicao539(ACBrNFe.NotasFiscais.Items[0].Msg); | |
if (nf.CHAVE_ACESSO <> '') and (length(nf.CHAVE_ACESSO) = 44) then | |
begin | |
if ACBrNFe.Consultar(nf.CHAVE_ACESSO) then | |
begin | |
nf.CODIGO_STATUS_RESPOSTA := '100'; | |
nf.STATUS_NOTA := 4; | |
nf.NUMERO_PROTOCOLO := ACBrNFe.WebServices.Consulta.Protocolo; | |
nf.DESCRICAO_MOTIVO_RESPOSTA := ACBrNFe.WebServices.Consulta.XMotivo; | |
TNfController.update(nf); | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment