Exemplo n.º 1
0
        internal static MDFe ObterParaDAMDFE(HttpContext context, string chaveAcesso)
        {
            MDFe mdfe = new MDFe();

            Glass.Data.Model.ManifestoEletronico _manifestoEletronico = Glass.Data.DAL.ManifestoEletronicoDAO.Instance.ObterPelaChaveAcesso(chaveAcesso);

            // Verifica se o MDFe existe
            if (!File.Exists(Utils.GetMDFeXmlPathInternal(context) + chaveAcesso + "-mdfe.xml"))
            {
                throw new Exception("Arquivo do MDFe não encontrado.");
            }

            // Carrega o arquivo XML
            XmlDocument xmlMDFe = new XmlDocument();

            xmlMDFe.Load(Utils.GetMDFeXmlPathInternal(context) + chaveAcesso + "-mdfe.xml");
            XmlElement xmlInfMDFe = ObterXmlInfMDFe(context, xmlMDFe);

            #region Busca dados do XML do MDFe

            #region IDENTIFICAÇÃO MDF-e

            mdfe.ChaveAcesso = Formatacoes.MascaraChaveAcessoNFe(chaveAcesso);
            mdfe.Modelo      = GetNodeValue(xmlInfMDFe, "ide", "mod");
            mdfe.Serie       = GetNodeValue(xmlInfMDFe, "ide", "serie");
            mdfe.TipoEmissao = GetNodeValue(xmlInfMDFe, "ide", "tpEmis") == "1" ? "Normal" : "Contingência";
            mdfe.NumeroManifestoEletronico = GetNodeValue(xmlInfMDFe, "ide", "nMDF");
            mdfe.TipoAmbiente = Conversoes.StrParaInt(GetNodeValue(xmlInfMDFe, "ide", "tpAmb"));
            mdfe.DataEmissao  = DateTime.Parse(GetNodeValue(xmlInfMDFe, "ide", "dhEmi")).ToString("dd/MM/yyyy HH:mm");
            mdfe.UFInicio     = GetNodeValue(xmlInfMDFe, "ide", "UFIni");
            mdfe.UFFim        = GetNodeValue(xmlInfMDFe, "ide", "UFFim");

            //Protocolo de autorização
            if (xmlMDFe["MDFe"] != null && xmlMDFe["MDFe"]["infProt"] != null) // Sql montado no sistema
            {
                mdfe.ProtocoloAutorizacao = GetNodeValue(xmlMDFe["MDFe"], "infProt", "nProt") + " " +
                                            DateTime.Parse(GetNodeValue(xmlMDFe["MDFe"], "infProt", "dhRecbto")).ToString("dd/MM/yyyy HH:mm");
            }
            else if (xmlMDFe["mdfeProc"] != null && xmlMDFe["mdfeProc"]["protMDFe"] != null) // Sql montado na receita
            {
                mdfe.ProtocoloAutorizacao = GetNodeValue(xmlMDFe["mdfeProc"]["protMDFe"], "infProt", "nProt") + " " +
                                            DateTime.Parse(GetNodeValue(xmlMDFe["mdfeProc"]["protMDFe"], "infProt", "dhRecbto")).ToString("dd/MM/yyyy HH:mm");
            }

            if (mdfe.TipoEmissao == "Contingência" && string.IsNullOrWhiteSpace(mdfe.ProtocoloAutorizacao))
            {
                mdfe.ProtocoloAutorizacao = "Impressão em contingência. Obrigatória a autorização em 168 horas após esta emissão. ("
                                            + mdfe.DataEmissao + ")";
            }

            // Emitente
            mdfe.RazaoSocialEmitente = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfMDFe, "emit", "xNome"));
            mdfe.EnderecoEmitente    = Formatacoes.RestauraStringDocFiscal(ObterEnderecoEmitente(xmlInfMDFe));
            mdfe.CNPJEmitente        = Formatacoes.MascaraCnpj(GetNodeValue(xmlInfMDFe, "emit", "CNPJ"));
            mdfe.InscEstEmitente     = GetNodeValue(xmlInfMDFe, "emit", "IE");

            #endregion

            #region INFORMAÇÕES DO MODAL RODOVIARIO

            if (xmlInfMDFe["infModal"]["rodo"] != null)
            {
                var _RNTRC = string.Empty;

                XmlElement xmlRodo = xmlInfMDFe["infModal"]["rodo"];

                #region Grupo de informações para Agência Reguladora

                if (xmlRodo["infANTT"] != null)
                {
                    var _CIOTs                    = new List <string>();
                    var _ResponsaveisCIOT         = new List <string>();
                    var _CNPJsResponsaveisPedagio = new List <string>();
                    var _CNPJsFornecedoresPedagio = new List <string>();
                    var _NumerosCompraPedagio     = new List <string>();

                    _RNTRC = GetNodeValue(xmlRodo, "infANTT", "RNTRC");

                    var xmlListainfCIOT = xmlRodo["infANTT"].GetElementsByTagName("infCIOT");
                    foreach (XmlElement infCIOT in xmlListainfCIOT)
                    {
                        _CIOTs.Add(infCIOT["CIOT"].InnerXml);
                        _ResponsaveisCIOT.Add(Formatacoes.MascaraCnpj(infCIOT["CNPJ"].InnerXml));
                    }

                    if (xmlRodo["infANTT"]["valePed"] != null)
                    {
                        var xmlListaValePedagio = xmlRodo["infANTT"]["valePed"].GetElementsByTagName("disp");
                        foreach (XmlElement disp in xmlListaValePedagio)
                        {
                            _CNPJsResponsaveisPedagio.Add(disp["CNPJPg"] != null ? Formatacoes.MascaraCnpj(disp["CNPJPg"].InnerXml) : mdfe.CNPJEmitente);
                            _CNPJsFornecedoresPedagio.Add(Formatacoes.MascaraCnpj(disp["CNPJForn"].InnerXml));
                            _NumerosCompraPedagio.Add(disp["nCompra"].InnerXml);
                        }
                    }

                    mdfe.CIOTs                    = string.Join("\n", _CIOTs);
                    mdfe.ResposaveisCIOTs         = string.Join("\n", _ResponsaveisCIOT);
                    mdfe.CNPJsResponsaveisPedagio = string.Join("\n", _CNPJsResponsaveisPedagio);
                    mdfe.CNPJsFornecedoresPedagio = string.Join("\n", _CNPJsFornecedoresPedagio);
                    mdfe.NumerosCompraPedagio     = string.Join("\n", _NumerosCompraPedagio);
                }

                #endregion

                #region Veículos e Condutores

                var _placasVeiculos  = new List <string>();
                var _RNTRCsVeiculos  = new List <string>();
                var _CPFsCondutores  = new List <string>();
                var _NomesCondutores = new List <string>();

                // Dados do Veículo Tração
                _placasVeiculos.Add(GetNodeValue(xmlRodo, "veicTracao", "placa"));
                if (xmlRodo["veicTracao"]["prop"] != null)
                {
                    _RNTRCsVeiculos.Add(GetNodeValue(xmlRodo, "veicTracao/prop", "RNTRC"));
                }
                else
                {
                    _RNTRCsVeiculos.Add(_RNTRC);
                }

                // Informações do(s) Condutor(s) do veículo
                var xmlListaCondutor = xmlRodo["veicTracao"].GetElementsByTagName("condutor");
                foreach (XmlElement condutor in xmlListaCondutor)
                {
                    _CPFsCondutores.Add(Formatacoes.MascaraCpf(condutor["CPF"].InnerXml));
                    _NomesCondutores.Add(condutor["xNome"].InnerXml);
                }

                // Dados do Veículo Reboque
                if (xmlRodo["veicReboque"] != null)
                {
                    var xmlListaVeicReboque = xmlRodo.GetElementsByTagName("veicReboque");
                    foreach (XmlElement veicReboque in xmlListaVeicReboque)
                    {
                        _placasVeiculos.Add(veicReboque["placa"].InnerXml);
                        if (xmlRodo["prop"] != null)
                        {
                            _RNTRCsVeiculos.Add(GetNodeValue(veicReboque, "prop", "RNTRC"));
                        }
                        else
                        {
                            _RNTRCsVeiculos.Add(_RNTRC);
                        }
                    }
                }

                mdfe.PlacasVeiculos  = string.Join("\n", _placasVeiculos);
                mdfe.RNTRCsVeiculos  = string.Join("\n", _RNTRCsVeiculos);
                mdfe.CPFsCondutores  = string.Join("\n", _CPFsCondutores);
                mdfe.NomesCondutores = string.Join("\n", _NomesCondutores);

                #endregion
            }

            #endregion

            #region INFORMAÇÕES DOS DOCUMENTOS FISCAIS VINCULADOS

            if (mdfe.TipoEmissao == "Contingência" && xmlInfMDFe["infDoc"] != null)
            {
                var _documentosVinculados  = new List <string>();
                var xmlListaInfMunDescarga = xmlInfMDFe["infDoc"].GetElementsByTagName("infMunDescarga");
                foreach (XmlElement infMunDescarga in xmlListaInfMunDescarga)
                {
                    // Se Tipo Emitente for Transportador de carga própria
                    if (GetNodeValue(xmlInfMDFe, "ide", "tpEmit") == "2")
                    {
                        var xmlListaInfNFe = infMunDescarga.GetElementsByTagName("infNFe");
                        foreach (XmlElement infNFe in xmlListaInfNFe)
                        {
                            _documentosVinculados.Add("NFe: " + infNFe["chNFe"].InnerXml);
                        }
                    }
                    else
                    {
                        var xmlListaInfCTe = infMunDescarga.GetElementsByTagName("infCTe");
                        foreach (XmlElement infCTe in xmlListaInfCTe)
                        {
                            _documentosVinculados.Add("CTe: " + infCTe["chCTe"].InnerXml);
                        }
                    }
                }

                mdfe.DocumentosFiscaisVinculados = string.Join("\n", _documentosVinculados);
            }

            #endregion

            #region TOTALIZADORES DA CARGA

            mdfe.QuantidadeCTe  = string.IsNullOrWhiteSpace(GetNodeValue(xmlInfMDFe, "tot", "qCTe")) ? "0" : GetNodeValue(xmlInfMDFe, "tot", "qCTe");
            mdfe.QuantidadeNFe  = string.IsNullOrWhiteSpace(GetNodeValue(xmlInfMDFe, "tot", "qNFe")) ? "0" : GetNodeValue(xmlInfMDFe, "tot", "qNFe");
            mdfe.ValorCarga     = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfMDFe, "tot", "vCarga"), 2);
            mdfe.CodigoUnidade  = GetNodeValue(xmlInfMDFe, "tot", "cUnid").StrParaInt() == 1 ? "KG" : "TON";
            mdfe.PesoTotalCarga = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfMDFe, "tot", "qCarga"), 4);

            #endregion

            #region INFORMAÇÕES ADICIONAIS

            mdfe.InformacoesAdicionaisFisco = GetNodeValue(xmlInfMDFe, "infAdic", "infAdFisco");
            mdfe.InformacoesComplementares  = GetNodeValue(xmlInfMDFe, "infAdic", "infCpl");

            #endregion

            #endregion

            return(mdfe);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Busca XML da NFe passada para imprimir o DANFE
        /// </summary>
        /// <param name="idNFe"></param>
        /// <returns></returns>
        internal NFe GetForDanfe(HttpContext context, string chaveAcesso)
        {
            NFe nfe = new NFe();

            // Verifica se NFe existe
            if (!File.Exists(Utils.GetNfeXmlPathInternal(context) + chaveAcesso + "-nfe.xml"))
            {
                throw new Exception("Arquivo da NF-e não encontrado.");
            }

            // Busca arquivo XML da NFe
            XmlDocument xmlNFe = new XmlDocument();

            xmlNFe.Load(Utils.GetNfeXmlPathInternal(context) + chaveAcesso + "-nfe.xml");
            XmlElement xmlInfNFe = GetXmlInfNFe(context, xmlNFe);

            var versao = xmlNFe["nfeProc"] != null ?
                         xmlNFe["nfeProc"]["NFe"]["infNFe"].GetAttribute("versao") :
                         xmlNFe["NFe"]["infNFe"].GetAttribute("versao");

            #region Busca dados do XML da NF-e

            // Cabeçalho
            nfe.RazaoSocialEmit = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "emit", "xNome"));
            nfe.NumeroNfe       = Formatacoes.MascaraNroNFe(GetNodeValue(xmlInfNFe, "ide", "nNF"));
            nfe.SerieNfe        = GetNodeValue(xmlInfNFe, "ide", "serie");
            nfe.ModeloNfe       = GetNodeValue(xmlInfNFe, "ide", "mod");
            nfe.EnderecoEmit    = Formatacoes.RestauraStringDocFiscal(GetEnderecoEmit(xmlInfNFe));
            nfe.TipoNfe         = GetNodeValue(xmlInfNFe, "ide", "tpNF");
            nfe.TipoAmbiente    = Glass.Conversoes.StrParaInt(GetNodeValue(xmlInfNFe, "ide", "tpAmb"));
            nfe.ChaveAcesso     = Formatacoes.MascaraChaveAcessoNFe(chaveAcesso);
            nfe.UfNfe           = Glass.Conversoes.StrParaInt(GetNodeValue(xmlInfNFe, "ide", "cUF"));
            nfe.TipoEmissao     = Glass.Conversoes.StrParaInt(GetNodeValue(xmlInfNFe, "ide", "tpEmis"));

            // Dados da NF-e
            nfe.NatOperacao   = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "ide", "natOp"));
            nfe.InscEstEmit   = GetNodeValue(xmlInfNFe, "emit", "IE");
            nfe.InscEstStEmit = GetNodeValue(xmlInfNFe, "emit", "IEST");
            nfe.CnpjEmit      = Formatacoes.MascaraCnpj(GetNodeValue(xmlInfNFe, "emit", "CNPJ"));

            if (xmlNFe["NFe"] != null && xmlNFe["NFe"]["infProt"] != null) // Sql montado no sistema
            {
                nfe.ProtAutorizacao = GetNodeValue(xmlNFe["NFe"], "infProt", "nProt") + " " + GetNodeValue(xmlNFe["NFe"], "infProt", "dhRecbto").Replace("T", " ");
            }
            else if (xmlNFe["nfeProc"] != null && xmlNFe["nfeProc"]["protNFe"] != null) // Sql montado na receita
            {
                nfe.ProtAutorizacao = GetNodeValue(xmlNFe["nfeProc"]["protNFe"], "infProt", "nProt") + " " + GetNodeValue(xmlNFe["nfeProc"]["protNFe"], "infProt", "dhRecbto").Replace("T", " ");
            }

            // Preencher a partir do banco até mudarmos para baixar o xml direto da receita com o protocolo, caso a nota fique sem após a autorização
            if (string.IsNullOrEmpty(nfe.ProtAutorizacao))
            {
                nfe.ProtAutorizacao = DAL.NotaFiscalDAO.Instance.ObtemValorCampo <string>("NumProtocolo", "ChaveAcesso=?chaveAcesso", new GDA.GDAParameter("?chaveAcesso", chaveAcesso));
            }

            // Esta verificação não pode ser feita ao pré-visualizar nota
            //if (String.IsNullOrEmpty(nfe.ProtAutorizacao))
            //    throw new Exception("Nota sem protocolo.");

            // Destinatário/Remetente
            nfe.RazaoSocialRemet = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "dest", "xNome"));
            nfe.CpfCnpjRemet     = Formatacoes.MascaraCpfCnpj(GetNodeValue(xmlInfNFe, "dest", "CNPJ") + GetNodeValue(xmlInfNFe, "dest", "CPF"));
            nfe.EnderecoRemet    = Formatacoes.RestauraStringDocFiscal((GetNodeValue(xmlInfNFe, "dest/enderDest", "xLgr") + ", " + GetNodeValue(xmlInfNFe, "dest/enderDest", "nro") + " " + GetNodeValue(xmlInfNFe, "dest/enderDest", "xCpl")));
            nfe.BairroRemet      = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "dest/enderDest", "xBairro"));
            nfe.CepRemet         = GetNodeValue(xmlInfNFe, "dest/enderDest", "CEP");
            nfe.MunicipioRemet   = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "dest/enderDest", "xMun"));
            nfe.FoneRemet        = GetNodeValue(xmlInfNFe, "dest/enderDest", "fone");
            nfe.UfRemet          = GetNodeValue(xmlInfNFe, "dest/enderDest", "UF");
            nfe.InscEstRemet     = GetNodeValue(xmlInfNFe, "dest", "IE");
            try
            {
                nfe.DataEmissao         = DateTime.Parse(GetNodeValue(xmlInfNFe, "ide", "dhEmi")).ToString("dd/MM/yyyy HH:mm:ss");
                nfe.DataEmissaoOriginal = GetNodeValue(xmlInfNFe, "ide", "dhEmi");
            }
            catch { }
            try
            {
                nfe.DataEntradaSaida = DateTime.Parse(GetNodeValue(xmlInfNFe, "ide", "dhSaiEnt")).ToString("dd/MM/yyyy HH:mm");
            }
            catch { }

            // Fatura/Duplicatas
            if (DAL.NotaFiscalDAO.Instance.ObtemFormaPagto(chaveAcesso) == Model.NotaFiscal.FormaPagtoEnum.AVista) // Pagamento à vista
            {
                string nFat  = GetNodeValue(xmlInfNFe, "cobr/fat", "nFat");
                string vOrig = GetNodeValue(xmlInfNFe, "cobr/fat", "vOrig");
                string vLiq  = GetNodeValue(xmlInfNFe, "cobr/fat", "vLiq");

                nfe.Fatura = "Pagamento à vista / Num.: " + nFat + " / V. Orig.: " + vOrig.Replace('.', ',') + " / V. Liq.: " + vLiq.Replace('.', ',');
            }
            else if (xmlInfNFe["cobr"] != null) // Pagamento à prazo/outros
            {
                // Busca tags com duplicatas
                XmlNodeList xmlListDup = xmlInfNFe["cobr"].GetElementsByTagName("dup");

                string nFat = xmlInfNFe["cobr"]["fat"] != null?GetNodeValue(xmlInfNFe, "cobr/fat", "nFat") : string.Empty;

                foreach (XmlElement xmlDup in xmlListDup)
                {
                    nfe.Fatura +=
                        "Num.: " + nFat + "-" + xmlDup["nDup"].InnerXml +
                        " Venc.: " + DateTime.Parse(xmlDup["dVenc"].InnerXml).ToString("dd/MM/yyyy") +
                        " Valor: " + xmlDup["vDup"].InnerXml.Replace('.', ',') + "   /   ";
                }

                if (nfe.Fatura != null)
                {
                    nfe.Fatura = nfe.Fatura.TrimEnd(' ').TrimEnd('/');
                }
            }

            // Cálculo do Imposto
            nfe.BcIcms         = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vBC"), 2);
            nfe.VlrIcms        = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vICMS"), 2);
            nfe.BcIcmsSt       = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vBCST"), 2);
            nfe.VlrIcmsSt      = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vST"), 2);
            nfe.VlrFrete       = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vFrete"), 2);
            nfe.VlrSeguro      = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vSeg"), 2);
            nfe.Desconto       = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vDesc"), 2);
            nfe.OutrasDespesas = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vOutro"), 2);
            nfe.VlrIpi         = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vIPI"), 2);
            nfe.VlrTotalProd   = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vProd"), 2);
            nfe.VlrTotalNota   = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ICMSTot", "vNF"), 2);

            // Transportador/Volumes transportados
            string modFrete = GetNodeValue(xmlInfNFe, "transp", "modFrete");
            nfe.RazaoSocialTransp = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "transp/transporta", "xNome"));
            nfe.CpfCnpjTransp     = Formatacoes.MascaraCpfCnpj(GetNodeValue(xmlInfNFe, "transp/transporta", "CNPJ") + GetNodeValue(xmlInfNFe, "transp/transporta", "CPF"));

            switch ((Model.ModalidadeFrete)(modFrete.StrParaInt()))
            {
            case Model.ModalidadeFrete.ContaDoRemetente: nfe.FretePorConta = "0 - Rem (CIF)"; break;

            case Model.ModalidadeFrete.ContaDoDestinatario: nfe.FretePorConta = "1 - Dest (FOB)"; break;

            case Model.ModalidadeFrete.ContaDeTerceiros: nfe.FretePorConta = "2 - Terceiros"; break;

            case Model.ModalidadeFrete.ProprioContaDoRemetente: nfe.FretePorConta = "3 - Prop Rem"; break;

            case Model.ModalidadeFrete.ProprioContaDoDestinatario: nfe.FretePorConta = "4 - Prop Dest"; break;

            case Model.ModalidadeFrete.SemTransporte: nfe.FretePorConta = "9 - Sem Ocorr"; break;

            default: break;
            }

            nfe.CodAntt         = GetNodeValue(xmlInfNFe, "transp/veicTransp", "RNTC");
            nfe.PlacaVeiculo    = GetNodeValue(xmlInfNFe, "transp/veicTransp", "placa");
            nfe.UfVeiculo       = GetNodeValue(xmlInfNFe, "transp/veicTransp", "UF");
            nfe.EnderecoTransp  = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "transp/transporta", "xEnder"));
            nfe.MunicipioTransp = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "transp/transporta", "xMun"));
            nfe.UfTransp        = GetNodeValue(xmlInfNFe, "transp/transporta", "UF");
            nfe.InscEstTransp   = GetNodeValue(xmlInfNFe, "transp/transporta", "IE");
            nfe.QtdTransp       = GetNodeValue(xmlInfNFe, "transp/vol", "qVol");
            nfe.EspecieTransp   = GetNodeValue(xmlInfNFe, "transp/vol", "esp");
            nfe.MarcaTransp     = GetNodeValue(xmlInfNFe, "transp/vol", "marca");
            nfe.NumeracaoTransp = GetNodeValue(xmlInfNFe, "transp/vol", "nVol");
            nfe.PesoLiquido     = GetNodeValue(xmlInfNFe, "transp/vol", "pesoL");
            nfe.PesoBruto       = GetNodeValue(xmlInfNFe, "transp/vol", "pesoB");

            // Cálculo do ISSQN
            nfe.InscMunicIssqn        = GetNodeValue(xmlInfNFe, "emit/enderEmit", "IM");
            nfe.VlrTotalServicosIssqn = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ISSQNtot", "vServ"), 2);
            nfe.BcIssqn  = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ISSQNtot", "vBC"), 2);
            nfe.VlrIssqn = Formatacoes.FormataValorDecimal(GetNodeValue(xmlInfNFe, "total/ISSQNtot", "vISS"), 2);

            // Dados adicionais
            nfe.InformacoesCompl = (!string.IsNullOrEmpty(GetNodeValue(xmlInfNFe, "infAdic", "infAdFisco")) ? GetNodeValue(xmlInfNFe, "infAdic", "infAdFisco") + "\r\n" : "") +
                                   (!string.IsNullOrEmpty(GetNodeValue(xmlInfNFe, "infAdic", "infCpl")) ? Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlInfNFe, "infAdic", "infCpl")) + "\r\n" : "") +
                                   (ConfigNFe.TipoAmbiente == ConfigNFe.TipoAmbienteNfe.Producao || nfe.ModeloNfe == "65" ? string.Empty : "SEM VALOR FISCAL.");

            // Dados de controle
            nfe.Crt = GetNodeValue(xmlInfNFe, "emit", "CRT");

            //NFC-e
            if (nfe.ModeloNfe == "65")
            {
                var xmlSignature = GetXmlSignature(context, xmlNFe);
                if (xmlSignature != null)
                {
                    nfe.DigestValue = GetNodeValue(xmlSignature, "SignedInfo/Reference", "DigestValue");

                    nfe.LinkQrCode = GetXmlInfNFeSupl(context, xmlNFe)["qrCode"].InnerText;
                    nfe.UrlChave   = GetXmlInfNFeSupl(context, xmlNFe)["urlChave"].InnerText;
                }
            }

            #endregion

            return(nfe);
        }