Ir para conteúdo
  • Cadastre-se

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

Recommended Posts

Postado

quando envio a nfce  da o erro  -   nehnuma nota no acbr foi preenchida  verificamos tudo numa versao antiga envia  atualizamos dia 14/10/25 o acbr e comecou isso na nfce  aqui no parana

  • Consultores
Postado

pega o exemplo e roda e tenta fazer o mesmo.

creio que possa ser algo no código seu

 

Consultora ACBr Pro

Juliomar Marchetti

Ajude o Projeto ACBr crescer - Seja Pro

discord: juliomar
telegram: juliomar
e-mail: [email protected]
http://www.juliomarmarchetti.com.br

 

MVP_NewLogo_100x100_Transparent-02.png
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 !!

Postado

desse jeito que e gerado e diz que nao esta no lote e nao vai

 

 

//######################################################################################################################
//
// NFCe
//
//######################################################################################################################
function TfGeraNotaFiscal.GerarNFCe: Boolean;
var
   NumeroNota: Integer;
   cProtocolo: String;
   sArquivo: String;
   TotalPrecoVenda: Double;
   TotalDescontoGeral: Double;
   PrecoVenda: Double;
   TotDescGeral: Double;
   TotalBCicms: Double;
   TotalICMS: Double;
   TotalTributacao: Double;
   DataHoraEmissao: TDateTime;
   sArquivoPDF: String;
   TotalMenosDesconto: Double;
   TotalNota: Double;
   QtdeRegistros: Integer;
   DiferencaDesconto: Double;
   InfoPgto: TpagCollectionItem;
   TotalRecebimento: Double;
   Diferenca: Double;

   function EnviarNotaNFCE: Boolean;
   var
      bRetornoEnvio: Boolean;
      Erro: String;
      NumNota: String;
    iPos: Integer;
    NumeroErro: String;
   begin
      MsgBarraRodape('Enviando nota Fiscal.');

      Result := True;

      try
         try
            //
            if DM.ACBrNFe_NFe.NotasFiscais.Count <= 0 then
               raise Exception.Create('Nenhuma adicionada para ser emitida.');

            //
            bRetornoEnvio := False;
             case DM.tbConfiguracaotipo_ambiente.Value of
              1:
                  bRetornoEnvio := DM.ACBrNFe_NFe.Enviar(1, False, True);
              2:
                  bRetornoEnvio := DM.ACBrNFe_NFe.Enviar(1, True, True);
             end;
            //
            //
            Sleep(3000);
            //
            DM.ACBrNFe_NFCE.DANFE.PathPDF := DM.sPathNFE_PDF;
            DM.ACBrNFe_NFCE.NotasFiscais.ImprimirPDF;

            MemoResp.Lines.Text := DM.ACBrNFe_NFCE.WebServices.Retorno.RetWS;
            memoRespWS.Lines.Text := DM.ACBrNFe_NFCE.WebServices.Retorno.RetornoWS;
            LoadXML(DM.ACBrNFe_NFCE.WebServices.Retorno.RetornoWS, WBResposta);

            IdStatus := DM.ACBrNFe_NFCE.NotasFiscais.Items[0].NFe.procNFe.cStat;
            cProtocolo := DM.ACBrNFe_NFCE.NotasFiscais.Items[0].NFe.procNFe.nProt;
            sArquivo := DM.sPathNFCE_Nfce + '\' + DM.AnoNF + '\' + DM.MesNF + '\' + tbNotaFiscalchave.Text + '-nfe.xml';
            sArquivoPDF := DM.sPathNFE_PDF + '\' + tbNotaFiscalchave.Text + '-nfe.pdf';

            //=======================================================================================================
            // Retornou cStat = 100)
            if (IdStatus in [100]) then
            begin
               tbNotaFiscal.Edit;
               tbNotaFiscalidmsgretorno.Value := IdStatus;
               tbNotaFiscalprotocolo.Value := cProtocolo;
               tbNotaFiscalxml.LoadFromFile(sArquivo);
               GravaRegistro(tbNotaFiscal);
            end;

            Result := True;

            //=======================================================================================================
            // Retornou cStat <> 100)
            if not (IdStatus in [100]) then
            begin
               Application.CreateForm(TfConsultaNFeSefaz, fConsultaNFeSefaz);
               fConsultaNFeSefaz.IdNotaFiscal := tbNotaFiscalID.Value;
               fConsultaNFeSefaz.NumeroNota := tbNotaFiscalNUMERO_NOTA.Value;
               fConsultaNFeSefaz.Chave := tbNotaFiscalCHAVE.Value;
               fConsultaNFeSefaz.TipoDocumento := tbNotaFiscalIDTIPODOCUMENTO.Value;
               fConsultaNFeSefaz.aConsultar.Execute;
               fConsultaNFeSefaz.ShowModal();

               Result := False;

               Msg('A Nota Fiscal foi autorizada mas n o retornou o XML Autorizado.', 1);
            end;
         except
            on E: Exception do
               begin
                  Erro := E.Message;
                  //-------------------------------------------------------------------------------------------------------
                  iPos := Pos('539', Erro);
                  NumeroErro := Copy(Erro, iPos, 3);
                  if NumeroErro = '539' then
                  begin
                     bRetornoEnvio := True;
                     AvancaNumeroNota(2);
                     Result := False;
                  end;
                  //-------------------------------------------------------------------------------------------------------
               end;
         end;
      finally
         begin
            PainelVisivel(pnImprimindo);
            PainelInvisivel(pnGeral);
            Enabled := True;

            if not bRetornoEnvio then
            begin
               Result := False;
               //
               NumNota := tbNotaFiscalNUMERO_NOTA.Text;
               //
               GravaLog(Concat('N o retornou envio. Num. Nota:', IntToStr(NumeroNota), '. ', Erro), False);
               GravaLog('----------------------------------', False);
               GravaLog(Concat('Erro:', Erro), False);
               //
               if (tbNotaFiscalIDPEDIDO.Value > 0) then
                  DM.ExcluiNotaFiscalNaoFaturada(tbNotaFiscalID.Value);
               //
               //-------------------------------------------------------------------------------------------------------
               // Avan a o n mero da nota.
//               iPos := Pos('539', Erro);
//               NumeroErro := Copy(Erro, iPos, 3);
//               if NumeroErro = '539' then
//               else
//                  VoltaNumeroNota(2);
               //-------------------------------------------------------------------------------------------------------

               EnviaTelaErro(Concat('N o foi poss vel enviar a Nota Fiscal N : ',  NumNota, '. ', Erro));

               MsgBarraRodape(Concat('A Nota Fiscal N : ',  NumNota, ' n o foi enviada.'));
            end;
         end;
      end;
  end;

begin
  Result := True;
  DM.ACBrNFe_NFCE.NotasFiscais.Clear;
  with DM.ACBrNFe_NFCE.NotasFiscais.Add.NFe do
  begin
    //##########################################################################
    // IDENTIFICA  O.
    //
    DataHoraEmissao := Now();
    Ide.cNF       := tbNotaFiscalNFeNFCeID.Value;
    Ide.natOp     := Copy(tbNotaFiscalNFeNFCecfop_descricao.Text, 1, 59);
    Ide.modelo    := tbNotaFiscalNFeNFCemodelo.AsInteger;
    Ide.serie     := tbNotaFiscalNFeNFCeserie.AsInteger;
    Ide.nNF       := tbNotaFiscalNFeNFCenumero_nota.Value;
    Ide.dEmi      := DataHoraEmissao;
    Ide.dSaiEnt   := tbNotaFiscalNFeNFCedata_hora_saida.Value;
//    Ide.dSaiEnt   := tbNotaFiscalNFeNFCedata_hora_saida.Value;
    Ide.tpNF      := tnSaida;
    Ide.cUF       := DM.tbEmpresacodigo_uf.Value;
    Ide.cMunFG    := DM.tbEmpresaidcidade.Value;
    Ide.tpImp     := tiNFCe;

    ide.idDest    := doInterna;
    ide.procEmi   := peAplicativoContribuinte;
    ide.verProc   := DM.tbConfiguracaoGeralversao_sistema.Value;

    // Tipo de emiss o.
    case DM.tbConfiguracaotipo_emissao.Value of
      1:Ide.tpEmis := teNormal;
    end;

    // Pagamento.
    case cdsIndPagamentoid.Value of
      0:
        Ide.indPag := ipVista;
      1:
        Ide.indPag := ipPrazo;
      2:
        Ide.indPag := ipOutras;
    end;

    // Ambiente.
    case DM.tbConfiguracaotipo_ambiente.Value of
     1:
         Ide.tpAmb := taProducao;
     2:
         Ide.tpAmb := taHomologacao;
    end;

    // Consumidor
    case cdsIndFinalID.Value  of
     0:
      Ide.indFinal := cfNao;
     1:
      Ide.indFinal := cfConsumidorFinal;
    end;

    // Presen a do consumidor.
    case cdsIndPresencaid.Value of
      0:
        Ide.indPres := pcNao;
      1:
        Ide.indPres := pcPresencial;
      2:
        Ide.indPres := pcInternet;
      3:
        Ide.indPres := pcTeleatendimento;
      4:
        Ide.indPres := pcEntregaDomicilio;
      9:
        Ide.indPres := pcOutros;
    end;

    //==================================================================================================================
    // Indicador de Itermediador.
    if not InverterSaida then
    begin
       case cdsIndPresencaid.Value of
         2,3,4,9:
            begin
               Ide.indIntermed := iiOperacaoSemIntermediador;
            end;
       end;
    end;

    // Finalidade.
    case cdsFinalidadeid.Value of
      1:
        Ide.finNFe := fnNormal;
      2:
        Ide.finNFe := fnComplementar;
      3:
        Ide.finNFe := fnAjuste;
      4:
        Ide.finNFe := fnDevolucao;
    end;

    // Finalidade.
    case cdsModalidadeFreteID.Value of
      0:
        Transp.modFrete := mfContaEmitente;
      1:
        Transp.modFrete := mfContaDestinatario;
      2:
        Transp.modFrete := mfContaTerceiros;
      3:
        Transp.modFrete := mfProprioRemetente;
      4:
        Transp.modFrete := mfProprioDestinatario;
      9:
        Transp.modFrete := mfSemFrete;
    end;

    //##########################################################################
    // EMITENTE.
    Emit.CNPJCPF           := DM.tbEmpresacnpj.Text;
    Emit.IE                := DM.tbEmpresaie.Text;
    Emit.xNome             := DM.tbEmpresarazaosocial.Text;
    Emit.xFant             := DM.tbEmpresanomefantasia.Text;
    //
    Emit.EnderEmit.fone    := DM.tbEmpresatelefone.Text;
    Emit.EnderEmit.CEP     := DM.tbEmpresacep.AsInteger;
    Emit.EnderEmit.xLgr    := DM.tbEmpresaendereco.Text;
    Emit.EnderEmit.nro     := DM.tbEmpresanumero.Text;
    Emit.EnderEmit.xCpl    := DM.tbEmpresacomplemento.Text;
    Emit.EnderEmit.xBairro := DM.tbEmpresabairro.Text;
    Emit.EnderEmit.cMun    := DM.tbEmpresaidcidade.AsInteger;
    Emit.EnderEmit.xMun    := DM.tbEmpresacidade.Text;
    Emit.EnderEmit.UF      := DM.tbEmpresaiduf.Text;
    Emit.enderEmit.cPais   := dm.tbConfiguracaoGeralcodigo_pais.AsInteger;
    Emit.enderEmit.xPais   := DM.tbConfiguracaoGeralpais.Text;

    // (1-crtSimplesNacional, 2-crtSimplesExcessoReceita, 3-crtRegimeNormal)
    case DM.tbEmpresaIDCRT.Value of
      1:
         Emit.CRT  := crtSimplesNacional;
      2:
         Emit.CRT  := crtSimplesExcessoReceita;
      3:
         Emit.CRT  := crtRegimeNormal;
    end;

    //##################################################################################################################
    // CPF/CNPJ do destinat rio.
    //
    Dest.CNPJCPF := FilterChars(dbeCpfCnpj.Text, ['0'..'9']);
    if Dest.CNPJCPF <> '' then
    begin
      tbNotaFiscal.Edit;
      tbNotaFiscalCPF_CNPJ.Value:= Dest.CNPJCPF;
      tbNotaFiscal.Post;

      Dest.indIEDest := inNaoContribuinte;
    end
    else
    begin
       case tbPessoaNFeNFCeidcontribuinte.Value of
         1:
           Dest.indIEDest := inContribuinte;
         2:
           Dest.indIEDest := inIsento;
         3:
           Dest.indIEDest := inNaoContribuinte;
       end;
    end;

    QtdeRegistros := tbNotaFiscalItem.RecordCount;

    while not tbNotaFiscalItem.Eof do
    begin
      with Det.Add do
      begin

        if tbNotaFiscalItemCBENEF.Text <> '' then
        begin
           prod.cBenef    := tbNotaFiscalItemCBENEF.Text;
        end;

        Prod.nItem    := tbNotaFiscalItemITEM.AsInteger;
        Prod.cProd    := tbNotaFiscalItemIDPRODUTOGRADE.Text;

         if Copy(Trim(tbNotaFiscalItemEAN.Text), 1, 1) = '1' then
            Prod.cEAN  := 'SEM GTIN'
         else
            Prod.cEAN  := Trim(tbNotaFiscalItemEAN.Text);

        Prod.xProd    := Concat(tbNotaFiscalItemproduto.Text,' ',tbNotaFiscalItemCOMPLEMENTO.Text);
        Prod.NCM      := tbNotaFiscalItemNCM.Text;
        Prod.CFOP     := tbNotaFiscalItemIDCFOP.AsString;
        Prod.uTrib    := tbNotaFiscalItemUN.Text;

        Prod.IndTot   := itSomaTotalNFe;
        Prod.uCom     := tbNotaFiscalItemUN.Text;
        Prod.qCom     := tbNotaFiscalItemQUANTIDADE.Value;

//        PrecoVenda := tbNotaFiscalItemPRECO_VENDA.AsCurrency;
        TotDescGeral := tbNotaFiscalItemTOTAL_DESCONTO_GERAL.AsCurrency;

        Prod.vUnCom   := tbNotaFiscalItemPRECO_VENDA.AsCurrency;
        Prod.vDesc    := TotDescGeral;
        Prod.vProd    := tbNotaFiscalItemTOTAL_PRECO_VENDA.Value;

         //-------------------------------------------------------------------------------------------------------------
         if Copy(Trim(tbNotaFiscalItemEAN.Text), 1, 1) = '1' then
            begin
               Prod.cEAN  := 'SEM GTIN';
               Prod.cEANTrib  := 'SEM GTIN';
            end
         else
            begin
               Prod.cEAN  := Trim(tbNotaFiscalItemEAN.Text);
               Prod.cEANTrib  := Trim(tbNotaFiscalItemEAN.Text);
            end;

         //-------------------------------------------------------------------------------------------------------------
         if Length( Copy(FilterChars(tbNotaFiscalItemEAN.Text, ['1'..'9']), 1, 7) ) < 7 then
            begin
               Prod.cEAN  := 'SEM GTIN';
               Prod.cEANTrib  := 'SEM GTIN';
            end
         else
            begin
               Prod.cEAN  := Trim(tbNotaFiscalItemEAN.Text);
               Prod.cEANTrib  := Trim(tbNotaFiscalItemEAN.Text);
            end;
         //-------------------------------------------------------------------------------------------------------------

         if DM.tbConfiguracaoNOTAFISCAL_ENVIAR_COM_SEMGTIN.Value = 'S' then
         begin
               Prod.cEAN  := 'SEM GTIN';
               Prod.cEANTrib  := 'SEM GTIN';
         end;

         Prod.uTrib    := tbNotaFiscalItemUN.Text;
        Prod.qTrib    := tbNotaFiscalItemQUANTIDADE.Value;
        Prod.vUnTrib  := tbNotaFiscalItemPRECO_VENDA.AsCurrency;

        TotalPrecoVenda :=  TotalPrecoVenda + tbNotaFiscalItemTOTAL_PRECO_VENDA.Value;
        TotalDescontoGeral := TotalDescontoGeral + tbNotaFiscalItemTOTAL_DESCONTO_GERAL.Value;

         //==============================================================================================================
         // DIFEREN A DO DESCONTO.
         if QtdeRegistros = tbNotaFiscalItem.RecNo then
         begin
            if TruncaValorMonetario(tbNotaFiscalTOTAL_DESCONTO_GERAL.Value, 2) < TruncaValorMonetario(TotalDescontoGeral, 2) then
            begin
               Diferenca := TotalDescontoGeral - tbNotaFiscalTOTAL_DESCONTO.Value;
               Prod.vDesc    := Prod.vDesc - Diferenca;
            end;
         end;

         if QtdeRegistros = tbNotaFiscalItem.RecNo then
         begin
            if TruncaValorMonetario(tbNotaFiscalTOTAL_DESCONTO_GERAL.Value, 2) > TruncaValorMonetario(TotalDescontoGeral, 2) then
            begin
               Prod.vDesc    := Prod.vDesc + 0.01;
               TotalDescontoGeral := TotalDescontoGeral + 0.01;
            end;
         end;

         if DM.tbEmpresaidcrt.Value = 3 then
         begin
            FechaTabela(tbNotaFiscalTributacao);
            tbNotaFiscalTributacao.ParamByName('id').Value := tbNotaFiscalID.AsInteger;
            tbNotaFiscalTributacao.ParamByName('idprodutograde').Value := tbNotaFiscalItemIDPRODUTOGRADE.AsInteger;
            AbreTabela(tbNotaFiscalTributacao);
            if not tbNotaFiscalTributacao.IsEmpty then
               begin
                  TotalBCicms := TotalBCicms + tbNotaFiscalTributacaoICMS_BASE_CALCULO.Value;
                  TotalICMS := TotalICMS + tbNotaFiscalTributacaoICMS_VALOR.Value;

                  TotalTributacao := TotalTributacao  + tbNotaFiscalTributacaoICMS_VALOR.Value;

                  Imposto.vTotTrib     := tbNotaFiscalTributacaoICMS_VALOR.Value;
                  //Imposto.ICMS.modBC   := 0;
                  Imposto.ICMS.vBC     := tbNotaFiscalTributacaoICMS_BASE_CALCULO.Value;
                  Imposto.ICMS.pICMS   := tbNotaFiscalTributacaoICMS_ALIQUOTA.Value;
                  Imposto.ICMS.vICMS   := tbNotaFiscalTributacaoICMS_VALOR.Value;
                  //Imposto.ICMS.modBCST := 0;
                  Imposto.ICMS.pMVAST  := 0;
                  Imposto.ICMS.pRedBCST:= 0;
                  Imposto.ICMS.vBCST   := 0;
                  Imposto.ICMS.pICMSST := 0;
                  Imposto.ICMS.vICMSST := 0;
                  Imposto.ICMS.pRedBC  := 0;
               end
            else
               begin
                  Imposto.vTotTrib     := 0;
                  //Imposto.ICMS.modBC   := 0;
                  Imposto.ICMS.vBC     := 0;
                  Imposto.ICMS.pICMS   := 0;
                  Imposto.ICMS.vICMS   := 0;
                  //Imposto.ICMS.modBCST := 0;
                  Imposto.ICMS.pMVAST  := 0;
                  Imposto.ICMS.pRedBCST:= 0;
                  Imposto.ICMS.vBCST   := 0;
                  Imposto.ICMS.pICMSST := 0;
                  Imposto.ICMS.vICMSST := 0;
                  Imposto.ICMS.pRedBC  := 0;
               end;
         end;

        Imposto.ICMS.orig    := oeNacional;

        if DM.tbEmpresaIDCRT.Value = 1 then
        begin
           // Empresa no SIMPLES NACIONAL
           case StrToInt(tbNotaFiscalItemidcsosn.Value) of
             101:
               Imposto.ICMS.CSOSN := csosn101;
             102:
               Imposto.ICMS.CSOSN := csosn102;
             103:
               Imposto.ICMS.CSOSN := csosn103;
             201:
               Imposto.ICMS.CSOSN := csosn201;
             202:
               Imposto.ICMS.CSOSN := csosn202;
             203:
               Imposto.ICMS.CSOSN := csosn203;
             300:
               Imposto.ICMS.CSOSN := csosn300;
             400:
               Imposto.ICMS.CSOSN := csosn400;
             500:
               Imposto.ICMS.CSOSN := csosn500;
             900:
               Imposto.ICMS.CSOSN := csosn900;
           end;
        end
        else
        begin
           // Empresa NORMAL.
           case StrToInt(tbNotaFiscalItemidcsosn.Value) of
             101:
               Imposto.ICMS.CSOSN := csosn101;
             102:
               Imposto.ICMS.CSOSN := csosn102;
             103:
               Imposto.ICMS.CSOSN := csosn103;
             201:
               Imposto.ICMS.CSOSN := csosn201;
             202:
               Imposto.ICMS.CSOSN := csosn202;
             203:
               Imposto.ICMS.CSOSN := csosn203;
             300:
               Imposto.ICMS.CSOSN := csosn300;
             400:
               Imposto.ICMS.CSOSN := csosn400;
             500:
               Imposto.ICMS.CSOSN := csosn500;
             900:
               Imposto.ICMS.CSOSN := csosn900;
           end;
        end;


        tbNotaFiscalItem.Next;
      end;
    end;

   if tbNotaFiscalvalor_troco.Value > 0 then
      Pag.vTroco         := tbNotaFiscalVALOR_TROCO.Value;

   //
   //===================================================================================================================
   // Soma o Total de Recebimento.
   tbNotaFiscalRecebimento.First;
   while not tbNotaFiscalRecebimento.Eof  do
   begin
      TotalRecebimento := TotalRecebimento + tbNotaFiscalRecebimentoVALOR_RECEBIDO.Value;
      tbNotaFiscalRecebimento.Next;
   end;
   //
   //===================================================================================================================
   // Para arrumar a diferen a de centavos entre (Valor Informado x Valor Calculado)
   TotalNota := TotalPrecoVenda - TotalDescontoGeral;

   if CurrToStr(TotalNota) < CurrToStr(TotalRecebimento) then
   begin
      TotalNota := TotalNota + 0.01;
      TotalDescontoGeral := TotalDescontoGeral - 0.01;
   end;

   if CurrToStr(TotalNota) > CurrToStr(TotalRecebimento) then
   begin
      Diferenca := TotalNota - TotalRecebimento;
      TotalNota := TotalNota - Diferenca;
   end;


   Total.ICMSTot.vTotTrib := TotalTributacao;
   Total.ICMSTot.vBC     := TotalBCicms;
   Total.ICMSTot.vICMS   := TotalICMS;
   Total.ICMSTot.vST     := 0;
   Total.ICMSTot.vProd   := TotalPrecoVenda;
   Total.ICMSTot.vFrete  := 0;
   Total.ICMSTot.vSeg    := 0;
   Total.ICMSTot.vDesc   := TotalDescontoGeral;
   Total.ICMSTot.vII     := 0;
   Total.ICMSTot.vIPI    := 0;
   Total.ICMSTot.vPIS    := 0;
   Total.ICMSTot.vCOFINS := 0;
   Total.ICMSTot.vOutro  := 0;
   Total.ICMSTot.vNF     := TotalNota;

   //ShowMessage(TotalNota.ToString());

   // lei da transparencia de impostos
   Total.ICMSTot.vTotTrib := 0;
   //
   tbNotaFiscalRecebimento.First;
   while not tbNotaFiscalRecebimento.Eof do
   begin
       case tbNotaFiscalRecebimentoIDFORMAPAGAMENTO.AsInteger of
           01:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                        indPag := ipVista;
                        tPag := fpDinheiro;
                        vPag := tbNotaFiscalRecebimentoVALOR_RECEBIDO.AsCurrency;
                    end;
                 end;
              end;
           02:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpCheque;
                    end;
                 end;
              end;
           03:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipPrazo;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpCartaoCredito;
                       tpIntegra := tiPagNaoIntegrado;
                    end;
                 end;
              end;
           04:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpCartaoDebito;
                       tpIntegra := tiPagNaoIntegrado;
                    end;

                 end;
              end;
           05:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpCreditoLoja;
                    end;
                 end;
              end;
           06:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpValeAlimentacao;
                    end;
                 end;
              end;
           07:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpValeRefeicao;
                    end;
                 end;
              end;
           08:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpValePresente;
                    end;
                 end;
              end;
           09:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpValeCombustivel;
                    end;
                 end;
              end;
           10:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpDuplicataMercantil;
                    end;
                 end;
              end;
           11:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpBoletoBancario;
                    end;
                 end;
              end;
           12:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipOutras;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpSemPagamento;
                    end;
                 end;
              end;
           13:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipOutras;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpOutro;
                    end;
                 end;
              end;
           21:
              begin
                 if tbNotaFiscalRecebimentovalor_recebido.AsCurrency > 0 then
                 begin
                    with pag.Add do
                    begin
                       indPag := ipVista;
                       vPag := tbNotaFiscalRecebimentovalor_recebido.AsCurrency;
                       tPag := fpDinheiro;
                    end;
                 end;
              end;
       end;
       tbNotaFiscalRecebimento.Next;
    end;

    if Trim(tbNotaFiscalobs_contribuinte.Text) <> '' then
    begin
      with InfAdic do
      begin
         infCpl := tbNotaFiscalobs_contribuinte.Text;
      end;
    end;

    case DM.tbConfiguracaotipo_ambiente.Value of
      1:
         begin
             with infRespTec do
             begin
               CNPJ     := '31147518000186';
               xContato := 'WELLINGTON BALEEIRO';
               email    := '[email protected]';
               fone     := '44999441443';
             end;

            DM.ACBrNFe_NFE.Configuracoes.RespTec.IdCSRT := DM.tbEmpresaID_CSRT_PRODUCAO.Value;
            DM.ACBrNFe_NFE.Configuracoes.RespTec.CSRT := DM.tbEmpresaCSRT_PRODUCAO.Value;
         end;
      2:
         begin
            with infRespTec do
            begin
               CNPJ     := '31147518000186';
               xContato := 'WELLINGTON BALEEIRO';
               email    := '[email protected]';
               fone     := '44999441443';
            end;

            DM.ACBrNFe_NFE.Configuracoes.RespTec.IdCSRT := DM.tbEmpresaID_CSRT_HOMOLOGACAO.Value;
            DM.ACBrNFe_NFE.Configuracoes.RespTec.CSRT := DM.tbEmpresaCSRT_HOMOLOGACAO.Value;
         end;
    end;

    if Trim(tbNotaFiscalobs_fisco.Text) <> '' then
    begin
      with infAdic do
      begin
         infAdFisco := tbNotaFiscalobs_fisco.Text;
      end;
    end;

    //##########################################################################

    Result := True;
    try
       MsgBarraRodape('Gerando o N mero da Nota Fiscal.');

       NumeroNota := tbNotaFiscalnumero_nota.Value;
       tbNotaFiscal.Edit;
       if tbNotaFiscalnumero_nota.Value <= 0 then
       begin
         NumeroNota := GeraNumeroNota(tbNotaFiscalIDTIPODOCUMENTO.Value);
         if NumeroNota <= 0 then
         begin
            myResult := mrAbort;
            Exit;
         end;
         //
         Ide.nNF := NumeroNota;
         tbNotaFiscalnumero_nota.Value := NumeroNota;
       end;
       GravaRegistro(tbNotaFiscal);

       DM.ACBrNFe_NFCE.NotasFiscais.GerarNFe;
       DM.ACBrNFe_NFCE.NotasFiscais.Assinar;
    except
       on E: Exception do
          begin
             tbNotaFiscal.Edit;
             tbNotaFiscalNUMERO_NOTA.Clear;
             tbNotaFiscalIDPEDIDO.Clear;
             GravaRegistro(tbNotaFiscal);
             //
             VoltaNumeroNota(2);
             //
             DM.ExcluiNotaFiscalNaoFaturada(tbNotaFiscalID.Value);
             //
             EnviaTelaErro();
             //
             Result := False;
             myResult := mrAbort;
             Exit;
          end;
    end;

    tbNotaFiscal.Edit;
    tbNotaFiscalchave.Value := FilterChars(DM.ACBrNFe_NFCE.NotasFiscais.Items[0].NFe.infNFe.id, ['0'..'9']);
    GravaRegistro(tbNotaFiscal);

    MsgBarraRodape('Processando o encerramento da Nota Fiscal.');

    DM.ACBrNFe_NFCE.NotasFiscais.GravarXML(Concat(DM.PastaExecutavel, 'NFCE.XML'));


    //##################################################################################################################
    //
    // ENCERRAMENTO DA NOTA FISCAL
    //
    try
       if tbNotaFiscalIDSITUACAO.Value <> 5 then     // ainda n o foi faturado.
       begin
          if tbNotaFiscalIDPEDIDO.Value <= 0 then
          begin
             //ShowMessage('Pedido meno ou igual zero');
             //
             if EnviarNotaNFCE() then
                begin
                   MsgBarraRodape('Atualizando as situa  es de estoque e financeiro.');
                   //
                   myResult := mrOk;
                   {
                   if not DM.EncerramentoNotaFiscalSaida(tbNotaFiscalID.Value, tbNotaFiscalIDPEDIDO.Value) then
                   begin
                      Result := False;
                      myResult := mrAbort;
                      Exit;
                   end
                   }
                end
             else
               begin
                  myResult := mrAbort;
                  Exit;
               end;
             //
          end
          else if tbNotaFiscalIDPEDIDO.Value > 0 then
          begin
            //
             //ShowMessage('Pedido maior que zero');

            if EnviarNotaNFCE() then
               begin
                  MsgBarraRodape('Atualizando as situa  es de estoque e financeiro.');

                  myResult := mrOk;
                  if not DM.EncerramentoPedido(tbNotaFiscalIDPEDIDO.Value, tbNotaFiscalID.Value) then
                  begin
                     Result := False;
                     myResult := mrAbort;
                     Exit;
                  end
               end
            else
               begin
                  myResult := mrAbort;
                  Exit;
               end;
            //
          end;
       end;
    except
       on E: Exception do
          begin
             Result := False;
             myResult := mrAbort;
             MessageDlg('N o foi poss vel realizar o encerramento da NFC-e.' + #10 + E.Message, mtError, [mbOk], 0 );
             Exit;
          end;
    end;

   DM.IdNotaFiscal := tbNotaFiscalID.Value;

   MsgBarraRodape('Aguardando a impress o da Nota Fiscal.');
   try
      bImprimiu := False;
      Application.CreateForm(TfEmissaoRelatorio, fEmissaoRelatorio);
      case fEmissaoRelatorio.ShowModal of
         mrOk:
            begin
               if fEmissaoRelatorio.IdImpressora >= 0 then
               begin
                  DM.ACBrNFeDANFEFR_NFCE.Impressora := fEmissaoRelatorio.Impressora;
                  DM.ACBrNFeDANFEFR_NFCE.NumCopias := fEmissaoRelatorio.seNumeroCopias.Value;
                  DM.ACBrNFeDANFEFR_NFCE.MostraStatus := False;
                  DM.ACBrNFeDANFEFR_NFCE.MostraPreview := False;
                  DM.ACBrNFeDANFEFR_NFCE.MostraSetup := False;

                  DM.ACBrNFe_NFCE.NotasFiscais.Imprimir;

                  bImprimiu := True;
               end
               else
               begin
                  DM.ACBrNFe_NFCE.DANFE.MostraPreview := True;
                  DM.ACBrNFe_NFCE.NotasFiscais.Imprimir;

                  bImprimiu := True;
               end;
            end;
         mrClose,mrCancel,mrAbort:
            begin
               Result := False;
               myResult := mrClose;
            end;
      end;
   except
      on E: Exception do
         begin
            MessageDlg(Concat('Erro ao imprimir o DANFE da Nota Fiscal.',#10, E.Message), mtError, [mbOk], 0 );
            myResult := mrAbort;
            Result := False;
            Exit;
         end;
   end;

 end;

 MsgBarraRodape('Nota Fiscal enviada e finalizada com sucesso...', 5);

 if not bImprimiu then
 begin
    if Pergunta('Voce escolheu n o imprimir a NFC-e. Deseja ainda v -la na tela', 2) then
    begin
       DM.ACBrNFe_NFCE.DANFE.MostraPreview := True;
       DM.ACBrNFe_NFCE.NotasFiscais.Imprimir;
    end;
 end;

 myResult := mrOk;
 Result := True;
end;
 

  • Consultores
Postado

quando postar trecho de código longo anexe como arquivo. pois para um tópico ele fica ruim até mesmo pra ler

 

Consultora ACBr Pro

Juliomar Marchetti

Ajude o Projeto ACBr crescer - Seja Pro

discord: juliomar
telegram: juliomar
e-mail: [email protected]
http://www.juliomarmarchetti.com.br

 

MVP_NewLogo_100x100_Transparent-02.png
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 !!

  • Moderadores
Postado
26 minutos atrás, Wellington umuarama disse:

gera nfce.txt inseri em txt  mais nao envia nfce de maneira alguma tudo parado  ...   Não foi possível enviar a Nota Fiscal Nº: xxx. Nenhuma adicionada para ser emitida

A mensagem vem já do início do método de envio:

if DM.ACBrNFe_NFe.NotasFiscais.Count <= 0 then
  raise Exception.Create('Nenhuma adicionada para ser emitida.');

Ou seja, não foi adicionada a nota no componente.

Isso porque você está adicionando a nota em outro ACBrNFe:

  DM.ACBrNFe_NFCE.NotasFiscais.Clear;
  with DM.ACBrNFe_NFCE.NotasFiscais.Add.NFe do
  begin

 

Equipe ACBr BigWings
Ajude o Projeto ACBr crescer - Assine o SAC

Projeto ACBr

 

 

  • Consultores
Postado
2 horas atrás, Max DB disse:

continua o erro enviei um txt da uma olhada

erronfcee.png

gera nfce.rar 5.63 kB · 2 downloads

olhe essa sugestão que mandei em anexo

use assim

var
  Gerador: TNFCeGerador;
begin
  Gerador := TNFCeGerador.Create(DM.ACBrNFe_NFCE, DM);
  try
    if Gerador.GerarNFCe then
      ShowMessage('NFC-e gerada com sucesso!')
    else
      ShowMessage('Falha ao gerar NFC-e');
  finally
    Gerador.Free;
  end;

 

uNFCeGerador.7z

 

Consultora ACBr Pro

Juliomar Marchetti

Ajude o Projeto ACBr crescer - Seja Pro

discord: juliomar
telegram: juliomar
e-mail: [email protected]
http://www.juliomarmarchetti.com.br

 

MVP_NewLogo_100x100_Transparent-02.png
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 !!

  • Consultores
Postado
2 horas atrás, Wellington umuarama disse:

deu certo uauauau   equipe e colaboradores do acbr vcs sao show

Sempre separe seu código. 

aplique Clean Code nele, use SOLID

 

Consultora ACBr Pro

Juliomar Marchetti

Ajude o Projeto ACBr crescer - Seja Pro

discord: juliomar
telegram: juliomar
e-mail: [email protected]
http://www.juliomarmarchetti.com.br

 

MVP_NewLogo_100x100_Transparent-02.png
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 !!

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

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 conta

Entrar

Já tem uma conta? Faça o login.

Entrar Agora
×
×
  • Criar Novo...

Informação Importante

Colocamos cookies em seu dispositivo para ajudar a tornar este site melhor. Você pode ajustar suas configurações de cookies, caso contrário, assumiremos que você está bem para continuar.