示例#1
0
        public override void LerDetalheRetornoCNAB240SegmentoT(ref Boleto boleto, string registro)
        {
            try
            {
                //Nº Controle do Participante
                boleto.NumeroControleParticipante = registro.Substring(105, 25);

                //Carteira
                boleto.Carteira = registro.Substring(57, 1);
                switch (boleto.Carteira)
                {
                case "3":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaCaucionada;
                    break;

                case "4":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaDescontada;
                    break;

                default:
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaSimples;
                    break;
                }

                //Identificação do Título no Banco
                boleto.NossoNumero          = registro.Substring(39, 17);
                boleto.NossoNumeroDV        = registro.Substring(56, 1);
                boleto.NossoNumeroFormatado = Format("{0}-{1}", boleto.NossoNumero, boleto.NossoNumeroDV);

                //Identificação de Ocorrência
                boleto.CodigoMovimentoRetorno    = registro.Substring(15, 2);
                boleto.DescricaoMovimentoRetorno = Cnab.MovimentoRetornoCnab240(boleto.CodigoMovimentoRetorno);
                boleto.CodigoMotivoOcorrencia    = registro.Substring(213, 10);
                boleto.ListMotivosOcorrencia     = Cnab.MotivoOcorrenciaCnab240(boleto.CodigoMotivoOcorrencia, boleto.CodigoMovimentoRetorno);

                //Número do Documento
                boleto.NumeroDocumento  = registro.Substring(58, 11);
                boleto.EspecieDocumento = TipoEspecieDocumento.NaoDefinido;

                //Valor do Título
                boleto.ValorTitulo  = Convert.ToDecimal(registro.Substring(81, 15)) / 100;
                boleto.ValorTarifas = Convert.ToDecimal(registro.Substring(198, 15)) / 100;

                //Data Vencimento do Título
                boleto.DataVencimento = Utils.ToDateTime(Utils.ToInt32(registro.Substring(73, 8)).ToString("##-##-####"));

                // Registro Retorno
                boleto.RegistroArquivoRetorno = boleto.RegistroArquivoRetorno + registro + Environment.NewLine;
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler detalhe do arquivo de RETORNO / CNAB 240 / T.", ex);
            }
        }
示例#2
0
        public void LerDetalheRetornoCNAB400Segmento1(ref Boleto boleto, string registro)
        {
            try
            {
                // Identificação do Título no Banco
                boleto.NossoNumero          = registro.Substring(47, 8);
                boleto.NossoNumeroDV        = registro.Substring(55, 1);
                boleto.NossoNumeroFormatado = string.Format("{0}/{1}-{2}", boleto.NossoNumero.Substring(0, 2), boleto.NossoNumero.Substring(2, 6), boleto.NossoNumeroDV);

                // Identificação de Ocorrência
                boleto.CodigoMovimentoRetorno    = registro.Substring(108, 2);
                boleto.DescricaoMovimentoRetorno = DescricaoOcorrenciaCnab400(boleto.CodigoMovimentoRetorno);

                // Data Ocorrência no Banco
                boleto.DataProcessamento = Utils.ToDateTime(Utils.ToInt32(registro.Substring(110, 6)).ToString("##-##-##"));

                // Número do Documento
                boleto.NumeroDocumento = registro.Substring(116, 10).Trim();

                // Seu número - Seu número enviado na Remessa
                boleto.NumeroControleParticipante = registro.Substring(116, 10).Trim();

                //Data Vencimento do Título
                boleto.DataVencimento = Utils.ToDateTime(Utils.ToInt32(registro.Substring(146, 6)).ToString("##-##-##"));

                //Valores do Título
                boleto.ValorTitulo         = Convert.ToDecimal(registro.Substring(152, 13)) / 100;
                boleto.ValorAbatimento     = Convert.ToDecimal(registro.Substring(227, 13)) / 100;
                boleto.ValorDesconto       = Convert.ToDecimal(registro.Substring(240, 13)) / 100;
                boleto.ValorPago           = Convert.ToDecimal(registro.Substring(253, 13)) / 100;
                boleto.ValorJurosDia       = Convert.ToDecimal(registro.Substring(266, 13)) / 100;
                boleto.ValorOutrosCreditos = Convert.ToDecimal(registro.Substring(279, 13)) / 100;

                boleto.ValorPago += boleto.ValorJurosDia;

                // Data do Crédito
                boleto.DataCredito = Utils.ToDateTime(Utils.ToInt32(registro.Substring(328, 8)).ToString("####-##-##"));

                // Identificação de Ocorrência - Código Auxiliar
                boleto.CodigoMotivoOcorrencia = registro.Substring(318, 10);
                boleto.ListMotivosOcorrencia  = Cnab.MotivoOcorrenciaCnab240(boleto.CodigoMotivoOcorrencia, boleto.CodigoMovimentoRetorno);

                // Registro Retorno
                boleto.RegistroArquivoRetorno = boleto.RegistroArquivoRetorno + registro + Environment.NewLine;
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler detalhe do arquivo de RETORNO / CNAB 400.", ex);
            }
        }
        public override void LerDetalheRetornoCNAB240SegmentoT(ref Boleto boleto, string registro)
        {
            try
            {
                boleto.NumeroControleParticipante = registro.Substring(105, 25);
                boleto.Carteira = registro.Substring(57, 1);
                switch (boleto.Carteira)
                {
                case "3":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaCaucionada;
                    break;

                default:
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaSimples;
                    break;
                }
                boleto.NossoNumero                = registro.Substring(37, 18);
                boleto.NossoNumeroDV              = registro.Substring(54, 1);
                boleto.NossoNumeroFormatado       = boleto.NossoNumero + "-" + boleto.NossoNumeroDV;
                boleto.CodigoMovimentoRetorno     = registro.Substring(15, 2);
                boleto.DescricaoMovimentoRetorno  = Cnab.MovimentoRetornoCnab240(boleto.CodigoMovimentoRetorno);
                boleto.CodigoMotivoOcorrencia     = registro.Substring(213, 10);
                boleto.ListMotivosOcorrencia      = Cnab.MotivoOcorrenciaCnab240(boleto.CodigoMotivoOcorrencia, boleto.CodigoMovimentoRetorno);
                boleto.NumeroDocumento            = registro.Substring(58, 15);
                boleto.EspecieDocumento           = TipoEspecieDocumento.NaoDefinido;
                boleto.ValorTitulo                = Convert.ToDecimal(registro.Substring(81, 15)) / 100M;
                boleto.ValorTarifas               = Convert.ToDecimal(registro.Substring(198, 15)) / 100M;
                boleto.DataVencimento             = Utils.ToDateTime(Utils.ToInt32(registro.Substring(73, 8)).ToString("##-##-####"));
                boleto.BancoCobradorRecebedor     = registro.Substring(96, 3);
                boleto.AgenciaCobradoraRecebedora = registro.Substring(99, 6);
                boleto.Pagador = new Pagador();
                string str = registro.Substring(133, 15);
                boleto.Pagador.CPFCNPJ        = str.Substring(str.Length - 14, 14);
                boleto.Pagador.Nome           = registro.Substring(148, 40);
                boleto.RegistroArquivoRetorno = boleto.RegistroArquivoRetorno + registro + Environment.NewLine;
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler detalhe do arquivo de RETORNO / CNAB 240 / T.", ex);
            }
        }
示例#4
0
        public void LerDetalheRetornoCNAB240SegmentoT(ref Boleto boleto, string registro)
        {
            try
            {
                //Nº Controle do Participante
                boleto.NumeroControleParticipante = registro.Substring(100, 25);

                //Carteira
                boleto.Carteira = registro.Substring(53, 1);
                switch (boleto.Carteira)
                {
                case "3":
                case "6":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaCaucionada;
                    break;

                case "4":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaDescontada;
                    break;

                default:
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaSimples;
                    break;
                }

                //Identificação do Título no Banco
                boleto.NossoNumero          = registro.Substring(40, 12);
                boleto.NossoNumeroDV        = registro.Substring(52, 1);
                boleto.NossoNumeroFormatado = Format("{0}-{1}", boleto.NossoNumero, boleto.NossoNumeroDV);

                //Identificação de Ocorrência
                boleto.CodigoOcorrencia         = registro.Substring(15, 2);
                boleto.DescricaoOcorrencia      = Cnab.OcorrenciaCnab240(boleto.CodigoOcorrencia);
                boleto.CodigoOcorrenciaAuxiliar = registro.Substring(208, 10);

                //Número do Documento
                boleto.NumeroDocumento  = registro.Substring(54, 15);
                boleto.EspecieDocumento = TipoEspecieDocumento.NaoDefinido;

                //Valor do Título
                boleto.ValorTitulo = Convert.ToDecimal(registro.Substring(77, 15)) / 100;

                //Data Vencimento do Título
                boleto.DataVencimento = Utils.ToDateTime(Utils.ToInt32(registro.Substring(69, 8)).ToString("##-##-####"));

                //093 – 095 Nº do Banco Cobrador / Recebedor N 003 - LAYOUT V 2.8 Fevereiro/2017 Pág 9
                boleto.BancoCobradorRecebedor = registro.Substring(92, 3);

                //096 – 099 Agência Cobradora / Recebedora N 004 - LAYOUT V 2.8 Fevereiro/2017 Pág 9
                //100 – 100 Dígito da Agência do Beneficiário N 001 - LAYOUT V 2.8 Fevereiro/2017 Pág 9
                boleto.AgenciaCobradoraRecebedora = registro.Substring(95, 5);

                //129 – 143 Número de inscrição Pagador N 015 30 - LAYOUT V 2.8 Fevereiro/2017 Pág 9
                //aqui, apesar de haver 15 caracteres no layout, pegamos apenas os últimos 14(o necessário) pois há uma validação no momento da atribuição(set) do CPFCNPJ
                boleto.Sacado         = new Sacado();
                boleto.Sacado.CPFCNPJ = registro.Substring(129, 14);

                //144 - 183 Nome do Pagador A 040 - LAYOUT V 2.8 Fevereiro/2017 Pág 9
                boleto.Sacado.Nome = registro.Substring(143, 40);

                //194 – 208 Valor da Tarifa / Custas N 015 2 - LAYOUT V 2.8 Fevereiro/2017 Pág 9
                boleto.ValorTarifas = Convert.ToDecimal(registro.Substring(193, 15)) / 100;

                // Registro Retorno
                boleto.RegistroArquivoRetorno = boleto.RegistroArquivoRetorno + registro + Environment.NewLine;
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler detalhe do arquivo de RETORNO / CNAB 240 / T.", ex);
            }
        }
示例#5
0
        public override void LerDetalheRetornoCNAB240SegmentoT(ref Boleto boleto, string registro)
        {
            try
            {
                //Nº Controle do Participante
                boleto.NumeroControleParticipante = registro.Substring(105, 25);

                //Carteira
                boleto.Carteira = registro.Substring(57, 1);
                switch (boleto.Carteira)
                {
                case "1":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaSimples;
                    break;

                case "2":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaVinculada;
                    break;

                case "3":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaCaucionada;
                    break;

                case "4":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaDescontada;
                    break;

                case "5":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaVendor;
                    break;

                default:
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaSimples;
                    break;
                }

                //Identificação do Título no Banco
                boleto.NossoNumero          = registro.Substring(37, 20).Trim();
                boleto.NossoNumeroDV        = "";
                boleto.NossoNumeroFormatado = boleto.NossoNumero;

                //Identificação de Ocorrência
                boleto.CodigoMovimentoRetorno    = registro.Substring(15, 2);
                boleto.DescricaoMovimentoRetorno = Cnab.MovimentoRetornoCnab240(boleto.CodigoMovimentoRetorno);
                boleto.CodigoMotivoOcorrencia    = registro.Substring(213, 10);
                boleto.ListMotivosOcorrencia     = Cnab.MotivoOcorrenciaCnab240(boleto.CodigoMotivoOcorrencia, boleto.CodigoMovimentoRetorno);

                //Número do Documento
                boleto.NumeroDocumento  = registro.Substring(58, 15);
                boleto.EspecieDocumento = TipoEspecieDocumento.NaoDefinido;

                //Valor do Título
                boleto.ValorTitulo  = Convert.ToDecimal(registro.Substring(81, 15)) / 100;
                boleto.ValorTarifas = Convert.ToDecimal(registro.Substring(198, 15)) / 100;

                //Data Vencimento do Título
                boleto.DataVencimento = Utils.ToDateTime(Utils.ToInt32(registro.Substring(73, 8)).ToString("##-##-####"));

                //18.3T 97 99 3 - Num Banco Cobr./Receb.
                boleto.BancoCobradorRecebedor = registro.Substring(96, 3);
                //19.3T 100 104 5 - Num	Ag. Cobradora
                boleto.AgenciaCobradoraRecebedora = registro.Substring(99, 6);

                //Dados Pagador
                boleto.Pagador = new Pagador();
                string str = registro.Substring(133, 15);
                boleto.Pagador.CPFCNPJ = str.Substring(str.Length - 14, 14);
                boleto.Pagador.Nome    = registro.Substring(148, 40);


                // Registro Retorno
                boleto.RegistroArquivoRetorno = boleto.RegistroArquivoRetorno + registro + Environment.NewLine;
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler detalhe do arquivo de RETORNO / CNAB 240 / T.", ex);
            }
        }
示例#6
0
        public override void LerDetalheRetornoCNAB240SegmentoT(ref Boleto boleto, string registro)
        {
            try
            {
                //Nº Controle do Participante
                boleto.NumeroControleParticipante = registro.Substring(105, 25);

                //Carteira
                boleto.Carteira = registro.Substring(57, 1);
                switch (boleto.Carteira)
                {
                case "3":
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaCaucionada;
                    break;

                default:
                    boleto.TipoCarteira = TipoCarteira.CarteiraCobrancaSimples;
                    break;
                }

                //Identificação do Título no Banco
                //Conforme Manual, Nosso Número deve ter 7 dígitos + DV.
                //No arquivo retorno, volta com 10 dígitos. Entendemos que os 2 primeiros serão sempre 00, seguido de 7 dígitos + 1 dígito DV.
                //Se isso não ocorrer, será necessário alterar o método FormatarNossoNumero (onde considera apenas 7 digitos).
                if (registro.Substring(37, 2) != "00")
                {
                    throw new Exception("Verificar arquivo retorno:  O nosso número no arquivo retorno é maior que 7 dígitos.");
                }
                boleto.NossoNumero          = registro.Substring(39, 7); //Sem o DV
                boleto.NossoNumeroDV        = registro.Substring(46, 1); //DV
                boleto.NossoNumeroFormatado = $"{boleto.NossoNumero}-{boleto.NossoNumeroDV}";

                //Identificação de Ocorrência
                boleto.CodigoMovimentoRetorno    = registro.Substring(15, 2);
                boleto.DescricaoMovimentoRetorno = Cnab.MovimentoRetornoCnab240(boleto.CodigoMovimentoRetorno);
                boleto.CodigoMotivoOcorrencia    = registro.Substring(213, 10);
                boleto.ListMotivosOcorrencia     = Cnab.MotivoOcorrenciaCnab240(boleto.CodigoMotivoOcorrencia, boleto.CodigoMovimentoRetorno);

                //Número do Documento
                boleto.NumeroDocumento  = registro.Substring(58, 15);
                boleto.EspecieDocumento = TipoEspecieDocumento.NaoDefinido;

                //Valor do Título
                boleto.ValorTitulo  = Convert.ToDecimal(registro.Substring(81, 15)) / 100;
                boleto.ValorTarifas = Convert.ToDecimal(registro.Substring(198, 15)) / 100;

                //Data Vencimento do Título
                boleto.DataVencimento = Utils.ToDateTime(Utils.ToInt32(registro.Substring(73, 8)).ToString("##-##-####"));

                //18.3T 97 99 3 - Num Banco Cobr./Receb.
                boleto.BancoCobradorRecebedor = registro.Substring(96, 3);
                //19.3T 100 104 5 - Num	Ag. Cobradora
                boleto.AgenciaCobradoraRecebedora = registro.Substring(99, 6);

                //Dados Pagador
                boleto.Pagador = new Pagador();
                string str = registro.Substring(133, 15);
                boleto.Pagador.CPFCNPJ = str.Substring(str.Length - 14, 14);
                boleto.Pagador.Nome    = registro.Substring(148, 40);


                // Registro Retorno
                boleto.RegistroArquivoRetorno = boleto.RegistroArquivoRetorno + registro + Environment.NewLine;
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler detalhe do arquivo de RETORNO / CNAB 240 / T.", ex);
            }
        }