Exemplo n.º 1
0
        private LoteRPS CarregaLote(string cd_nfseq)
        {
            try
            {
                base.GetRps(cd_nfseq);

                LoteRPS rps = null;
                foreach (DataRow row in dtRPS.Rows)
                {
                    rps = new LoteRPS();
                    rps.CD_NFSEQ = cd_nfseq;

                    #region Carrega as propriedades do RPS
                    rps.InscricaoMunicipalPrestador = Util.TiraSimbolo(row["InscricaoMunicipalPrestador"].ToString()).PadLeft(9, '0');
                    rps.TipoRPS = "RPS";
                    rps.SerieRPS = "NF";
                    rps.RazaoSocialPrestador = row["RazaoSocialPrestador"].ToString();
                    //rps.NumeroRPS = sNumeroRps;
                    rps.DataEmissaoRPS = DateTime.Today;// Convert.ToDateTime(row["DataEmissaoRPS"].ToString());
                    rps.SituacaoRPS = row["SituacaoRPS"].ToString();
                    rps.SerieRPSSubstituido = row["SerieRPSSubstituido"].ToString();
                    rps.NumeroRPSSubstituido = Convert.ToByte(row["NumeroRPSSubstituido"].ToString());
                    rps.NumeroNFSeSubstituida = Convert.ToByte(row["NumeroNFSeSubstituida"].ToString());
                    rps.DataEmissaoNFSeSubstituida = Convert.ToDateTime(row["DataEmissaoNFSeSubstituida"].ToString());
                    rps.SeriePrestacao = Convert.ToByte(row["SeriePrestacao"].ToString());
                    rps.InscricaoMunicipalTomador = row["InscricaoMunicipalTomador"].ToString().PadLeft(9,'0');
                    rps.CPFCNPJTomador = Util.TiraSimbolo(row["CNPJ_Tomador"].ToString() == "" ? row["CPF_Tomador"].ToString() : row["CNPJ_Tomador"].ToString());
                    rps.RazaoSocialTomador = row["RazaoSocialTomador"].ToString().Trim();
                    rps.DocTomadorEstrangeiro = row["DocTomadorEstrangeiro"].ToString();
                    rps.TipoLogradouroTomador = row["TipoLogradouroTomador"].ToString();
                    rps.LogradouroTomador = row["LogradouroTomador"].ToString();
                    rps.NumeroEnderecoTomador = row["NumeroEnderecoTomador"].ToString();
                    rps.TipoBairroTomador = "Bairro";
                    rps.ComplementoEnderecoTomador = row["ComplementoEnderecoTomador"].ToString();
                    rps.BairroTomador = row["BairroTomador"].ToString();
                    rps.CidadeTomador = daoUtil.GetCodigoSiafiByCodigo((row["CidadeTomador"].ToString()));
                    rps.CidadeTomadorDescricao = row["CidadeTomadorDescricao"].ToString();
                    rps.CEPTomador = Util.TiraSimbolo(row["CEPTomador"].ToString());
                    rps.EmailTomador = row["EmailTomador"].ToString();
                    rps.CodigoAtividade = row["CodigoAtividade"].ToString();
                    rps.TipoRecolhimento = row["TipoRecolhimento"].ToString();
                    if (row["cd_munPrestacao"].ToString() == "")
                    {
                        rps.MunicipioPrestacao = rps.CidadeTomador; // VERIFICAR TRATAMENTO
                        rps.MunicipioPrestacaoDescricao = rps.CidadeTomadorDescricao; // VERIFICAR TRATAMENTO   
                    }
                    else
                    {
                        rps.MunicipioPrestacao = daoUtil.GetCodigoSiafiByCodigo(row["cd_munPrestacao"].ToString());
                        rps.MunicipioPrestacaoDescricao = daoUtil.GetNM_MUNICIPIO(row["cd_munPrestacao"].ToString());
                    }
                    rps.Operacao = row["Operacao"].ToString();
                    rps.Tributacao = row["Tributacao"].ToString();

                    rps.ValorPIS = row["ValorPIS"].ToString();
                    rps.ValorCOFINS = row["ValorCOFINS"].ToString();
                    rps.ValorINSS = row["ValorINSS"].ToString();
                    rps.ValorCSLL = row["ValorCSLL"].ToString();


                    rps.ValorIR = GetValorIR(cd_nfseq).ToString();



                    rps.AliquotaPIS = Convert.ToDecimal(row["AliquotaPIS"].ToString());
                    rps.AliquotaCOFINS = Convert.ToDecimal(row["AliquotaCOFINS"].ToString());
                    rps.AliquotaINSS = Convert.ToDecimal(row["AliquotaINSS"].ToString());
                    rps.AliquotaIR = Convert.ToDecimal(row["AliquotaIR"].ToString());    //Convert.ToDecimal(GetValorIR(cd_nfseq));
                    rps.AliquotaCSLL = Convert.ToDecimal(row["AliquotaCSLL"].ToString());




                    rps.DescricaoRPS = daoUtil.GetTotImpostosServ(cd_nfseq) + GetDescricaoRPS(cd_nfseq);
                    if (Acesso.TRANSPARENCIA == 0 || Acesso.TRANSPARENCIA == 2)
                    {
                        rps.DescricaoRPS += Environment.NewLine + daoUtil.CarregaObsTransparenciaNF(cd_nfseq);
                    }

                    rps.TelefonePrestador = row["TelefonePrestador"].ToString();
                    rps.TelefoneTomador = row["TelefoneTomador"].ToString();
                    rps.MotCancelamento = "";

                    #endregion

                    rps.Itens = new LoteRPSItens();
                    rps.Itens.Item = new List<LoteRPSItensItem>();
                    // Carregos os Itens da Nota
                    base.GetItens(cd_nfseq);
                    LoteRPSItensItem item;
                    foreach (DataRow rowItem in dtItem.Rows)
                    {
                        rps.AliquotaAtividade = base.GetAliquotaAtividade(rowItem["cd_clifor"].ToString(), rowItem["cd_oper"].ToString()).ToString();
                        item = new LoteRPSItensItem();
                        item.DiscriminacaoServico = rowItem["DiscriminacaoServico"].ToString();
                        if (Acesso.TRANSPARENCIA == 1 || Acesso.TRANSPARENCIA == 2)
                        {
                            item.DiscriminacaoServico += Environment.NewLine + daoUtil.CarregaObsTransparenciaITEM(rowItem["nr_lanc"].ToString());
                        }
                        item.Quantidade = Convert.ToByte(rowItem["Quantidade"].ToString());
                        item.ValorUnitario = Convert.ToDecimal(rowItem["ValorUnitario"].ToString());
                        item.ValorTotal = Convert.ToDecimal(rowItem["ValorTotal"].ToString());
                        rps.Itens.Item.Add(item);
                    }

                    // Verificar de onde ira puxar as deduções.
                    rps.Deducoes = new LoteRPSDeducoes();
                    rps.Deducoes.Deducao = new List<LoteRPSDeducoesDeducao>();

                    belConsultaSequencia seq = new belConsultaSequencia();
                    if (!bBuscaRetonro)
                    {
                        rps.NumeroRPS = seq.GetSequenciaNota(rps.InscricaoMunicipalPrestador, cd_nfseq);
                        this.SaveNumRPS(cd_nfseq, rps.NumeroRPS);
                    }
                    else
                    {
                        rps.NumeroRPS = this.GetNumeroRPSsalvo(cd_nfseq);
                    }

                    rps.Assinatura = belCarregaDadosRPS.GetAssinatura(rps);

                }
                return rps;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private LoteRPS CarregaLote(string cd_nfseq)
        {
            try
            {
                base.GetRps(cd_nfseq);

                LoteRPS rps = null;
                foreach (DataRow row in dtRPS.Rows)
                {
                    rps          = new LoteRPS();
                    rps.CD_NFSEQ = cd_nfseq;

                    #region Carrega as propriedades do RPS
                    rps.InscricaoMunicipalPrestador = Util.TiraSimbolo(row["InscricaoMunicipalPrestador"].ToString()).PadLeft(9, '0');
                    rps.TipoRPS              = "RPS";
                    rps.SerieRPS             = "NF";
                    rps.RazaoSocialPrestador = row["RazaoSocialPrestador"].ToString();
                    //rps.NumeroRPS = sNumeroRps;
                    rps.DataEmissaoRPS             = DateTime.Today;// Convert.ToDateTime(row["DataEmissaoRPS"].ToString());
                    rps.SituacaoRPS                = row["SituacaoRPS"].ToString();
                    rps.SerieRPSSubstituido        = row["SerieRPSSubstituido"].ToString();
                    rps.NumeroRPSSubstituido       = Convert.ToByte(row["NumeroRPSSubstituido"].ToString());
                    rps.NumeroNFSeSubstituida      = Convert.ToByte(row["NumeroNFSeSubstituida"].ToString());
                    rps.DataEmissaoNFSeSubstituida = Convert.ToDateTime(row["DataEmissaoNFSeSubstituida"].ToString());
                    rps.SeriePrestacao             = Convert.ToByte(row["SeriePrestacao"].ToString());
                    rps.InscricaoMunicipalTomador  = row["InscricaoMunicipalTomador"].ToString().PadLeft(9, '0');
                    rps.CPFCNPJTomador             = Util.TiraSimbolo(row["CNPJ_Tomador"].ToString() == "" ? row["CPF_Tomador"].ToString() : row["CNPJ_Tomador"].ToString());
                    rps.RazaoSocialTomador         = row["RazaoSocialTomador"].ToString().Trim();
                    rps.DocTomadorEstrangeiro      = row["DocTomadorEstrangeiro"].ToString();
                    rps.TipoLogradouroTomador      = row["TipoLogradouroTomador"].ToString();
                    rps.LogradouroTomador          = row["LogradouroTomador"].ToString();
                    rps.NumeroEnderecoTomador      = row["NumeroEnderecoTomador"].ToString();
                    rps.TipoBairroTomador          = "Bairro";
                    rps.ComplementoEnderecoTomador = row["ComplementoEnderecoTomador"].ToString();
                    rps.BairroTomador              = row["BairroTomador"].ToString();
                    rps.CidadeTomador              = daoUtil.GetCodigoSiafiByCodigo((row["CidadeTomador"].ToString()));
                    rps.CidadeTomadorDescricao     = row["CidadeTomadorDescricao"].ToString();
                    rps.CEPTomador       = Util.TiraSimbolo(row["CEPTomador"].ToString());
                    rps.EmailTomador     = row["EmailTomador"].ToString();
                    rps.CodigoAtividade  = row["CodigoAtividade"].ToString();
                    rps.TipoRecolhimento = row["TipoRecolhimento"].ToString();
                    if (row["cd_munPrestacao"].ToString() == "")
                    {
                        rps.MunicipioPrestacao          = rps.CidadeTomador;          // VERIFICAR TRATAMENTO
                        rps.MunicipioPrestacaoDescricao = rps.CidadeTomadorDescricao; // VERIFICAR TRATAMENTO
                    }
                    else
                    {
                        rps.MunicipioPrestacao          = daoUtil.GetCodigoSiafiByCodigo(row["cd_munPrestacao"].ToString());
                        rps.MunicipioPrestacaoDescricao = daoUtil.GetNM_MUNICIPIO(row["cd_munPrestacao"].ToString());
                    }
                    rps.Operacao   = row["Operacao"].ToString();
                    rps.Tributacao = row["Tributacao"].ToString();

                    rps.ValorPIS    = row["ValorPIS"].ToString();
                    rps.ValorCOFINS = row["ValorCOFINS"].ToString();
                    rps.ValorINSS   = row["ValorINSS"].ToString();
                    rps.ValorCSLL   = row["ValorCSLL"].ToString();


                    rps.ValorIR = GetValorIR(cd_nfseq).ToString();



                    rps.AliquotaPIS    = Convert.ToDecimal(row["AliquotaPIS"].ToString());
                    rps.AliquotaCOFINS = Convert.ToDecimal(row["AliquotaCOFINS"].ToString());
                    rps.AliquotaINSS   = Convert.ToDecimal(row["AliquotaINSS"].ToString());
                    rps.AliquotaIR     = Convert.ToDecimal(row["AliquotaIR"].ToString()); //Convert.ToDecimal(GetValorIR(cd_nfseq));
                    rps.AliquotaCSLL   = Convert.ToDecimal(row["AliquotaCSLL"].ToString());



                    rps.DescricaoRPS = daoUtil.GetTotImpostosServ(cd_nfseq) + GetDescricaoRPS(cd_nfseq);
                    if (Acesso.TRANSPARENCIA == 0 || Acesso.TRANSPARENCIA == 2)
                    {
                        rps.DescricaoRPS += Environment.NewLine + daoUtil.CarregaObsTransparenciaNF(cd_nfseq);
                    }

                    rps.TelefonePrestador = row["TelefonePrestador"].ToString();
                    rps.TelefoneTomador   = row["TelefoneTomador"].ToString();
                    rps.MotCancelamento   = "";

                    #endregion

                    rps.Itens      = new LoteRPSItens();
                    rps.Itens.Item = new List <LoteRPSItensItem>();
                    // Carregos os Itens da Nota
                    base.GetItens(cd_nfseq);
                    LoteRPSItensItem item;
                    foreach (DataRow rowItem in dtItem.Rows)
                    {
                        rps.AliquotaAtividade = base.GetAliquotaAtividade(rowItem["cd_clifor"].ToString(), rowItem["cd_oper"].ToString()).ToString();
                        item = new LoteRPSItensItem();
                        item.DiscriminacaoServico = rowItem["DiscriminacaoServico"].ToString();
                        if (Acesso.TRANSPARENCIA == 1 || Acesso.TRANSPARENCIA == 2)
                        {
                            item.DiscriminacaoServico += Environment.NewLine + daoUtil.CarregaObsTransparenciaITEM(rowItem["nr_lanc"].ToString());
                        }
                        item.Quantidade    = Convert.ToByte(rowItem["Quantidade"].ToString());
                        item.ValorUnitario = Convert.ToDecimal(rowItem["ValorUnitario"].ToString());
                        item.ValorTotal    = Convert.ToDecimal(rowItem["ValorTotal"].ToString());
                        rps.Itens.Item.Add(item);
                    }

                    // Verificar de onde ira puxar as deduções.
                    rps.Deducoes         = new LoteRPSDeducoes();
                    rps.Deducoes.Deducao = new List <LoteRPSDeducoesDeducao>();

                    belConsultaSequencia seq = new belConsultaSequencia();
                    if (!bBuscaRetonro)
                    {
                        rps.NumeroRPS = seq.GetSequenciaNota(rps.InscricaoMunicipalPrestador, cd_nfseq);
                        this.SaveNumRPS(cd_nfseq, rps.NumeroRPS);
                    }
                    else
                    {
                        rps.NumeroRPS = this.GetNumeroRPSsalvo(cd_nfseq);
                    }

                    rps.Assinatura = belCarregaDadosRPS.GetAssinatura(rps);
                }
                return(rps);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }