Пример #1
0
        public JsonResult GetGestionCobro(int id_razon_social, int id_proceso_facturacion)
        {
            var GestionCobro = db.Gestion_Cobro.SingleOrDefault(e => e.id_razon_social == id_razon_social && e.id_proceso_facturacion == id_proceso_facturacion && !e.eliminado);

            if (GestionCobro == null)
            {
                return(Json(new { result = 1 }, JsonRequestBehavior.AllowGet));
            }
            string actividad       = "Ninguna";
            bool   tiene_actividad = false;

            foreach (var item in GestionCobro.Gestion_Cobro_Detalle.Where(e => e.activo && !e.eliminado && !e.realizada))
            {
                if (item.fecha_proyectada.ToString("dd/MM/yyyy") == DateTime.Today.ToString("dd/MM/yyyy"))
                {
                    actividad       = item.Cat_Tipos_Gestion1.nombre;
                    tiene_actividad = true;
                    break;
                }
            }
            List <object> facturacion = new List <object>();

            foreach (var item in db.Resumen_Gestion_Cobro(id_proceso_facturacion, id_razon_social))
            {
                facturacion.Add(new { item.nombre, total = item.total.ToString("C", CultureInfo.GetCultureInfo("es-GT")) });
            }

            return(Json(new
            {
                GestionCobro.id_gestion_cobro,
                GestionCobro.id_proceso_facturacion,
                GestionCobro.id_razon_social,
                fecha_inicio = GestionCobro.fecha_inicio.ToString("dd/MM/yyyy"),
                fecha_fin = GestionCobro.fecha_fin.HasValue ? GestionCobro.fecha_fin.Value.ToString("dd/MM/yyyy") : "",
                nombre = GestionCobro.Razones_Sociales.razon_social + " - " + GestionCobro.Razones_Sociales.Clientes.nombre,
                actividad,
                tiene_actividad,
                facturacion
            }, JsonRequestBehavior.AllowGet));
        }