Jump to content

dev botao
  • Este tópico foi criado há 4237 dias atrás.
  • Talvez seja melhor você criar um NOVO TÓPICO do que postar uma resposta aqui.

Recommended Posts

  • Membros Pro
Posted

Boa noite 

 

Gostaria de ajuda para saber como capturar o "XML", "xJustificativa" e "xCorrecao" dos Eventos.

 

A situação é a seguinte: A empresa  emite uma nota fiscal, após o Xim ser enviado ao contador, o mesmo, ( em alguns casos) gera uma ou varias cartas de correção ou mesmo cancelamento. 

Gostaria de saber com sincronizar com o aplicativo que se encontra na empresa. (isto já é feito pelo aplicativo gratuito emissor da NF-e). 

 

Estou tentando da forma (parte to trecho) abaixo.

1º -dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.XML; 

 

Não me retorna o Xlm do envento, o mesmo vem nulo.

 

2º - Não localizei onde consigo capturar o campo "xJustificativa" ou "xCorrecao"

 

Outra situação corriqueira, e que sempre vejo sem resposta nos foruns: Após um evento ser registrado na sefaz , por algun motivo (qualquer que seja),  a  aplicação não captura o retorno e não cria o Xml do evento (O Acbrnfe cria após o retorno correto), como faria para consultar este evento e salvar as "informações" juntamente com  "XMLdo evento no meu BD?

 

      // se tiver carregado ao nenos uma nota fiscal
      if dmBaseDados.ACBrNFe1.NotasFiscais.Count > 0 then
      begin
        // consultando a nota fiscal
        if dmBaseDados.ACBrNFe1.Consultar then
        begin
            try
              with dmBaseDados.ACBrNFe1.NotasFiscais do
              begin
 
                      for i:= 0 to dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Count - 1 do
                      begin
                            if dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.InfEvento.tpEvento = teCancelamento then
                          begin
                             with FIBQuery do
                             begin
                              Close;
                              SQL.Clear;
                              SQL.Add
                                ('UPDATE OR INSERT INTO NFE_EVENTO(');
                              SQL.Add('ID_EMPRESA,');
                              // SQL.Add('ID,');
                              SQL.Add('ID_NFE,');
                              SQL.Add('SEQUENCIA,');
                              SQL.Add('EVENTO,');
                              // SQL.Add('DATA,');
                              // SQL.Add('HORA,');
                              SQL.Add('DESCRICAO,');
                              SQL.Add('PROTOCOLO,');
                              SQL.Add('DATA_HORA,');
                              SQL.Add('XML');
                              SQL.Add(')');
                              SQL.Add('VALUES(');
                              SQL.Add(':ID_EMPRESA,');
                              // SQL.Add(':ID,');
                              SQL.Add(':ID_NFE,');
                              SQL.Add(':SEQUENCIA,');
                              SQL.Add(':EVENTO,');
                              // SQL.Add(':DATA,');
                              // SQL.Add(':HORA,');
                              SQL.Add(':DESCRICAO,');
                              SQL.Add(':PROTOCOLO,');
                              SQL.Add(':DATA_HORA,');
                              SQL.Add(':XML');
                              SQL.Add(')');
                              SQL.Add('MATCHING (ID_EMPRESA, ID_NFE, SEQUENCIA, EVENTO)');
 
                              Parambyname('ID_EMPRESA').AsInteger := VarPub.Empresa;
                              Parambyname('ID_NFE').AsInteger := FIBNFeID.AsInteger;
                              Parambyname('SEQUENCIA').AsInteger :=                              dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.nSeqEvento;
                              Parambyname('EVENTO').AsString :=
                              TpEventoToStr( dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.tpEvento);
                              Parambyname('PROTOCOLO').AsString :=                              dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.nProt;//Items.NFe.procNFe.nProt;
                              Parambyname('DATA_HORA').Value :=                              dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.dhRegEvento;
                              Parambyname('DESCRICAO').AsString:=                              dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.xEvento;
                              Parambyname('XML').Value :=    dmBaseDados.ACBrNFe1.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.XML;
                              ExecQuery;
                             end;
                          end;
 
                          end;
                      end;//For
                end;
 
 
        MemoResp.Lines.Text := UTF8Encode(dmBaseDados.ACBrNFe1.WebServices.Consulta.RetWS);
        memoRespWS.Lines.Text := UTF8Encode(dmBaseDados.ACBrNFe1.WebServices.Consulta.RetornoWS);
        LoadXML(MemoResp, WBResposta);
 
 
 
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

The popup will be closed in 10 seconds...