/// <summary> /// Contrutor que já carrega as notas no RPS e gera o XML de Envio /// </summary> /// <param name="lNotas"></param> public belCarregaDadosRPS(List<belPesquisaNotas> lNotas, string sNumeroLote = "") { this.lNotas = lNotas; if (sNumeroLote != "") { bBuscaRetonro = true; } objLoteEnvio = new ReqEnvioLoteRPS(); objLoteEnvio.cabec = CarregaCabecalho(); objLoteEnvio.cabec.NumeroLote = sNumeroLote; objLoteEnvio.lote = new Lote(); daoUtil objdaoUtil = new daoUtil(); objLoteEnvio.lote.Id = "Lote:" + objdaoUtil.RetornaProximoValorGenerator("GEN_LOTE_NFES", 7); objLoteEnvio.lote.RPS = new List<LoteRPS>(); Principal principal = new Principal("http://issdigital.campinas.sp.gov.br/WsNFe2/LoteRps.jws"); //int inumero = 0;//Ultima nota enviada. //principal.dllConsultarSequencial(Convert.ToInt32(objLoteEnvio.cabec.CodCidade), objLoteEnvio.cabec.CPFCNPJRemetente, base.GetInscricaoMunicipal(), "99", ref inumero); foreach (belPesquisaNotas nota in lNotas) { objLoteEnvio.lote.RPS.Add(CarregaLote(nota.sCD_NFSEQ)); } objLoteEnvio.cabec.QtdRPS = objLoteEnvio.lote.RPS.Count(); objLoteEnvio.cabec.ValorTotalDeducoes = objLoteEnvio.lote.RPS.Sum(c => c.Deducoes.Deducao.Sum(x => x.ValorDeduzir)); objLoteEnvio.cabec.ValorTotalServicos = objLoteEnvio.lote.RPS.Sum(c => c.Itens.Item.Sum(x => x.ValorTotal)); }
public tcLoteRps BuscaDadosNFes(List<belPesquisaNotas> objListaNotas) { try { tcLoteRps objLoteRps = new tcLoteRps(); objLoteRps.Rps = new List<TcRps>(); foreach (belPesquisaNotas Nota in objListaNotas) { TcRps objTcRps = new TcRps(); #region IdentificacaoRps - TcIdentificacaoRps beltcIdentificacaoRps objbeltcIdentificacaoRps = new beltcIdentificacaoRps(); objTcRps.InfRps = new TcInfRps(); objTcRps.InfRps.DataEmissao = daoUtil.GetDateServidor(); objTcRps.InfRps.Status = 1;//Normal; DataTable dt = BuscaDadosNota(Nota.sCD_NFSEQ); foreach (DataRow dr in dt.Rows) { 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); if (objTcRps.InfRps.OptanteSimplesNacional == 1) { objTcRps.InfRps.RegimeEspecialTributacao = Convert.ToInt16(dr["RegimeEspecialTributacao"].ToString()); } else { objTcRps.InfRps.RegimeEspecialTributacao = 0; } } objTcRps.InfRps.IdentificacaoRps = objbeltcIdentificacaoRps.BuscatcIdentificacaoRps(Nota.sCD_NFSEQ); #endregion #region Servico - TcDadosServico belServico objbelServico = new belServico(); objTcRps.InfRps.Servico = objbelServico.RetornaDadosServico(Nota.sCD_NFSEQ, objTcRps.InfRps.NaturezaOperacao); #endregion #region Prestador - tcIdentificacaoPrestador belPrestador objbelPrestador = new belPrestador(); objTcRps.InfRps.Prestador = objbelPrestador.RettcIdentificacaoPrestador(Nota.sCD_NFSEQ); objLoteRps.Cnpj = objTcRps.InfRps.Prestador.Cnpj; objLoteRps.InscricaoMunicipal = objTcRps.InfRps.Prestador.InscricaoMunicipal; #endregion #region Tomador - TcDadosTomador belTomador objbelTomador = new belTomador(); objTcRps.InfRps.Tomador = objbelTomador.RettcDadosTomador(Nota.sCD_NFSEQ); #endregion #region ConstrucaoCivil - TcDadosContrucaoCivil - Tratado na Visualização da Nota if (Acesso.NM_EMPRESA.Equals("AENGE")) { belConstrucaoCivil objbelConstrucaoCivil = new belConstrucaoCivil(); objTcRps.InfRps.ConstrucaoCivil = objbelConstrucaoCivil.RettcDadosConstrucaoCivil(Nota.sCD_NFSEQ); } #endregion 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; } }