public JsonResult DatosCierre() { var fecha = DateTime.Now.Date; var Entrada = (from A in db.Sales where A.FechaFactura == fecha select A).ToList(); var Ingresos = Entrada.Sum(o => o.ValorFactura); var Pagos = (from A in db.PaymentProviders where A.Fecha_Pago == fecha select A).ToList(); var Egresos = Pagos.Sum(o => o.Valor_Pago); var ayer = fecha.AddDays(-1); var BaseIni = (from A in db.Accountings where A.FechaCierre == ayer select A.BaseCaja).FirstOrDefault(); EDAccounting EDAccounting = new EDAccounting(); EDAccounting.FechaCierre = DateTime.Now.ToString("dd/MM/yyyy"); EDAccounting.Ingresos = Ingresos; EDAccounting.Egresos = Egresos; EDAccounting.BaseInicial = BaseIni; return(Json(EDAccounting, JsonRequestBehavior.AllowGet)); }
public JsonResult Crear(EDAccounting CierreDiario) { bool Probar = true; string Mensaje = ""; EDAccounting EDAccounting = new EDAccounting(); EDAccounting.FechaCierre = CierreDiario.FechaCierre; EDAccounting.Ingresos = CierreDiario.Ingresos; EDAccounting.Egresos = CierreDiario.Egresos; EDAccounting.BaseCaja = CierreDiario.BaseCaja; try { Accounting Accounting = new Accounting(); Accounting.FechaCierre = DateTime.Parse(EDAccounting.FechaCierre); Accounting.Ingresos = EDAccounting.Ingresos; Accounting.Egresos = EDAccounting.Egresos; Accounting.BaseCaja = EDAccounting.BaseCaja; db.Accountings.Add(Accounting); db.SaveChanges(); Mensaje = " Registro agregado con exito."; } catch (Exception) { Probar = false; Mensaje = " Se produjo un error al modificar el registro."; } return(Json(new { Probar, Mensaje }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetbyID(int?ID) { var Entrada = (from A in db.Accountings where A.ContabilidadId == ID select A); EDAccounting EDAccounting = new EDAccounting(); if (Entrada != null) { foreach (var item in Entrada) { EDAccounting.ContabilidadId = item.ContabilidadId; EDAccounting.FechaCierre = item.FechaCierre.ToString("dd/MM/yyyy"); EDAccounting.Ingresos = item.Ingresos; EDAccounting.Egresos = item.Egresos; EDAccounting.BaseCaja = item.BaseCaja; } } return(Json(EDAccounting, JsonRequestBehavior.AllowGet)); }
public JsonResult List() { List <EDAccounting> ListaEDAccounting = new List <EDAccounting>(); var Listaux = (from A in db.Accountings orderby A.FechaCierre descending select A).ToList(); if (Listaux != null) { foreach (var item in Listaux) { EDAccounting EDAccounting = new EDAccounting(); EDAccounting.ContabilidadId = item.ContabilidadId; EDAccounting.FechaCierre = item.FechaCierre.ToString("dd/MM/yyyy"); EDAccounting.Ingresos = item.Ingresos; EDAccounting.Egresos = item.Egresos; EDAccounting.BaseCaja = item.BaseCaja; ListaEDAccounting.Add(EDAccounting); } ListaEDAccounting = ListaEDAccounting.OrderBy(o => o.FechaCierre).ToList(); } return(Json(ListaEDAccounting, JsonRequestBehavior.AllowGet)); }