Jump to content

dev botao

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

Recommended Posts

Posted

não achei nada do forum, entao vai a duvida....

ao tentar cancelar uma NFCE usando o mesmo código que utilizo para cancelar uma NFE... recebo o seguinte problema abaixo ao tentar compilar....

 

   with frmprincipal.acbrnfceenvia.EventoNFe.Evento.Add do
    begin
      //infEvento.chNFe      := q_pedidosRETORNOWS_CHAVEACESSO.asstring;
      infEvento.CNPJ       := dm.q_empresalogadaCNPJ.asstring;
      infEvento.dhEvento   := NOW;
      infEvento.tpEvento   :=  tecancelamento;
      infEvento.detEvento.nProt := q_listavendasprotocolonfce.asstring;
      infEvento.detEvento.xJust := Justificativa;
      InfEvento.cOrgao := frmprincipal.acbrnfceenvia.NotasFiscais.Items[0].NFe.Ide.cUF;
      InfEvento.nSeqEvento := 1;

      InfEvento.chNFe := Copy(frmprincipal.acbrnfceenvia.NotasFiscais.Items[0].NFe.infNFe.ID, 4, 44);
    end;

ref. a linha grifada em negrito... se tento compilar dá o erro:
[Error] u_historicovendas.pas(893): Undeclared identifier: 'tecancelamento'

 

se tento cancelar a NFCE sem esta linha citade recebo o erro que:

xcorrecao with value ''

 

obrigado desde já.
 

 

 

 

  • Moderadores
Posted

Tente o seguinte:

var
  DataHoraEvento: TDateTime;
  NumeroLote: Integer;
begin

  // numero do lote de envio
  DataHoraEvento := NOW;
  NumeroLote     := StrToInt(FormatDateTime('yymmddhhmm', NOW));

  // carregar xml da nota fiscal eletronica para ser atualizado 
  ACBrNFe1.NotasFiscais.LoadFromFile(<caminho do xml da nota que for cancelar>);
  // ou 
  //ACBrNFe1.NotasFiscais.LoadFromString(<conteudo do xml da nota que for cancelar, geralmente usado quando lê o XML do banco>);

  // montagem do cancelamento
  ACBrNFe1.EventoNFe.Evento.Clear;
  ACBrNFe1.EventoNFe.idLote := NumeroLote;

  with ACBrNFe1.EventoNFe.Evento.Add do
  begin
    infEvento.CNPJ            := CNPJ_EMPRESA;
    infEvento.dhEvento        := DataHoraEvento;
    infEvento.tpEvento        := teCancelamento;
    infEvento.chNFe           := ACBrNFe1.NotasFiscais[0].NFe.procNFe.chNFe;
    infEvento.detEvento.nProt := ACBrNFe1.NotasFiscais[0].NFe.procNFe.nProt;
    infEvento.detEvento.xJust := <TEXTO_JUSTIFICATIVA>;
  end;

  if ACBrNFe1.EnviarEventoNFe(NumeroLote) then
  begin
    with ACBrNFe1.WebServices do
    begin
      if EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.cStat <> 135 then
      begin
        raise Exception.CreateFmt(
          'Ocorreu o seguinte erro ao cancelar a nota fiscal eletrônica:'  + sLineBreak +
          'Código:%d' + sLineBreak +
          'Motivo: %s', [
            EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.cStat,
            EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.xMotivo
        ]);
      end;

      try
        // Informações retornadas para o evento, usadas para gravar no banco de dados se quiser
        // EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.dhRegEvento
        // EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.nProt
        // EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.cStat
        // EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.xMotivo
        // EnvEvento.EventoRetorno.retEvento.Items[0].RetInfEvento.XML

        Application.MessageBox('Cancelamento efetuado com sucesso!', 'Cancelamento', MB_ICONINFORMATION + MB_OK);
      except
        on E: Exception do
        begin
          raise Exception.Create(
            'Ocorreram erros ao gravar o evento no banco de dados' + sLineBreak +
            E.Message
          );
        end;
      end;
    end;
  end
  else
  begin
    with ACBrNFe1.WebServices.EnvEvento do
    begin
      raise Exception.Create(
        'Ocorreram erros ao tentar efetuar o cancelamento:' + sLineBreak +
        'Lote: '     + IntToStr(EventoRetorno.idLote) + sLineBreak +
        'Ambiente: ' + TpAmbToStr(EventoRetorno.tpAmb) + sLineBreak +
        'Orgao: '    + IntToStr(EventoRetorno.cOrgao) + sLineBreak +
        'Status: '   + IntToStr(EventoRetorno.cStat) + sLineBreak +
        'Motivo: '   + EventoRetorno.xMotivo
      );
    end;
  end;
end;

 

Equipe ACBr

Régys Borges da Silveira

http://www.regys.com.br

certificacao delphicertificacao delphi
  • 4 months later...
Posted

Bom dia 

Estou tentando cancelar uma nota fiscal do consumidor no ceará e não estou conseguindo.

alguem poderia me ajudar, pois estou recebendo o retorno abaixo e quando consulto a nota ela não estar cancelada.

desde já agradeço.

 

//

<?xml version="1.0" encoding="UTF-8" ?>
- <retEnvEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00">
  <idLote>1</idLote>
  <tpAmb>2</tpAmb>
  <verAplic>CE_NFe_VNao Identificada</verAplic>
  <cOrgao>$loteEvento.cUF</cOrgao>
  <cStat>$loteEvento.resultado.id</cStat>
  <xMotivo>$loteEvento.resultado.descricao</xMotivo>
- <retEvento versao="1.00">
- <infEvento>
  <tpAmb>2</tpAmb>
  <verAplic>CE_NFe_V1.00</verAplic>
  <cOrgao>23</cOrgao>
  <cStat>297</cStat>
  <xMotivo>Rejeicao: Assinatura difere do calculado</xMotivo>
  <tpEvento>110111</tpEvento>
  <nSeqEvento>1</nSeqEvento>
  <dhRegEvento>2015-12-01T10:12:07-03:00</dhRegEvento>
  </infEvento>
  </retEvento>
  </retEnvEvento>
 
 

 

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.