public JsonResult ReporteV4(string fd, string fh)
 {
     double to = 0;
     DateTime dt1 = DateTime.Parse(fd);
     DateTime dt2 = DateTime.Now;
     if (fh != null && fh != "")
     {
         dt2 = DateTime.Parse(fh);
     }
     TimeSpan ts = dt2.Subtract(dt1);
     Session["FechaRI4"] = dt1;
     Session["FechaRF4"] = dt2;
     int nd = (int)ts.Days;
     nd = nd + 1;
     if (dt1 > dt2) return Json("Fecha inicio debe ser menor que fecha fin", JsonRequestBehavior.AllowGet);
     List<ReporteModel.ReporteVentas4Model> lr = new List<ReporteModel.ReporteVentas4Model>();
     List<PuntoVenta> lv = db.PuntoVenta.Where(c => c.estaActivo == true).ToList();
     for (int i = 0; i < lv.Count; i++)
     {
         ReporteModel.ReporteVentas4Model r = new ReporteModel.ReporteVentas4Model();
         r.codigo = lv[i].codPuntoVenta;
         r.nombre = lv[i].nombre;
         r.ubicacion = lv[i].ubicacion;
         r.distrito = db.Region.Find(lv[i].idRegion).nombre;
         r.provincia = db.Region.Find(lv[i].idProvincia).nombre;
         double total = 0;
         DateTime di = dt1;
         for (int j = 0; j < nd; j++)
         {
             int cp = lv[i].codPuntoVenta;
             List<Turno> lt = db.Turno.Where(c => c.codPuntoVenta == cp && c.fecha == di).ToList();
             if (lt.Count > 0)
             {
                 for (int s = 0; s < lt.Count; s++)
                 {
                     Turno t = lt[s];
                     List<Ventas> lven2 = db.Ventas.Where(c => c.Estado == "Pagado" && c.vendedor == t.usuario).ToList();
                     DateTime dat = di.Date;
                     List<Ventas> lven = lven2.Where(c => c.fecha.Value.Date == dat).ToList();
                     for (int k = 0; k < lven.Count; k++)
                     {
                         total += (double)lven[k].MontoTotalSoles;
                     }
                 }
             }
             di = di.AddDays(1);
         }
         r.total = total;
         to += total;
         lr.Add(r);
     }
     Session["ReporteVentasTotal4"] = lr;
     Session["ReporteTotal4"] = to;
     return Json("Reporte Generado", JsonRequestBehavior.AllowGet);
 }