DIEGO J B PIRES Postado 15 Outubro, 2025 Postado 15 Outubro, 2025 Boa tarde, tenho essa função no meu sistema para processar o retorno de cancelamento de NF, porém quando o cancelamento dá duplicidade, não estou conseguindo pegar o protocolo do cancelamento Tentei pegar por ai e não deu certo. ALguem já precisou dessa informação ? prot := NotaAcbr.WebServices.Consulta.procEventoNFe[i].RetEventoNFe.InfEvento.detEvento.nProtEvento; procedure TProcessoNotaFiscal.ProcessarRetornoCancelamento(just : string); var codStat, i : Integer; xml, prot : string; dt : TDateTime; trans : TDBXTransaction; begin codStat := NotaAcbr.WebServices.EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.cStat; case codStat of //Evento registrado 135 : begin xml := NotaACBR.WebServices.EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.XML; prot := NotaAcbr.WebServices.EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.nProt; dt := NotaAcbr.WebServices.EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.dhRegEvento; end; //Duplicidade 573 : begin NotaAcbr.NotasFiscais.Clear; NotaAcbr.WebServices.Consulta.NFeChave := CdsDfe.AsStr('DFECHAVE'); NotaAcbr.WebServices.Consulta.ExtrairEventos := true; NotaAcbr.WebServices.Consulta.Executar; if NotaAcbr.WebServices.Consulta.cStat in [100, 101] then begin for i := 0 to NotaAcbr.WebServices.Consulta.procEventoNFe.Count - 1 do begin if NotaAcbr.WebServices.Consulta.procEventoNFe[i].RetEventoNFe.InfEvento.tpEvento = TpcnTpEvento.teCancelamento then begin xml := NotaAcbr.WebServices.Consulta.procEventoNFe[i].RetEventoNFe.XML; prot := NotaAcbr.WebServices.Consulta.procEventoNFe[i].RetEventoNFe.InfEvento.detEvento.nProtEvento; dt := NotaAcbr.WebServices.Consulta.procEventoNFe[i].RetEventoNFe.InfEvento.dhEvento; just := NotaAcbr.WebServices.Consulta.procEventoNFe[i].RetEventoNFe.InfEvento.detEvento.xJust; end; end; end else AddMsg(NotaAcbr.WebServices.Consulta.xMotivo, true); end; else AddMsg('Não foi possível cancelar a NF.' + sLineBreak + notaAcbr.WebServices.EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.xMotivo, true); end; if Sucesso then begin trans := IniciarTransacao; CdsDfe.Editar; CdsDfe.FieldByName('DFEXMLCANCELADO').AsString := xml; CdsDfe.FieldByName('DFEPROTOCOLOCANC').AsString := prot; CdsDfe.FieldByName('DFEDATACANC').AsDateTime := dt; CdsDfe.FieldByName('DFEJUSTCANC').AsString := just; CdsDfe.FieldByName('DFESIT').AsInteger := Ord(esdCANCELADO); CdsDfe.Commit; CommitTransacao(trans); end; end;
Consultores Juliomar Marchetti Postado 16 Fevereiro Consultores Postado 16 Fevereiro testou o exemplo um desses eventos? sugiro pegar o xml só assinado e consultar Juliomar Marchetti Ajude o Projeto ACBr crescer - Seja Pro discord: juliomar telegram: juliomar e-mail: [email protected] http://www.juliomarmarchetti.com.br Projeto ACBr - A maior comunidade Open Source de Automação Comercial do Brasil Participe de nosso canal no Discord e fique ainda mais próximo da Comunidade !!
Recommended Posts
Crie uma conta ou entre para comentar
Você precisar ser um membro para fazer um comentário
Criar uma conta
Crie uma nova conta em nossa comunidade. É fácil!
Crie uma nova contaEntrar
Já tem uma conta? Faça o login.
Entrar Agora