예제 #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 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);
            }
        }
        public override 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.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(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.Pagador         = new Pagador();
                boleto.Pagador.CPFCNPJ = registro.Substring(129, 14);

                //144 - 183 Nome do Pagador A 040 - LAYOUT V 2.8 Fevereiro/2017 Pág 9
                boleto.Pagador.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);
            }
        }
예제 #4
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);
            }
        }
예제 #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 "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);
            }
        }