Пример #1
0
        public static bool setAlteraPagamentos(NpgsqlConnection conexao, Pagamentos pagamentos)
        {
            bool alterou = false;

            try
            {
                String        sql = "update pagamentos set parcelas = @parcelas, valor = @valor, tipo = @tipo where i_pagamentos = @codigo";
                NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao);
                cmd.Parameters.Add("@parcelas", NpgsqlTypes.NpgsqlDbType.Integer).Value = pagamentos.parcelas;
                cmd.Parameters.Add("@valor", NpgsqlTypes.NpgsqlDbType.Double).Value     = pagamentos.valor;
                cmd.Parameters.Add("@tipo", NpgsqlTypes.NpgsqlDbType.Varchar).Value     = pagamentos.tipo;
                cmd.Parameters.Add("@codigo", NpgsqlTypes.NpgsqlDbType.Integer).Value   = pagamentos.i_pagamentos;

                int valor = cmd.ExecuteNonQuery();
                if (valor == 1)
                {
                    alterou = true;
                }
            }
            catch (NpgsqlException erro)
            {
                MessageBox.Show("Erro de sql:" + erro.Message);
                Console.WriteLine("Erro de sql:" + erro.Message);
            }
            return(alterou);
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    pagamentoID = int.Parse(tbPagamento.Text);
            String tipo        = tbTipo.Text;
            int    parcelas    = int.Parse(tbParcelas.Text);
            double valor       = double.Parse(tbValor.Text);

            Pagamentos pagamentos = new Pagamentos();

            pagamentos.i_pagamentos = pagamentoID;
            pagamentos.tipo         = tipo;
            pagamentos.parcelas     = parcelas;
            pagamentos.valor        = valor;

            bool incluiu = PagamentosDB.setIncluiPagamentos(conexao, pagamentos);

            if (incluiu)
            {
                MessageBox.Show("Pagamento cadastrado com sucesso!");
                Close();
            }
            else
            {
                MessageBox.Show("Erro ao cadastrar pagamento!");
            }
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Pagamentos newPagamento = new Pagamentos(Session.GetClientes(), Session.getCarrinho().IngresosSelec.Count() * 15);

            newPagamento.Id = pagamentoDB.lastPagamento() + 1;
            if (Session.GetClientes().UsePIMCoin)
            {
                int    pimCoin  = blockRepoDB.getId(Session.GetClientes().Id);
                int    lastId   = pimCoinTransDB.lastTransId();
                string previous = pimCoinTransDB.lastHashByUser(pimCoin);

                if (previous == "empty")
                {
                    previous = "first";
                }

                PimCoinTrans newPimCoinTrans = new PimCoinTrans(previous, pimCoin);
                newPimCoinTrans.Id = lastId + 1;
                newPimCoinTrans.setNewkeyCurrent(Session.GetClientes().Id);

                newPagamento.PimCoinTrans = newPimCoinTrans.Id;
                newOrderForClient(Session.getCarrinho(), newPagamento, newPimCoinTrans);
            }
            else
            {
                newOrderForClient(Session.getCarrinho(), newPagamento);
            }



            paymentConfirmationMessage msg = new paymentConfirmationMessage();

            this.Hide();
            msg.Show();
        }
Пример #4
0
        public static bool setIncluiPagamentos(NpgsqlConnection conexao, Pagamentos pagamentos)
        {
            bool incluiu = false;

            try
            {
                String        sql = "insert into pagamentos(i_pagamentos,parcelas, valor, tipo) values(@i_pagamentos,@parcelas, @valor, @tipo)";
                NpgsqlCommand cmd = new NpgsqlCommand(sql, conexao);
                cmd.Parameters.Add("@i_pagamentos", NpgsqlTypes.NpgsqlDbType.Integer).Value = pagamentos.i_pagamentos;
                cmd.Parameters.Add("@parcelas", NpgsqlTypes.NpgsqlDbType.Integer).Value     = pagamentos.parcelas;
                cmd.Parameters.Add("@valor", NpgsqlTypes.NpgsqlDbType.Double).Value         = pagamentos.valor;
                cmd.Parameters.Add("@tipo", NpgsqlTypes.NpgsqlDbType.Varchar).Value         = pagamentos.tipo;

                int valor = cmd.ExecuteNonQuery();
                if (valor == 1)
                {
                    incluiu = true;
                }
            }
            catch (NpgsqlException erro)
            {
                MessageBox.Show("Erro de SQL:" + erro.Message);
                Console.WriteLine("Erro de SQL:" + erro.Message);
            }
            return(incluiu);
        }
Пример #5
0
        public ActionResult Inserir(Pagamentos pagamento)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                new Business.PagamentosBusiness().AddPagamentos(pagamento);

                //}
                var retorno = new
                {
                    mensagem = "Pagamento Inserida com Sucesso!",
                    erro     = false,
                    id       = pagamento.pagamentoID
                };

                return(Json(retorno, JsonRequestBehavior.AllowGet));
            }
            catch (System.Exception e)
            {
                var retorno = new
                {
                    mensagem = e.Message.ToString(),//"Ocorreu algum erro ao inserir Usuário!",
                    erro     = true
                };

                return(Json(retorno, JsonRequestBehavior.AllowGet));
            }
        }
Пример #6
0
        public ActionResult Editar(Pagamentos pagamento)
        {
            try
            {
                new Business.PagamentosBusiness().EditPagamentos(pagamento);

                var retorno = new
                {
                    mensagem = "Pagamento Atualizada com Sucesso!",
                    erro     = false,
                    id       = pagamento.pagamentoID
                };

                return(Json(retorno, JsonRequestBehavior.AllowGet));
            }
            catch (System.Exception e)
            {
                var retorno = new
                {
                    mensagem = e.Message.ToString(),//"Ocorreu algum erro ao editar Usuário!",
                    erro     = true
                };

                return(Json(retorno, JsonRequestBehavior.AllowGet));
            }
        }
Пример #7
0
        public static int Insert(Pagamentos pagamentos)
        {
            int retorno = 0;

            try {
                IDbConnection objConexao; // Abre a conexao
                IDbCommand    objCommand; // Cria o comando
                string        sql = "INSERT INTO pagamentos(pag_data_criacao, pag_data_vencimento, pag_data_pagamento, ins_codigo, pla_codigo)" +
                                    " VALUES(?pag_data_criacao, ?pag_data_vencimento, ?pag_data_pagamento, ?ins_codigo, ?pla_codigo);" +
                                    "SELECT LAST_INSERT_ID();";
                objConexao = Mapped.Connection();
                objCommand = Mapped.Command(sql, objConexao);
                objCommand.Parameters.Add(Mapped.Parameter("?pag_data_criacao", pagamentos.Pag_data_criacao));
                objCommand.Parameters.Add(Mapped.Parameter("?pag_data_vencimento", pagamentos.Pag_data_vencimento));
                objCommand.Parameters.Add(Mapped.Parameter("?pag_data_pagamento", pagamentos.Pag_data_pagamento));
                //FK
                objCommand.Parameters.Add(Mapped.Parameter("?ins_codigo", pagamentos.Ins_codigo.Ins_codigo));
                objCommand.Parameters.Add(Mapped.Parameter("?pla_codigo", pagamentos.Pla_codigo.Pla_codigo));

                retorno = Convert.ToInt32(objCommand.ExecuteScalar());

                objConexao.Close();
                objCommand.Dispose();
                objConexao.Dispose();
            } catch (Exception e) {
                retorno = -2;
            }
            return(retorno);
        }
        private void btnAdicionar_Click(object sender, EventArgs e)
        {
            Pagamentos pagamentoSelecionado = (Pagamentos)cboPagamento.SelectedItem;

            if (txtValor.Numero == decimal.Zero)
            {
                MessageBox.Show("Valor nulo inválido");
            }
            else if (modelo.PagamentosColecao.Any(a => a.PagamentoSelecionado == pagamentoSelecionado))
            {
                MessageBox.Show("Pagamento já incluso na lista");
            }
            else if (txtValorPendente.Numero < (txtValor.Numero + txtValorVariavel.Numero))
            {
                MessageBox.Show("Pagamento ultrapassou o valor do produto");
            }
            else
            {
                modelo.PagamentosColecao.Add(new Pagamento()
                {
                    PagamentoSelecionado = pagamentoSelecionado,
                    Valor = txtValor.Numero,
                    Vezes = pagamentoSelecionado != Pagamentos.Crédito ? (byte?)null : (byte)numericVezes.Value
                });
                if (pagamentoSelecionado == Pagamentos.Desconto)
                {
                    txtValorPendente.Numero = txtValorPendente.Numero - txtValor.Numero;
                }
                else
                {
                    txtValorVariavel.Numero = txtValorVariavel.Numero + txtValor.Numero;
                }
                txtValor.Numero = 0;
            }
        }
Пример #9
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtTaxa.Text == "")
                {
                    lblMessagem.Text = "Por favor, Preencha todos os campos";
                }
                else
                {
                    Pagamentos p = new Pagamentos();
                    p.Apartamento    = Convert.ToInt32(cbxApartamento.Text);
                    p.TaxaCondominio = Convert.ToDecimal(txtTaxa.Text);
                    p.FormaPagamento = cbxFormaPagamento.Text;
                    p.Data           = Convert.ToDateTime(dtpDataPagamento.Text);
                    p.Mes            = cbxMes.Text;
                    p.Observacoes    = txtObservacoes.Text;

                    PagamentosController pc = new PagamentosController();
                    pc.Create(p);

                    lblMessagem.Text = "Pagamento Cadastrado com sucesso!";

                    txtObservacoes.Text = "";
                    txtTaxa.Text        = "";
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        // POST: api/Endereco
        public IHttpActionResult Pagamentos([FromBody] Pagamentos pagamentos)
        {
            if (autenticar.autenticacao(Request, 2) == null)
            {
                return(Content(HttpStatusCode.Unauthorized, "Credenciais Invalidas ou Ausentes!"));
            }

            Pagamentos pag = new Pagamentos();

            pag.Pag_data_criacao    = pagamentos.Pag_data_criacao;
            pag.Pag_data_vencimento = pagamentos.Pag_data_vencimento;
            pag.Pag_data_pagamento  = pagamentos.Pag_data_pagamento;
            pag.Ins_codigo          = pagamentos.Ins_codigo;
            pag.Pla_codigo          = pagamentos.Pla_codigo;

            int retorno = PagamentosDB.Insert(pag);

            if (retorno == -2)
            {
                return(BadRequest());
            }
            else
            {
                return(Ok(retorno));
            }
        }
Пример #11
0
        private void button3_Click(object sender, EventArgs e)
        {
            int    codigoPagamento = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            int    parcelas        = int.Parse(dataGridView1.CurrentRow.Cells[1].Value.ToString());
            double valor           = double.Parse(dataGridView1.CurrentRow.Cells[2].Value.ToString());
            String tipo            = dataGridView1.CurrentRow.Cells[3].Value.ToString();

            Pagamentos pagamentos = new Pagamentos();

            pagamentos.i_pagamentos = codigoPagamento;
            pagamentos.parcelas     = parcelas;
            pagamentos.valor        = valor;
            pagamentos.tipo         = tipo;

            bool alterou = PagamentosDB.setAlteraPagamentos(conexao, pagamentos);

            if (alterou)
            {
                MessageBox.Show("Pagamento alterado com sucesso!");
            }
            else
            {
                MessageBox.Show("Erro ao alterar pagamento");
            }
            atualizaTela();
        }
Пример #12
0
        private void btnEndSale_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja encerrar o pedido?", "Atenção", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if ((Pedido.limparPedido(inicial1.pedido, codigoDBarra) && (Cliente.atualizaCompra(inicial1.clientes, cpf))) == true)
                {
                    string cliente;
                    if (cpf != "null")
                    {
                        cliente = mskBNome.Text + "  " + cpf;
                    }
                    else
                    {
                        cliente = mskBNome.Text;
                    }

                    inicial1.armazenaPedido.Add(new Pagamentos()
                    {
                        ID          = Pagamentos.geradorId(inicial1.armazenaPedido),
                        CodigoUsado = codigoDBarra,
                        Cliente     = cliente,
                        DataeHora   = lblData.Text,
                        Situacao    = "Pedido finalizado",
                        Carrinho    = salvaCarrinho,
                        Valor       = Convert.ToDouble(mskValorTotal.Text.Replace("R$", ""))
                    });
                    Limpar_Pagamento();
                }
            }
        }
Пример #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            Pagamentos pagamentos = db.Pagamentos.Find(id);

            db.Pagamentos.Remove(pagamentos);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #14
0
 public void AdicionaPagamento(Pagamento pagamento)
 {
     Pagamentos.Add(pagamento);
     if (valorTotalDosPagamentos() >= Valor)
     {
         this.Pago = true;
     }
 }
Пример #15
0
        public void AdicionaPagamento(Pagamento pagamento)
        {
            Pagamentos.Add(pagamento);

            if (TotalPagamentos() >= Valor)
            {
                Pago = true;
            }
        }
Пример #16
0
        public void newPagamentoUseCard(Pagamentos newPagamento)
        {
            int    idCliente = newPagamento.getCliente().IdUsuario;
            float  valor     = newPagamento.Valor;
            int    id        = newPagamento.getId();
            string query     = "INSERT INTO `pagamento`(`id`,`id_cliente_id`, `use_card`, `valor`) VALUES (" + id + "," + idCliente + ", 1 ," + valor + ");";

            Insert(query);
        }
Пример #17
0
 public ActionResult Edit([Bind(Include = "idPagamentos,dt_pagamento,vl_pago,vl_cobrado,status_pagamento")] Pagamentos pagamentos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pagamentos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pagamentos));
 }
Пример #18
0
        public void newPagamentoUsePIM(Pagamentos newPagamento)
        {
            int   idCliente      = newPagamento.getCliente().IdUsuario;
            float valor          = newPagamento.Valor;
            int   id             = newPagamento.getId();
            int   pimCoinTransId = (int)newPagamento.PimCoinTrans;

            string query = "INSERT INTO `pagamento`(`id`, `id_cliente_id`, `use_pimcoin`, `valor`, `id_pim_coin_trans_id`) VALUES (" + id + "," + idCliente + ", 1 ," + valor + "," + pimCoinTransId + ")";

            Insert(query);
        }
Пример #19
0
 public ActionResult Edit([Bind(Include = "ID,DataPagamento,ValorPago,Jog_SocFK")] Pagamentos pagamentos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pagamentos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Jog_SocFK = new SelectList(db.Jog_Socs, "ID", "ID", pagamentos.Jog_SocFK);
     return(View(pagamentos));
 }
Пример #20
0
        public ActionResult Create([Bind(Include = "ID,DataPagamento,ValorPago,Jog_SocFK")] Pagamentos pagamentos)
        {
            if (ModelState.IsValid)
            {
                db.Pagamentos.Add(pagamentos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Jog_SocFK = new SelectList(db.Jog_Socs, "ID", "ID", pagamentos.Jog_SocFK);
            return(View(pagamentos));
        }
        private void cboPagamento_SelectedValueChanged(object sender, EventArgs e)
        {
            Pagamentos pagamento = (Pagamentos)cboPagamento.SelectedItem;

            if (pagamento == Pagamentos.Crédito)
            {
                numericVezes.Visible = lblVezes.Visible = true;
            }
            else
            {
                numericVezes.Visible = lblVezes.Visible = false;
            }
        }
Пример #22
0
        public async Task RemoverDadosAlunoAsync(int alunoId)
        {
            var aluno = await Alunos.FindAsync(alunoId);

            // Apagar aulas assistidas
            var aulasAssistidas = await AulasAssistidas.Where(aa => aa.AlunoId == aluno.Id).ToListAsync();

            if (aulasAssistidas != null)
            {
                AulasAssistidas.RemoveRange(aulasAssistidas);
            }

            // Apagar anotacoes
            var anotacoes = await AnotacoesAulas.Where(aa => aa.AlunoId == aluno.Id).ToListAsync();

            if (anotacoes != null)
            {
                AnotacoesAulas.RemoveRange(anotacoes);
            }

            // Apagar notas
            var notas = await Notas.Where(n => n.AlunoId == aluno.Id).ToListAsync();

            if (notas != null)
            {
                Notas.RemoveRange(notas);
            }

            // Apagar matriculas
            var matriculas = await Matriculas.Where(m => m.AlunoId == aluno.Id).ToListAsync();

            if (matriculas != null)
            {
                // Apagar Status Aulas
                foreach (var matricula in matriculas)
                {
                    var statusAulas = StatusAulas.Where(sa => sa.MatriculaId == matricula.Id).SingleOrDefault();
                    if (statusAulas != null)
                    {
                        StatusAulas.Remove(statusAulas);
                    }

                    var pagamento = await Pagamentos.Where(p => p.Id == matricula.PagamentoId).SingleOrDefaultAsync();

                    Pagamentos.Remove(pagamento);
                    Matriculas.Remove(matricula);
                }
            }

            await SaveChangesAsync();
        }
        /// <summary>
        /// Mostra a VIEW dos detalhes de um pagamento
        /// GET - ex.: Pagamentos/Details/5
        /// </summary>
        /// <param name="id"></param>
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            Pagamentos pagamento = db.Pagamentos.Find(id);

            if (pagamento == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(pagamento));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Pagamentos pagamento = db.Pagamentos.Find(id);

            try {
                db.Pagamentos.Remove(pagamento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception) {
                ModelState.AddModelError("", string.Format("Não foi possível eliminar este pagamento..."));
            }
            return(View(pagamento));
        }
Пример #25
0
        // GET: Pagamentos/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Pagamentos pagamentos = db.Pagamentos.Find(id);

            if (pagamentos == null)
            {
                return(HttpNotFound());
            }
            return(View(pagamentos));
        }
Пример #26
0
        // GET: Pagamentos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Pagamentos pagamentos = db.Pagamentos.Find(id);

            if (pagamentos == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Jog_SocFK = new SelectList(db.Jog_Socs, "ID", "ID", pagamentos.Jog_SocFK);
            return(View(pagamentos));
        }
Пример #27
0
        public void AdicionaPagamento(Pagamento pagamento)
        {
            Pagamentos.Add(pagamento);

            double valorTotal = 0;

            foreach (var p in Pagamentos)
            {
                valorTotal += p.Valor;
            }

            if (valorTotal >= Valor)
            {
                Pago = true;
            }
        }
Пример #28
0
        public ActionResult Create([Bind(Include = "idPagamentos,dt_pagamento,vl_pago,vl_cobrado,status_pagamento")] Pagamentos pagamentos, string DataServicos, string TipoPagamento)
        {
            ViewBag.DataServicos  = new SelectList(db.Clientes, "idCliente", "desc_nome_cliente");
            ViewBag.TipoPagamento = new SelectList(db.Tipos_Pagamentos, "idTipos_pagamento", "desc_tipo_pagamento");
            if (ModelState.IsValid)
            {
                int idAgenda = Convert.ToInt32(DataServicos);
                pagamentos.Agenda = db.Agendas.Find(idAgenda);
                int idTipos_pagamento = Convert.ToInt32(TipoPagamento);
                pagamentos.Tipos_Pagamento = db.Tipos_Pagamentos.Find(idTipos_pagamento);
                db.Pagamentos.Add(pagamentos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pagamentos));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            Pagamentos pagamento = db.Pagamentos.Find(id);

            if (pagamento == null)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.FuncionarioFK = new SelectList(db.Funcionarios, "FuncionarioID", "Nome", pagamento.FuncionarioFK);
            ViewBag.QuotaFK       = new SelectList(db.Quotas, "QuotaID", "Referencia", pagamento.QuotaFK);
            ViewBag.SocioFK       = new SelectList(db.Socios, "SocioID", "Nome", pagamento.SocioFK);
            return(View(pagamento));
        }
 public async Task AdicionaPagamentoAsync(Alunos aluno)
 {
     {
         double valorTotal = 0;
         string nomesAulas = "";
         foreach (var modalidade in aluno.Modalidades)
         {
             valorTotal += modalidade.Modalidade.Preco;
             nomesAulas += " - ";
             nomesAulas  = nomesAulas + modalidade.Modalidade.Name;
         }
         Pagamentos pagamento = new Pagamentos {
             DataPagamento = DateTime.Now, IdAluno = aluno.ID, ValorPago = valorTotal, AulasPagas = nomesAulas
         };
         _context.Pagamentos.Add(pagamento);
         await _context.SaveChangesAsync();
     }
 }
Пример #31
0
        private static void InsereTransacionado(IDbConnection conexão, IDbTransaction transação, Pagamentos.Pagamento pagamento, VendaDébito vendaDébito)
        {
            using (IDbCommand cmd = conexão.CreateCommand())
            {
                cmd.Transaction = transação;

                StringBuilder comandoStr = new StringBuilder();

                comandoStr.Append(" INSERT INTO vendadebito(venda, descricao, valorliquido, valorbruto, data, diasdejuros, cobrarjuros, pagamento) VALUES (");
                comandoStr.Append(DbTransformar(vendaDébito.Venda.Código));
                comandoStr.Append(", ");
                comandoStr.Append(DbTransformar(vendaDébito.Descrição, true));
                comandoStr.Append(", ");
                comandoStr.Append(DbTransformar(vendaDébito.ValorLíquido));
                comandoStr.Append(", ");
                comandoStr.Append(DbTransformar(vendaDébito.ValorBruto));
                comandoStr.Append(", ");
                comandoStr.Append(DbTransformar(vendaDébito.Data));
                comandoStr.Append(", ");
                comandoStr.Append(DbTransformar(vendaDébito.DiasDeJuros));
                comandoStr.Append(", ");
                comandoStr.Append(DbTransformar(vendaDébito.CobrarJuros));
                comandoStr.Append(", ");
                comandoStr.Append(DbTransformar(pagamento.Código));
                comandoStr.Append(" ) ");

                cmd.CommandText = comandoStr.ToString();

                if (pagamento.Código != vendaDébito.Pagamento.Value)
                    throw new InvalidProgramException();

                cmd.ExecuteNonQuery();
            }
        }
Пример #32
0
        private static void InsereTransacionado(IDbConnection conexão, IDbTransaction transação, Pagamentos.Pagamento pagamento)
        {
            using (IDbCommand cmd = conexão.CreateCommand())
            {
                cmd.Transaction = transação;

                cmd.CommandText = " update pagamento set pendente = 0 where codigo = " +
                    DbTransformar(pagamento.Código);

                cmd.ExecuteNonQuery();
            }
        }
Пример #33
0
        /// <summary>
        /// Calcula a dívida desta venda.
        /// </summary>
        /// <param name="valorFinalVenda">Valor com desconto e débitos da venda.</param>
        /// <param name="dataVenda">Data da venda.</param>
        /// <param name="hoje">Voce quer saber a dívida em qual data? </param>
        /// <param name="pagamentos">Lista de pagamentos efetuados.</param>
        /// <param name="prestações">Formato das prestações, para cálculo de juros.</param>
        /// <param name="dívida">Valor da dívida a pagar.</param>
        /// <param name="totaljuros">Juros cobrados.</param>
        /// <param name="taxajuros">Taxa de juros da venda.</param>
        /// <exception cref="PagamentoAmbíguo">Existe um ou mais pagamentos para várias vendas.</exception>
        public static void CalcularDívida(double valorFinalVenda, DateTime dataVenda, DateTime hoje, Pagamentos.IPagamento[] pagamentos, string[] prestações, double taxajuros, out double dívida, out double totaljuros)
        {
            //DateTime hoje = DadosGlobais.Instância.HoraDataAtual.Date;
            //int iPagamento = 0;

            dívida = valorFinalVenda;
            totaljuros = 0;

            List<Pagamentos.IPagamento> listaPagamentos = new List<Entidades.Pagamentos.IPagamento>(pagamentos);

            double pagoLíquido = Entidades.Pagamentos.Pagamento.CalcularValorPagoLíquido(listaPagamentos, dataVenda, taxajuros);
            dívida -= pagoLíquido;
            totaljuros = Entidades.Pagamentos.Pagamento.CalcularJuros(listaPagamentos, dataVenda, taxajuros);


            /* A variável dívida até agora tem a mesma data da venda.
             * O Seguinte código desloca para o tempo de hoje. 
             */

            //if (dívida > 0)
            //{
            double juros;

            //if (pagamentos.Length > 0)
            //    juros = Preço.CalcularJuros(
            //        ((TimeSpan)(hoje - pagamentos[pagamentos.Length - 1].Vencimento.Date)).Days,
            //        dívida, taxajuros);
            //else
            juros = Preço.CalcularJuros(
                dataVenda.Date,
                hoje,
                //                        ((TimeSpan)(hoje - data.Date)).Days,
                dívida, taxajuros);

            totaljuros += juros;
            dívida += juros;
            //}
        }