private List <ChartViewModel> BuildTrustBenchmarkCharts(RevenueGroupType revGroup, ChartGroupType chartGroup, UnitType showValue, MatFinancingType mFinancing) { var cookie = Request.Cookies[CookieNames.COMPARISON_LIST_MAT]; var comparisonList = JsonConvert.DeserializeObject <TrustComparisonViewModel>(cookie.Value); var benchmarkCharts = _benchmarkChartBuilder.Build(revGroup, chartGroup, EstablishmentType.MAT); var financialDataModels = this.GetFinancialDataForTrusts(comparisonList.Trusts, mFinancing); var trimSchoolNames = Request.Browser.IsMobileDevice; _fcService.PopulateBenchmarkChartsWithFinancialData(benchmarkCharts, financialDataModels, comparisonList.Trusts, comparisonList.DefaultTrustMatNo, showValue, trimSchoolNames); return(benchmarkCharts); }
public async Task <PartialViewResult> GetCharts(int urn, string term, RevenueGroupType revGroup, ChartGroupType chartGroup, UnitType unit, CentralFinancingType financing = CentralFinancingType.Include, ChartFormat format = ChartFormat.Charts) { financing = revGroup == RevenueGroupType.Workforce ? CentralFinancingType.Exclude : financing; var schoolDetailsFromEdubase = _contextDataService.GetSchoolByUrn(urn.ToString()); SchoolViewModel schoolVM = await BuildSchoolVMAsync(revGroup, chartGroup, financing, schoolDetailsFromEdubase, unit); _fcService.PopulateHistoricalChartsWithSchoolData(schoolVM.HistoricalCharts, schoolVM.HistoricalSchoolFinancialDataModels, term, revGroup, unit, schoolVM.FinancialType); ViewBag.ChartFormat = format; return(PartialView("Partials/Chart", schoolVM)); }
private async Task <SchoolViewModel> BuildSchoolVMAsync(RevenueGroupType revenueGroup, ChartGroupType chartGroup, CentralFinancingType cFinance, dynamic schoolDetailsData, UnitType unit = UnitType.AbsoluteCount) { var schoolVM = new SchoolViewModel(schoolDetailsData, base.ExtractSchoolComparisonListFromCookie()); schoolVM.HistoricalCharts = _historicalChartBuilder.Build(revenueGroup, chartGroup, schoolVM.FinancialType, unit); schoolVM.ChartGroups = _historicalChartBuilder.Build(revenueGroup, schoolVM.FinancialType).DistinctBy(c => c.ChartGroup).ToList(); schoolVM.Terms = BuildTermsList(schoolVM.FinancialType); schoolVM.Tab = revenueGroup; schoolVM.HistoricalSchoolFinancialDataModels = await this.GetFinancialDataHistoricallyAsync(schoolVM.Id, schoolVM.FinancialType, cFinance); schoolVM.TotalRevenueIncome = schoolVM.HistoricalSchoolFinancialDataModels.Last().TotalIncome; schoolVM.TotalRevenueExpenditure = schoolVM.HistoricalSchoolFinancialDataModels.Last().TotalExpenditure; schoolVM.InYearBalance = schoolVM.HistoricalSchoolFinancialDataModels.Last().InYearBalance; return(schoolVM); }
private async Task <List <ChartViewModel> > BuildSchoolBenchmarkChartsAsync(RevenueGroupType revGroup, ChartGroupType chartGroup, UnitType?showValue, CentralFinancingType cFinancing) { var comparisonList = base.ExtractSchoolComparisonListFromCookie(); var establishmentType = DetectEstablishmentType(comparisonList); var benchmarkCharts = _benchmarkChartBuilder.Build(revGroup, chartGroup, establishmentType); RemoveIrrelevantCharts(showValue.GetValueOrDefault(), benchmarkCharts); var financialDataModels = await this.GetFinancialDataForSchoolsAsync(comparisonList.BenchmarkSchools, cFinancing); var trimSchoolNames = false; if (Request.Browser != null) { trimSchoolNames = Request.Browser.IsMobileDevice; } _fcService.PopulateBenchmarkChartsWithFinancialData(benchmarkCharts, financialDataModels, comparisonList.BenchmarkSchools, comparisonList.HomeSchoolUrn, showValue, trimSchoolNames); return(benchmarkCharts); }
public ActionResult Mats(RevenueGroupType tab = RevenueGroupType.Expenditure, MatFinancingType financing = MatFinancingType.TrustAndAcademies) { ChartGroupType chartGroup; switch (tab) { case RevenueGroupType.Expenditure: chartGroup = ChartGroupType.TotalExpenditure; break; case RevenueGroupType.Income: chartGroup = ChartGroupType.TotalIncome; break; case RevenueGroupType.Balance: chartGroup = ChartGroupType.InYearBalance; break; default: chartGroup = ChartGroupType.All; break; } var defaultUnitType = tab == RevenueGroupType.Workforce ? UnitType.AbsoluteCount : UnitType.AbsoluteMoney; var benchmarkCharts = BuildTrustBenchmarkCharts(tab, chartGroup, UnitType.AbsoluteMoney, financing); var chartGroups = _benchmarkChartBuilder.Build(tab, EstablishmentType.MAT).DistinctBy(c => c.ChartGroup).ToList(); var academiesTerm = FormatHelpers.FinancialTermFormatAcademies(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Academies)); var maintainedTerm = FormatHelpers.FinancialTermFormatMaintained(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Maintained)); var vm = new BenchmarkChartListViewModel(benchmarkCharts, null, chartGroups, ComparisonType.Manual, null, null, null, EstablishmentType.MAT, EstablishmentType.MAT, null, null, academiesTerm, maintainedTerm, ComparisonArea.All, null, null, ComparisonListLimit.DEFAULT, base.ExtractTrustComparisonListFromCookie()); ViewBag.Tab = tab; ViewBag.ChartGroup = chartGroup; ViewBag.UnitType = defaultUnitType; ViewBag.HomeSchoolId = vm.TrustComparisonList.DefaultTrustMatNo; ViewBag.EstablishmentType = vm.EstablishmentType; ViewBag.TrustFinancing = financing; return(View("Index", vm)); }
public async Task <PartialViewResult> GetCharts(RevenueGroupType revGroup, ChartGroupType chartGroup, UnitType showValue, CentralFinancingType centralFinancing = CentralFinancingType.Include, MatFinancingType trustCentralFinancing = MatFinancingType.TrustAndAcademies, EstablishmentType type = EstablishmentType.All, ChartFormat format = ChartFormat.Charts) { List <ChartViewModel> benchmarkCharts; if (type == EstablishmentType.MAT) { benchmarkCharts = BuildTrustBenchmarkCharts(revGroup, chartGroup, showValue, trustCentralFinancing); ViewBag.HomeSchoolId = this.ExtractTrustComparisonListFromCookie().DefaultTrustMatNo; } else { benchmarkCharts = await BuildSchoolBenchmarkChartsAsync(revGroup, chartGroup, showValue, centralFinancing); ViewBag.HomeSchoolId = this.ExtractSchoolComparisonListFromCookie().HomeSchoolUrn; } ViewBag.EstablishmentType = type; ViewBag.ChartFormat = format; return(PartialView("Partials/Chart", benchmarkCharts)); }
private void BuildChart(List <SchoolFinancialDataModel> SchoolFinancialDataModels, string term, RevenueGroupType revgroup, UnitType unit, SchoolFinancialType schoolFinancialType, ChartViewModel chart) { var historicalChartData = new List <HistoricalChartData>(); foreach (var schoolData in SchoolFinancialDataModels) { decimal?amount = null; decimal?rawAmount = null; switch (unit) { case UnitType.AbsoluteMoney: case UnitType.AbsoluteCount: amount = schoolData.GetDecimal(chart.FieldName); break; case UnitType.PerTeacher: rawAmount = schoolData.GetDecimal(chart.FieldName); if (rawAmount == null) { break; } amount = (schoolData.TeacherCount == 0) ? null : (rawAmount / (decimal)schoolData.TeacherCount); if (amount.HasValue) { amount = decimal.Round(amount.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero); } break; case UnitType.PerPupil: rawAmount = schoolData.GetDecimal(chart.FieldName); if (rawAmount == null) { break; } amount = (schoolData.PupilCount == 0) ? null : (rawAmount / (decimal)schoolData.PupilCount); if (amount.HasValue) { amount = decimal.Round(amount.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero); } break; case UnitType.PercentageOfTotal: decimal total = 0; rawAmount = schoolData.GetDecimal(chart.FieldName); if (rawAmount == null) { break; } switch (revgroup) { case RevenueGroupType.Expenditure: total = schoolData.TotalExpenditure; break; case RevenueGroupType.Income: total = schoolData.TotalIncome; break; case RevenueGroupType.Balance: total = schoolData.InYearBalance; break; } if (total == 0) { amount = 0; } else { amount = (total == 0) ? 0 : (rawAmount / total) * 100; amount = decimal.Round(amount.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero); } break; case UnitType.NoOfPupilsPerMeasure: rawAmount = schoolData.GetDecimal(chart.FieldName); if (rawAmount == null || rawAmount == 0) { break; } amount = (schoolData.PupilCount == 0) ? null : ((decimal)schoolData.PupilCount / rawAmount); amount = decimal.Round(amount.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero); break; case UnitType.HeadcountPerFTE: string fieldNameBase = chart.FieldName.Contains("FullTimeEquivalent") ? chart.FieldName.Substring(0, chart.FieldName.Length - 18) : chart.FieldName.Substring(0, chart.FieldName.Length - 9); total = schoolData.GetDecimal(fieldNameBase + "Headcount").GetValueOrDefault(); rawAmount = schoolData.GetDecimal(fieldNameBase + "FullTimeEquivalent"); if (rawAmount == null) { break; } if (total == 0) { amount = 0; } else { amount = (total == 0) ? 0 : (total / rawAmount); amount = decimal.Round(amount.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero); } break; case UnitType.FTERatioToTotalFTE: total = schoolData.GetDecimal("TotalSchoolWorkforceFullTimeEquivalent").GetValueOrDefault(); rawAmount = schoolData.GetDecimal(chart.FieldName); if (rawAmount == null) { break; } if (total == 0) { amount = 0; } else { amount = (total == 0) ? 0 : (rawAmount / total) * 100; amount = decimal.Round(amount.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero); } break; } historicalChartData.Add(new HistoricalChartData() { Year = schoolData.Term, Amount = amount, TeacherCount = schoolData.TeacherCount, PupilCount = schoolData.PupilCount, Unit = unit.ToString() }); } chart.HistoricalData = historicalChartData; chart.DataJson = GenerateJson(historicalChartData, schoolFinancialType); chart.LastYear = term; chart.LastYearBalance = historicalChartData.Find(d => d.Year == term).Amount; chart.ShowValue = unit; }
private BenchmarkChartModel BuildBenchmarkChartModel(string fieldName, IEnumerable <CompareEntityBase> bmSchools, List <SchoolFinancialDataModel> financialDataModels, UnitType unit, RevenueGroupType revGroup, string homeSchoolId, bool trimSchoolNames = false) { var chartDataList = new List <BenchmarkChartData>(); foreach (var school in bmSchools) { var dataModel = financialDataModels.First(f => f.Id.ToString() == school.Id); decimal total = 0; switch (revGroup) { case RevenueGroupType.Expenditure: total = dataModel.TotalExpenditure; break; case RevenueGroupType.Income: total = dataModel.TotalIncome; break; case RevenueGroupType.Balance: total = dataModel.InYearBalance; break; } decimal?amountPerUnit = null; if (revGroup == RevenueGroupType.Workforce) { amountPerUnit = CalculateWFAmount(dataModel, fieldName, unit); } else { amountPerUnit = CalculateAmountPerUnit(dataModel, fieldName, unit, total); } chartDataList.Add(new BenchmarkChartData() { School = trimSchoolNames ? $"{school.ShortName}#{school.Id}" : $"{school.Name}#{school.Id}", Amount = amountPerUnit, Urn = school.Id, TeacherCount = dataModel.TeacherCount, PupilCount = dataModel.PupilCount, Term = dataModel.Term, Type = school.Type, La = _localAuthoritiesService.GetLaName(dataModel.LaNumber.ToString()), IsCompleteYear = dataModel.PeriodCoveredByReturn >= 12, IsWFDataPresent = dataModel.WorkforceDataPresent, PartialYearsPresentInSubSchools = dataModel.PartialYearsPresentInSubSchools, Unit = unit.ToString() }); } var sortedChartData = chartDataList.OrderByDescending(a => a.Amount).ToList(); var benchmarkSchoolIndex = !string.IsNullOrEmpty(homeSchoolId) ? sortedChartData.IndexOf(sortedChartData.Find(s => s.Urn.ToString() == homeSchoolId)) : -1; var incompleteFinanceDataIndex = new List <int>(); var incompleteWorkforceDataIndex = new List <int>(); if (revGroup == RevenueGroupType.Workforce) { var incompleteWorkForce = sortedChartData.FindAll(s => !s.IsWFDataPresent); incompleteWorkForce.ForEach(i => incompleteWorkforceDataIndex.Add(sortedChartData.IndexOf(i))); } else { var incompleteFinances = sortedChartData.FindAll(s => !s.IsCompleteYear || s.PartialYearsPresentInSubSchools); incompleteFinances.ForEach(i => incompleteFinanceDataIndex.Add(sortedChartData.IndexOf(i))); } return(new BenchmarkChartModel { ChartData = sortedChartData, BenchmarkSchoolIndex = benchmarkSchoolIndex, IncompleteFinanceDataIndex = incompleteFinanceDataIndex, IncompleteWorkforceDataIndex = incompleteWorkforceDataIndex, }); }
public void PopulateHistoricalChartsWithSchoolData(List <ChartViewModel> historicalCharts, List <SchoolFinancialDataModel> SchoolFinancialDataModels, string term, RevenueGroupType revgroup, UnitType unit, SchoolFinancialType schoolFinancialType) { foreach (var chart in historicalCharts) { BuildChart(SchoolFinancialDataModels, term, revgroup, unit, schoolFinancialType, chart); if (chart.SubCharts != null) { foreach (var subChart in chart.SubCharts) { BuildChart(SchoolFinancialDataModels, term, revgroup, unit, schoolFinancialType, subChart); } } } }
public async Task <PartialViewResult> TabChange(EstablishmentType type, UnitType showValue, RevenueGroupType tab = RevenueGroupType.Expenditure, CentralFinancingType financing = CentralFinancingType.Include, MatFinancingType trustFinancing = MatFinancingType.TrustAndAcademies, ChartFormat format = ChartFormat.Charts) { ChartGroupType chartGroup; switch (tab) { case RevenueGroupType.Expenditure: chartGroup = ChartGroupType.TotalExpenditure; break; case RevenueGroupType.Income: chartGroup = ChartGroupType.TotalIncome; break; case RevenueGroupType.Balance: chartGroup = ChartGroupType.InYearBalance; break; case RevenueGroupType.Workforce: chartGroup = ChartGroupType.Workforce; break; default: chartGroup = ChartGroupType.All; break; } UnitType unitType; switch (tab) { case RevenueGroupType.Workforce: unitType = UnitType.AbsoluteCount; break; case RevenueGroupType.Balance: unitType = showValue == UnitType.AbsoluteMoney || showValue == UnitType.PerPupil || showValue == UnitType.PerTeacher ? showValue : UnitType.AbsoluteMoney; break; default: unitType = showValue; break; } List <ChartViewModel> benchmarkCharts; if (type == EstablishmentType.MAT) { benchmarkCharts = BuildTrustBenchmarkCharts(tab, chartGroup, unitType, trustFinancing); } else { benchmarkCharts = await BuildSchoolBenchmarkChartsAsync(tab, chartGroup, unitType, financing); } var chartGroups = _benchmarkChartBuilder.Build(tab, EstablishmentType.All).DistinctBy(c => c.ChartGroup).ToList(); var academiesTerm = FormatHelpers.FinancialTermFormatAcademies(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Academies)); var maintainedTerm = FormatHelpers.FinancialTermFormatMaintained(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Maintained)); var vm = new BenchmarkChartListViewModel(benchmarkCharts, base.ExtractSchoolComparisonListFromCookie(), chartGroups, ComparisonType.Manual, null, null, null, type, type, null, null, academiesTerm, maintainedTerm, ComparisonArea.All, null, null, ComparisonListLimit.DEFAULT, base.ExtractTrustComparisonListFromCookie()); ViewBag.Tab = tab; ViewBag.ChartGroup = chartGroup; ViewBag.UnitType = unitType; ViewBag.EstablishmentType = type; ViewBag.Financing = financing; ViewBag.TrustFinancing = trustFinancing; ViewBag.HomeSchoolId = (type == EstablishmentType.MAT) ? vm.TrustComparisonList.DefaultTrustMatNo : vm.SchoolComparisonList.HomeSchoolUrn; ViewBag.ChartFormat = format; return(PartialView("Partials/TabContent", vm)); }
public async Task <ActionResult> Index( string urn, SimpleCriteria simpleCriteria, BenchmarkCriteria benchmarkCriteria, int basketSize = ComparisonListLimit.DEFAULT, SchoolFinancialDataModel benchmarkSchoolData = null, EstablishmentType searchedEstabType = EstablishmentType.All, ComparisonType comparisonType = ComparisonType.Manual, ComparisonArea areaType = ComparisonArea.All, string laCode = null, RevenueGroupType tab = RevenueGroupType.Expenditure, CentralFinancingType financing = CentralFinancingType.Include) { ChartGroupType chartGroup; switch (tab) { case RevenueGroupType.Expenditure: chartGroup = ChartGroupType.TotalExpenditure; break; case RevenueGroupType.Income: chartGroup = ChartGroupType.TotalIncome; break; case RevenueGroupType.Balance: chartGroup = ChartGroupType.InYearBalance; break; case RevenueGroupType.Workforce: chartGroup = ChartGroupType.Workforce; break; default: chartGroup = ChartGroupType.All; break; } var defaultUnitType = tab == RevenueGroupType.Workforce ? UnitType.AbsoluteCount : UnitType.AbsoluteMoney; var benchmarkCharts = await BuildSchoolBenchmarkChartsAsync(tab, chartGroup, defaultUnitType, financing); var establishmentType = DetectEstablishmentType(base.ExtractSchoolComparisonListFromCookie()); var chartGroups = _benchmarkChartBuilder.Build(tab, establishmentType).DistinctBy(c => c.ChartGroup).ToList(); string selectedArea = ""; switch (areaType) { case ComparisonArea.All: selectedArea = "All England"; break; case ComparisonArea.LaCode: case ComparisonArea.LaName: selectedArea = _laService.GetLaName(laCode); break; } string schoolArea = ""; if (benchmarkSchoolData != null) { schoolArea = _laService.GetLaName(benchmarkSchoolData.LaNumber.ToString()); } var academiesTerm = FormatHelpers.FinancialTermFormatAcademies(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Academies)); var maintainedTerm = FormatHelpers.FinancialTermFormatMaintained(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Maintained)); var vm = new BenchmarkChartListViewModel(benchmarkCharts, base.ExtractSchoolComparisonListFromCookie(), chartGroups, comparisonType, benchmarkCriteria, simpleCriteria, benchmarkSchoolData, establishmentType, searchedEstabType, schoolArea, selectedArea, academiesTerm, maintainedTerm, areaType, laCode, urn, basketSize); ViewBag.Tab = tab; ViewBag.ChartGroup = chartGroup; ViewBag.UnitType = defaultUnitType; ViewBag.HomeSchoolId = vm.SchoolComparisonList.HomeSchoolUrn; ViewBag.EstablishmentType = vm.EstablishmentType; ViewBag.Financing = financing; ViewBag.ChartFormat = ChartFormat.Charts; return(View("Index", vm)); }
public async Task <ActionResult> Detail(int urn, UnitType unit = UnitType.AbsoluteMoney, CentralFinancingType financing = CentralFinancingType.Include, RevenueGroupType tab = RevenueGroupType.Expenditure, ChartFormat format = ChartFormat.Charts) { ChartGroupType chartGroup; switch (tab) { case RevenueGroupType.Expenditure: chartGroup = ChartGroupType.TotalExpenditure; break; case RevenueGroupType.Income: chartGroup = ChartGroupType.TotalIncome; break; case RevenueGroupType.Balance: chartGroup = ChartGroupType.InYearBalance; break; case RevenueGroupType.Workforce: chartGroup = ChartGroupType.Workforce; break; default: chartGroup = ChartGroupType.All; break; } var schoolDetailsFromEdubase = _contextDataService.GetSchoolByUrn(urn.ToString()); if (schoolDetailsFromEdubase == null) { return(View("EmptyResult", new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), SearchTypes.SEARCH_BY_NAME_ID))); } SchoolViewModel schoolVM = await BuildSchoolVMAsync(tab, chartGroup, financing, schoolDetailsFromEdubase); UnitType unitType; switch (tab) { case RevenueGroupType.Workforce: unitType = UnitType.AbsoluteCount; break; case RevenueGroupType.Balance: unitType = unit == UnitType.AbsoluteMoney || unit == UnitType.PerPupil || unit == UnitType.PerTeacher ? unit : UnitType.AbsoluteMoney; break; default: unitType = unit; break; } _fcService.PopulateHistoricalChartsWithSchoolData(schoolVM.HistoricalCharts, schoolVM.HistoricalSchoolFinancialDataModels, (BuildTermsList(schoolVM.FinancialType)).First(), tab, unitType, schoolVM.FinancialType); ViewBag.Tab = tab; ViewBag.ChartGroup = chartGroup; ViewBag.UnitType = unitType; ViewBag.Financing = financing; ViewBag.ChartFormat = format; return(View("Detail", schoolVM)); }
public async Task <ActionResult> Index(string matNo, string name, UnitType unit = UnitType.AbsoluteMoney, RevenueGroupType tab = RevenueGroupType.Expenditure, MatFinancingType financing = MatFinancingType.TrustAndAcademies, ChartFormat format = ChartFormat.Charts) { ChartGroupType chartGroup; switch (tab) { case RevenueGroupType.Expenditure: chartGroup = ChartGroupType.TotalExpenditure; break; case RevenueGroupType.Income: chartGroup = ChartGroupType.TotalIncome; break; case RevenueGroupType.Balance: chartGroup = ChartGroupType.InYearBalance; break; default: chartGroup = ChartGroupType.All; break; } var latestYear = _financialDataService.GetLatestDataYearForTrusts(); var term = FormatHelpers.FinancialTermFormatAcademies(latestYear); var dataResponse = _financialDataService.GetAcademiesByMatNumber(term, matNo); var sponsorVM = await BuildSponsorVMAsync(matNo, name, dataResponse, tab, chartGroup, financing); List <string> terms = _financialDataService.GetActiveTermsForMatCentral(); var latestTerm = terms.First(); UnitType unitType; switch (tab) { case RevenueGroupType.Workforce: unitType = UnitType.AbsoluteCount; break; case RevenueGroupType.Balance: unitType = unit == UnitType.AbsoluteMoney || unit == UnitType.PerPupil || unit == UnitType.PerTeacher ? unit : UnitType.AbsoluteMoney; break; default: unitType = unit; break; } _fcService.PopulateHistoricalChartsWithSchoolData(sponsorVM.HistoricalCharts, sponsorVM.HistoricalSchoolFinancialDataModels, latestTerm, tab, unitType, SchoolFinancialType.Academies); ViewBag.Tab = tab; ViewBag.ChartGroup = chartGroup; ViewBag.UnitType = unitType; ViewBag.Financing = financing; ViewBag.ChartFormat = format; return(View(sponsorVM)); }
private async Task <SponsorViewModel> BuildSponsorVMAsync(string matNo, string name, dynamic response, RevenueGroupType tab, ChartGroupType chartGroup, MatFinancingType matFinancing) { var schoolListVM = new List <SchoolViewModel>(); foreach (var result in response.Results) { schoolListVM.Add(new SchoolViewModel(result, null)); } var comparisonListVM = base.ExtractSchoolComparisonListFromCookie(); var sponsorVM = new SponsorViewModel(matNo, name, new SchoolListViewModel(schoolListVM, comparisonListVM), comparisonListVM); sponsorVM.HistoricalCharts = _historicalChartBuilder.Build(tab, chartGroup, sponsorVM.FinancialType); sponsorVM.ChartGroups = _historicalChartBuilder.Build(tab, sponsorVM.FinancialType).DistinctBy(c => c.ChartGroup).ToList(); sponsorVM.Terms = _financialDataService.GetActiveTermsForAcademies(); sponsorVM.HistoricalSchoolFinancialDataModels = await this.GetFinancialDataHistoricallyAsync(sponsorVM.MatNo, matFinancing); if (sponsorVM.HistoricalSchoolFinancialDataModels.Count > 0) { sponsorVM.TotalRevenueIncome = sponsorVM.HistoricalSchoolFinancialDataModels.Last().TotalIncome; sponsorVM.TotalRevenueExpenditure = sponsorVM.HistoricalSchoolFinancialDataModels.Last().TotalExpenditure; sponsorVM.InYearBalance = sponsorVM.HistoricalSchoolFinancialDataModels.Last().InYearBalance; } return(sponsorVM); }
public async Task <PartialViewResult> GetCharts(string matNo, string name, string term, RevenueGroupType revGroup, ChartGroupType chartGroup, UnitType unit, MatFinancingType financing = MatFinancingType.TrustAndAcademies, ChartFormat format = ChartFormat.Charts) { var dataResponse = _financialDataService.GetAcademiesByMatNumber(term, matNo); var sponsorVM = await BuildSponsorVMAsync(matNo, name, dataResponse, revGroup, chartGroup, financing); _fcService.PopulateHistoricalChartsWithSchoolData(sponsorVM.HistoricalCharts, sponsorVM.HistoricalSchoolFinancialDataModels, term, revGroup, unit, SchoolFinancialType.Academies); ViewBag.ChartFormat = format; return(PartialView("Partials/Chart", sponsorVM)); }