public Boolean PagarCuota(DetallePrestamoEntidad cuota)
 {
     try
     {
         Boolean cuotaPagada = DetallePrestamoDAO.Instancia.PagarCuota(cuota);
         //LOGICA DE ULTIMA CUOTA
         if (cuotaPagada && cuota.detprestamo_nro_cuota == cuota.prestamoID.prestamo_cuotas)
         {
             Boolean prestamocompleto = PrestamoServicio.Instancia.CompletarPrestamo(cuota.prestamoID.prestamoID);
             if (prestamocompleto)
             {
                 cuotaPagada = true;
             }
             else
             {
                 throw new ArgumentException("Error al actualizar estado de prestamo");
             }
         }
         return(cuotaPagada);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public List <DetallePrestamoEntidad> GenerarCronograma(PrestamoEntidad pr)
        {
            List <DetallePrestamoEntidad> listadetalleprestamo    = new List <DetallePrestamoEntidad>();
            DetallePrestamoEntidad        detallePrestamoAnterior = null;


            for (int x = 0; x <= pr.prestamo_cuotas; x++)
            {
                DetallePrestamoEntidad detallePrestamoExistente = null;

                if (x == 0)
                {
                    detallePrestamoExistente = GenerarPrimeraCuota(pr.monto_prestado);
                }
                else
                {
                    detallePrestamoExistente = GenerarCuota(x, pr.tasa_efectiva_mensual, pr.cuota_fija_mensual, detallePrestamoAnterior);
                }
                detallePrestamoExistente.prestamoID = pr;
                detallePrestamoAnterior             = detallePrestamoExistente;

                listadetalleprestamo.Add(detallePrestamoExistente);
            }


            return(listadetalleprestamo);
        }
        public ActionResult pagarCuota(int id)
        {
            ClienteEntidad         cliente  = (ClienteEntidad)Session["clientebuscado"];
            PrestamoEntidad        prestamo = PrestamoServicio.Instancia.RetornarPrestamo(cliente.clienteID);
            DetallePrestamoEntidad cuota    = DetallePrestamoServicio.Instancia.RetornaDetallePrestamo(prestamo, id);

            try
            {
                Boolean pagado = DetallePrestamoServicio.Instancia.PagarCuota(cuota);
                if (pagado)
                {
                    if (!cuota.esUltimaCuota())
                    {
                        return(RedirectToAction("mostrarPrestamo", new { id = cliente.cliente_DNI }));
                    }
                    else
                    {
                        TempData["msj"] = "<script>alert('Todas las cuotas han sido pagadas');</script>";
                        return(RedirectToAction("buscarCliente"));
                    }
                }
                else
                {
                    return(View("Error"));
                }
            }catch (Exception e)
            {
                throw e;
            }
        }
Exemple #4
0
        public Boolean PagarCuota(DetallePrestamoEntidad cuota)
        {
            SqlCommand cmd       = null;
            Boolean    pagacuota = false;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cn.Open();


                cmd = new SqlCommand("sp_pagaCuota", cn)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@detalleprestamoID", cuota.detalleprestamoID);
                cmd.Parameters.AddWithValue("@nrocuota", cuota.detprestamo_nro_cuota);



                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    pagacuota = true;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(pagacuota);
        }
Exemple #5
0
        public DetallePrestamoEntidad RetornaCuotaAPagar(PrestamoEntidad prestamo)
        {
            SqlCommand             cmd             = null;
            DetallePrestamoEntidad detalleprestamo = new DetallePrestamoEntidad();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("sp_retornaCuotaAPagar", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prestamoID", prestamo.prestamoID);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                dr.Read();



                detalleprestamo.detalleprestamoID        = Convert.ToInt16(dr["detalleprestamoID"]);
                detalleprestamo.detprestamo_nro_cuota    = Convert.ToInt16(dr["detprest_nro_cuota"]);
                detalleprestamo.detprestamo_monto_cuota  = Convert.ToDouble(dr["detprest_monto_cuota"]);
                detalleprestamo.detprestamo_interes      = Convert.ToDouble(dr["detprest_interes"]);
                detalleprestamo.detprestamo_amortizacion = Convert.ToDouble(dr["detprest_amortizacion"]);
                detalleprestamo.detprestamo_saldo        = Convert.ToDouble(dr["detprest_saldo"]);
                detalleprestamo.prestamoID = prestamo;
            }catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(detalleprestamo);
        }
        public DetallePrestamoEntidad GenerarCuota(int nCuota, Double tasa_efectiva_mensual, Double cuota_fija_mensual, DetallePrestamoEntidad cuotaAnterior)
        {
            DetallePrestamoEntidad cuota = new DetallePrestamoEntidad();

            cuota.detprestamo_nro_cuota    = nCuota;
            cuota.detprestamo_interes      = Math.Round(cuotaAnterior.detprestamo_saldo * tasa_efectiva_mensual, 2, MidpointRounding.AwayFromZero);
            cuota.detprestamo_amortizacion = Math.Round(cuota_fija_mensual - cuota.detprestamo_interes, 2, MidpointRounding.AwayFromZero);
            cuota.detprestamo_saldo        = Math.Round(cuotaAnterior.detprestamo_saldo - cuota.detprestamo_amortizacion, 2, MidpointRounding.AwayFromZero);
            cuota.detprestamo_monto_cuota  = Math.Round(cuota_fija_mensual, 2, MidpointRounding.AwayFromZero);
            return(cuota);
        }
        public DetallePrestamoEntidad GenerarPrimeraCuota(Double montoPrestamo)
        {
            DetallePrestamoEntidad primeraCuota = new DetallePrestamoEntidad();

            primeraCuota.detprestamo_monto_cuota  = 0;
            primeraCuota.detprestamo_amortizacion = 0;
            primeraCuota.detprestamo_nro_cuota    = 0;
            primeraCuota.detprestamo_interes      = 0;
            primeraCuota.detprestamo_saldo        = montoPrestamo;
            return(primeraCuota);
        }
 public ActionResult mostrarPrestamo(String id)
 {
     try
     {
         ClienteEntidad  cliente  = ClienteServicio.Instancia.RetornarCliente(id);
         PrestamoEntidad prestamo = PrestamoServicio.Instancia.RetornarPrestamo(cliente.clienteID);
         List <DetallePrestamoEntidad> listadetalleprestamo = DetallePrestamoServicio.Instancia.RetornaListaDetallePrestamo(prestamo);
         DetallePrestamoEntidad        cuotapagar           = DetallePrestamoServicio.Instancia.RetornaCuotaAPagar(prestamo);
         return(View(Tuple.Create(listadetalleprestamo, cuotapagar)));
     }catch (Exception e)
     {
         throw e;
     }
 }
Exemple #9
0
        public List <DetallePrestamoEntidad> RetornaListaDetallePrestamo(PrestamoEntidad prestamo)
        {
            SqlCommand cmd = null;
            List <DetallePrestamoEntidad> listadetalleentidad = new List <DetallePrestamoEntidad>();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("sp_retornaListaDetallePrestamo", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prestamoID", prestamo.prestamoID);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    DetallePrestamoEntidad detalleprestamo = new DetallePrestamoEntidad();
                    detalleprestamo.detalleprestamoID        = Convert.ToInt16(dr["detalleprestamoID"]);
                    detalleprestamo.detprestamo_nro_cuota    = Convert.ToInt16(dr["detprest_nro_cuota"]);
                    detalleprestamo.detprestamo_monto_cuota  = Convert.ToDouble(dr["detprest_monto_cuota"]);
                    detalleprestamo.detprestamo_interes      = Convert.ToDouble(dr["detprest_interes"]);
                    detalleprestamo.detprestamo_amortizacion = Convert.ToDouble(dr["detprest_amortizacion"]);
                    detalleprestamo.detprestamo_saldo        = Convert.ToDouble(dr["detprest_saldo"]);
                    detalleprestamo.prestamoID = prestamo;
                    if (dr["pagoID"] != DBNull.Value)
                    {
                        PagoEntidad pago = new PagoEntidad();
                        pago.pagoID            = Convert.ToInt16(dr["pagoID"]);
                        pago.pago_fechapago    = Convert.ToDateTime(dr["pago_fechapago"]);
                        pago.pago_nro_cuota    = Convert.ToInt16(dr["pago_nro_cuota"]);
                        pago.pago_activo       = Convert.ToBoolean(dr["pago_activo"]);
                        detalleprestamo.pagoID = pago;
                    }



                    listadetalleentidad.Add(detalleprestamo);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(listadetalleentidad);
        }