//[ActionName("PostItau")]
        public BoletoOut PostItau(BoletoIn boletoIn)
        {
            GeradorItau geradorItau = new GeradorItau();
            var         boletoOut   = new BoletoOut();

            try
            {
                string MsgError = Validacao.ValidarGeral(boletoIn);
                if (!string.IsNullOrEmpty(MsgError))
                {
                    boletoOut.Sucesso  = false;
                    boletoOut.Mensagem = MsgError;
                    return(boletoOut);
                }

                //geradorItau.GerarBoletoTeste(boletoIn);
                geradorItau.GerarBoleto(boletoIn);
                boletoOut.Sucesso = true;
                return(boletoOut);
            }
            catch (Exception ex)
            {
                boletoOut.Sucesso = false;
                //boletoOut.Mensagem = "Falha Desconhecida: ";
                boletoOut.Mensagem = "Falha na Geração do Boleto: " + ex.Message;
                return(boletoOut);
            }
        }
예제 #2
0
        public MemoryStream GerarBoletoTeste(BoletoIn paramsBoleto)
        {
            DateTime           vencimento = DateTime.Now.AddDays(10);
            Instrucao_Bradesco item       = new Instrucao_Bradesco(9, 5);

            Cedente c = new Cedente("00.000.000/0000-00", "Empresa de Atacado",
                                    "1234", "5", "123456", "7");

            c.Codigo = "13000";

            //Carteiras
            BoletoNet.Boleto b = new BoletoNet.Boleto(vencimento, 1.00m, "09", "01000000001", c);
            b.ValorMulta      = 0.10m;
            b.ValorCobrado    = 1.10m;
            b.NumeroDocumento = "01000000001";
            b.DataVencimento  = new DateTime(2015, 09, 12);

            b.Sacado = new Sacado("000.000.000-00", "Nome do seu Cliente ");
            b.Sacado.Endereco.End    = "Endereço do seu Cliente ";
            b.Sacado.Endereco.Bairro = "Bairro";
            b.Sacado.Endereco.Cidade = "Cidade";
            b.Sacado.Endereco.CEP    = "00000000";
            b.Sacado.Endereco.UF     = "UF";

            item.Descricao += " após " + item.QuantidadeDias.ToString() + " dias corridos do vencimento.";
            b.Instrucoes.Add(item); //"Não Receber após o vencimento");

            Instrucao i = new Instrucao(237);

            i.Descricao = "Nova Instrução";
            b.Instrucoes.Add(i);

            /* A data de vencimento não é usada
             * Usado para mostrar no lugar da data de vencimento o termo "Contra Apresentação";
             * Usado na carteira 06 */

            var boletoBancario = new BoletoBancario();

            boletoBancario.CodigoBanco = 237;
            boletoBancario.MostrarContraApresentacaoNaDataVencimento = true;
            boletoBancario.Boleto = b;
            boletoBancario.Boleto.Valida();

            try
            {
                //return SaveBoletoPDF(boleto_bancario.MontaBytesPDF(), false);
                return(SaveBoletoPDF(boletoBancario.MontaBytesPDF(), true));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #3
0
        public BoletoOut GerarBoleto(BoletoIn boletoIn)
        {
            DateTime           vencimento = Convert.ToDateTime(boletoIn.Vencimento);
            Instrucao_Bradesco item       = new Instrucao_Bradesco(9, 5);

            Cedente cedente = new Cedente(boletoIn.Cedente.CNPJ, boletoIn.Cedente.Nome,
                                          boletoIn.Cedente.Agencia, boletoIn.Cedente.DigitoAgencia, boletoIn.Cedente.Conta, boletoIn.Cedente.DigitoConta);

            cedente.Codigo   = boletoIn.Cedente.Codigo;
            cedente.Convenio = 9;

            //Carteiras
            BoletoNet.Boleto b = new BoletoNet.Boleto(vencimento,
                                                      Convert.ToDecimal(boletoIn.Valor), "09", boletoIn.Numero, cedente);

            b.ValorMulta      = 0.10m;
            b.ValorCobrado    = 1.10m;
            b.NumeroDocumento = boletoIn.Numero;
            //b.DataVencimento = new DateTime(2015, 09, 12);

            b.Sacado = new Sacado(boletoIn.Sacado.CNPJ, boletoIn.Sacado.Nome);
            b.Sacado.Endereco.End    = boletoIn.Sacado.Endereco;
            b.Sacado.Endereco.Bairro = boletoIn.Sacado.Bairro;
            b.Sacado.Endereco.Cidade = boletoIn.Sacado.Cidade;
            b.Sacado.Endereco.CEP    = boletoIn.Sacado.CEP;
            b.Sacado.Endereco.UF     = boletoIn.Sacado.UF;

            item.Descricao += " após " + item.QuantidadeDias.ToString() + " dias corridos do vencimento.";
            b.Instrucoes.Add(item); //"Não Receber após o vencimento");

            var boletoBancario = new BoletoBancario();

            boletoBancario.CodigoBanco = 237;
            boletoBancario.MostrarContraApresentacaoNaDataVencimento = true;

            boletoBancario.Boleto = b;
            boletoBancario.Boleto.Valida();

            BoletoOut boletoOut = new BoletoOut();

            try
            {
                boletoOut.Boleto = ConvertBase64(SaveBoletoPDF(boletoBancario.MontaBytesPDF()));
                //boletoOut.Remessa = ConvertBase64(GerarRemessa(b.Cedente, boletoBancario.Boleto));
                return(boletoOut);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #4
0
        public MemoryStream GerarBoleto(BoletoIn boletoIn)
        {
            Cedente cedente = new Cedente(boletoIn.Cedente.CPF,
                                          boletoIn.Cedente.Nome, boletoIn.Cedente.Agencia, boletoIn.Cedente.Conta, boletoIn.Cedente.DigitoConta);

            cedente.Codigo = Convert.ToInt32(boletoIn.Cedente.Codigo).ToString();

            Boleto boleto = new Boleto(Convert.ToDateTime(boletoIn.Vencimento),
                                       Convert.ToDecimal(boletoIn.Valor),
                                       "109", boletoIn.Cedente.NumeroBoleto, cedente);

            boleto.NumeroDocumento = boletoIn.Numero;

            Sacado sacado = new Sacado(boletoIn.Sacado.CPF, boletoIn.Sacado.Nome);

            boleto.Sacado = sacado;
            boleto.Sacado.Endereco.End    = boletoIn.Sacado.Endereco;
            boleto.Sacado.Endereco.Bairro = boletoIn.Sacado.Bairro;
            boleto.Sacado.Endereco.Cidade = boletoIn.Sacado.Cidade;
            boleto.Sacado.Endereco.CEP    = boletoIn.Sacado.CEP;
            boleto.Sacado.Endereco.UF     = boletoIn.Sacado.UF;

            Instrucao_Itau instrucao = new Instrucao_Itau();

            instrucao.Descricao = "Não Receber após o vencimento";
            boleto.Instrucoes.Add(instrucao);

            EspecieDocumento_Itau especieItau     = new EspecieDocumento_Itau("99");
            BoletoBancario        boleto_bancario = new BoletoBancario();

            boleto.EspecieDocumento     = especieItau;
            boleto_bancario.CodigoBanco = 341;

            boleto_bancario.Boleto = boleto;
            boleto_bancario.MostrarCodigoCarteira = true;
            //boleto_bancario.Boleto.Valida();
            boleto_bancario.MostrarComprovanteEntrega = true;

            try
            {
                return(SaveBoletoPDF(boleto_bancario.MontaBytesPDF()));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public static string ValidarGeral(BoletoIn boletoIn)
        {
            string MsgError = Validacao.ValidarBoleto(boletoIn.Vencimento, boletoIn.Valor);

            if (!string.IsNullOrEmpty(MsgError))
            {
                return(MsgError);
            }

            MsgError = Validacao.ValidarCedente(boletoIn.Cedente);
            if (!string.IsNullOrEmpty(MsgError))
            {
                return(MsgError);
            }

            MsgError = Validacao.ValidarSacado(boletoIn.Sacado);
            if (!string.IsNullOrEmpty(MsgError))
            {
                return(MsgError);
            }

            return(string.Empty);
        }
예제 #6
0
        public MemoryStream GerarBoletoTeste(BoletoIn paramsBoleto)
        {
            String vencimento      = paramsBoleto.Vencimento;
            String valorBoleto     = paramsBoleto.Valor;
            String numeroDocumento = "B20005446";

            //cedente
            String cedente_codigo            = "1111111";
            String cedente_nossoNumeroBoleto = "22222222";
            String cedente_cpfCnpj           = "123.456.789-01";
            String cedente_nome        = "CHRISTOPHER LAMBERT FRIGERIO DE SOUZA.";
            String cedente_agencia     = "1000";
            String cedente_conta       = "22507";
            String cedente_digitoConta = "6";

            //sacado
            String sacado_cpfCnpj  = "000.000.000-00";
            String sacado_nome     = "Christopher Lambert";
            String sacado_endereco = "Rua Domingos da Costa Aroso 149 R/C";
            String sacado_bairro   = "Moreira";
            String sacado_cidade   = "Cidade";
            String sacado_cep      = "4470-313";
            String sacado_uf       = "PR";

            Cedente cedente = new Cedente(cedente_cpfCnpj,
                                          cedente_nome,
                                          cedente_agencia,
                                          cedente_conta,
                                          cedente_digitoConta);

            cedente.Codigo = Convert.ToInt32(cedente_codigo).ToString();

            Boleto boleto = new Boleto(Convert.ToDateTime(vencimento),
                                       Convert.ToDecimal(valorBoleto),
                                       "109",
                                       cedente_nossoNumeroBoleto, cedente);

            boleto.NumeroDocumento = numeroDocumento;

            Sacado sacado = new Sacado(sacado_cpfCnpj, sacado_nome);

            boleto.Sacado = sacado;
            boleto.Sacado.Endereco.End    = sacado_endereco;
            boleto.Sacado.Endereco.Bairro = sacado_bairro;
            boleto.Sacado.Endereco.Cidade = sacado_cidade;
            boleto.Sacado.Endereco.CEP    = sacado_cep;
            boleto.Sacado.Endereco.UF     = sacado_uf;

            Instrucao_Itau instrucao = new Instrucao_Itau();

            instrucao.Descricao = "Não Receber após o vencimento";
            boleto.Instrucoes.Add(instrucao);

            EspecieDocumento_Itau especieItau     = new EspecieDocumento_Itau("99");
            BoletoBancario        boleto_bancario = new BoletoBancario();

            boleto.EspecieDocumento     = especieItau;
            boleto_bancario.CodigoBanco = 341;

            boleto_bancario.Boleto = boleto;
            boleto_bancario.MostrarCodigoCarteira = true;
            //boleto_bancario.Boleto.Valida();
            boleto_bancario.MostrarComprovanteEntrega = true;

            try
            {
                //return SaveBoletoPDF(boleto_bancario.MontaBytesPDF(), false);
                return(SaveBoletoPDF(boleto_bancario.MontaBytesPDF(), true));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }