public ActionResult Index(string id)
        {
            Models.Boleto boleto = Models.TalonarioService.VerificarBoleto(id);
            if (boleto == null)
            {
                return(RedirectToAction("Invalido"));
            }

            ViewBag.CuentaBancaria = null;
            if (boleto.clave_sorteo.HasValue)
            {
                Sorteo sorteo = SorteoService.Obtener(boleto.clave_sorteo.Value);
                if (sorteo != null)
                {
                    ViewBag.CuentaBancaria = sorteo.cuenta_bancaria;
                }
            }

            ViewBag.ReferenciaBancaria = null;
            if (boleto.clave_colaborador.HasValue)
            {
                Colaborador colaborador = ColaboradorService.ObtienePorClave(boleto.clave_colaborador.Value);
                if (colaborador != null)
                {
                    ViewBag.ReferenciaBancaria = colaborador.referencia_bancaria;
                }
            }
            ViewBag.Boleto = boleto;
            ViewBag.QrCode = Convert.ToBase64String(Models.TalonarioService.GenerateQRCode(string.Format("{0}/boleto/{1}", ConfigurationManager.AppSettings["App.Url.Base"], boleto.token)).ToArray());
            return(View());
        }
Ejemplo n.º 2
0
        private Models.Boleto GerarBoleto(int id_faturamento)
        {
            MobLink.Framework.WebServices.WSBoleto ws = new Framework.WebServices.WSBoleto(MobLink.Framework.Util.DetectarAmbiente());
            var b = Business.Report.ViewBoleto.Retornar(id_faturamento);

            var boletoTodos = new Framework.WebServices._WSBoleto.BoletoTodos()
            {
                banco           = b.cedente_codigo_febraban,
                carteira        = b.sacado_carteira,
                numeroDocumento = b.numero_documento,
                valor_boleto    = b.valor_boleto,
                vencimento      = b.vencimento,

                cedente_agencia           = b.cedente_agencia,
                cedente_codigo            = b.cedente_codigo,
                cedente_conta             = b.cedente_conta_corrente,
                cedente_cpfCnpj           = b.cedente_documento,
                cedente_digitoConta       = b.cedente_dv,
                cedente_nome              = b.cedente_nome,
                cedente_nossoNumeroBoleto = b.cedente_nosso_numero,

                instrucoes      = b.sacado_instrucoes,
                sacado_bairro   = b.sacado_bairro,
                sacado_cep      = b.sacado_cep,
                sacado_cidade   = b.sacado_cidade,
                sacado_cpfCnpj  = b.sacado_documento,
                sacado_endereco = b.sacado_endereco,
                sacado_nome     = b.sacado_nome,
                sacado_uf       = b.sacado_uf
            };

            int    id_boleto       = 0;
            string linha_digitavel = string.Empty;

            var ambiente = Framework.Util.LerConfiguracao("AMBIENTE");

            var boleto = ws.BoletoBancosRetornoLinha(boletoTodos, "pdf", out linha_digitavel, out id_boleto, IsDev: ambiente == "D");

            var modelBoleto = new Models.Boleto()
            {
                IdBoleto       = id_boleto,
                ImagemBoleto   = boleto,
                LinhaDigitavel = linha_digitavel,
                Valor          = b.valor_boleto,
                Vencimento     = b.vencimento
            };

            var idFaturamentoBoleto = Business.Faturamento.FaturamentoBoletos.Cadastrar(id_faturamento,
                                                                                        modelBoleto.IdBoleto,
                                                                                        Business.Sistema.Configuracoes.id_usuario,
                                                                                        Convert.ToDecimal(modelBoleto.Valor),
                                                                                        modelBoleto.LinhaDigitavel);

            Business.Faturamento.FaturamentoBoletosImagens.Cadastrar(idFaturamentoBoleto, modelBoleto.ImagemBoleto);

            return(modelBoleto);
        }
Ejemplo n.º 3
0
        // Post api/<controller>/Vender
        public int Vender([FromBody] Models.BoletoVenta boleto)
        {
            Models.Boleto boletoVenta = new Models.Boleto();
            boletoVenta.clave           = long.Parse(boleto.clave);
            boletoVenta.comprador       = boleto.comprador;
            boletoVenta.folio           = boleto.folio;
            boletoVenta.folio_talonario = boleto.folio_talonario;

            Models.Colaborador persona = Models.ColaboradorService.Obtiene(User.Identity.Name);
            return(Models.TalonarioService.VenderBoleto(boletoVenta, persona.clave));
        }
Ejemplo n.º 4
0
 public string GetDigitableLineBoleto(Models.Boleto boleto)
 {
     try
     {
         var response = GetBoleto(boleto);
         return(response.create_request.bank_slip.digitable_line);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 5
0
 public string GetPdfBoleto(Models.Boleto boleto)
 {
     try
     {
         var returnTicket = GetBoleto(boleto);
         return(returnTicket.create_request.bank_slip.url_slip_pdf);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult Detalles(string id, string folio_digital)
        {
            Models.Boleto boleto = Models.TalonarioService.VerificarBoleto(id);
            if (boleto == null || string.IsNullOrEmpty(folio_digital))
            {
                return(RedirectToAction("Invalido"));
            }

            if (string.IsNullOrEmpty(boleto.folio_digital) || boleto.folio_digital.ToLower() != folio_digital.ToLower())
            {
                return(RedirectToAction("Invalido"));
            }

            ViewBag.CuentaBancaria = null;
            if (boleto.clave_sorteo.HasValue)
            {
                Sorteo sorteo = SorteoService.Obtener(boleto.clave_sorteo.Value);
                if (sorteo != null)
                {
                    ViewBag.CuentaBancaria = sorteo.cuenta_bancaria;
                }
            }

            ViewBag.ReferenciaBancaria = null;
            if (boleto.clave_colaborador.HasValue)
            {
                Colaborador colaborador = ColaboradorService.ObtienePorClave(boleto.clave_colaborador.Value);
                if (colaborador != null)
                {
                    ViewBag.ReferenciaBancaria = colaborador.referencia_bancaria;
                }
            }
            ViewBag.Boleto = boleto;
            ViewBag.QrCode = Convert.ToBase64String(Models.TalonarioService.GenerateQRCode(string.Format("{0}/boleto/{1}", ConfigurationManager.AppSettings["App.Url.Base"], boleto.token)).ToArray());


            System.Drawing.Image frenteBoleto = Bitmap.FromFile(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Imagenes/Boleto_final_Sorteo_2017.png"));
            Graphics             g            = Graphics.FromImage(frenteBoleto);

            g.DrawString(boleto.folio, System.Drawing.SystemFonts.DefaultFont, System.Drawing.Brushes.Black, new RectangleF(832, 13, 85, 29));

            MemoryStream frenteImage = new MemoryStream();

            frenteBoleto.Save(frenteImage, System.Drawing.Imaging.ImageFormat.Jpeg);
            frenteImage.Position = 0;

            ViewBag.BoletoFrente = Convert.ToBase64String(frenteImage.ToArray());
            return(View());
        }
Ejemplo n.º 7
0
        private BoletoResponse GetBoleto(Models.Boleto boleto)
        {
            var response = DoRequest.Post("/transaction/create/", boleto);

            if (!response.IsSuccessful)
            {
                throw new Exception("Erro na requisição!");
            }

            var returnTicket = JsonConvert.DeserializeObject <BoletoResponse>(response.Content);

            if (returnTicket is not null && returnTicket.create_request.result == "reject")
            {
                throw new Exception($"Erro na requisição! - erro: {returnTicket.create_request.response_message}");
            }

            throw new NullReferenceException("Erro na geração do boleto!");
        }
Ejemplo n.º 8
0
        public Models.Boleto PegarSegundaViaBoleto(int id_faturamento)
        {
            Model.Faturamento.FaturamentoBoletos boleto =
                new Model.Faturamento.FaturamentoBoletos();

            List <Model.Faturamento.FaturamentoBoletos> boletos =
                Business.Faturamento.FaturamentoBoletos.Listar(id_faturamento);

            if (boletos != null)
            {
                boleto = boletos.LastOrDefault();
            }
            else
            {
                return(new Models.Boleto());
            }

            var imagem =
                Business.Faturamento.FaturamentoBoletosImagens.DownloadByteArray(boleto.id_faturamento_boleto);

            var figura =
                Business.Faturamento.FaturamentoBoletosImagens.DownloadMemoryStream(boleto.id_faturamento_boleto);

            var retorno = new Models.Boleto()
            {
                IdBoleto       = boleto.id_boleto,
                ImagemBoleto   = imagem,
                LinhaDigitavel = boleto.linha,
                Valor          = Convert.ToString(boleto.valor)
            };

            return(retorno);

            #region ANTIGO
            //#region DECLARAÇÃO DE VARIÁVEIS
            //DateTime data_vencimento = DateTime.Now;
            //#endregion DECLARAÇÃO DE VARIÁVEIS

            //#region PRIMEIRO VERIFICO SE HOUVE AVANÇO NO STATUS DO GRV, PARA NÃO REEMPRIMIR A SEGUNDA-VIA INDEVIDAMENTE.
            //try
            //{
            //    using (var consulta = Business.GRV.GRV.ConsultarRelacionado(modelGRV, null, null, Business.Sistema.Configuracoes.id_usuario))
            //    {
            //        if (consulta != null)
            //        {
            //            modelGRV.id_grv = Funcoes.DataBase.GetInt(consulta, "id_grv");

            //            modelGRV.numero_formulario_grv = Funcoes.DataBase.GetString(consulta, "numero_formulario_grv");

            //            modelGRV.id_deposito = Funcoes.DataBase.GetInt(consulta, "id_deposito");

            //            modelGRV.id_status_operacao = Funcoes.DataBase.GetString(consulta, "id_status_operacao");

            //            modelGRV.data_hora_guarda = Funcoes.DataBase.GetString(consulta, "data_hora_guarda");

            //            if (!new[] { "L" }.Contains(modelGRV.id_status_operacao))
            //            {
            //                //Global.MessageBoxExclamation(this, "Houve avanço no Status deste GRV.\n\nStatus atual: " + DataBase.GetString(consulta, "status_operacao_descricao"));

            //                //btnImprimir.Enabled = false;

            //                //txtGRV.Focus(); return;
            //            }
            //        }
            //        else
            //        {
            //            //Global.MessageBoxExclamation(this, "Você não possui permissão para selecionar este GRV, este GRV não está apto para Atendimento ou este GRV não existe.");

            //            //txtGRV.Focus(); return;

            //            return new Model.Faturamento.Faturamento();
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    //Global.MessageBoxError(this, "Ocorreu um erro ao selecionar o GRV.", ex);
            //    //return;
            //    return new Model.Faturamento.Faturamento();
            //}
            //#endregion PRIMEIRO VERIFICO SE HOUVE AVANÇO NO STATUS DO GRV, PARA NÃO REEMPRIMIR A SEGUNDA-VIA INDEVIDAMENTE.

            //#region ÚLTIMO FATURAMENTO
            //var modelFaturamento = new Model.Faturamento.Faturamento();

            //modelFaturamento.id_atendimento = modelAtendimento.id_atendimento;

            //using (var consultaFaturamento = Business.Faturamento.Faturamento.ConsultarUltimoFaturamento(modelFaturamento))
            //{
            //    if (consultaFaturamento != null)
            //    {
            //        modelFaturamento.id_faturamento = Funcoes.DataBase.GetInt(consultaFaturamento, "id_faturamento");

            //        modelFaturamento.id_tipo_meio_cobranca = Funcoes.DataBase.GetInt(consultaFaturamento, "id_tipo_meio_cobranca");
            //    }
            //    else
            //    {
            //        //Global.MessageBoxExclamation(this, "Faturamento não encontrado."); return;
            //        return new Model.Faturamento.Faturamento();
            //    }
            //}
            //#endregion ÚLTIMO FATURAMENTO

            //#region DEPOIS VERIFICO A DATA DE VENCIMENTO
            //try
            //{
            //    modelFaturamento = Business.Faturamento.Faturamento.Consultar(modelFaturamento.id_faturamento);

            //    if (modelFaturamento == null)
            //    {
            //        //Global.MessageBoxExclamation(this, "Faturamento não encontrado."); return;
            //        return new Model.Faturamento.Faturamento();
            //    }

            //    data_vencimento = modelFaturamento.data_vencimento;
            //}
            //catch (Exception ex)
            //{
            //    //Global.MessageBoxError(this, "Ocorreu um erro ao selecionar o Faturamento.", ex); //return;
            //    return new Model.Faturamento.Faturamento();
            //}
            //#endregion DEPOIS VERIFICO A DATA DE VENCIMENTO

            //#region CADASTRAR NOVO FATURAMENTO

            ////if (!Global.MessageBoxQuestion(this, "Atenção, o valor do pagamento será recalculado e uma nova data de vencimento será gerada.\n\nDeseja realmente realizar a impressão da segunda via deste Atendimento?"))
            ////{
            ////    return;
            ////}

            //#region AÍ VERIFICO DE NOVO, USUÁRIO É FODA!
            //try
            //{
            //    using (var consulta = Business.GRV.GRV.ConsultarRelacionado(modelGRV, null, null, Business.Sistema.Configuracoes.id_usuario))
            //    {
            //        if (consulta != null)
            //        {
            //            modelGRV.id_grv = Funcoes.DataBase.GetInt(consulta, "id_grv");

            //            modelGRV.numero_formulario_grv = Funcoes.DataBase.GetString(consulta, "numero_formulario_grv");

            //            modelGRV.id_deposito = Funcoes.DataBase.GetInt(consulta, "id_deposito");

            //            modelGRV.id_status_operacao = Funcoes.DataBase.GetString(consulta, "id_status_operacao");

            //            modelGRV.data_hora_guarda = Funcoes.DataBase.GetString(consulta, "data_hora_guarda");

            //            if (!new[] { "L" }.Contains(modelGRV.id_status_operacao))
            //            {
            //                //Global.MessageBoxExclamation(this, "Houve avanço no Status deste GRV.\n\nStatus atual: " + DataBase.GetString(consulta, "status_operacao_descricao"));

            //                //btnImprimir.Enabled = false;

            //                //txtGRV.Focus(); return;
            //                return new Model.Faturamento.Faturamento();
            //            }
            //        }
            //        else
            //        {
            //            //Global.MessageBoxExclamation(this, "Você não possui permissão para selecionar este GRV, este GRV não está apto para Atendimento ou este GRV não existe.");

            //            //txtGRV.Focus(); return;
            //            return new Model.Faturamento.Faturamento();
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    //Global.MessageBoxError(this, "Ocorreu um erro ao selecionar o GRV.", ex); return;
            //    return new Model.Faturamento.Faturamento();
            //}
            //#endregion AÍ VERIFICO DE NOVO, USUÁRIO É FODA!

            //#region INICIAR TRANSAÇÃO
            //try
            //{
            //    Business.Sistema.GlobalDataBase.BeginTransaction();
            //}
            //catch (Exception ex)
            //{
            //    //Global.MessageBoxError(this, "Ocorreu um erro ao iniciar a transação com o Banco de Dados.", ex); return;
            //    return new Model.Faturamento.Faturamento();
            //}
            //#endregion INICIAR TRANSAÇÃO

            //#region CADASTRAR O FATURAMENTO
            //try
            //{
            //    var modelParametrosCalculoFaturamento = new Model.Faturamento.CalcularFaturamentoParametros();

            //    modelParametrosCalculoFaturamento.id_grv = modelGRV.id_grv;

            //    modelParametrosCalculoFaturamento.id_usuario = Business.Sistema.Configuracoes.id_usuario;

            //    modelParametrosCalculoFaturamento.origemTipoComposicao = 'P'; // P = PÁTIO, L = LEILÃO

            //    modelParametrosCalculoFaturamento.flag_cadastrar_faturamento = true;

            //    modelParametrosCalculoFaturamento.dataHoraGuarda = modelCalculoDiarias.data_hora_guarda;

            //    modelParametrosCalculoFaturamento.listFaturamentoDesconto = new List<Model.Faturamento.FaturamentoDesconto>();

            //    modelFaturamento = Business.Faturamento.CalcularFaturamento.Calcular(modelParametrosCalculoFaturamento).modelFaturamento;


            //}
            //catch (Exception ex)
            //{
            //    Business.Sistema.GlobalDataBase.RollbackTransaction();

            //    //Global.MessageBoxError(this, "Ocorreu um erro ao cadastrar o Faturamento.", ex); return;
            //    return new Model.Faturamento.Faturamento();
            //}
            //#endregion CADASTRAR O FATURAMENTO

            //#region FINALIZAR TRANSAÇÃO
            //try
            //{
            //    Business.Sistema.GlobalDataBase.CommitTransaction();
            //}
            //catch (Exception ex)
            //{
            //    Business.Sistema.GlobalDataBase.RollbackTransaction();

            //    //Global.MessageBoxError(this, "Ocorreu um erro ao finalizar a transação com o Banco de Dados.", ex); return;
            //    return new Model.Faturamento.Faturamento();
            //}
            //#endregion FINALIZAR TRANSAÇÃO

            //#endregion CADASTRAR NOVO FATURAMENTO

            //return modelFaturamento;
            #endregion
        }