Esempio n. 1
0
        public ActionResult MisCuentas()
        {
            int idUsuario = Convert.ToInt32(ClaimsPrincipal.Current.FindFirst(ClaimTypes.Sid).Value);
            M_FiltroMisCuentas filtroMisCuentas = Session["FiltroMisCuentas"] as M_FiltroMisCuentas;
            M_Home             model            = CompletarDatosHome(idUsuario, filtroMisCuentas);

            return(PartialView("_MisCuentas", model.MisCuentas));
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            int idUsuario = Convert.ToInt32(ClaimsPrincipal.Current.FindFirst(ClaimTypes.Sid).Value);
            M_FiltroMisCuentas filtroMisCuentas = new M_FiltroMisCuentas();

            filtroMisCuentas.FechaDesde = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            filtroMisCuentas.FechaHasta = filtroMisCuentas.FechaDesde.AddMonths(1).AddDays(-1);

            M_Home model = CompletarDatosHome(idUsuario, filtroMisCuentas);

            #region [Región: Actualizar Estados Objetivo
            var objetivoBusiness = new ObjetivoBusiness();
            objetivoBusiness.ActualizarEstados(idUsuario);
            #endregion

            Session["FiltroMisCuentas"] = model.FiltroMisCuentas;
            return(View(model));
        }
Esempio n. 3
0
        private static M_Home CompletarDatosHome(int idUsuario, M_FiltroMisCuentas filtroMisCuentas)
        {
            Usuario             usuario            = new UsuarioBusiness().Obtener(idUsuario);
            List <Recordatorio> listaRecordatorios = new RecordatorioBusiness().ListarUltimos(idUsuario, 5, filtroMisCuentas.FechaDesde, filtroMisCuentas.FechaHasta);
            M_Home model = new M_Home();

            decimal ingresos             = 0;
            decimal gastos               = 0;
            decimal netoPesos            = 0;
            decimal netoDolares          = 0;
            decimal ahorrosPesos         = 0;
            decimal ahorrosDolares       = 0;
            decimal netoActualPesos      = 0;
            decimal netoActualDolares    = 0;
            decimal ahorrosActualPesos   = 0;
            decimal ahorrosActualDolares = 0;

            #region [Región: Saldos entre fechas]
            ingresos  = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Pesos && x.idCategoria != eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            gastos    = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Pesos && x.idCategoria != eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            netoPesos = ingresos - gastos;

            ingresos    = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Dolares && x.idCategoria != eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            gastos      = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Dolares && x.idCategoria != eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            netoDolares = ingresos - gastos;

            ingresos     = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Pesos && x.idCategoria == eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            gastos       = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Pesos && x.idCategoria == eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            ahorrosPesos = ingresos - gastos;

            ingresos       = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Dolares && x.idCategoria == eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            gastos         = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Dolares && x.idCategoria == eCategoria.Ahorros && x.Fecha >= filtroMisCuentas.FechaDesde && x.Fecha <= filtroMisCuentas.FechaHasta)?.Sum(x => x.Importe) ?? 0;
            ahorrosDolares = ingresos - gastos;
            #endregion

            #region [Región: Saldos Actuales]
            ingresos        = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Pesos && x.idCategoria != eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            gastos          = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Pesos && x.idCategoria != eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            netoActualPesos = ingresos - gastos;

            ingresos          = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Dolares && x.idCategoria != eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            gastos            = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Dolares && x.idCategoria != eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            netoActualDolares = ingresos - gastos;

            ingresos           = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Pesos && x.idCategoria == eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            gastos             = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Pesos && x.idCategoria == eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            ahorrosActualPesos = ingresos - gastos;

            ingresos             = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Ingreso && x.idMoneda == eMoneda.Dolares && x.idCategoria == eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            gastos               = usuario?.Registro.Where(x => x.idTipoRegistro == eTipoRegistro.Gasto && x.idMoneda == eMoneda.Dolares && x.idCategoria == eCategoria.Ahorros)?.Sum(x => x.Importe) ?? 0;
            ahorrosActualDolares = ingresos - gastos;
            #endregion

            model = new M_Home();
            model.FiltroMisCuentas.FechaDesde = filtroMisCuentas.FechaDesde;
            model.FiltroMisCuentas.FechaHasta = filtroMisCuentas.FechaHasta;

            model.MisCuentas.Usuario              = usuario.Nombre;
            model.MisCuentas.FechaDesde           = filtroMisCuentas.FechaDesde;
            model.MisCuentas.FechaHasta           = filtroMisCuentas.FechaHasta;
            model.MisCuentas.SaldoPesos           = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", netoPesos);
            model.MisCuentas.SaldoDolares         = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", netoDolares);
            model.MisCuentas.AhorrosPesos         = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", ahorrosPesos);
            model.MisCuentas.AhorrosDolares       = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", ahorrosDolares);
            model.MisCuentas.SaldoActualPesos     = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", netoActualPesos);
            model.MisCuentas.SaldoActualDolares   = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", netoActualDolares);
            model.MisCuentas.AhorrosActualPesos   = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", ahorrosActualPesos);
            model.MisCuentas.AhorrosActualDolares = string.Format(new System.Globalization.CultureInfo("es-AR"), "{0:N2}", ahorrosActualDolares);

            model.MisCuentas.ListaUltimosRecordatorios = listaRecordatorios;

            return(model);
        }