public bool AdicionarXml(Models.InformacoesContribuinte cont, string caminho) { //cria uma instância do Produto e atribui valores às propriedades InformacoesContribuinte oContribuinte = new InformacoesContribuinte(); XmlTextWriter writer = new XmlTextWriter(caminho + cont.CpfCtt, System.Text.Encoding.UTF8); writer.WriteStartDocument(true); writer.Formatting = Formatting.Indented; writer.Indentation = 4; //writer.WriteAttributeString("classificacao", "R"); writer.WriteStartElement("Reinf", "http://www.reinf.esocial.gov.br/schemas/evtInfoContribuinte/v1_03_02"); writer.WriteStartElement("EvtInfoContri", cont.ID); writer.WriteStartElement("ideEvento"); writer.WriteElementString("tpAmb", cont.TpAmb); writer.WriteElementString("procEmi", cont.ProcEmi); writer.WriteElementString("verProc", cont.VerProc); writer.WriteEndElement(); writer.WriteStartElement("ideContri"); writer.WriteElementString("tpInsc", cont.TpInsc); writer.WriteElementString("nrInsc", cont.NrInsc); writer.WriteEndElement(); writer.WriteStartElement("infoContri"); writer.WriteStartElement("inclusao"); writer.WriteStartElement("idePeriodo"); writer.WriteElementString("iniValid", cont.IniValid); writer.WriteElementString("fimValid", cont.FimValid); writer.WriteEndElement(); writer.WriteStartElement("infoCadastro"); writer.WriteElementString("classTrib", cont.ClassTrib); writer.WriteElementString("indEscrituracao", cont.IndEscrituracao); writer.WriteElementString("indDesoneracao", cont.IndDesoneracao); writer.WriteElementString("indAcordoIsenMulta", cont.IndAcordoIsenMulta); writer.WriteElementString("indSitPJ", cont.IndSitPJ); writer.WriteStartElement("contato"); writer.WriteElementString("nmCtt", cont.NmCtt); writer.WriteElementString("cpfCtt", cont.CpfCtt); writer.WriteElementString("foneFixo", cont.FoneFixo); writer.WriteElementString("foneCel", cont.FoneCel); writer.WriteElementString("email", cont.FoneCel); writer.WriteEndElement(); writer.WriteStartElement("softHouse"); writer.WriteElementString("cnpjSoftHouse", cont.CnpjSoftHouse); writer.WriteElementString("nmRazao", cont.NmRazao); writer.WriteElementString("nmCont", cont.NmCont); writer.WriteElementString("telefone", cont.FoneFixosoftHouse); writer.WriteElementString("email", cont.EmailSoftHouse); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); return(true); }
//public bool AdicionarXml(Models.Endereco end,string caminho) public bool AdicionarXml(Models.RetencoesFonte ret, string caminho, string nomearquivo) { //DateTime data = DateTime.Now.Date; //string dataInicio = String.Format("{0:yyyyMMddHHMMss}", DateTime.Now); //cria uma instância do Produto e atribui valores às propriedades InformacoesContribuinte oRetencaoFonte = new InformacoesContribuinte(); XmlTextWriter writer = new XmlTextWriter(caminho + nomearquivo, System.Text.Encoding.UTF8); writer.WriteStartDocument(true); writer.Formatting = Formatting.Indented; writer.Indentation = 4; //writer.WriteAttributeString("classificacao", "R"); writer.WriteStartElement("Reinf", "xmlns=http://www.reinf.esocial.gov.br/schemas/evtRetFonte/v1_03_02"); writer.WriteStartElement("evtPgtosDivs", ret.ID); writer.WriteStartElement("ideEvento"); writer.WriteElementString("indRetif", ret.IndRetif); writer.WriteElementString("nrRecibo", ret.NrRecibo); writer.WriteElementString("perApur", ret.PerApur); writer.WriteElementString("tpAmb", ret.TpAmb); writer.WriteElementString("procEmi", ret.ProcEmi); writer.WriteElementString("verProc", ret.VerProc); writer.WriteEndElement(); writer.WriteStartElement("ideContri"); writer.WriteElementString("tpInsc", ret.TpInsc); writer.WriteElementString("nrInsc", ret.NrInsc); writer.WriteEndElement(); writer.WriteStartElement("ideBenef"); writer.WriteElementString("codPgto", ret.CodPgto); writer.WriteElementString("tpInscBenef", ret.TpInscBenef); writer.WriteElementString("nrInscBenef", ret.NrInscBenef); writer.WriteElementString("nmRazaoBenef", ret.NmRazaoBenef); writer.WriteStartElement("infoResidExt"); writer.WriteStartElement("infoEnder"); writer.WriteElementString("paisResid", ret.PaisResid); writer.WriteElementString("dscLograd", ret.DscLograd); writer.WriteElementString("nrLograd", ret.NrLograd); writer.WriteElementString("complem", ret.Complem); writer.WriteElementString("bairro", ret.Bairro); writer.WriteElementString("cidade", ret.Cidade); writer.WriteElementString("codPostal", ret.CodPostal); writer.WriteEndElement(); writer.WriteStartElement("infoFiscal"); writer.WriteElementString("indNIF", ret.IndNIF); writer.WriteElementString("nifBenef", ret.NifBenef); writer.WriteElementString("relFontePagad", ret.RelFontePagad); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteStartElement("infoMolestia"); writer.WriteElementString("dtLaudo", ret.DtLaudo); writer.WriteEndElement(); writer.WriteStartElement("infoPgto"); writer.WriteStartElement("ideEstab"); writer.WriteElementString("tpInsc", ret.TpInscPgto); writer.WriteElementString("nrInsc", ret.NrInscPgto); writer.WriteStartElement("pgtoResidBR"); writer.WriteStartElement("pgtoPF"); writer.WriteElementString("dtPgto", ret.DtPagto); writer.WriteElementString("indSuspExig", ret.IndSuspExig); writer.WriteElementString("indDecTerceiro", ret.IndDecTerceiro); writer.WriteElementString("vlrRendTributavel", ret.VlrRendTributavel); writer.WriteElementString("vlrIRRF", ret.VlrIRRF); writer.WriteStartElement("detDeducao"); writer.WriteElementString("indTpDeducao", ret.IndTpDeducao); writer.WriteElementString("vlrDeducao", ret.VlrDeducao); writer.WriteEndElement(); writer.WriteStartElement("rendIsento"); writer.WriteElementString("tpIsencao", ret.TpIsencao); writer.WriteElementString("vlrIsento", ret.VlrIsento); writer.WriteElementString("descRendimento", ret.DescRendimento); writer.WriteEndElement(); writer.WriteStartElement("detCompet"); writer.WriteElementString("indPerReferencia", ret.IndPerReferencia); writer.WriteElementString("perRefPagto", ret.PerRefPagto); writer.WriteElementString("vlrRendTributavel", ret.VlrRendTributavelCompet); writer.WriteEndElement(); writer.WriteStartElement("compJud"); writer.WriteElementString("vlrCompAnoCalend", ret.VlrCompAnoCalend); writer.WriteElementString("vlrCompAnoAnt", ret.VlrCompAnoAnt); writer.WriteEndElement(); writer.WriteStartElement("infoRRA"); writer.WriteElementString("tpProcRRA", ret.TpProcRRA); writer.WriteElementString("nrProcRRA", ret.NrProcRRA); writer.WriteElementString("codSusp", ret.CodSusp); writer.WriteElementString("natRRA", ret.NatRRA); writer.WriteElementString("qtdMesesRRA", ret.QtdMesesRRA); writer.WriteStartElement("despProcJud"); writer.WriteElementString("vlrDespCustas", ret.VlrDespCustas); writer.WriteElementString("vlrDespAdvogados", ret.VlrDespAdvogados);//linha 67 writer.WriteStartElement("ideAdvogado"); writer.WriteElementString("tpInscAdvogado", ret.TpInscAdvogado); writer.WriteElementString("nrInscAdvogado", ret.NrInscAdvogado); writer.WriteElementString("vlrAdvogado", ret.VlrAdvogado);//71 writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); // continua aqui writer.WriteStartElement("infoProcJud"); writer.WriteElementString("nrProcJud", ret.NrProcJud); writer.WriteElementString("codSusp", ret.CodSuspJud); writer.WriteElementString("indOrigemRecursos", ret.IndOrigemRecursos);//75 writer.WriteStartElement("despProcJud"); writer.WriteElementString("vlrDespCustas", ret.VlrDespCustaspgtoPF); writer.WriteElementString("vlrDespAdvogados", ret.VlrDespAdvogadospgtoPF); writer.WriteStartElement("ideAdvogado"); writer.WriteElementString("tpInscAdvogado", ret.TpInscAdvogadopgtoPF);//80 writer.WriteElementString("nrInscAdvogado", ret.NpInscAdvogadopgtoPF); writer.WriteElementString("vlrAdvogado", ret.VlrAdvogadopgtoPF); writer.WriteStartElement("origemRecursos"); writer.WriteElementString("cnpjOrigemRecursos", ret.CnpjOrigemRecursos); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteStartElement("depJudicial"); writer.WriteElementString("vlrDepJudicial", ret.VlrDepJudicial); //86 writer.WriteStartElement("pgtoPJ"); writer.WriteElementString("dtPagto", ret.DtPagto); //88 writer.WriteElementString("vlrRendTributavel", ret.VlrRendTributaveldepJudicial); writer.WriteElementString("vlrRet", ret.VlrRet); writer.WriteStartElement("infoProcJud"); writer.WriteElementString("nrProcJud", ret.NrProcJuddepJudicial); //92 writer.WriteElementString("codSusp", ret.CodSuspdepJudicial); writer.WriteElementString("indOrigemRecursos", ret.IndOrigemRecursosdepJudicial); writer.WriteStartElement("despProcJud"); writer.WriteElementString("vlrDespCustas", ret.VlrDespCustasdepJudicial); writer.WriteElementString("vlrDespAdvogados", ret.VlrDespAdvogadosdepJudicial);//97 writer.WriteStartElement("ideAdvogado"); writer.WriteElementString("tpInscAdvogado", ret.TpInscAdvogadopgtoPJ); writer.WriteElementString("nrInscAdvogado", ret.NrInscAdvogadopgtoPJ); writer.WriteElementString("vlrAdvogado", ret.VlrAdvogadopgtoPJ); writer.WriteStartElement("origemRecursos"); writer.WriteElementString("cnpjOrigemRecursos", ret.CnpjOrigemRecursospgtoPJ); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); if (ret.CodPgto == "S") { writer.WriteStartElement("pgtoResidExt"); writer.WriteElementString("dtPagto", ret.DtPagtoExt);//105 writer.WriteElementString("tpRendimento", ret.TpRendimentoExt); writer.WriteElementString("formaTributacao", ret.FormaTributacaoExt); writer.WriteElementString("vlrPgto", ret.VlrPgtoExt); writer.WriteElementString("vlrRet", ret.VlrRetExt); writer.WriteEndElement(); } writer.WriteEndDocument(); writer.Close(); return(true); }
public bool RetornaReinfContribuinte(EmpresaCliente cliente) { try { bool acesso = false; string strconTpAmb = ConfigurationManager.AppSettings["TpAmb"].ToString(); string strconProcEmi = ConfigurationManager.AppSettings["ProcEmi"].ToString(); string strconVerProc = ConfigurationManager.AppSettings["VerProc"].ToString(); string strClassTrib = ConfigurationManager.AppSettings["classTrib"].ToString(); string strindSitPJ = ConfigurationManager.AppSettings["indSitPJ"].ToString(); string strCnpjSoftHouse = ConfigurationManager.AppSettings["cnpjSoftHouse"].ToString(); string strnmRazaoSoftHouse = ConfigurationManager.AppSettings["nmRazao"].ToString(); string strnmContSoftHouse = ConfigurationManager.AppSettings["nmCont"].ToString(); string strtelefoneSoftHouse = ConfigurationManager.AppSettings["telefone"].ToString(); string stremailSoftHouse = ConfigurationManager.AppSettings["email"].ToString(); string AcordoIsenMulta = ""; string impostoretCliente = ""; string descricaocliente = ""; string cpfcnpjraiz = ""; string IDEvento = ""; using (var infocontribuinte = new WsReinf.ConsultaEFDClient("NetTcpBinding_IConsultaEFD")) { /* FAZ UMA AUTENTICAÇÃO NO SERVIÇO E RETORNA FALSO OU VERDADEIRO */ acesso = infocontribuinte.Authenticate(cliente.UsuarioSinacor, cliente.SenhaSinacor, cliente.CodigoEmpresa); if (acesso == true) { /* PASSO AS INFORMAÇÕES QUE SÃO OBRIGATORIAS NO REQUEST */ EFDRequest request = new EFDRequest() { CodigoEmpresa = Convert.ToInt32(cliente.CodigoEmpresa), DataInicio = cliente.DataInicio, DataFinal = cliente.DataFinal, }; EFDRequestCliente requestcliente = new EFDRequestCliente() { CodigoEmpresa = Convert.ToInt32(cliente.CodigoEmpresa), DataInicio = cliente.DataInicio, DataFinal = cliente.DataFinal, }; EFDRequestInstitucional requestInsitucional = new EFDRequestInstitucional() { CodigoEmpresa = Convert.ToInt32(cliente.CodigoEmpresa) }; /* CONSULTO LISTA DE RETENÇÃO CLIENTE PASSANDO O REQUEST(DADO ANTERIOR) RETORNANDO A LISTA DE RETENÇÃO */ var consulta = infocontribuinte.ConsultaListaRetencaoClientes(request).ListaRetencao; foreach (var retCliente in consulta) { impostoretCliente = Convert.ToString(retCliente.CodigoImposto); descricaocliente = retCliente.DescricaoImposto; } /* CONSULTO DADOS DO CLIENTE PASSANDO O REQUEST(DADO ANTERIOR) RETORNANDO A LISTA DE RETENÇÃO */ var consultaCliente = infocontribuinte.ConsultarDadosClientes(requestcliente).ListaClientes; if (strClassTrib == "60") { AcordoIsenMulta = "1"; } else { AcordoIsenMulta = "0"; } //if (item.TipoPessoa == "J") //{ // item.TipoPessoa = "1"; // cpfcnpjraiz = Convert.ToString(item.CPFCNPJ).Substring(0, 8); // IDEvento = "ID" + item.TipoPessoa + Convert.ToString(item.CPFCNPJ);//+ cliente.DataInicio; //} InformacoesContribuinte cont = new InformacoesContribuinte() { ID = IDEvento, TpAmb = strconTpAmb, //1 - Produção e 2 - Produção restrita; ProcEmi = strconProcEmi, VerProc = strconVerProc, TpInsc = "1", NrInsc = cpfcnpjraiz, IniValid = cliente.DataInicio.ToString("yyyy-MM"), FimValid = cliente.DataFinal.ToString("yyyy-MM"), ClassTrib = strClassTrib, IndEscrituracao = cliente.indEscrituracao, IndDesoneracao = cliente.indDesoneracao, IndAcordoIsenMulta = AcordoIsenMulta, IndSitPJ = strindSitPJ, NmCtt = cliente.NomeContatoContri, CpfCtt = cliente.CPFContatoContri, FoneFixo = cliente.TelefoneContatoContr, FoneCel = cliente.CelularContatoContr, Email = cliente.EmailContatoContr, CnpjSoftHouse = strCnpjSoftHouse, NmRazao = strnmRazaoSoftHouse, NmCont = strnmContSoftHouse, FoneFixosoftHouse = strtelefoneSoftHouse, EmailSoftHouse = stremailSoftHouse, }; AdicionarXml(cont, cliente.caminho); } else { Console.WriteLine(" Problemas na autenticação", DateTime.Now.ToString()); } } } catch (Exception ex) { Console.WriteLine(" 99-Erro na geração do XML" + ex, DateTime.Now.ToString()); } return(true); }