private async Task <List <FinancialDataModel> > GetFinancialDataHistoricallyAsync(long urn, EstablishmentType estabType, CentralFinancingType cFinance)
        {
            var models     = new List <FinancialDataModel>();
            var latestYear = await _financialDataService.GetLatestDataYearPerEstabTypeAsync(estabType);

            var taskList = new List <Task <SchoolTrustFinancialDataObject> >();

            for (int i = ChartHistory.YEARS_OF_HISTORY - 1; i >= 0; i--)
            {
                var term = SchoolFormatHelpers.FinancialTermFormatAcademies(latestYear - i);
                var task = _financialDataService.GetSchoolFinancialDataObjectAsync(urn, term, estabType, cFinance);
                taskList.Add(task);
            }

            for (int i = ChartHistory.YEARS_OF_HISTORY - 1; i >= 0; i--)
            {
                var term             = SchoolFormatHelpers.FinancialTermFormatAcademies(latestYear - i);
                var resultDataObject = await taskList[ChartHistory.YEARS_OF_HISTORY - 1 - i];

                if (estabType == EstablishmentType.Academies && cFinance == CentralFinancingType.Include && resultDataObject == null)//if nothing found in MAT-Allocs collection try to source it from (non-allocated) Academies data
                {
                    resultDataObject = (await _financialDataService.GetSchoolFinancialDataObjectAsync(urn, term, estabType, CentralFinancingType.Exclude));
                }

                if (resultDataObject != null && resultDataObject.DidNotSubmit)//School did not submit finance, return & display "no data" in the charts
                {
                    resultDataObject = null;
                }

                models.Add(new FinancialDataModel(urn.ToString(), term, resultDataObject, estabType));
            }

            return(models);
        }
        public async Task <ActionResult> Download(long fuid)
        {
            var vm = await BuildFullFederationViewModelAsync(fuid, TabType.AllExcludingSchoolPerf, ChartGroupType.All, UnitType.AbsoluteMoney);

            var csv = _csvBuilder.BuildCSVContentHistorically(vm, await _financialDataService.GetLatestDataYearPerEstabTypeAsync(EstablishmentType.Federation));

            return(File(Encoding.UTF8.GetBytes(csv), "text/plain", $"HistoricalData-{fuid}.csv"));
        }
Пример #3
0
        public async Task <ActionResult> Download(long urn)
        {
            await _schoolVMBuilder.BuildCoreAsync(urn);

            _schoolVMBuilder.SetTab(TabType.AllIncludingSchoolPerf);
            await _schoolVMBuilder.AddHistoricalChartsAsync(TabType.AllIncludingSchoolPerf, ChartGroupType.All, CentralFinancingType.Include, UnitType.AbsoluteMoney);

            _schoolVMBuilder.SetChartGroups(TabType.AllIncludingSchoolPerf);
            var schoolVM = _schoolVMBuilder.GetResult();

            var csv = _csvBuilder.BuildCSVContentHistorically(schoolVM, await _financialDataService.GetLatestDataYearPerEstabTypeAsync(schoolVM.EstablishmentType));

            return(File(Encoding.UTF8.GetBytes(csv), "text/plain", $"HistoricalData-{urn}.csv"));
        }
        public async Task <ActionResult> Download(int companyNo, string name)
        {
            var latestYear = await _financialDataService.GetLatestDataYearPerEstabTypeAsync(EstablishmentType.MAT);

            var trustVM = await BuildFinancialTrustVMAsync(companyNo, TabType.AllExcludingSchoolPerf, ChartGroupType.All, MatFinancingType.TrustOnly);

            var termsList = await _financialDataService.GetActiveTermsForMatCentralAsync();

            _fcService.PopulateHistoricalChartsWithFinancialData(trustVM.HistoricalCharts, trustVM.HistoricalFinancialDataModels, termsList.First(), TabType.AllExcludingSchoolPerf, UnitType.AbsoluteMoney, EstablishmentType.MAT);

            string csv = _csvBuilder.BuildCSVContentHistorically(trustVM, latestYear);

            return(File(Encoding.UTF8.GetBytes(csv),
                        "text/plain",
                        $"HistoricalData-{name}.csv"));
        }
Пример #5
0
        private async Task <string> LatestMATTermAsync()
        {
            var latestYear = await _financialDataService.GetLatestDataYearPerEstabTypeAsync(EstablishmentType.MAT);

            return(SchoolFormatHelpers.FinancialTermFormatAcademies(latestYear));
        }
        private async Task <string> GetLatestTermYears(EstablishmentType financeType)
        {
            var term = await _financialDataService.GetLatestDataYearPerEstabTypeAsync(financeType);

            return(SchoolFormatHelpers.FinancialTermFormatAcademies(term).Replace(" ", ""));
        }