Пример #1
0
        public async Task <IActionResult> Print2(int Id)
        {
            var servicios = new MaestroContableServices(DbIpsa).ObtenerServicios();

            var recibo = db.IngresosEgresosCaja
                         .Include(c => c.Estado)
                         .Include(c => c.IngresosEgresosCajaDetalle)
                         .Include(c => c.TipoMoneda)
                         .Where(c => c.Id == Id)
                         .Select(r => new ReciboViewModel
            {
                FechaProceso  = r.FechaProceso,
                NumRecibo     = r.NumRecibo,
                Beneficiario  = r.Beneficiario,
                EstadoId      = r.EstadoId,
                MotivoAnulado = r.MotivoAnulado,
                Total         = r.Total,
                TipoMoneda    = r.TipoMoneda.Descripcion,
                Id            = r.Id,
                detalles      = r.IngresosEgresosCajaDetalle.Select(c => new ReciboDetalle
                {
                    Cantidad    = c.Cantidad,
                    CtaContable = c.CtaContable,
                    Montodolar  = c.Montodolar,
                    Precio      = c.Precio,
                    servicio    = servicios.Where(s => s.CtaContable == c.CtaContable).FirstOrDefault().Nombre
                })
            }).FirstOrDefault();

            return(View(recibo));
        }
Пример #2
0
        public IActionResult Edit(int id, int?tempCajaId)
        {
            var user = this.GetServiceUser();

            if (tempCajaId != null)
            {
                user.cajaid = tempCajaId.Value;
            }

            var serviciosDetalle = db.IngresosEgresosCajaDetalle.Where(d => d.ReciboId == id).ToArray();
            var cuentasContables = db.CajaCuentaContable.Where(c => c.CajaId == user.cajaid).Select(ccc => ccc.CtaCuenta).ToArray();
            var hasAllAccounting = serviciosDetalle.Select(r => r.CtaContable).All(cta => cuentasContables.Contains(cta));

            if (!hasAllAccounting)
            {
                var CajaId      = db.IngresosEgresosCaja.Find(id).CajaId;
                var cccs        = serviciosDetalle.Where(s => !cuentasContables.Contains(s.CtaContable)).Select(p => p.CtaContable);
                var Descripcion = db.Caja.Find(CajaId).Description;
                return(View("Error", new ErrorViewModel {
                    RequestId = $"El usuario {user.username} asignado a la caja {user.description} no contiene la(s) cuenta(s) {string.Join(",", cccs)} para poder editar recibo {db.IngresosEgresosCaja.Find(id).NumRecibo}",
                    CajaId = CajaId,
                    ReciboId = id,
                    Descripcion = Descripcion
                }));
            }

            var recibo = db.IngresosEgresosCaja
                         .Include(iec => iec.Estado).FirstOrDefault(iec => iec.Id == id);


            ViewData["TipoIngresoId"] = new SelectList(db.TipoIngreso, "Id", "Descripcion", recibo.TipoIngresoId);
            ViewData["TipoMonedaId"]  = new SelectList(db.TipoMoneda, "Id", "Descripcion", recibo.TipoMonedaId);
            ViewData["TipoCliente"]   = new SelectList(db.TipoCliente, "Id", "Tipocliente");

            var cuentas = new MaestroContableServices(DbIpsa).ObtenerServicios();

            ViewBag.servicios = from mc in cuentas
                                join mcp in cuentas on mc.CtaPadre equals mcp.CtaContable
                                join ccc in db.CajaCuentaContable on mc.CtaContable equals ccc.CtaCuenta
                                where ccc.CajaId == user.cajaid
                                select new
            {
                mc.Cuenta,
                mc.Nombre,
                padre = mcp.Nombre,
                mc.TipoCta
            };


            ViewBag.referencias = db.IngresosEgresosCajaReferencias.Where(r => r.ReciboId == id).ToArray();
            ViewBag.detalle     = serviciosDetalle;
            ViewBag.roles       = user.roles;
            return(View(recibo));
        }
Пример #3
0
        public IActionResult Create()
        {
            var user = this.GetServiceUser();

            ViewData["TipoIngresoId"] = new SelectList(db.TipoIngreso, "Id", "Descripcion");
            ViewData["TipoMonedaId"]  = new SelectList(db.TipoMoneda, "Id", "Descripcion");
            ViewData["EstadoId"]      = new SelectList(db.CajaEstado, "Id", "Descripcion", 1);
            ViewData["Banco"]         = new SelectList(DbIpsa.Bancos, "Bancoid", "Descripcion");
            ViewData["TipoCliente"]   = new SelectList(db.TipoCliente, "Id", "Tipocliente", 1);

            var lote = db.LoteRecibos.Where(lt => lt.CajaId == user.cajaid).FirstOrDefault();

            if (lote == null)
            {
                return(NotFound(new string[] { "No se encontró un lote de recibos para la caja de " + user.description }));
            }

            if (lote.Actual < lote.Inicio)
            {
                return(NotFound($"El lote actual {lote.Actual} esta fuera del rango de lotes asignados ({lote.Inicio} a {lote.Final})"));
            }

            if (lote.Actual >= lote.Final)
            {
                return(NotFound($"Ya llego al limite de lotes asignados Max({lote.Final}) para la caja de {user.description}"));
            }

            ViewBag.NumRecibo = (lote.Actual + 1).ToString().PadLeft(10, '0');

            var cuentas = new MaestroContableServices(DbIpsa).ObtenerServicios();

            var servicios = from mc in cuentas
                            join mcp in cuentas on mc.CtaPadre equals mcp.CtaContable
                            join ccc in db.CajaCuentaContable on mc.CtaContable equals ccc.CtaCuenta
                            where ccc.CajaId == user.cajaid
                            select new
            {
                mc.Cuenta,
                mc.Nombre,
                padre = mcp.Nombre,
                mc.TipoCta
            };

            if (servicios == null)
            {
                return(NotFound(new string[] { "La caja " + user.description + " no contiene ninguna cuenta contable asociada" }));
            }

            ViewBag.servicios = servicios;

            ViewBag.roles = user.roles;

            return(View());
        }
Пример #4
0
        public async Task <IActionResult> ObtenerLista()
        {
            //var cuentas = await _context.MaestroContable
            //    .Where(mc => mc.TipoCta == 4 || mc.Cuenta.StartsWith("1101") || mc.Cuenta.StartsWith("1108") || mc.Cuenta.StartsWith("1105"))
            //    .ToArrayAsync();

            var maestroContableServices = new MaestroContableServices(_context);
            var cuentas = maestroContableServices.ObtenerServicios();

            var servicios = from mc in cuentas
                            join mcp in cuentas
                            on mc.CtaPadre equals mcp.CtaContable
                            select new
            {
                NombrePadre = mcp.Nombre,
                ctaPadre    = mcp.Cuenta,
                mc.Cuenta,
                mc.Nombre,
                mc.CtaContable
            };

            return(Json(servicios));
        }
Пример #5
0
        public IActionResult RecibosCaja_Detelle1_GetList(DateTime desde, DateTime hasta, int?cajaId)
        {
            var usr = this.GetServiceUser();

            var reporte = db.IngresosEgresosCaja
                          .Include(i => i.Caja)
                          //.Include(i=>i.IngresosEgresosCajaDetalle)
                          //.Include(i=>i.IngresosEgresosCajaReferencias).ThenInclude(c => c.TipoPago)
                          .Include(i => i.TipoMoneda)
                          .Include(i => i.Estado)
                          .Where(i => i.FechaProceso >= desde && i.FechaProceso <= hasta);

            if (cajaId.HasValue)
            {
                if (usr.roles.Contains((int)Roles.Administrador))
                {
                    reporte = reporte.Where(iec => iec.CajaId == cajaId);
                }
                else
                {
                    reporte = reporte.Where(iec => iec.CajaId == usr.cajaid);
                }
            }
            else
            {
                if (!usr.roles.Contains((int)Roles.Administrador))
                {
                    reporte = reporte.Where(iec => iec.CajaId == usr.cajaid);
                }
            }

            var data      = reporte.ToArray();
            var servicios = new MaestroContableServices(DbIpsa).ObtenerServicios();

            var ingresosEgresosCajaReferencias = db.IngresosEgresosCajaReferencias.Include(x => x.TipoPago).Where(r => data.Select(x => x.Id).Contains(r.ReciboId)).ToArray();
            var ingresosEgresosCajaDetalle     = db.IngresosEgresosCajaDetalle.Where(r => data.Select(x => x.Id).Contains(r.ReciboId)).ToArray();

            var result = data.Select(rep => new
            {
                rep.Id,
                Estado = rep.Estado.Descripcion,
                Caja   = rep.Caja.Description,
                rep.Beneficiario,
                rep.FechaProceso,
                rep.Username,
                rep.Total,
                TipoMoneda = rep.TipoMoneda.Descripcion,
                rep.NumRecibo,
                Dolar   = rep.EstadoId == (int)IngresosEgresosCajaEstado.Anulado ? 0 : Math.Round((rep.TipoMonedaId == (short)TipoMonedaParamFilter.Dolar ? rep.Total : 0), 2),
                Cordoba = rep.EstadoId == (int)IngresosEgresosCajaEstado.Anulado ? 0 : Math.Round((rep.TipoMonedaId == (short)TipoMonedaParamFilter.Cordoba ? rep.Total : 0), 2),
                rep.Referencias,
                IngresosEgresosCajaReferencias = ingresosEgresosCajaReferencias.Where(x => x.ReciboId == rep.Id).Select(c => new
                {
                    c.Fecha,
                    TipoPago = c.TipoPago.Descripcion,
                    c.TipoCambio,
                    Dolar   = Math.Round((rep.TipoMonedaId == (short)TipoMonedaParamFilter.Dolar ? c.Total : c.Total / c.TipoCambio), 2),
                    Cordoba = Math.Round((rep.TipoMonedaId == (short)TipoMonedaParamFilter.Cordoba ? c.Total : c.Total * c.TipoCambio), 2),
                    c.Referencia
                }),
                IngresosEgresosCajaDetalle = ingresosEgresosCajaDetalle.Where(x => x.ReciboId == rep.Id).Select(c => new
                {
                    c.Cantidad,
                    c.CtaContable,
                    c.Montodolar,
                    c.Precio,
                    servicio = servicios.Where(s => s.CtaContable == c.CtaContable).FirstOrDefault().Nombre
                })
            }).ToArray();

            return(Json(result, new Newtonsoft.Json.JsonSerializerSettings {
                MaxDepth = 1, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            }));
        }
Пример #6
0
        public IActionResult RecibosCaja_Detelle2_GetList(CajaParameterModel p)
        {
            var usr = this.GetServiceUser();

            var servicios = new MaestroContableServices(DbIpsa).ObtenerServicios();

            //var servicios = DbIpsa.MaestroContable
            //    .Where(mc => mc.TipoCta == 4 || mc.Cuenta.StartsWith("1101") || mc.Cuenta.StartsWith("1108") || mc.Cuenta.StartsWith("1105"))
            //    .ToArray();


            var reporteMinutas = from iec in db.IngresosEgresosCaja
                                 join iecr in db.IngresosEgresosCajaReferencias on iec.Id equals iecr.ReciboId
                                 join c in db.Caja on iec.CajaId equals c.Id
                                 join m in db.TipoMoneda on iec.TipoMonedaId.Value equals m.Id
                                 where iec.FechaProceso >= p.Desde && iec.FechaProceso <= p.Hasta &&
                                 iec.EstadoId == (int)IngresosEgresosBancoEstados.Registrado
                                 select new ReporteMinutaVsServicio {
                NumRecibo        = iec.NumRecibo,
                FechaProceso     = iec.FechaProceso,
                Caja             = c.Description,
                CajaId           = c.Id,
                Beneficiario     = iec.Beneficiario,
                Moneda           = m.Descripcion,
                MinutaReferencia = iecr.Referencia,
                MinutaFecha      = iecr.Fecha,
                MontoDolar       = Math.Round((iec.TipoMonedaId == (short)TipoMonedaParamFilter.Dolar?iecr.Total:iecr.Total / iecr.TipoCambio), 2),
                MontoCordoba     = Math.Round((iec.TipoMonedaId == (short)TipoMonedaParamFilter.Cordoba?iecr.Total:iecr.Total * iecr.TipoCambio), 2),
            };
            var reporteServicios = from iec in db.IngresosEgresosCaja
                                   join iecd in db.IngresosEgresosCajaDetalle on iec.Id equals iecd.ReciboId
                                   join c in db.Caja on iec.CajaId equals c.Id
                                   join m in db.TipoMoneda on iec.TipoMonedaId.Value equals m.Id
                                   where iec.FechaProceso >= p.Desde && iec.FechaProceso <= p.Hasta &&
                                   iec.EstadoId == (int)IngresosEgresosBancoEstados.Registrado
                                   select new ReporteMinutaVsServicio {
                NumRecibo        = iec.NumRecibo,
                FechaProceso     = iec.FechaProceso,
                Caja             = c.Description,
                CajaId           = c.Id,
                Beneficiario     = iec.Beneficiario,
                Moneda           = m.Descripcion,
                ServicioNombre   = servicios.Where(s => s.CtaContable == iecd.CtaContable).FirstOrDefault().Nombre,
                ServicioPrecio   = iecd.Precio,
                ServicioCantidad = iecd.Cantidad,
                ServicioTotal    = iecd.Montodolar,
                MinutaFecha      = iec.FechaProceso
            };

            if (p.caja.Value > 0)
            {
                reporteMinutas = from rm in reporteMinutas
                                 where rm.CajaId == p.caja.Value
                                 select rm;

                reporteServicios = from rs in reporteServicios
                                   where rs.CajaId == p.caja.Value
                                   select rs;
            }


            var allReporteMinutas   = reporteMinutas.ToArray();
            var allReporteServicios = reporteServicios.ToArray();

            var MinutasYServicios = allReporteMinutas.Concat(allReporteServicios);

            //var reporteAgrupado = from t in MinutasYServicios
            //            group t by t.NumRecibo into g
            //            select new ReporteMinutaVsServicio
            //            {
            //                    NumRecibo = g.Key,
            //                    MontoCordoba = g.Sum(x => x.MontoCordoba),
            //                    MontoDolar = g.Sum(x => x.MontoDolar),
            //                    ServicioTotal = g.Sum(x => x.ServicioTotal)
            //            };

            //var all = reporteAgrupado.ToArray().Concat(MinutasYServicios);

            //return Json(all);

            //Quitar la primera columna el resumen
            return(Json(MinutasYServicios));
        }
Пример #7
0
        public IActionResult obtenerPrevio(ParameterCaja parameter)
        {
            if (parameter.SearchType == SearchType.None)
            {
                return(BadRequest("Seleccione un tipo de busqueda, mensual o diario"));
            }

            var bancoService = new BancoCuentasServices(DbIpsa);
            var bancoInfo    = bancoService.GetList().ToArray();

            var servicios = new MaestroContableServices(DbIpsa).ObtenerServicios();

            var resultCaja = from iec in db.IngresosEgresosCaja
                             join iecd in db.IngresosEgresosCajaDetalle on iec.Id equals iecd.ReciboId
                             join c in db.Caja on iec.CajaId equals c.Id
                             where parameter.CajaIds.Contains(c.Id) && iec.FechaProceso >= parameter.desde && iec.FechaProceso <= parameter.hasta
                             select new
            {
                Fecha = iec.FechaProceso,
                _Caja = c.Description,
                iec.Total,
                iecd.CtaContable,
                iecd.Montodolar,
                iec.Id,
                iec.TipoMonedaId
            };

            var result = resultCaja.ToArray();

            var bancosReferencias = from iec in db.IngresosEgresosCaja
                                    join iecd in db.IngresosEgresosCajaReferencias on iec.Id equals iecd.ReciboId
                                    join c in db.Caja on iec.CajaId equals c.Id
                                    where parameter.CajaIds.Contains(c.Id) && iec.FechaProceso >= parameter.desde && iec.FechaProceso <= parameter.hasta
                                    select new
            {
                Id      = iec.Id,
                BancoId = iecd.IdBanco
            };


            var bancosReferenciasArr = bancosReferencias.ToArray();

            var resultFinal = result.Select(x => new
            {
                x.Fecha,
                x._Caja,
                x.Total,
                Servicio = servicios.Where(c => c.CtaContable == x.CtaContable).FirstOrDefault().Nombre,
                x.CtaContable,
                x.Montodolar,
                x.TipoMonedaId,
                x.Id,
                BancoId = bancosReferenciasArr.Where(h => h.Id == x.Id).First().BancoId
            });

            var resultados = new List <Resultados>();

            foreach (var x in resultFinal)
            {
                try
                {
                    resultados.Add(new Resultados
                    {
                        Fecha          = x.Fecha,
                        _Caja          = x._Caja,
                        Total          = x.Total,
                        Servicio       = x.Servicio,
                        CtaContable    = x.CtaContable,
                        Montodolar     = x.Montodolar,
                        Banco          = bancoInfo.Where(b => b.Bancoid == x.BancoId && (b.Moneda ?? 0) == x.TipoMonedaId).FirstOrDefault().Banco.Descripcion,
                        CuentaBancaria = bancoInfo.Where(b => b.Bancoid == x.BancoId && (b.Moneda ?? 0) == x.TipoMonedaId).FirstOrDefault().Descripcion
                    });
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            //var resultFinal2 = resultFinal.Select(x => new
            //{
            //    x.Fecha,
            //    x._Caja,
            //    x.Total,
            //    x.Servicio,
            //    x.CtaContable,
            //    x.Montodolar,
            //    x.BancoId,
            //    Banco = bancoInfo.Where(b => b.Bancoid == x.BancoId && (b.Moneda??0) == x.TipoMonedaId).FirstOrDefault().Banco.Descripcion,
            //    CuentaBancaria = bancoInfo.Where(b => b.Bancoid == x.BancoId && (b.Moneda??0) == x.TipoMonedaId).FirstOrDefault().Descripcion
            //});

            return(Json(resultados));
        }