예제 #1
0
        public JsonResult Calcular(string dataJson)    //mejorar esto
        {
            if (string.IsNullOrEmpty(dataJson))
            {
                return(Json(new { codError = "400", mensaje = "Olvidaste ingresar algún campo" }));
            }
            FromFormSolicitudCreditoDto data = null;

            try
            {
                data = JsonConvert.DeserializeObject <FromFormSolicitudCreditoDto>(dataJson);
            }
            catch (System.Exception)
            {
                return(Json(new { codError = "400", mensaje = "Petición erronea" }));
            }

            string mensaje;
            var    infoCliente = Session["datosClienteCP"] as DatosClientePy;

            var infoCatalogo = Session["datosCatSimulacion"] as DatosForSimuladorViewDto;

            if (infoCatalogo == null)
            {
                return(Json(new { codError = "405" }));
            }

            if (!data.IsValidModelSimulador(_settings, out mensaje))
            {
                return(Json(new { codError = "400", mensaje }));
            }

            //aqui va servicio calcula    ******** MEJORAR ESTO
            string codError = "", resp = null;

            if (data.modoDePago.idCodigo == 12167)
            {
                resp = _repoCreditoPyme.CalcularCuotaAlVencimiento(data);
            }
            else
            {
                resp = _repoCreditoPyme.CalculaCuotaMensual(data, infoCliente.Cedula, ref codError);
            }
            if (resp == null)
            {
                return(Json(new { codError = "503", mensaje = InitialConfig.getNotiMessage("503", _settings).paragraph }));
            }

            data.tasaEfectiva              = infoCatalogo.TasaEfectiva;
            data.tasaNominal               = infoCatalogo.TasaNominal;
            data.cuota                     = resp;
            infoCliente.infoSolicitud      = data;
            infoCatalogo.SeleccionAnterior = data;
            Session["datosCatSimulacion"]  = infoCatalogo;
            Session["datosClienteCP"]      = infoCliente;

            return(Json(new { codError = "200", cuota = resp }));
        }
예제 #2
0
        public string CalcularCuotaAlVencimiento(FromFormSolicitudCreditoDto data)
        {
            //round( (20000 *(1+ (11.23/36500)* 60 )),2)
            //round( (monto solicitado * ( 1 + (tasa de interés nominal /365000) número de días)),2)
            DateTime futureDay; int days = 60;
            DateTime now = Convert.ToDateTime(DateTime.Today.Date, new CultureInfo("es-EC"));

            if (DateTime.TryParse(data.diaDePago, CultureInfo.CreateSpecificCulture("es-EC"), DateTimeStyles.None, out futureDay))
            {
                TimeSpan ts = futureDay - now;
                days = ts.Days;
            }

            return(Math.Round((int.Parse(data.monto) * (1 + (11.23 / 36500) * days)), 2).ToString());
        }
예제 #3
0
        public string CalculaCuotaMensual(FromFormSolicitudCreditoDto datosCredito, string cedula, ref string codError)
        {
            string mensajeRetorno = "", dividendo = "", totalCredito;

            try
            {
                var resp = _ContratacionProducto.SimulacionCreditoMate14("C", cedula, _settings.ProductoCP.IdProductoNeo.ToString(), "1", datosCredito.plazoCredito.Descripcion.GetMonths(),
                                                                         datosCredito.amortizacion, datosCredito.monto + ".00", "", "0", "0", ref codError, ref mensajeRetorno, out dividendo, out totalCredito);
            }
            catch (System.Exception)
            {
                codError = "503";
            }

            return(dividendo);
        }
예제 #4
0
        public string RegistrarSolitud(string cedula, FromFormSolicitudCreditoDto soli)
        {
            string resp, mensajeRetorno, codigoRetorno;

            try
            {
                resp = _ContratacionProducto.RegistrarSolicitudCreditoPyme(cedula, soli.monto, soli.destinoCredito.idCodigo,
                                                                           soli.modoDePago.idCodigo, soli.plazoCredito.idCodigo,
                                                                           soli.amortizacion, soli.fechaPago.ToInt(), soli.diaDePago,
                                                                           soli.tasaNominal, soli.cuota, out codigoRetorno, out mensajeRetorno);
            }
            catch (Exception)
            {
                resp = "503";
            }

            return(resp);
        }
예제 #5
0
        public byte[] GetTablaAmortizacion(DatosClientePy dataCliente, FromFormSolicitudCreditoDto soli)
        {
            string CodigoRetorno, MensajeRetorno;

            byte[] pdf;
            try
            {
                pdf = _ContratacionProducto.SimularTablaAmortizacion("PDF", dataCliente.Cedula, "C", dataCliente.Nombres,
                                                                     _settings.ProductoSG.IdProductoNeo.ToString(), soli.amortizacion, soli.monto + ".00", soli.plazoCredito.Descripcion.Split(' ')[0], "1", out CodigoRetorno, out MensajeRetorno);
            }
            catch (Exception)
            {
                pdf            = null;
                CodigoRetorno  = "503";
                MensajeRetorno = "servicio no desoinible por el momento.";
            }

            return(pdf);
        }
예제 #6
0
        public static bool IsValidModelSimulador(this FromFormSolicitudCreditoDto value, CommonApplicationSettings _settings, out string mensaje)
        {
            if (value == null)
            {
                mensaje = "Petición Erronea";
                return(false);
            }
            mensaje = "";
            if (string.IsNullOrEmpty(value.monto))
            {
                mensaje = "Debes Ingresar un monto para acceder a su crédito";
                return(false);
            }
            if (string.IsNullOrEmpty(value.destinoCredito.Descripcion))
            {
                mensaje = "Debes seleccionar el destino de su crédito";
                return(false);
            }
            if (string.IsNullOrEmpty(value.modoDePago.Descripcion))
            {
                mensaje = "Debes seleccionar el modo de pago de su crédito";
                return(false);
            }
            if (value.monto.Any(char.IsLetter))
            {
                mensaje = "El campo monto contiene Letras";
                return(false);
            }

            /*var valorSoli = int.Parse(value.Monto);
             * if (valorSoli > _settings.RangoDeSobregiro.valorMax || valorSoli < _settings.RangoDeSobregiro.valorMin){
             *  mensaje = "Debes ingresar un monto entre [1,000 - 40,000]";
             *  return false;
             * }*/

            if (value.modoDePago.idCodigo == 12167) //al vencimiento
            {
                DateTime temp;
                if (!(DateTime.TryParse(value.fechaPago, CultureInfo.CreateSpecificCulture("es-EC"), DateTimeStyles.None, out temp)))
                {
                    mensaje = "fecha no válida. formato fecha: " + String.Format("{0:dd/MM/yyyy}", DateTime.Today);
                    return(false);
                }

                if ((temp.DayOfWeek == DayOfWeek.Saturday) || (temp.DayOfWeek == DayOfWeek.Sunday))
                {
                    mensaje = "\n No se permiten Sábado y Domingos";
                    return(false);
                }

                var hoy     = Convert.ToDateTime(DateTime.Today.Date, new CultureInfo("es-EC"));
                var MinDate = hoy.AddDays(_settings.RangoDeCreditoPyme.minDias);
                var MaxDate = MinDate.AddDays(_settings.RangoDeCreditoPyme.maxDias);

                if (temp > MaxDate)
                {
                    mensaje = "\n  Fecha erroneo. Fecha Permitida hasta el " + String.Format("{0:dd/MM/yyyy}", MaxDate) + "\n fecha actual: " + String.Format("{0:dd/MM/yyyy}", hoy) + "\n" + "fecha introducida: " + String.Format("{0:dd/MM/yyyy}", temp);
                    return(false);
                }

                if (temp < MinDate)
                {
                    mensaje = "\n  Fecha erroneo. Fecha minima de selección: " + String.Format("{0:dd/MM/yyyy}", MinDate) + "\n fecha actual: " + String.Format("{0:dd/MM/yyyy}", hoy) + "\n" + "fecha introducida: " + String.Format("{0:dd/MM/yyyy}", temp);
                    return(false);
                }
            }

            if (value.modoDePago.idCodigo == 12168) //mensualmente
            {
                if (string.IsNullOrEmpty(value.plazoCredito.Descripcion))
                {
                    mensaje = "Debes seleccionar un plazo de su crédito";
                    return(false);
                }
                if (string.IsNullOrEmpty(value.amortizacion))
                {
                    mensaje = "Debes seleccionar el tipo de amortización";
                    return(false);
                }
                if (string.IsNullOrEmpty(value.diaDePago))
                {
                    mensaje = "Debes ingresar el dia de pago de su crédito";
                    return(false);
                }
                var dia = int.Parse(value.diaDePago);
                if (dia > 30 || dia < 1)
                {
                    mensaje = "Debes ingresar un dia entre [1-30]";
                    return(false);
                }
                if (value.amortizacion != "FRANCESA" && value.amortizacion != "ALEMANA")
                {
                    mensaje = "Tipo de amortizacion no válida";
                    return(false);
                }
            }
            return(true);
        }