public ActionResult minMax()
        {
            FacturasModel fm = new FacturasModel();

            ViewBag.minMax = fm.minMax();
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Validaciones(FacturasModel facturasModel)
        {
            ModelState.Remove("Archivos");

            var sucursalId = ObtenerSucursal();
            var sucursal   = _db.Sucursales.Find(sucursalId);

            facturasModel = new FacturasModel
            {
                FacturasRecibidas = _db.FacturasRecibidas.Where(fp => fp.ReceptorId == sucursalId).OrderBy(fp => fp.Emisor.RazonSocial).ThenByDescending(vf => vf.Fecha).ToList()
            };

            if (ModelState.IsValid)
            {
                if (Request.Files.Count == 0)
                {
                    ModelState.AddModelError("", "Sin archivos para procesar");
                    return(View(facturasModel));
                }

                try
                {
                    var facturaRecibida = new FacturaRecibida();

                    PopularArchivos(ref facturaRecibida);
                    var pathFactura = Path.Combine(Server.MapPath("~/Archivos/Validaciones/"), facturaRecibida.NombreArchivoXml);
                    _operacionesStreams.ByteArrayArchivo(facturaRecibida.ArchivoFisicoXml, pathFactura);

                    _decodificaFacturas.DecodificarFactura(ref facturaRecibida, pathFactura);

                    var rfcReceptor = facturaRecibida.Receptor.Rfc;
                    facturaRecibida.Receptor = _db.Sucursales.FirstOrDefault(s => s.Rfc == rfcReceptor);

                    //Validaciones
                    _validacionesFacturas.Negocios(facturaRecibida, ObtenerSucursal());
                    facturaRecibida.Validacion = _validacionesFacturas.Sat(pathFactura, facturaRecibida.Receptor.Rfc);

                    //Guardar factura
                    try
                    {
                        _guarda.GuardarFacturaRecibida(facturaRecibida, ObtenerSucursal(), API.Enums.TiposGastos.Proveedores);
                        _db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError("", String.Format("No se pudo guardar la factura {0}", ex.Message));
                        return(View(facturasModel));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(facturasModel));
                }

                return(RedirectToAction("Validaciones"));
            }

            return(View(facturasModel));
        }
        public ActionResult detcartera()
        {
            FacturasModel fm = new FacturasModel();

            ViewBag.detCartera = fm.detCartera();
            return(View());
        }
Exemplo n.º 4
0
        public ActionResult Validar()
        {
            var sucursalId = ObtenerSucursal();

            var facturasModel = new FacturasModel
            {
                FacturasRecibidas = _db.FacturasRecibidas.Where(fp => fp.ReceptorId == sucursalId).OrderBy(fp => fp.Emisor.RazonSocial).ThenByDescending(vf => vf.Fecha).ToList()
            };

            return(View(facturasModel));
        }
 public JsonResult opeAñoChart()
 {
     try
     {
         FacturasModel fm = new FacturasModel();
         return(Json(fm.ListopeAño(), JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json("Error", JsonRequestBehavior.AllowGet));
     }
 }
 public JsonResult estCarteraChart()
 {
     try
     {
         FacturasModel fm = new FacturasModel();
         return(Json(fm.ListRepoOperacion(), JsonRequestBehavior.AllowGet));
     }
     catch (Exception Ex)
     {
         return(Json("Error", JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult SearchHistfacturas(string _FecIni, string _FecFin)
 {
     try
     {
         FacturasModel fm = new FacturasModel();
         return(View(fm.ListFactPendientes(_FecIni, _FecFin)));
     }
     catch (Exception Exc)
     {
         ModelState.AddModelError("Error", Exc);
         return(View());
     }
 }
 public ActionResult Estcartera()
 {
     try
     {
         FacturasModel fm = new FacturasModel();
         return(View(fm.ListestCartera()));
     }
     catch (Exception Exc)
     {
         ModelState.AddModelError("Error", Exc);
         return(View());
     }
 }
 public ActionResult Vencidas()
 {
     try
     {
         FacturasModel fm = new FacturasModel();
         return(View(fm.ListFactVencidas()));
     }
     catch (Exception Exc)
     {
         ModelState.AddModelError("Error", Exc);
         return(View());
     }
 }
Exemplo n.º 10
0
        public ActionResult Validaciones()
        {
            var sucursalId = ObtenerSucursal();
            var usuarioId  = ObtenerUsuario();

            var proveedor = _db.Proveedores.Find(usuarioId);

            var facturasModel = new FacturasModel
            {
                FacturasRecibidas = _db.FacturasRecibidas.Where(fp => fp.ReceptorId == sucursalId && fp.EmisorId == proveedor.Id).OrderBy(fp => fp.Emisor.RazonSocial).ThenByDescending(vf => vf.Fecha).ToList()
            };

            return(View(facturasModel));
        }