public JsonResult GetLedgerList() { var list = db.Ledgers.ToList(); List <Ledger_Group> group = new List <Ledger_Group>(); foreach (var item in list) { Ledger_Group lg = new Ledger_Group(); lg.Id = item.Id; lg.Name = item.Name; lg.CreatedBy = item.CreatedBy; //lg.SessionId = item.AspNetSession.Year; lg.StartingBalance = item.StartingBalance; lg.CurrentBalance = item.CurrentBalance; if (item.LedgerGroupId == null) { lg.LedgerGroupId = null; } else { lg.LedgerGroupId = item.LedgerGroup.Name; } if (item.LedgerHeadId == null) { lg.LedgerHeadId = null; } else { lg.LedgerHeadId = item.LedgerHead.Name; } group.Add(lg); } return(Json(group, JsonRequestBehavior.AllowGet)); }
public JsonResult GetLedgerGroups() { var ledger = db.LedgerGroups.ToList(); List <Ledger_Group> group = new List <Ledger_Group>(); foreach (var item in ledger) { Ledger_Group lg = new Ledger_Group(); lg.Name = item.Name; lg.CreatedBy = item.CreatedBy; lg.LedgerHeadId = item.LedgerHead.Name; lg.SessionId = db.AspNetSessions.Where(x => x.Status == "Active").Select(x => x.SessionName).FirstOrDefault(); group.Add(lg); } return(Json(group, JsonRequestBehavior.AllowGet)); }
public JsonResult GetChart() { var headlist = db.LedgerHeads.OrderBy(x => x.Name).ToList(); List <Ledger_Head> ledgerheadlist = new List <Ledger_Head>(); foreach (var h_item in headlist) { Ledger_Head ledgerhead = new Ledger_Head(); ledgerhead.HeadName = h_item.Name; ledgerhead.HeadId = h_item.Id; var grouplist = db.LedgerGroups.Where(x => x.LedgerHeadID == h_item.Id).OrderBy(x => x.Name).ToList(); var _ledgerlist = db.Ledgers.Where(x => x.LedgerHeadId == h_item.Id).OrderBy(x => x.Name).ToList(); ledgerhead.ledgerGroup = new List <Ledger_Group>(); ledgerhead.ledger = new List <_Ledger>(); foreach (var g_item in grouplist) { Ledger_Group lg = new Ledger_Group(); lg.GroupId = g_item.Id; lg.GroupName = g_item.Name; lg.ledger = new List <_Ledger>(); var ledgerlist = db.Ledgers.Where(x => x.Id == lg.GroupId).OrderBy(x => x.Name).ToList(); foreach (var l_item in ledgerlist) { _Ledger l = new _Ledger(); l.LedgerId = l_item.Id; l.LedgerName = l_item.Name; lg.ledger.Add(l); } ledgerhead.ledgerGroup.Add(lg); } foreach (var item in _ledgerlist) { _Ledger l = new _Ledger(); l.LedgerId = item.Id; l.LedgerName = item.Name; ledgerhead.ledger.Add(l); } ledgerheadlist.Add(ledgerhead); } return(Json(ledgerheadlist, JsonRequestBehavior.AllowGet)); }
public JsonResult GetSumamryReport() { var headlist = db.LedgerHeads.ToList(); List <Ledger_Head> ledgerheadlist = new List <Ledger_Head>(); foreach (var h_item in headlist) { Ledger_Head ledgerhead = new Ledger_Head(); ledgerhead.HeadId = h_item.Id; ledgerhead.HeadName = h_item.Name; decimal?amount = 0; var grouplist = db.LedgerGroups.Where(x => x.LedgerHeadID == h_item.Id).ToList(); var _ledgerlist = db.Ledgers.Where(x => x.LedgerHeadId == h_item.Id && x.LedgerGroupId == null).ToList(); ledgerhead.ledgerGroup = new List <Ledger_Group>(); ledgerhead.ledger = new List <_Ledger>(); foreach (var g_item in grouplist) { Ledger_Group lg = new Ledger_Group(); lg.GroupId = g_item.Id; lg.GroupName = g_item.Name; lg.ledger = new List <_Ledger>(); decimal?groupAmount = 0; var ledgerlist = db.Ledgers.Where(x => x.LedgerGroupId == lg.GroupId).ToList(); foreach (var l_item in ledgerlist) { _Ledger l = new _Ledger(); l.LedgerId = l_item.Id; l.LedgerName = l_item.Name; l.LedgerAmount = l_item.CurrentBalance; if (l_item.CurrentBalance == null) { groupAmount = groupAmount + 0; amount = amount + 0; } else { groupAmount = groupAmount + l_item.CurrentBalance; amount = amount + l_item.CurrentBalance; } lg.ledger.Add(l); } lg.GroupTotal = groupAmount; ledgerhead.ledgerGroup.Add(lg); } foreach (var item in _ledgerlist) { _Ledger l = new _Ledger(); l.LedgerId = item.Id; l.LedgerName = item.Name; l.LedgerAmount = item.CurrentBalance; if (item.CurrentBalance == null) { amount = amount + 0; } else { amount = amount + item.CurrentBalance; } ledgerhead.ledger.Add(l); } ledgerhead.TotalAmount = amount; ledgerheadlist.Add(ledgerhead); } return(Json(ledgerheadlist, JsonRequestBehavior.AllowGet)); }