/// <summary> /// Limpa Recibo no Envio /// </summary> /// <param name="objListaLote"></param> public void LimpaRecibo(tcLoteRps objListaLote) { StringBuilder sSql = new StringBuilder(); try { for (int i = 0; i < objListaLote.Rps.Count; i++) { sSql = new StringBuilder(); sSql.Append("update nf "); sSql.Append("set cd_recibonfe ='' "); sSql.Append("where "); sSql.Append("cd_empresa ='"); sSql.Append(belStatic.codEmpresaNFe); sSql.Append("' "); sSql.Append("and "); sSql.Append("cd_nfseq ='"); sSql.Append(objLoteRpsAlter.Rps[i].InfRps.IdentificacaoRps.Nfseq); sSql.Append("'"); using (FbCommand cmdUpdate = new FbCommand(sSql.ToString(), cx.get_Conexao())) { cx.Open_Conexao(); cmdUpdate.ExecuteNonQuery(); } } } catch (Exception) { throw; } finally { cx.Close_Conexao(); } }
public belRecepcao(string sLoteXml, X509Certificate2 cert, bel.NFes.tcLoteRps objLoteRpsAlter) { this.sLoteXml = sLoteXml; this.cert = cert; this.objLoteRpsAlter = objLoteRpsAlter; TransmitirLote(); }
public void GerarAqruivoXml(tcLoteRps objLoteRpd) { try { List<string> ListaNfes = new List<string>(); Globais glob = new Globais(); XDocument xdoc = new XDocument(); XNamespace tns = "http://www.ginfes.com.br/servico_enviar_lote_rps_envio"; XNamespace tipos = "http://www.ginfes.com.br/tipos_v03.xsd"; XNamespace ds = "http://www.w3.org/2000/09/xmldsig#"; XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance"; XNamespace n1 = "http://www.altova.com/samplexml/other-namespace"; XNamespace pf = "http://www.ginfes.com.br/servico_enviar_lote_rps_envio_v03.xsd"; XContainer conEnviarLoteRpsEnvio = (new XElement(pf + "EnviarLoteRpsEnvio", new XAttribute("xmlns", "http://www.ginfes.com.br/servico_enviar_lote_rps_envio_v03.xsd"))); XContainer conLoteRps = (new XElement(pf + "LoteRps", new XAttribute("Id", objLoteRpd.NumeroLote), new XAttribute(XNamespace.Xmlns + "tipos", "http://www.ginfes.com.br/tipos_v03.xsd"), new XElement(tipos + "NumeroLote", objLoteRpd.NumeroLote.ToString()), new XElement(tipos + "Cnpj", objLoteRpd.Cnpj.ToString()), new XElement(tipos + "InscricaoMunicipal", objLoteRpd.InscricaoMunicipal.ToString()), new XElement(tipos + "QuantidadeRps", objLoteRpd.QuantidadeRps.ToString()))); XContainer conListaRps = (new XElement(tipos + "ListaRps")); XContainer conRps = (new XElement(tipos + "Rps")); XContainer conInfRps = null; XContainer conSubstituto = null; XContainer conServico = null; XContainer conPrestador = null; XContainer conTomador = null; XContainer conIntermediarioServico = null; XContainer conConstrucaoCivil = null; AssinaNFeXml Assinatura = new AssinaNFeXml(); foreach (TcRps rps in objLoteRpd.Rps) { #region IdentificacaoRps conRps try { conInfRps = (new XElement(tipos + "InfRps", new XElement(tipos + "IdentificacaoRps", new XElement(tipos + "Numero", rps.InfRps.IdentificacaoRps.Numero), new XElement(tipos + "Serie", rps.InfRps.IdentificacaoRps.Serie), new XElement(tipos + "Tipo", rps.InfRps.IdentificacaoRps.Tipo)), new XElement(tipos + "DataEmissao", HLP.Util.Util.GetDateServidor().Date.ToString("yyyy-MM-ddTHH:mm:ss")), new XElement(tipos + "NaturezaOperacao", rps.InfRps.NaturezaOperacao), ((rps.InfRps.RegimeEspecialTributacao != 0) ? new XElement(tipos + "RegimeEspecialTributacao", rps.InfRps.RegimeEspecialTributacao) : null), new XElement(tipos + "OptanteSimplesNacional", rps.InfRps.OptanteSimplesNacional), new XElement(tipos + "IncentivadorCultural", rps.InfRps.IncentivadorCultural), new XElement(tipos + "Status", rps.InfRps.Status))); } catch (Exception x) { throw new Exception("Nota : " + rps.InfRps.IdentificacaoRps.Numero + "Erro na geração do XML, Regiao:('IdentificacaoRps')- " + Environment.NewLine + "XML_Detalhes: " + Environment.NewLine + x.Message); } #endregion #region RpsSubstituido if (rps.InfRps.RpsSubstituido != null) { try { conSubstituto = (new XElement(tipos + "RpsSubstituido", new XElement(tipos + "Numero", rps.InfRps.RpsSubstituido.Numero), new XElement(tipos + "Serie", rps.InfRps.RpsSubstituido.Serie), new XElement(tipos + "Tipo", rps.InfRps.RpsSubstituido.Tipo))); } catch (Exception x) { throw new Exception("Nota : " + rps.InfRps.IdentificacaoRps.Numero + "Erro na geração do XML, Regiao:('RpsSubstituido')- " + Environment.NewLine + "XML_Detalhes: " + Environment.NewLine + x.Message); } } #endregion #region Servico try { conServico = (new XElement(tipos + "Servico", new XElement(tipos + "Valores", new XElement(tipos + "ValorServicos", rps.InfRps.Servico.Valores.ValorServicos.ToString("#0.00").Replace(",", ".")), ((rps.InfRps.Servico.Valores.ValorDeducoes > 0) ? new XElement(tipos + "ValorDeducoes", rps.InfRps.Servico.Valores.ValorDeducoes.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.ValorPis > 0) ? new XElement(tipos + "ValorPis", rps.InfRps.Servico.Valores.ValorPis.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.ValorCofins > 0) ? new XElement(tipos + "ValorCofins", rps.InfRps.Servico.Valores.ValorCofins.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.ValorInss > 0) ? new XElement(tipos + "ValorInss", rps.InfRps.Servico.Valores.ValorInss.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.ValorIr > 0) ? new XElement(tipos + "ValorIr", rps.InfRps.Servico.Valores.ValorIr.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.ValorCsll > 0) ? new XElement(tipos + "ValorCsll", rps.InfRps.Servico.Valores.ValorCsll.ToString("#0.00").Replace(",", ".")) : null), new XElement(tipos + "IssRetido", rps.InfRps.Servico.Valores.IssRetido), ((rps.InfRps.Servico.Valores.ValorIss > 0) ? new XElement(tipos + "ValorIss", rps.InfRps.Servico.Valores.ValorIss.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.ValorIssRetido > 0) ? new XElement(tipos + "ValorIssRetido", rps.InfRps.Servico.Valores.ValorIssRetido.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.OutrasRetencoes > 0) ? new XElement(tipos + "OutrasRetencoes", rps.InfRps.Servico.Valores.OutrasRetencoes.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.BaseCalculo > 0) ? new XElement(tipos + "BaseCalculo", rps.InfRps.Servico.Valores.BaseCalculo.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.Aliquota > 0) ? new XElement(tipos + "Aliquota", (rps.InfRps.Servico.Valores.Aliquota / 100).ToString("#0.0000").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.ValorLiquidoNfse > 0) ? new XElement(tipos + "ValorLiquidoNfse", rps.InfRps.Servico.Valores.ValorLiquidoNfse.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.DescontoCondicionado > 0) ? new XElement(tipos + "DescontoCondicionado", rps.InfRps.Servico.Valores.DescontoCondicionado.ToString("#0.00").Replace(",", ".")) : null), ((rps.InfRps.Servico.Valores.DescontoIncondicionado > 0) ? new XElement(tipos + "DescontoIncondicionado", rps.InfRps.Servico.Valores.DescontoIncondicionado.ToString("#0.00").Replace(",", ".")) : null)), new XElement(tipos + "ItemListaServico", rps.InfRps.Servico.ItemListaServico), ((rps.InfRps.Servico.CodigoCnae != "") ? new XElement(tipos + "CodigoCnae", rps.InfRps.Servico.CodigoCnae) : null), (((rps.InfRps.Servico.CodigoTributacaoMunicipio != "") && (rps.InfRps.Servico.CodigoTributacaoMunicipio != "0")) ? new XElement(tipos + "CodigoTributacaoMunicipio", rps.InfRps.Servico.CodigoTributacaoMunicipio) : null), new XElement(tipos + "Discriminacao", rps.InfRps.Servico.Discriminacao), new XElement(tipos + "CodigoMunicipio", rps.InfRps.Servico.CodigoMunicipio))); } catch (Exception x) { throw new Exception("Nota : " + rps.InfRps.IdentificacaoRps.Numero + "Erro na geração do XML, Regiao:('Servico')- " + Environment.NewLine + "XML_Detalhes: " + Environment.NewLine + x.Message); } #endregion #region Prestador try { conPrestador = (new XElement(tipos + "Prestador", new XElement(tipos + "Cnpj", rps.InfRps.Prestador.Cnpj), ((rps.InfRps.Prestador.InscricaoMunicipal != "") ? new XElement(tipos + "InscricaoMunicipal", rps.InfRps.Prestador.InscricaoMunicipal) : null))); } catch (Exception x) { throw new Exception("Nota : " + rps.InfRps.IdentificacaoRps.Numero + "Erro na geração do XML, Regiao:('Prestador')- " + Environment.NewLine + "XML_Detalhes: " + Environment.NewLine + x.Message); } #endregion #region Tomador try { conTomador = (new XElement(tipos + "Tomador", ((rps.InfRps.Tomador.IdentificacaoTomador != null) ? new XElement(tipos + "IdentificacaoTomador", new XElement(tipos + "CpfCnpj", new XElement(tipos + (rps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cnpj != "" ? "Cnpj" : "Cpf"), (rps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cnpj != "" ? rps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cnpj : rps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cpf))), (rps.InfRps.Tomador.IdentificacaoTomador.InscricaoMunicipal != "" ? (new XElement(tipos + "InscricaoMunicipal", rps.InfRps.Tomador.IdentificacaoTomador.InscricaoMunicipal)) : null)) : null), new XElement(tipos + "RazaoSocial", rps.InfRps.Tomador.RazaoSocial), new XElement(tipos + "Endereco", new XElement(tipos + "Endereco", rps.InfRps.Tomador.Endereco.Endereco), new XElement(tipos + "Numero", rps.InfRps.Tomador.Endereco.Numero), (rps.InfRps.Tomador.Endereco.Complemento != "" ? new XElement(tipos + "Complemento", rps.InfRps.Tomador.Endereco.Complemento) : null), new XElement(tipos + "Bairro", rps.InfRps.Tomador.Endereco.Bairro), new XElement(tipos + "CodigoMunicipio", rps.InfRps.Tomador.Endereco.CodigoMunicipio), new XElement(tipos + "Uf", rps.InfRps.Tomador.Endereco.Uf), new XElement(tipos + "Cep", rps.InfRps.Tomador.Endereco.Cep)))); } catch (Exception x) { throw new Exception("Nota : " + rps.InfRps.IdentificacaoRps.Numero + "Erro na geração do XML, Regiao:('Tomador')- " + Environment.NewLine + "XML_Detalhes: " + Environment.NewLine + x.Message); } #endregion #region IntermediarioServico try { if (rps.InfRps.IntermediarioServico != null) { conIntermediarioServico = (new XElement(tipos + "IntermediarioServico", new XElement(tipos + "RazaoSocial", rps.InfRps.IntermediarioServico.RazaoSocial), new XElement(tipos + "CpfCnpj", (new XElement(tipos + (rps.InfRps.IntermediarioServico.CpfCnpj.Cnpj != null ? "Cnpj" : "Cpf"), (rps.InfRps.IntermediarioServico.CpfCnpj.Cnpj != null ? rps.InfRps.IntermediarioServico.CpfCnpj.Cnpj : rps.InfRps.IntermediarioServico.CpfCnpj.Cpf)))), new XElement(tipos + "InscricaoMunicipal", rps.InfRps.IntermediarioServico.InscricaoMunicipal))); } } catch (Exception x) { throw new Exception("Nota : " + rps.InfRps.IdentificacaoRps.Numero + "Erro na geração do XML, Regiao:('IntermediarioServico')- " + Environment.NewLine + "XML_Detalhes: " + Environment.NewLine + x.Message); } #endregion #region ConstrucaoCivil try { if (rps.InfRps.ConstrucaoCivil != null) { if ((rps.InfRps.ConstrucaoCivil.CodigoObra != "") && (rps.InfRps.ConstrucaoCivil.Art != "")) { conConstrucaoCivil = (new XElement(tipos + "ConstrucaoCivil", new XElement(tipos + "CodigoObra", rps.InfRps.ConstrucaoCivil.CodigoObra), new XElement(tipos + "Art", rps.InfRps.ConstrucaoCivil.Art))); } } } catch (Exception x) { throw new Exception("Nota : " + rps.InfRps.IdentificacaoRps.Numero + "Erro na geração do XML, Regiao:('ConstrucaoCivil')- " + Environment.NewLine + "XML_Detalhes: " + Environment.NewLine + x.Message); } #endregion try { if (conSubstituto != null) { conInfRps.Add(conSubstituto); } conInfRps.Add(conServico); conInfRps.Add(conPrestador); conInfRps.Add(conTomador); if (conIntermediarioServico != null) { conInfRps.Add(conIntermediarioServico); } if (conConstrucaoCivil != null) { conInfRps.Add(conConstrucaoCivil); } conRps.Add(conInfRps); // string nfe = Assinatura.ConfigurarArquivo(conRps.ToString(), "InfRps", cert); // XmlDocument xml = new XmlDocument(); // xml.LoadXml(nfe); // conListaRps.Add(xml); conListaRps.Add(conRps); //Salva o Rps; XDocument xdocsalvanfesemlot = new XDocument(conRps); string sPasta = rps.InfRps.DataEmissao.ToString("MM/yy").Replace("/", ""); string sNomeArquivo = rps.InfRps.DataEmissao.ToString("MM/yy").Replace("/", "") + rps.InfRps.IdentificacaoRps.Serie + rps.InfRps.IdentificacaoRps.Numero; DirectoryInfo dPastaData = new DirectoryInfo(belStaticPastas.ENVIO + "\\Servicos\\" + sPasta); if (!dPastaData.Exists) { dPastaData.Create(); } xdocsalvanfesemlot.Save(belStaticPastas.ENVIO + "\\Servicos\\" + sPasta + "\\" + sNomeArquivo + "-nfes.xml"); conRps = (new XElement(tipos + "Rps")); } catch (Exception x) { throw new Exception("Nota de Sequência - " + "sNota" + "Erro ao assinar a nfe de sequencia " + "sNota" + x.Message); } } conLoteRps.Add(conListaRps); conEnviarLoteRpsEnvio.Add(conLoteRps); //Assina Arquivo string nfes = Assinatura.ConfigurarArquivo(conEnviarLoteRpsEnvio.ToString(), "LoteRps", cert); sXmlLote = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + nfes; //Grava string sPathLote = belStaticPastas.ENVIO + "\\Servicos\\" + "Lote_" + objLoteRpd.NumeroLote + ".xml"; StreamWriter sw = new StreamWriter(sPathLote); sw.Write(sXmlLote); sw.Close(); #region Valida_Xml| Globais getschema = new Globais(); XmlSchemaCollection myschema = new XmlSchemaCollection(); XmlValidatingReader reader; try { XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None); reader = new XmlValidatingReader(sXmlLote, XmlNodeType.Element, context); myschema.Add("http://www.ginfes.com.br/servico_enviar_lote_rps_envio_v03.xsd", belStaticPastas.SCHEMA_NFSE + "\\servico_enviar_lote_rps_envio_v03.xsd"); reader.ValidationType = ValidationType.Schema; reader.Schemas.Add(myschema); while (reader.Read()) { } } catch (XmlException x) { File.Delete(sPathLote); throw new Exception(x.Message); } catch (XmlSchemaException x) { File.Delete(sPathLote); throw new Exception(x.Message); } #endregion } catch (Exception ex) { throw ex; } }
public tcLoteRps BuscaDadosNFes(List<string> sListaNotas) { belConnection cx = new belConnection(); try { objLoteRps = new tcLoteRps(); objLoteRps.Rps = new List<TcRps>(); foreach (string sNota in sListaNotas) { TcRps objTcRps = new TcRps(); //IdentificacaoRps - TcIdentificacaoRps daotcIdentificacaoRps objdaotcIdentificacaoRps = new daotcIdentificacaoRps(); objTcRps.InfRps = new TcInfRps(); StringBuilder sQuery = new StringBuilder(); sQuery.Append("SELECT coalesce (tpdoc.cd_natureza_oper_nfse,'1')cd_natureza_oper_nfse , "); sQuery.Append("coalesce (empresa.st_simples,'')st_simples , "); sQuery.Append("coalesce (empresa.cd_regime_trib_especial,'0')RegimeEspecialTributacao , "); sQuery.Append("coalesce (empresa.st_insentivador_cultural,'N')st_insentivador_cultural from nf "); sQuery.Append("inner join tpdoc on nf.cd_tipodoc = tpdoc.cd_tipodoc "); sQuery.Append("inner join empresa on empresa.cd_empresa = nf.cd_empresa "); sQuery.Append(" where nf.cd_nfseq = '" + sNota + "' and "); sQuery.Append(" nf.cd_empresa = '" + belStatic.codEmpresaNFe + "'"); FbCommand Command = new FbCommand(sQuery.ToString(), cx.get_Conexao()); cx.Open_Conexao(); Command.ExecuteNonQuery(); FbDataReader dr = Command.ExecuteReader(); dr.Read(); objTcRps.InfRps.DataEmissao = HLP.Util.Util.GetDateServidor(); objTcRps.InfRps.NaturezaOperacao = Convert.ToInt16(dr["cd_natureza_oper_nfse"].ToString()); objTcRps.InfRps.OptanteSimplesNacional = (dr["st_simples"].ToString().Equals("S") ? 1 : 2); objTcRps.InfRps.IncentivadorCultural = (dr["st_insentivador_cultural"].ToString().Equals("S")?1:2); objTcRps.InfRps.Status = 1;//Normal; if (objTcRps.InfRps.OptanteSimplesNacional == 1) { objTcRps.InfRps.RegimeEspecialTributacao = Convert.ToInt16(dr["RegimeEspecialTributacao"].ToString()); } else { objTcRps.InfRps.RegimeEspecialTributacao = 0; } objTcRps.InfRps.IdentificacaoRps = objdaotcIdentificacaoRps.BuscatcIdentificacaoRps(cx.get_Conexao(), sNota); //RpsSubstituido - TcIdentificacaoRps // Método tratado na visualização da Nota; //daoRpsSubstituido objdaoRpsSubstituido = new daoRpsSubstituido(); //objTcRps.InfRps.RpsSubstituido = objdaoRpsSubstituido.RetornaIdentificacaoRpds(Conn, sNota); //Servico - TcDadosServico daoServico objdaoServico = new daoServico(); objTcRps.InfRps.Servico = objdaoServico.RetornaDadosServico(cx.get_Conexao(), sNota, objTcRps.InfRps.NaturezaOperacao); //Prestador - tcIdentificacaoPrestador daoPrestador objdaoPrestador = new daoPrestador(); objTcRps.InfRps.Prestador = objdaoPrestador.RettcIdentificacaoPrestador(cx.get_Conexao(), sNota); objLoteRps.Cnpj = objTcRps.InfRps.Prestador.Cnpj; // Tag Pai; objLoteRps.InscricaoMunicipal = objTcRps.InfRps.Prestador.InscricaoMunicipal; //Tag Pai; //Tomador - TcDadosTomador daoTomador objdaoTomador = new daoTomador(); objTcRps.InfRps.Tomador = objdaoTomador.RettcDadosTomador(cx.get_Conexao(), sNota); //IntermediarioServico - tcIdentificacaoIntermediarioServico //Tratado na visualização da Nota //daoIntermediarioServico objdaoIntermediarioServico = new daoIntermediarioServico(); //objTcRps.InfRps.IntermediarioServico = objdaoIntermediarioServico.RettcIdentificacaoIntermediarioServico(Conn, sNota); //ConstrucaoCivil - TcDadosContrucaoCivil - Tratado na Visualização da Nota if (belStatic.sNomeEmpresa.Equals("AENGE")) { daoConstrucaoCivil objdaoConstrucaoCivil = new daoConstrucaoCivil(); objTcRps.InfRps.ConstrucaoCivil = objdaoConstrucaoCivil.RettcDadosConstrucaoCivil(cx.get_Conexao(), sNota); } objLoteRps.Rps.Add(objTcRps); } daoUtil objdaoUtil = new daoUtil(); objLoteRps.NumeroLote = objdaoUtil.RetornaProximoValorGenerator("GEN_LOTE_NFES", 15); objLoteRps.QuantidadeRps = objLoteRps.Rps.Count; return objLoteRps; } catch (Exception ex) { throw ex; } finally { cx.Close_Conexao(); } }
public daoRecepcao(string sReciboProt, bel.NFes.tcLoteRps objLoteRpsAlter) { this.sReciboProt = sReciboProt; this.objLoteRpsAlter = objLoteRpsAlter; }
public frmVisualizaNfs(tcLoteRps objLoteRps) { InitializeComponent(); this.objLoteRps = objLoteRps; }
private void CriaObjAlter() { try { tcLoteRps obj = new tcLoteRps(); obj.Rps = new List<TcRps>(); obj.NumeroLote = this.objLoteRps.NumeroLote; obj.Cnpj = this.objLoteRps.Cnpj; obj.InscricaoMunicipal = this.objLoteRps.InscricaoMunicipal; obj.QuantidadeRps = this.objLoteRps.QuantidadeRps; for (int i = 0; i < this.objLoteRps.Rps.Count; i++) { TcRps objTcTcRps = new TcRps(); #region Identificacao objTcTcRps.InfRps = new TcInfRps(); objTcTcRps.InfRps.DataEmissao = this.objLoteRps.Rps[i].InfRps.DataEmissao; objTcTcRps.InfRps.NaturezaOperacao = this.objLoteRps.Rps[i].InfRps.NaturezaOperacao; objTcTcRps.InfRps.RegimeEspecialTributacao = this.objLoteRps.Rps[i].InfRps.RegimeEspecialTributacao; objTcTcRps.InfRps.OptanteSimplesNacional = this.objLoteRps.Rps[i].InfRps.OptanteSimplesNacional; objTcTcRps.InfRps.IncentivadorCultural = this.objLoteRps.Rps[i].InfRps.IncentivadorCultural; objTcTcRps.InfRps.Status = this.objLoteRps.Rps[i].InfRps.Status; objTcTcRps.InfRps.IdentificacaoRps = new tcIdentificacaoRps(); objTcTcRps.InfRps.IdentificacaoRps.Numero = this.objLoteRps.Rps[i].InfRps.IdentificacaoRps.Numero; objTcTcRps.InfRps.IdentificacaoRps.Serie = this.objLoteRps.Rps[i].InfRps.IdentificacaoRps.Serie; objTcTcRps.InfRps.IdentificacaoRps.Tipo = this.objLoteRps.Rps[i].InfRps.IdentificacaoRps.Tipo; objTcTcRps.InfRps.IdentificacaoRps.Nfseq = this.objLoteRps.Rps[i].InfRps.IdentificacaoRps.Nfseq; if (this.objLoteRps.Rps[i].InfRps.RpsSubstituido != null) { objTcTcRps.InfRps.RpsSubstituido = new tcIdentificacaoRps(); objTcTcRps.InfRps.RpsSubstituido.Numero = this.objLoteRps.Rps[i].InfRps.RpsSubstituido.Numero; objTcTcRps.InfRps.RpsSubstituido.Serie = this.objLoteRps.Rps[i].InfRps.RpsSubstituido.Serie; objTcTcRps.InfRps.RpsSubstituido.Tipo = this.objLoteRps.Rps[i].InfRps.RpsSubstituido.Tipo; } #endregion #region Serviço objTcTcRps.InfRps.Servico = new TcDadosServico(); objTcTcRps.InfRps.Servico.Valores = new TcValores(); objTcTcRps.InfRps.Servico.Valores.ValorServicos = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorServicos; objTcTcRps.InfRps.Servico.Valores.ValorDeducoes = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorDeducoes; objTcTcRps.InfRps.Servico.Valores.ValorCsll = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorCsll; objTcTcRps.InfRps.Servico.Valores.ValorPis = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorPis; objTcTcRps.InfRps.Servico.Valores.ValorCofins = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorCofins; objTcTcRps.InfRps.Servico.Valores.IssRetido = this.objLoteRps.Rps[i].InfRps.Servico.Valores.IssRetido; objTcTcRps.InfRps.Servico.Valores.ValorInss = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorInss; objTcTcRps.InfRps.Servico.Valores.ValorIr = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorIr; objTcTcRps.InfRps.Servico.Valores.ValorIss = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorIss; objTcTcRps.InfRps.Servico.Valores.OutrasRetencoes = this.objLoteRps.Rps[i].InfRps.Servico.Valores.OutrasRetencoes; objTcTcRps.InfRps.Servico.Valores.BaseCalculo = this.objLoteRps.Rps[i].InfRps.Servico.Valores.BaseCalculo; objTcTcRps.InfRps.Servico.Valores.Aliquota = this.objLoteRps.Rps[i].InfRps.Servico.Valores.Aliquota; objTcTcRps.InfRps.Servico.Valores.ValorLiquidoNfse = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorLiquidoNfse; objTcTcRps.InfRps.Servico.Valores.ValorIssRetido = this.objLoteRps.Rps[i].InfRps.Servico.Valores.ValorIssRetido; objTcTcRps.InfRps.Servico.Valores.DescontoCondicionado = this.objLoteRps.Rps[i].InfRps.Servico.Valores.DescontoCondicionado; objTcTcRps.InfRps.Servico.Valores.DescontoIncondicionado = this.objLoteRps.Rps[i].InfRps.Servico.Valores.DescontoIncondicionado; objTcTcRps.InfRps.Servico.ItemListaServico = this.objLoteRps.Rps[i].InfRps.Servico.ItemListaServico; objTcTcRps.InfRps.Servico.CodigoTributacaoMunicipio = this.objLoteRps.Rps[i].InfRps.Servico.CodigoTributacaoMunicipio; objTcTcRps.InfRps.Servico.CodigoCnae = this.objLoteRps.Rps[i].InfRps.Servico.CodigoCnae; objTcTcRps.InfRps.Servico.CodigoMunicipio = this.objLoteRps.Rps[i].InfRps.Servico.CodigoMunicipio; objTcTcRps.InfRps.Servico.Discriminacao = this.objLoteRps.Rps[i].InfRps.Servico.Discriminacao; #endregion #region Dados Adicionais objTcTcRps.InfRps.Prestador = new tcIdentificacaoPrestador(); objTcTcRps.InfRps.Prestador.Cnpj = this.objLoteRps.Rps[i].InfRps.Prestador.Cnpj; objTcTcRps.InfRps.Prestador.InscricaoMunicipal = this.objLoteRps.Rps[i].InfRps.Prestador.InscricaoMunicipal; objTcTcRps.InfRps.Tomador = new tcDadosTomador(); objTcTcRps.InfRps.Tomador.IdentificacaoTomador = new tcIdentificacaoTomador(); if (this.objLoteRps.Rps[i].InfRps.Tomador.IdentificacaoTomador.CpfCnpj != null) { if (this.objLoteRps.Rps[i].InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cnpj != "") { objTcTcRps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj = new TcCpfCnpj(); objTcTcRps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cnpj = this.objLoteRps.Rps[i].InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cnpj; } else if (this.objLoteRps.Rps[i].InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cpf != "") { objTcTcRps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj = new TcCpfCnpj(); objTcTcRps.InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cpf = this.objLoteRps.Rps[i].InfRps.Tomador.IdentificacaoTomador.CpfCnpj.Cpf; } } objTcTcRps.InfRps.Tomador.IdentificacaoTomador.InscricaoMunicipal = this.objLoteRps.Rps[i].InfRps.Tomador.IdentificacaoTomador.InscricaoMunicipal; objTcTcRps.InfRps.Tomador.RazaoSocial = this.objLoteRps.Rps[i].InfRps.Tomador.RazaoSocial; if (this.objLoteRps.Rps[i].InfRps.Tomador.Endereco != null) { objTcTcRps.InfRps.Tomador.Endereco = new TcEndereco(); objTcTcRps.InfRps.Tomador.Endereco.Endereco = this.objLoteRps.Rps[i].InfRps.Tomador.Endereco.Endereco; objTcTcRps.InfRps.Tomador.Endereco.Numero = this.objLoteRps.Rps[i].InfRps.Tomador.Endereco.Numero; objTcTcRps.InfRps.Tomador.Endereco.Complemento = this.objLoteRps.Rps[i].InfRps.Tomador.Endereco.Complemento; objTcTcRps.InfRps.Tomador.Endereco.Bairro = this.objLoteRps.Rps[i].InfRps.Tomador.Endereco.Bairro; objTcTcRps.InfRps.Tomador.Endereco.Uf = this.objLoteRps.Rps[i].InfRps.Tomador.Endereco.Uf; objTcTcRps.InfRps.Tomador.Endereco.CodigoMunicipio = this.objLoteRps.Rps[i].InfRps.Tomador.Endereco.CodigoMunicipio; objTcTcRps.InfRps.Tomador.Endereco.Cep = this.objLoteRps.Rps[i].InfRps.Tomador.Endereco.Cep; } if (this.objLoteRps.Rps[i].InfRps.Tomador.Contato != null) { objTcTcRps.InfRps.Tomador.Contato = new TcContato(); objTcTcRps.InfRps.Tomador.Contato.Telefone = this.objLoteRps.Rps[i].InfRps.Tomador.Contato.Telefone; objTcTcRps.InfRps.Tomador.Contato.Email = this.objLoteRps.Rps[i].InfRps.Tomador.Contato.Email; } if (this.objLoteRps.Rps[i].InfRps.IntermediarioServico != null) { objTcTcRps.InfRps.IntermediarioServico = new TcIdentificacaoIntermediarioServico(); objTcTcRps.InfRps.IntermediarioServico.RazaoSocial = this.objLoteRps.Rps[i].InfRps.IntermediarioServico.RazaoSocial; objTcTcRps.InfRps.IntermediarioServico.InscricaoMunicipal = this.objLoteRps.Rps[i].InfRps.IntermediarioServico.InscricaoMunicipal; if (this.objLoteRps.Rps[i].InfRps.IntermediarioServico.CpfCnpj != null) { if (this.objLoteRps.Rps[i].InfRps.IntermediarioServico.CpfCnpj.Cnpj != "") { objTcTcRps.InfRps.IntermediarioServico.CpfCnpj = new TcCpfCnpj(); objTcTcRps.InfRps.IntermediarioServico.CpfCnpj.Cnpj = this.objLoteRps.Rps[i].InfRps.IntermediarioServico.CpfCnpj.Cnpj; } else if (this.objLoteRps.Rps[i].InfRps.IntermediarioServico.CpfCnpj.Cpf != "") { objTcTcRps.InfRps.IntermediarioServico.CpfCnpj = new TcCpfCnpj(); objTcTcRps.InfRps.IntermediarioServico.CpfCnpj.Cpf = this.objLoteRps.Rps[i].InfRps.IntermediarioServico.CpfCnpj.Cpf; } } } if (this.objLoteRps.Rps[i].InfRps.ConstrucaoCivil != null) { objTcTcRps.InfRps.ConstrucaoCivil = new tcDadosConstrucaoCivil(); objTcTcRps.InfRps.ConstrucaoCivil.Art = this.objLoteRps.Rps[i].InfRps.ConstrucaoCivil.Art; objTcTcRps.InfRps.ConstrucaoCivil.CodigoObra = this.objLoteRps.Rps[i].InfRps.ConstrucaoCivil.CodigoObra; } #endregion obj.Rps.Add(objTcTcRps); } this.objLoteRpsAlter = obj; } catch (Exception ex) { throw ex; } }