Ir para conteúdo
  • Cadastre-se

Leonardo.Coelho

Membros Pro
  • Total de ítens

    32
  • Registro em

  • Última visita

Sobre Leonardo.Coelho

Leonardo.Coelho's Achievements

Explorer

Explorer (4/14)

  • Collaborator Rare
  • Conversation Starter
  • First Post
  • Week One Done
  • One Month Later

Recent Badges

2

Reputação

3

Community Answers

  1. Mesmo problema por aqui, para São Paulo e outros municípios também
  2. Olá ao tentar realizar uma emissão para o município de Sorriso que utiliza o provedor Agile eu recebo o retorno Descricao=Erro de Validação: --> 1871 - Element '{http://www.agili.com.br/nfse_v_1.00.xsd}ListaServico': Missing child element(s). Expected is ( {http://www.agili.com.br/nfse_v_1.00.xsd}DadosServico ). Meu xml está realmente sendo gerado sem essa tag: <ListaServico> <DadosServico> <Discriminacao>TESTE</Discriminacao> <CodigoCnae>45.3.0-7.03</CodigoCnae> <Quantidade>1.0000</Quantidade> <ValorServico>10.00</ValorServico> <ValorDesconto>0.00</ValorDesconto> </DadosServico> </ListaServico> Estou preenchendo da seguinte forma: data["IdentificacaoNFSe"]["Numero"] = nfse.Cod_NFSe.ToString(); data["IdentificacaoNFSe"]["CodigoVerificacao"] = nfse.Cod_Verificador ?? ""; data["IdentificacaoRps"]["Producao"] = (configNFSe.Ambiente == 2) ? "1" : "2"; data["IdentificacaoRps"]["Status"] = "1"; data["IdentificacaoRps"]["OutrasInformacoes"] = ""; data["IdentificacaoRps"]["TipoTributacaoRps"] = "T"; data["IdentificacaoRps"]["SeriePrestacao"] = "99"; data["IdentificacaoRps"]["Numero"] = nfse.Cod_NF.ToString(); data["IdentificacaoRps"]["Serie"] = "1"; data["IdentificacaoRps"]["Tipo"] = "1"; data["IdentificacaoRps"]["DataEmissao"] = nfse.Dta_Cad.ToString("dd/MM/yyyy"); data["IdentificacaoRps"]["Competencia"] = nfse.Dta_Cad.ToString("dd/MM/yyyy"); data["IdentificacaoRps"]["NaturezaOperacao"] = nfse.Tributacao == (int)NFSeUtil.TipoTributacao.DentroDoMunicipio ? "01" : "02"; data["IdentificacaoRps"]["PercentualCargaTributariaMunicipal"] = nfse.TF_PctMunicipal.ToString(); data["IdentificacaoRps"]["ValorCargaTributariaMunicipal"] = (nfse.Vlr_Total) * (decimal)(nfse.TF_PctMunicipal) / 100 + ""; data["IdentificacaoRps"]["PercentualCargaTributariaEstadual"] = nfse.TF_PctEstadual.ToString(); data["IdentificacaoRps"]["ValorCargaTributariaEstadual"] = (nfse.Vlr_Total) * (decimal)(nfse.TF_PctEstadual) / 100 + ""; data["IdentificacaoRps"]["verAplic"] = ""; // Preencher a seção [Prestador] string Enquandramento = ""; switch (prestador.Enquadramento) { case 1: Enquandramento = "7"; break; case 2: Enquandramento = "8"; break; case 3: Enquandramento = "9"; break; case 4: Enquandramento = ""; break; } ; data["Prestador"]["Regime"] = "2"; // Verificar de acordo com o tipo da empresa/ alguns provedores validam outros não data["Prestador"]["OptanteSN"] = prestador.Enquadramento == 9 ? "1" : "2"; data["Prestador"]["IncentivadorCultural"] = "2"; data["Prestador"]["CNPJ"] = prestador.Nro_Docto; data["Prestador"]["InscricaoMunicipal"] = prestador.CCM_NIT; data["Prestador"]["NIF"] = ""; data["Prestador"]["CAEPF"] = prestador.IE_RG; data["Prestador"]["RazaoSocial"] = NormalizarNomeEmpresa(prestador.Nome_Empresa); data["Prestador"]["NomeFantasia"] = NormalizarNomeEmpresa(prestador.Fantasia); data["Prestador"]["Logradouro"] = prestador.Tipo_End + " " + prestador.Endereco; data["Prestador"]["Numero"] = prestador.End_Nro; data["Prestador"]["Complemento"] = prestador.Complemento; data["Prestador"]["Bairro"] = prestador.Bairro; data["Prestador"]["CodigoMunicipio"] = prestador.Cod_Municipio.ToString(); data["Prestador"]["UF"] = prestador.UF; data["Prestador"]["CodigoPais"] = "1058"; data["Prestador"]["xPais"] = "Brasil"; data["Prestador"]["CEP"] = prestador.Cep; data["Prestador"]["Telefone"] = prestador.Fone1; data["Prestador"]["Email"] = prestador.Email; data["Tomador"]["Tipo"] = (nfse.Tomador.Tipo_Docto == 1) ? "2" : nfse.Tributacao == (int)NFSeUtil.TipoTributacao.DentroDoMunicipio ? "03" : "04"; data["Tomador"]["CNPJCPF"] = nfse.Tomador.Nro_Docto; data["Tomador"]["InscricaoMunicipal"] = nfse.Tomador.CCM_NIT; data["Tomador"]["NIF"] = ""; data["Tomador"]["CAEPF"] = nfse.Tomador.Nro_Docto; data["Tomador"]["InscricaoEstadual"] = nfse.Tomador.IE_RG; data["Tomador"]["RazaoSocial"] = NormalizarNomeEmpresa(nfse.Tomador.Nome_Empresa); data["Tomador"]["TipoLogradouro"] = nfse.Tomador.Tipo_End; data["Tomador"]["Logradouro"] = nfse.Tomador.Endereco; data["Tomador"]["Numero"] = nfse.Tomador.End_Nro; data["Tomador"]["Complemento"] = nfse.Tomador.Complemento; data["Tomador"]["Bairro"] = nfse.Tomador.Bairro; data["Tomador"]["CodigoMunicipio"] = nfse.Tomador.Cod_Municipio.ToString(); data["Tomador"]["xMunicipio"] = nfse.Tomador.Municipio; data["Tomador"]["UF"] = nfse.Tomador.UF; data["Tomador"]["CodigoPais"] = "1058"; data["Tomador"]["CEP"] = nfse.Tomador.Cep; data["Tomador"]["xPais"] = "Brasil"; data["Tomador"]["Telefone"] = nfse.Tomador.Fone1; data["Tomador"]["Email"] = nfse.Tomador.Email; data["Tomador"]["AtualizaTomador"] = "1"; data["Tomador"]["TomadorExterior"] = "2"; data["Servico"]["ItemListaServico"] = nfse.Cod_Servico.ToString(); data["Servico"]["CodigoCnae"] = nfse.Cod_Atividade.ToString().Substring(0, Math.Min(7, nfse.Cod_Atividade.ToString().Length)); data["Servico"]["CodigoTributacaoMunicipio"] = nfse.Cod_Atividade.ToString(); data["Servico"]["Discriminacao"] = formatarDiscriminacaoServicosRPS(nfse); data["Servico"]["CodigoMunicipio"] = prestador.Cod_Municipio.ToString(); data["Servico"]["CodigoPais"] = "1058"; data["Servico"]["ExigibilidadeISS"] = (nfse.Deducao_ISS == 0 && nfse.ExcFiscal_ISS == 1) ? "3" : "1"; data["Servico"]["MunicipioIncidencia"] = prestador.Cod_Municipio.ToString(); data["Servico"]["UFPrestacao"] = prestador.UF; data["Servico"]["ResponsavelRetencao"] = ""; data["Servico"]["Operacao"] = "A"; data["Servico"]["Tributacao"] = "C"; data["Servico"]["CodigoNBS"] = nfse.TF_Codigo.ToString(); data["Servico"]["ValorCargaTributaria"] = Math.Round((decimal)(nfse.TF_PctImportado + nfse.TF_PctFederal + nfse.TF_PctEstadual + nfse.TF_PctMunicipal) * nfse.Vlr_Total, 2).ToString("000000000000000"); data["Servico"]["PercentualCargaTributaria"] = ((float)(nfse.TF_PctImportado + nfse.TF_PctFederal + nfse.TF_PctEstadual + nfse.TF_PctMunicipal) * 100).ToString("00000"); data["Servico"]["FonteCargaTributaria"] = nfse.TF_Fonte; Só não identifiquei como fazer o preenchimento das tags faltando. Agili.xml
  3. Estou enfrentando o mesmo problema utilizando a lib, mesmo removendo completamente os indicadores desse tributo o xml gerado inclui a tag com o valor zerado causando a rejeição da nfse, mesmo utilizando as versões mais atualizadas disponibilizadas ontem o comportamento permanece. Utilizo a lib via integração com C#; um exemplo do preenchimento das classes. Agradeceria se alguém tivesse alguma recomendação ou sugestão para resolução. using ACBrLib; using ACBrLib.Core; using ACBrLib.Core.DFe; using ACBrLib.Core.Extensions; using ACBrLib.Core.NFSe; using ACBrLib.NFSe; using NFSe.WebServices.Provedores; using NFSe.WebServices.Provedores.PadraoNacional; using OpenAC.Net.Core.Extensions; using OpenAC.Net.DFe.Core.Common; using OpenAC.Net.NFSe; using OpenAC.Net.NFSe.Configuracao; using OpenAC.Net.NFSe.Nota; using OpenAC.Net.NFSe.Providers; using Sigo.NFSe.DAO; using Sigo.NFSe.Models; using Sigo.NFSe.Util; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Mail; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; using System.Web; using System.Xml.Linq; using System.Xml.Serialization; using static System.Net.Mime.MediaTypeNames; namespace Sigo.NFSe.WebServices.Provedores.PadraoNacional { class PadraoNacional : AbsProvedor, IProvedor { private ACBrNFSe ACBrNFSe; public PadraoNacional() { } public object GerarPdfNFSe(Prestador prestador, Sigo.NFSe.Models.NFSe nFSe) { string caminhoNotaFsical = ""; return null; } public object EmitirLoteRPS(Prestador prestador, List<Sigo.NFSe.Models.NFSe> listaRPS, NFSeConfig configNFSe, SigoCFG sigoCFG, PrestadorCerts PessCerts) { string caminhoAplicacao = AppDomain.CurrentDomain.BaseDirectory; try { ACBrNFSe = new ACBrNFSe(caminhoAplicacao + "ACBrLib.ini"); //ACBrNFSe = new ACBrNFSe("[Memory]"); ACBrNFSe.Config.Principal.CodificacaoResposta = CodResposta.ANSI; // ACBrNFSe.CarregarINI("") } catch (Exception) { throw; } ACBrNFSe.Config.DFe.UF = "SP"; ACBrNFSe.Config.SSLType = SSLType.LT_TLSv1_2; ACBrNFSe.Config.Timeout = 5000; ACBrNFSe.Config.Ambiente = configNFSe.Ambiente == 2 ? TipoAmbiente.taProducao : TipoAmbiente.taHomologacao; ACBrNFSe.Config.Visualizar = false; ACBrNFSe.Config.SalvarWS = true; ACBrNFSe.Config.AdicionarLiteral = false; ACBrNFSe.Config.RetirarAcentos = false; ACBrNFSe.Config.PathSalvar = "D:\\Sigo\\arquivos\\" + sigoCFG.NomeDB + "\\NFSeTemp";//configNFSe.Caminhowroot + "\\NFSeTemp"; ACBrNFSe.Config.ExibirErroSchema = true; ACBrNFSe.Config.FormaEmissao = ACBrLib.Core.DFe.TipoEmissao.teNormal; //@"C:\Users\Developer\Documents\NFSe\Schemas"; ACBrNFSe.Config.MontarPathSchema = false; // ACBrNFSe.Config.PathSchemas = "C:\\Users\\Developer\\Documents\\NFSe\\Schemas"; ACBrNFSe.Config.IniServicos = caminhoAplicacao + "ACBrNFSeXServicos.ini"; ACBrNFSe.Config.ConsultaLoteAposEnvio = false; ACBrNFSe.Config.ConsultaAposCancelar = false; ACBrNFSe.Config.LayoutNFSe = LayoutNFSe.lnfsPadraoNacionalv1; // ACBrNFSe.Config. ACBrNFSe.Config.IdentarXML = false; //Proxy ACBrNFSe.Config.Proxy.Servidor = ""; ACBrNFSe.Config.Proxy.Porta = ""; ACBrNFSe.Config.Proxy.Usuario = ""; ACBrNFSe.Config.Proxy.Senha = ""; ACBrNFSe.Config.PathNFSe = "D:\\Sigo\\arquivos\\" + sigoCFG.NomeDB + "\\NFSe";//"C:\\Users\\Developer\\Documents\\NFSe\\Schemas\\XmlRetorno"; ACBrNFSe.Config.PathSchemas = configNFSe.Caminhowroot + "\\Schemas\\NFSe\\PadraoNacional\\1.01"; // ACBrNFSe.Config.PathSchemas = @"C:\Users\Developer\Documents\NFSe\Teste"; ACBrNFSe.Config.DFe.SSLCryptLib = SSLCryptLib.cryWinCrypt; ACBrNFSe.Config.DFe.SSLHttpLib = SSLHttpLib.httpWinHttp; ACBrNFSe.Config.DFe.SSLXmlSignLib = SSLXmlSignLib.xsLibXml2; ACBrNFSe.Config.DFe.Senha = PessCerts.Senha; //ACBrNFSe.Config.DFe.NumeroSerie = txtCertNumero.Text; ACBrNFSe.Config.DFe.DadosPFX = Convert.ToBase64String(PessCerts.Certificado); ACBrNFSe.Config.Sistema.Versao = "1.01"; ACBrNFSe.Config.SalvarArq = true; ACBrNFSe.Config.SepararPorMes = false; ACBrNFSe.Config.AdicionarLiteral = false; ACBrNFSe.Config.EmissaoPathNFSe = false; ACBrNFSe.Config.SepararPorCNPJ = true; //Emitente ACBrNFSe.Config.Emitente.CNPJ = prestador.Nro_Docto; ACBrNFSe.Config.Emitente.InscMun = prestador.CCM_NIT; ACBrNFSe.Config.Emitente.RazSocial = prestador.Nome_Empresa; ACBrNFSe.Config.Emitente.WSUser = ""; ACBrNFSe.Config.Emitente.WSSenha = ""; ACBrNFSe.Config.Emitente.WSFraseSecr = ""; ACBrNFSe.Config.Emitente.WSChaveAcesso = ""; ACBrNFSe.Config.Emitente.WSChaveAutoriz = ""; ACBrNFSe.Config.Emitente.Dados.NomeFantasia = prestador.Fantasia; ACBrNFSe.Config.Emitente.Dados.Telefone = prestador.Fone1; ACBrNFSe.Config.Emitente.Dados.CEP = prestador.Cep; ACBrNFSe.Config.Emitente.Dados.Endereco = prestador.Tipo_End + " " + prestador.Endereco; ACBrNFSe.Config.Emitente.Dados.Numero = prestador.End_Nro; ACBrNFSe.Config.Emitente.Dados.Complemento = prestador.Complemento; ACBrNFSe.Config.Emitente.Dados.Bairro = prestador.Bairro; ACBrNFSe.Config.CodigoMunicipio = (CodigoMunicipio)prestador.Cod_Municipio;//cmbCidadeEmitente.GetSelectedValue<CodigoMunicipio>(); // Pasta para guardar os arquivos enviados (INI) por dia var dirEnvios = Path.Combine(ACBrNFSe.Config.PathNFSe, "Envios", DateTime.Now.ToString("yyyy-MM-dd")); Directory.CreateDirectory(dirEnvios); // Diretório para XML enviados (por dia) var dirXmlEnviados = Path.Combine(ACBrNFSe.Config.PathNFSe, "XmlEnviados", DateTime.Now.ToString("yyyy-MM-dd")); Directory.CreateDirectory(dirXmlEnviados); string strMsgErro = ""; List<EnviarLoteDpsResposta2> LsNumeroProcolo = new List<EnviarLoteDpsResposta2>(); CarregarIni carregarIni = new CarregarIni(); int contadorLoteRps = 0; int NumeroLote = configNFSe.Cod_LoteRPS; int contadorRps = 0; // Emitir um por um na lista (Modo Unitário) foreach (var nfse in listaRPS) { contadorLoteRps++; contadorRps++; if (contadorLoteRps <= configNFSe.Qtde_Max_NFSe) { // Gera INI (arquivo enviado) e salva para auditoria string iniConteudo = carregarIni.CarregarIniAbrasaf(prestador, nfse, configNFSe, sigoCFG, null); var nomeIni = $"RPS_{nfse.Cod_NF}_{DateTime.Now:yyyyMMdd_HHmmssfff}.ini"; var caminhoIni = Path.Combine(dirEnvios, nomeIni); File.WriteAllText(caminhoIni, iniConteudo, Encoding.UTF8); ACBrNFSe.CarregarINI(iniConteudo); } contadorLoteRps = 0; // Retry de emissão em falhas transitórias de comunicação const int maxRetries = 3; Envio envio = null; string resposta = null; Exception lastEx = null; for (int attempt = 1; attempt <= maxRetries; attempt++) { try { resposta = ACBrNFSe.Emitir(NumeroLote.ToString(), 0, false); envio = carregarIni.RetornoIniAcbr(resposta); // Salva o XML enviado para o webservice (envio.XmlEnvio) var xmlEnvioPath = Path.Combine(dirXmlEnviados, $"RPS_{nfse.Cod_NF}_XmlEnvio_{attempt}.xml"); File.WriteAllText(xmlEnvioPath, envio.XmlEnvio ?? string.Empty, Encoding.UTF8); // Opcional: salvar também o XML de retorno bruto (envio.XmlRetorno) var xmlRetornoPath = Path.Combine(dirXmlEnviados, $"RPS_{nfse.Cod_NF}_XmlRetorno_{attempt}.xml"); File.WriteAllText(xmlRetornoPath, envio.XmlRetorno ?? string.Empty, Encoding.UTF8); // Se retornou erros, mas são de comunicação e ainda há tentativa disponível, re-tenta if (envio?.Erros != null && envio.Erros.Count > 0 && IsTransientCommError(envio) && attempt < maxRetries) { Thread.Sleep(Math.Min(8000, 1000 * attempt)); // backoff simples continue; } // Sucesso ou erro não transitório -> sai do loop break; } catch (Exception ex) { lastEx = ex; if (!IsTransientCommError(ex) || attempt == maxRetries) break; Thread.Sleep(Math.Min(8000, 1000 * attempt)); // backoff simples } } // Se falhou sem retorno estruturado (exceção nas tentativas) if (envio == null) { strMsgErro += (lastEx?.Message ?? "Falha de comunicação na emissão.") + " "; ACBrNFSe.LimparLista(); continue; } if (envio.Erros.Count > 0) { foreach (var erro in envio.Erros) { strMsgErro += "NºRPS: " + nfse.Cod_NF + " " + erro.Codigo + " " + erro.Descricao + " " + erro.Correcao + "<br>"; } ACBrNFSe.LimparLista(); continue; } var JSONLote = NFSeUtil.DeserializeJson<EnviarLoteDpsResposta2>(envio.XmlRetorno.ToString()); LsNumeroProcolo.Add(JSONLote); ACBrNFSe.LimparLista(); if (contadorRps != listaRPS.Count) { //string carregarIni2 = carregarIni.CarregarIniAbrasaf(prestador, nfse, configNFSe, sigoCFG, null); //ACBrNFSe.CarregarINI(carregarIni2); } } List<NFSeRetorno> listaRetorno = new List<NFSeRetorno>(); foreach (var itemNumeroProtocolo in LsNumeroProcolo) { int TempoMS = 5000; int tentativas = 0; ConsultaLoteNfse consultaLoteRps = new ConsultaLoteNfse(); while (tentativas <= 10) { tentativas++; Thread.Sleep(TempoMS); if (TempoMS < 1920000) TempoMS += TempoMS; string RetornoLote = ACBrNFSe.ConsultarNFSePorChave(itemNumeroProtocolo.ChaveAcesso); consultaLoteRps = carregarIni.RetornoConsultaLoteNFSEIniAcbr(RetornoLote); string msgTemp = ""; if (consultaLoteRps.Erros.Count > 0) { foreach (var erro in consultaLoteRps.Erros) { // re try em E999/X203 ou mensagens equivalentes if (erro.Descricao == "Remessa ainda não foi processada" || IsGovCommErrorCode(erro.Codigo, erro.Descricao)) { msgTemp = erro.Descricao; break; } strMsgErro += erro.Codigo + " " + erro.Descricao + " " + erro.Correcao; } if (!string.IsNullOrEmpty(msgTemp)) continue; break; } else { break; } } using JsonDocument docJson = JsonDocument.Parse(consultaLoteRps.XmlRetorno.ToString()); if (!docJson.RootElement.TryGetProperty("nfseXmlGZipB64", out var propB64) || propB64.ValueKind != JsonValueKind.String) { // Sem NFSe no retorno (caso típico X203) strMsgErro += "X203 Não foi retornado nenhuma NFSe. "; continue; } string nfseXmlGZipB64 = propB64.GetString(); var xmlFormatado = NFSeUtil.DecodeNfseXmlGZipB64(nfseXmlGZipB64); XDocument doc = XDocument.Parse(xmlFormatado); XNamespace ns = "http://www.sped.fazenda.gov.br/nfse"; var nfseList = doc.Descendants(ns + "NFSe"); if (nfseList.Any()) { foreach (var n in nfseList) { var inf = n.Element(ns + "infNFSe"); var dps = inf.Element(ns + "DPS"); var infDps = dps.Element(ns + "infDPS"); listaRetorno.Add(new NFSeRetorno { Cod_NFSe = int.Parse(inf.Element(ns + "nNFSe")?.Value ?? "0"), // número da NFSe Cod_Verificador = "Padrao Nacional", //inf.Attribute("Id")?.Value, // Informa no lugar do cod verificador que a nota foi emitida via padrão nacional que não possui esse valor Dta_Emissao = DateTime.Parse(infDps.Element(ns + "dhEmi")?.Value ?? DateTime.MinValue.ToString()), // data emissão da DPS Cod_NF = int.Parse(infDps.Element(ns + "nDPS")?.Value ?? "0"), // número interno da DPS (substitui o RPS) Situacao = 1 }); } } } if (strMsgErro != "") { int notaProcessada = 0; if (listaRetorno.Count > 0) notaProcessada = new NFSeDAO().processaRetornoNFSe(sigoCFG, prestador, listaRetorno, 0); string resultadoErro = ""; if (notaProcessada == 0) resultadoErro = " <br> Ocorreu erro no envio do lote da nota fiscal " + "<br> Mensagem de Erro:<span style=\"color: #ff0000;\"> " + strMsgErro + " </span>"; else resultadoErro = " Quantidade de Nota(s) Processada(s) com sucesso: " + notaProcessada + "<br> Ocorreu erro no envio do lote da nota fiscal " + "<br> Mensagem de Erro:<span style=\"color: #ff0000;\"> " + strMsgErro + " </span>"; ACBrNFSe.Dispose(); return base.FormataRetornoJSON(false, (int)NFSeUtil.TipoEmissao.WebService, null, resultadoErro); } int TotaldeNotas = 0; TotaldeNotas = new NFSeDAO().processaRetornoNFSe(sigoCFG, prestador, listaRetorno, 0); //caso nao tenha erro string resultadoOK = " Todas as nota(s) fiscal foram enviada com sucesso para a prefeitura e enviado ao email do cliente!<br> Quantidade de Nota(s) Processada(s): " + TotaldeNotas;/// "<br><br><span> Token do email" + TokenReposta + "<br><br>"+ TokenReposta2 + "</span>"; ACBrNFSe.Dispose(); return base.FormataRetornoJSON(false, (int)NFSeUtil.TipoEmissao.WebService, null, resultadoOK); } public string Descriminacao(Sigo.NFSe.Models.NFSe NFSe, Prestador prestador, string ItensAux) { string c_TextoAux = ""; string c_TextoTF = ""; decimal fimposto = 0; if (NFSe.Deducao_IR == 0 && NFSe.ExcFiscal_IR == 1) // 484 A 498 ir fimposto += (NFSe.Vlr_IR); if (NFSe.Deducao_PCC == 0 && NFSe.ExcFiscal_PCC == 1) //484 A 498 CSLL fimposto += (NFSe.Vlr_CSLL + NFSe.Vlr_Cofins + NFSe.Vlr_PIS); if ((NFSe.Exibe_Impostos == 0) /*&& prestador.Enquadramento != (int)NFSeUtil.Enquadramento.SimplesNacional*/) { if (NFSe.Deducao_ISS == 0 && NFSe.ExcFiscal_ISS == 1) { if (c_TextoAux != "") { c_TextoAux += " / ISS:" + (NFSe.PCT_ISS / 100).ToString("P02") + "%" + " Vlr: " + (NFSe.Vlr_ISS / 100).ToString("P02").Replace("%", ""); } else { c_TextoAux += "ISS: " + (NFSe.PCT_ISS / 100).ToString("P02") + "%" + " Vlr: " + (NFSe.Vlr_ISS / 100).ToString("P02").Replace("%", ""); ; } } if (NFSe.Deducao_IR == 0 && NFSe.ExcFiscal_IR == 1 && NFSe.Vlr_IR > 0) { if (c_TextoAux != "") { c_TextoAux += " / I.R: " + ((NFSe.Vlr_Total / NFSe.Vlr_IR) / 100).ToString("P02");// String.Format("{0:C}", NFSe.Vlr_IR/NFSe.Vlr_Total) ; } else { c_TextoAux += "I.R: " + ((NFSe.Vlr_Total / NFSe.Vlr_IR) / 100).ToString("P02"); } } if (NFSe.Deducao_PCC == 0 && NFSe.ExcFiscal_PCC == 1 && fimposto > 0) //484 A 498 CSLL { float rPct_Pis = 0; float rPct_Cofins = 0; float rPct_Csll = 0; if (c_TextoAux != "") c_TextoAux += " / PIS: " + ((NFSe.Vlr_PIS / NFSe.Vlr_Total) / 100).ToString("P02") + (NFSe.Vlr_PIS / 100).ToString("P02").Replace("%", "") + " / "; else c_TextoAux += "PIS: " + ((NFSe.Vlr_PIS / NFSe.Vlr_Total) / 100).ToString("P02") + (NFSe.Vlr_PIS / 100).ToString("P02").Replace("%", "") + " / "; if (NFSe.Vlr_Cofins / NFSe.Vlr_Total > 0) c_TextoAux += " / COFINS: " + ((NFSe.Vlr_Cofins / NFSe.Vlr_Total) / 100).ToString("P02") + (NFSe.Vlr_Cofins / 100).ToString("P02").Replace("%", "") + " / "; c_TextoAux += " CSLL:" + ((NFSe.Vlr_CSLL / NFSe.Vlr_Total) / 100).ToString("P02") + (NFSe.Vlr_CSLL / 100).ToString("P02").Replace("%", ""); } if (NFSe.Deducao_INSS == 0 && NFSe.ExcFiscal_INSS == 1) { if (c_TextoAux != "") c_TextoAux += " / INSS: " + ((NFSe.Vlr_INSS / NFSe.Vlr_Total) / 100).ToString("P02") + (NFSe.Vlr_PIS / 100).ToString("P02").Replace("%", ""); else c_TextoAux += "INSS: " + ((NFSe.Vlr_INSS / NFSe.Vlr_Total) / 100).ToString("P02") + (NFSe.Vlr_PIS / 100).ToString("P02").Replace("%", ""); } } if (c_TextoAux != "") { c_TextoAux = "Impostos Retidos Nesta Nota Fiscal: " + c_TextoAux; } if (NFSe.Vlr_TxAdm > 0) { if (c_TextoAux != "") c_TextoAux += "Taxas Administrativas: " + (NFSe.Vlr_TxAdm / 100).ToString("P02").Replace("%", "") + " / " + c_TextoAux; // c_TextoAux += "Taxas Administrativas: " + String.Format("{0:C}", NFSe.Vlr_TxAdm) + " / " + c_TextoAux; else c_TextoAux += "Taxas Administrativas: " + (NFSe.Vlr_TxAdm / 100).ToString("P02").Replace("%", ""); // c_TextoAux += "Taxas Administrativas: " + String.Format("{0:C}", NFSe.Vlr_TxAdm); } string TFCOD = !String.IsNullOrEmpty(NFSe.TF_Codigo) ? NFSe.TF_Codigo : "0"; if (int.Parse(TFCOD) > 0) { c_TextoTF = " || Valor Aprox. dos Tributos "; float rVlr_TF = 0; float rPct_TF = 0; if (NFSe.TF_PctFederal > 0) { rVlr_TF += (float)Math.Round((decimal)NFSe.Vlr_Total * (decimal)(NFSe.TF_PctFederal / 100), 2); rPct_TF += (float)NFSe.TF_PctFederal; } if (NFSe.TF_PctImportado > 0) { rVlr_TF += (float)Math.Round((decimal)NFSe.Vlr_Total * (decimal)(NFSe.TF_PctImportado / 100), 2); rPct_TF += (float)NFSe.TF_PctImportado; } if (NFSe.TF_PctEstadual > 0) { rVlr_TF += (float)Math.Round((decimal)NFSe.Vlr_Total * (decimal)(NFSe.TF_PctEstadual / 100), 2); rPct_TF += (float)NFSe.TF_PctEstadual; } if (NFSe.TF_PctMunicipal > 0) { rVlr_TF += (float)Math.Round((decimal)NFSe.Vlr_Total * (decimal)(NFSe.TF_PctMunicipal / 100), 2); rPct_TF += (float)NFSe.TF_PctMunicipal; } //c_TextoTF += String.Format("{0:C}", rVlr_TF); c_TextoTF += "R$ " + (rVlr_TF / 100).ToString("P02").Replace("%", ""); c_TextoTF += "(" + (rPct_TF / 100).ToString("P02") + ")"; if (!String.IsNullOrEmpty(NFSe.TF_Fonte)) { c_TextoTF += " " + NFSe.TF_Fonte; if (!String.IsNullOrEmpty(NFSe.TF_Chave)) { c_TextoTF += " Chave: " + NFSe.TF_Chave; } } } c_TextoAux = ItensAux + c_TextoTF; if (!String.IsNullOrEmpty(NFSe.Obs)) c_TextoAux += " | Observação da Nota Fiscal: " + NFSe.Obs; if (c_TextoAux.Length > 1000) return c_TextoAux.Substring(0, 999); else return c_TextoAux; } // Heurística para detectar falhas transitórias de comunicação private static bool IsTransientCommError(Exception ex) { if (ex == null) return false; // Tipos comuns de falha de comunicação if (ex is HttpRequestException || ex is WebException || ex is IOException) return true; if (ex is System.Net.Sockets.SocketException) return true; var msg = ex.Message?.ToLowerInvariant() ?? string.Empty; return msg.Contains("timeout") || msg.Contains("timed out") || msg.Contains("temporar") // temporariamente indisponível || msg.Contains("comunica") // comunicação || msg.Contains("conex") // conexão || msg.Contains("ssl") || msg.Contains("tls") || msg.Contains("dns") || msg.Contains("503") || msg.Contains("502") || msg.Contains("504") || msg.Contains("gateway") || msg.Contains("unavailable"); } private static bool IsTransientCommError(Envio envio) { if (envio?.Erros == null || envio.Erros.Count == 0) return false; foreach (var e in envio.Erros) { if (IsGovCommErrorCode(e?.Codigo, e?.Descricao)) return true; var d = (e?.Descricao ?? string.Empty).ToLowerInvariant(); if (d.Contains("timeout") || d.Contains("temporar") || d.Contains("comunica") || d.Contains("conex") || d.Contains("ssl") || d.Contains("tls") || d.Contains("dns") || d.Contains("503") || d.Contains("502") || d.Contains("504") || d.Contains("gateway") || d.Contains("unavailable")) return true; } return false; } // Códigos/descrições típicos de falha de comunicação do governo private static bool IsGovCommErrorCode(string codigo, string descricao) { var code = (codigo ?? "").Trim().ToUpperInvariant(); var desc = (descricao ?? "").ToLowerInvariant(); if (code == "E999" || code == "X203") return true; if (desc.Contains("não foi retornado nenhuma nfse") || desc.Contains("nao foi retornado nenhuma nfse")) return true; if (desc.Contains("erro não catalogado") || desc.Contains("erro nao catalogado")) return true; return false; } } } using Sigo.NFSe.Models; using System; using System.Collections.Generic; using System.Text; using IniParser; using IniParser.Model; using Sigo.NFSe.Util; using Sigo.NFSe.WebServices.Provedores; using System.IO; using IniParser.Parser; using NFSe.WebServices.Provedores.ISSDSF; namespace NFSe.WebServices.Provedores.PadraoNacional { public class CarregarIni { public string CarregarIniAbrasaf(Prestador prestador, Sigo.NFSe.Models.NFSe nfse, NFSeConfig configNFSe, SigoCFG sigoCFG, PrestadorCerts PessCerts) { IniData data = new IniData(); data["IdentificacaoNFSe"]["Numero"] = nfse.Cod_NF.ToString(); data["IdentificacaoNFSe"]["CodigoVerificacao"] = nfse.Cod_Verificador ?? ""; data["IdentificacaoRps"]["Producao"] = (configNFSe.Ambiente == 2) ? "1" : "2"; data["IdentificacaoRps"]["Status"] = "1"; data["IdentificacaoRps"]["OutrasInformacoes"] = ""; data["IdentificacaoRps"]["TipoTributacaoRps"] = "T"; data["IdentificacaoRps"]["SeriePrestacao"] = "99"; data["IdentificacaoRps"]["Numero"] = nfse.Cod_NF.ToString(); data["IdentificacaoRps"]["Serie"] = "1"; data["IdentificacaoRps"]["Tipo"] = "1"; data["IdentificacaoRps"]["DataEmissao"] = nfse.Dta_Cad.ToString("dd/MM/yyyy"); data["IdentificacaoRps"]["Competencia"] = nfse.Dta_Cad.ToString("dd/MM/yyyy"); data["IdentificacaoRps"]["NaturezaOperacao"] = nfse.Tributacao == (int)NFSeUtil.TipoTributacao.DentroDoMunicipio ? "01" : "02"; //Usado pelo provedor ISSSaoPaulo data["IdentificacaoRps"]["PercentualCargaTributaria"] = "0"; //Usado pelo provedor ISSSaoPaulo data["IdentificacaoRps"]["ValorCargaTributaria"] = "0"; data["IdentificacaoRps"]["PercentualCargaTributariaMunicipal"] = nfse.TF_PctMunicipal.ToString(); data["IdentificacaoRps"]["ValorCargaTributariaMunicipal"] = (nfse.Vlr_Total) * (decimal)(nfse.TF_PctMunicipal) / 100 + ""; data["IdentificacaoRps"]["PercentualCargaTributariaEstadual"] = nfse.TF_PctEstadual.ToString(); data["IdentificacaoRps"]["ValorCargaTributariaEstadual"] = (nfse.Vlr_Total) * (decimal)(nfse.TF_PctEstadual) / 100 + ""; data["IdentificacaoRps"]["verAplic"] = "ACBrNFSeX-1.00"; // Preencher a seção [Prestador] string Enquandramento = ""; switch (prestador.Enquadramento) { case 1: Enquandramento = "7"; break; case 2: Enquandramento = "8"; break; case 3: Enquandramento = "9"; break; case 4: Enquandramento = ""; break; } ; data["Prestador"]["Regime"] = "0";//Verificar esse campo depois no sistema data["Prestador"]["OptanteSN"] = Enquandramento == "9" ? "2" : "1"; data["Prestador"]["opSimpNac"] = prestador.Enquadramento == 3 ? "3" : "1"; data["Prestador"]["IncentivadorCultural"] = "2"; data["Prestador"]["CNPJ"] = prestador.Nro_Docto; data["Prestador"]["InscricaoMunicipal"] = prestador.Enquadramento == 3 ? prestador.CCM_NIT : ""; data["Prestador"]["NIF"] = ""; data["Prestador"]["CAEPF"] = ""; data["Prestador"]["RazaoSocial"] = ""; data["Prestador"]["NomeFantasia"] = prestador.Fantasia; data["Prestador"]["Logradouro"] = prestador.Tipo_End + " " + prestador.Endereco; data["Prestador"]["Numero"] = prestador.End_Nro; data["Prestador"]["Complemento"] = prestador.Complemento; data["Prestador"]["Bairro"] = prestador.Bairro; data["Prestador"]["CodigoMunicipio"] = prestador.Cod_Municipio.ToString(); data["Prestador"]["UF"] = prestador.UF; data["Prestador"]["CodigoPais"] = "1058"; data["Prestador"]["xPais"] = "Brasil"; data["Prestador"]["CEP"] = prestador.Cep; data["Prestador"]["Telefone"] = prestador.Fone1; data["Prestador"]["Email"] = prestador.Email; data["Tomador"]["Tipo"] = (nfse.Tomador.Tipo_Docto == 1) ? "2" : nfse.Tributacao == (int)NFSeUtil.TipoTributacao.DentroDoMunicipio ? "03" : "04"; data["Tomador"]["CNPJCPF"] = nfse.Tomador.Nro_Docto; data["Tomador"]["InscricaoMunicipal"] = nfse.Tomador.CCM_NIT; data["Tomador"]["NIF"] = ""; data["Tomador"]["CAEPF"] = nfse.Tomador.Nro_Docto.Length == 14 ? nfse.Tomador.Nro_Docto : ""; data["Tomador"]["InscricaoEstadual"] = nfse.Tomador.IE_RG; data["Tomador"]["RazaoSocial"] = nfse.Tomador.Nome_Empresa; data["Tomador"]["TipoLogradouro"] = nfse.Tomador.Tipo_End; data["Tomador"]["Logradouro"] = nfse.Tomador.Endereco; data["Tomador"]["Numero"] = nfse.Tomador.End_Nro; data["Tomador"]["Complemento"] = nfse.Tomador.Complemento; data["Tomador"]["Bairro"] = nfse.Tomador.Bairro; data["Tomador"]["CodigoMunicipio"] = nfse.Tomador.Cod_Municipio.ToString(); data["Tomador"]["xMunicipio"] = nfse.Tomador.Municipio; data["Tomador"]["UF"] = nfse.Tomador.UF; data["Tomador"]["CodigoPais"] = "1058"; data["Tomador"]["CEP"] = nfse.Tomador.Cep; data["Tomador"]["xPais"] = "Brasil"; data["Tomador"]["Telefone"] = nfse.Tomador.Fone1; data["Tomador"]["Email"] = nfse.Tomador.Email; data["Tomador"]["AtualizaTomador"] = "1"; data["Tomador"]["TomadorExterior"] = "2"; data["Servico"]["ItemListaServico"] = nfse.Cod_Servico.ToString(); data["Servico"]["CodigoCnae"] = nfse.Cod_Atividade.ToString().Substring(0, Math.Min(7, nfse.Cod_Atividade.ToString().Length)); data["Servico"]["CodigoTributacaoMunicipio"] = nfse.Cod_Atividade.ToString(); ;//nfse.Cod_Servico.ToString(); data["Servico"]["Discriminacao"] = formatarDiscriminacaoServicosRPS(nfse); data["Servico"]["CodigoMunicipio"] = prestador.Cod_Municipio.ToString(); data["Servico"]["CodigoPais"] = "1058"; data["Servico"]["ExigibilidadeISS"] = (nfse.Deducao_ISS == 0 && nfse.ExcFiscal_ISS == 1) ? "3" : "1"; data["Servico"]["MunicipioIncidencia"] = prestador.Cod_Municipio.ToString(); data["Servico"]["UFPrestacao"] = prestador.UF; data["Servico"]["ResponsavelRetencao"] = ""; data["Servico"]["Operacao"] = "A"; data["Servico"]["Tributacao"] = "C"; data["Servico"]["CodigoNBS"] = nfse.TF_Codigo.ToString(); // Preencher a seção [Valores] data["Valores"]["ValorServicos"] = nfse.Vlr_Total.ToString("F2").Replace('.', ','); data["Valores"]["ValorDeducoes"] = "0,00"; data["Valores"]["AliquotaDeducoes"] = "0,00";//nfse.Valores.AliquotaDeducoes.ToString("F2").Replace(',', '.'); if (nfse.Deducao_PCC == 0 && nfse.ExcFiscal_PCC == 1 && nfse.Vlr_PIS > 0) { data["Valores"]["ValorPis"] = Math.Round(nfse.Vlr_PIS, 2).ToString("F2").Replace(',', '.'); data["Valores"]["AliquotaPis"] = Math.Round((nfse.Vlr_Total / nfse.Vlr_PIS), 2).ToString("F2"); data["Valores"]["ValorCofins"] = Math.Round(nfse.Vlr_Cofins, 2).ToString("F2");//nfse.Valores.ValorCofins.ToString("F2").Replace(',', '.'); data["Valores"]["AliquotaCofins"] = Math.Round((nfse.Vlr_Total / nfse.Vlr_Cofins), 2).ToString("F2"); } else { data["Valores"]["ValorPis"] = ""; data["Valores"]["AliquotaPis"] = ""; data["Valores"]["ValorCofins"] = ""; data["Valores"]["AliquotaCofins"] = ""; } if (nfse.Deducao_INSS == 0 && nfse.ExcFiscal_INSS == 1 && nfse.Vlr_INSS > 0) data["Valores"]["ValorInss"] = Math.Round((nfse.Vlr_Total / nfse.Vlr_INSS), 2).ToString("F2"); else data["Valores"]["ValorInss"] = "0"; if (nfse.Deducao_IR == 0 && nfse.ExcFiscal_IR == 1 && nfse.Vlr_IR > 0) data["Valores"]["ValorIr"] = Math.Round(nfse.Vlr_IR, 2).ToString("F2"); else data["Valores"]["ValorIr"] = "0"; if (nfse.Deducao_PCC == 0 && nfse.ExcFiscal_PCC == 1 && nfse.Vlr_PIS > 0) data["Valores"]["ValorCsll"] = nfse.Vlr_CSLL.ToString("F2"); else data["Valores"]["ValorCsll"] = ""; data["Valores"]["OutrasRetencoes"] = "0"; data["Valores"]["DescontoIncondicionado"] = "0"; data["Valores"]["DescontoCondicionado"] = "0"; data["Valores"]["BaseCalculo"] = nfse.Vlr_Total.ToString("F2"); data["Valores"]["Aliquota"] = ((nfse.ExcFiscal_ISS == 1 && nfse.Deducao_ISS == 0) && nfse.Vlr_ISS > 0) ? nfse.PCT_ISS.ToString("F2").Replace('.', ',') : ""; // nfse.PCT_ISS.ToString("F2"); data["Valores"]["ValorIss"] = nfse.Vlr_ISS.ToString("F2"); data["Valores"]["ValorIssRetido"] = nfse.Vlr_ISS.ToString("F2"); data["Valores"]["ValorLiquidoNfse"] = nfse.Vlr_Liquido.ToString("F2"); data["Valores"]["ValorTotalNotaFiscal"] = nfse.Vlr_Total.ToString("F2"); data["InformacoesComplementares"]["xInfComp"] = nfse.Obs; data["tribMun"]["tribISSQN"] = "1"; data["tribMun"]["cPaisResult"] = "0"; data["tribMun"]["tpBM"] = "0"; data["tribMun"]["nBM"] = ""; data["tribMun"]["vRedBCBM"] = "0"; data["tribMun"]["pRedBCBM"] = "0"; data["tribMun"]["tpSusp"] = ""; data["tribMun"]["nProcesso"] = ""; data["tribMun"]["tpImunidade="] = ""; if (prestador.Enquadramento == 3) data["tribMun"]["pAliq"] = ((nfse.ExcFiscal_ISS == 1 && nfse.Deducao_ISS == 0) && nfse.Vlr_ISS > 0) ? nfse.PCT_ISS.ToString("F2").Replace('.', ',') : ""; // nfse.PCT_ISS.ToString("F2"); //data["totTrib"]["indTotTrib"] = "1"; //data["totTrib"]["pTotTribSN"] = ((nfse.TF_PctMunicipal) + (nfse.TF_PctEstadual) + (nfse.TF_PctFederal)).ToString(); //data["totTrib"]["vTotTrib"] = ""; //data["totTrib"]["pTotTrib"] = ""; data["tribMun"]["tpRetISSQN"] = ((nfse.ExcFiscal_ISS == 1 && nfse.Deducao_ISS == 0) && nfse.Vlr_ISS > 0) ? "2" : "1"; if ((nfse.ExcFiscal_PCC == 1 && nfse.Deducao_PCC == 0) && (nfse.Vlr_PIS > 0 || nfse.Vlr_Cofins > 0 || nfse.Vlr_CSLL > 0)) { data["tribFederal"]["CST"] = "01"; data["tribFederal"]["tpRetPisCofins"] = "1"; data["tribFederal"]["vBCPisCofins"] = nfse.Vlr_Total.ToString("F2"); data["tribFederal"]["pAliqPis"] = ((nfse.Vlr_PIS / nfse.Vlr_Total) * 100).ToString("F2").Replace('.', ','); data["tribFederal"]["vPis"] = nfse.Vlr_PIS.ToString("F2").Replace('.', ','); data["tribFederal"]["pAliqCofins"] = ((nfse.Vlr_Cofins / nfse.Vlr_Total) * 100).ToString("F2").Replace('.', ','); data["tribFederal"]["vCofins"] = nfse.Vlr_Cofins.ToString("F2").Replace('.', ','); data["tribFederal"]["vRetCSLL"] = nfse.Vlr_CSLL.ToString("F2").Replace('.', ','); } else { data["tribFederal"]["tpRetPisCofins"] = "2"; } data["tribFederal"]["vRetIRRF"] = ((nfse.ExcFiscal_IR == 1 && nfse.Deducao_IR == 0) && nfse.Vlr_IR > 0) ? nfse.Vlr_IR.ToString("F2").Replace('.', ',') : ""; data["tribFederal"]["vRetCP"] = ((nfse.ExcFiscal_INSS == 1 && nfse.Deducao_INSS == 0) && nfse.Vlr_INSS > 0) ? nfse.Vlr_INSS.ToString("F2").Replace('.', ',') : ""; return data.ToString(); } public Envio RetornoIniAcbr(string RetornoIni) { Envio envio = new Envio(); var parser = new IniDataParser(); IniData data; data = parser.Parse(RetornoIni); var envioSection = data["Envio"]; if (envioSection != null) { envio.CodigoVerificacao = envioSection["CodigoVerificacao"]; // Parse da data no formato "dd/MM/yyyy HH:mm:ss" if (DateTime.TryParseExact(envioSection["Data"], "dd/MM/yyyy HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out DateTime parsedDate)) { envio.Data = parsedDate; } else { envio.Data = DateTime.MinValue; } envio.Link = envioSection["Link"]; // Parse de inteiros envio.Lote = int.TryParse(envioSection["Lote"], out int lote) ? lote : 0; envio.MaxRps = int.TryParse(envioSection["MaxRps"], out int maxRps) ? maxRps : 0; envio.ModoEnvio = envioSection["ModoEnvio"]; envio.NumeroNota = envioSection["NumeroNota"]; envio.Protocolo = envioSection["Protocolo"]; envio.Situacao = envioSection["Situacao"]; envio.Sucesso = int.TryParse(envioSection["Sucesso"], out int sucesso) ? sucesso : 0; envio.XmlEnvio = envioSection["XmlEnvio"]; envio.XmlRetorno = envioSection["XmlRetorno"]; } List<Erro> errosListaRetornoLote = new List<Erro>(); foreach (var section in data.Sections) { if (section.SectionName.StartsWith("Erro", StringComparison.OrdinalIgnoreCase)) { Erro erro = new Erro { Codigo = section.Keys["Codigo"], Correcao = section.Keys["Correcao"], Descricao = section.Keys["Descricao"] }; errosListaRetornoLote.Add(erro); } } envio.Erros = errosListaRetornoLote; return envio; } public ConsultaLoteRps RetornoConsultaLoteIniAcbr(string RetornoIni) { var parser = new IniDataParser(); IniData data; data = parser.Parse(RetornoIni); ConsultaLoteRps consulta = new ConsultaLoteRps(); var consultaSection = data["ConsultaLoteRps"]; if (consultaSection != null) { consulta.CodVerificacao = consultaSection["CodVerificacao"]; consulta.Lote = int.TryParse(consultaSection["Lote"], out int lote) ? lote : 0; consulta.Protocolo = consultaSection["Protocolo"]; consulta.Situacao = int.TryParse(consultaSection["Situacao"], out int situacao) ? situacao : 0; consulta.XmlEnvio = consultaSection["XmlEnvio"]; consulta.XmlRetorno = consultaSection["XmlRetorno"]; } List<Erro> errosListaRetornoLote = new List<Erro>(); foreach (var section in data.Sections) { if (section.SectionName.StartsWith("Erro", StringComparison.OrdinalIgnoreCase)) { Erro erro = new Erro { Codigo = section.Keys["Codigo"], Correcao = section.Keys["Correcao"], Descricao = section.Keys["Descricao"] }; errosListaRetornoLote.Add(erro); } } consulta.Erros = errosListaRetornoLote; return consulta; } public ConsultaLoteNfse RetornoConsultaLoteNFSEIniAcbr(string RetornoIni) { var parser = new IniDataParser(); IniData data; data = parser.Parse(RetornoIni); ConsultaLoteNfse consulta = new ConsultaLoteNfse(); var consultaSection = data["ConsultaNFSe"]; if (consultaSection != null) { consulta.XmlEnvio = consultaSection["XmlEnvio"]; consulta.XmlRetorno = consultaSection["XmlRetorno"]; } List<Erro> errosListaRetornoLote = new List<Erro>(); foreach (var section in data.Sections) { if (section.SectionName.StartsWith("Erro", StringComparison.OrdinalIgnoreCase)) { Erro erro = new Erro { Codigo = section.Keys["Codigo"], Correcao = section.Keys["Correcao"], Descricao = section.Keys["Descricao"] }; errosListaRetornoLote.Add(erro); } } consulta.Erros = errosListaRetornoLote; return consulta; } public string formatarDiscriminacaoServicosRPS(Sigo.NFSe.Models.NFSe NFSe, string quebraDeLinha = "|") { var descricaoItensNFSe = ""; if (NFSe.Tipo_ExibeItens == (int)NFSeUtil.TipoDiscriminacao.DescricaoSimplificada) { descricaoItensNFSe += NFSe.Descricao_Simpl + quebraDeLinha; } else { foreach (var item in NFSe.NFSeItens) { descricaoItensNFSe += item.Quantidade + " " + item.Descricao + " - " + item.Vlr_Unitario + " Cada = " + item.Vlr_SubTotal + quebraDeLinha; } } // OBS NFSe descricaoItensNFSe += NFSe.Obs; return descricaoItensNFSe; } public string formatarImpostosRPS(Prestador Prestador, Sigo.NFSe.Models.NFSe NFSe, string quebraDeLinha = "|") { var descricaoImpostosNFSe = ""; if ((NFSe.Exibe_Impostos == 0) && (Prestador.Enquadramento != (int)NFSeUtil.Enquadramento.SimplesNacional)) { if (NFSe.Deducao_ISS == 0 && NFSe.ExcFiscal_ISS == 1 && NFSe.Vlr_ISS > 0) { descricaoImpostosNFSe += descricaoImpostosNFSe != "" ? " / " : ""; descricaoImpostosNFSe += String.Format("ISS: {0:P2} - Vlr: R${1:0.00}", ((NFSe.Vlr_ISS / NFSe.Vlr_Total)), (NFSe.Vlr_ISS)); } if (NFSe.Deducao_IR == 0 && NFSe.ExcFiscal_IR == 1 && NFSe.Vlr_IR > 0) { descricaoImpostosNFSe += descricaoImpostosNFSe != "" ? " / " : ""; descricaoImpostosNFSe += String.Format("IR: {0:P2} - Vlr: R${1:0.00}", ((NFSe.Vlr_IR / NFSe.Vlr_Total)), (NFSe.Vlr_IR)); } if ((NFSe.Deducao_PCC == 0 && NFSe.ExcFiscal_PCC == 1) && (NFSe.Vlr_PIS > 0 || NFSe.Vlr_Cofins > 0 || NFSe.Vlr_CSLL > 0)) { descricaoImpostosNFSe += descricaoImpostosNFSe != "" ? " / " : ""; descricaoImpostosNFSe += String.Format( "PIS: {0:P2} - Vlr: R${1:0.00} / COFINS: {2:P2} - Vlr: R${3:0.00} / CSLL: {4:P2} - Vlr: R${5:0.00}", ((NFSe.Vlr_PIS / NFSe.Vlr_Total)), (NFSe.Vlr_PIS), ((NFSe.Vlr_Cofins / NFSe.Vlr_Total)), (NFSe.Vlr_Cofins), ((NFSe.Vlr_CSLL / NFSe.Vlr_Total)), (NFSe.Vlr_CSLL) ); } if (NFSe.Deducao_INSS == 0 && NFSe.ExcFiscal_INSS == 1 && NFSe.Vlr_INSS > 0) { descricaoImpostosNFSe += descricaoImpostosNFSe != "" ? " / " : ""; descricaoImpostosNFSe += String.Format("IR: {0:P2} - Vlr: R${1:0.00}", ((NFSe.Vlr_INSS / NFSe.Vlr_Total)), (NFSe.Vlr_INSS)); } } return descricaoImpostosNFSe != "" ? " - Impostos Retidos Nesta Nota Fiscal: " + descricaoImpostosNFSe : ""; } } } 6388-lista-nfse-ger.json 6388-lista-nfse-ger-soap.json 6388-ger-nfse.json 6388-ger-nfse-soap.json NFSe.xml
×
×
  • 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.