public async Task <IPeriodisedValuesLookup> ProvideAsync(IReportServiceContext reportServiceContext, CancellationToken cancellationToken) { var ukprn = reportServiceContext.Ukprn; var fm35 = BuildFm35DictionaryAsync(ukprn, cancellationToken); var fm25 = BuildFm25DictionaryAsync(ukprn, cancellationToken); var fm81 = BuildFm81DictionaryAsync(ukprn, cancellationToken); var fm99 = BuildFm99DictionaryAsync(ukprn, cancellationToken); var eas = BuildEasDictionaryAsync(ukprn, cancellationToken); var das = BuildDasDictionaryAsync(ukprn, cancellationToken); var easdas = BuildEasDasDictionaryAsync(ukprn, cancellationToken); await Task.WhenAll(fm35, fm25, fm81, fm99, eas, das, easdas); var periodisedValuesLookup = new PeriodisedValuesLookup(); periodisedValuesLookup.Add(FundingDataSource.FM35, fm35.Result); periodisedValuesLookup.Add(FundingDataSource.FM25, fm25.Result); periodisedValuesLookup.Add(FundingDataSource.FM81, fm81.Result); periodisedValuesLookup.Add(FundingDataSource.FM99, fm99.Result); periodisedValuesLookup.Add(FundingDataSource.EAS, eas.Result); periodisedValuesLookup.Add(FundingDataSource.DAS, das.Result); periodisedValuesLookup.Add(FundingDataSource.EASDAS, easdas.Result); return(periodisedValuesLookup); }
public void BuildFundLine_Performance() { var title = "title"; var currentPeriod = 3; var fundModel = FundingDataSources.FM35; var fundLine = new[] { "fundLine" }; var attribute1 = "attribute1"; var attributes = new[] { attribute1, }; var dictionary = new PeriodisedValuesLookup() { [fundModel] = new Dictionary <string, Dictionary <string, decimal?[][]> >() { [fundLine[0]] = new Dictionary <string, decimal?[][]>() { [attribute1] = Enumerable.Range(0, 1000000) .Select(i => new decimal?[] { 1, null, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }) .ToArray() } } }; var result = NewGroup("FundGroupTitle", currentPeriod, fundModel, fundLine, dictionary).BuildFundLine(title, attributes); result.Period1.Should().Be(1000000); result.Period2.Should().Be(0); }
public void BuildFundLine() { var title = "title"; var currentPeriod = 3; var fundModel = FundingDataSources.FM35; var fundLine = new[] { "fundLine" }; var attribute1 = "attribute1"; var attribute2 = "attribute2"; var missing = "missing"; var attributes = new[] { attribute1, attribute2, missing }; var dictionary = new PeriodisedValuesLookup() { [fundModel] = new Dictionary <string, Dictionary <string, decimal?[][]> >() { [fundLine[0]] = new Dictionary <string, decimal?[][]>() { [attribute1] = new decimal?[][] { new decimal?[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, new decimal?[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, new decimal?[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, new decimal?[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, new decimal?[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, [attribute2] = new decimal?[][] { new decimal?[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, } } } }; var result = NewGroup(title, currentPeriod, fundModel, fundLine, dictionary).BuildFundLine(title, attributes); result.Period1.Should().Be(6); result.Period2.Should().Be(6); result.Period3.Should().Be(6); result.Period4.Should().Be(6); result.Period5.Should().Be(6); result.Period6.Should().Be(6); result.Period7.Should().Be(6); result.Period8.Should().Be(6); result.Period9.Should().Be(6); result.Period10.Should().Be(6); result.Period11.Should().Be(6); result.Period12.Should().Be(6); result.Period1To8.Should().Be(48); result.Period9To12.Should().Be(24); result.Total.Should().Be(72); result.YearToDate.Should().Be(18); }
public IPeriodisedValuesLookup Provide(IEnumerable <FundingDataSources> fundingDataSources, IReportServiceDependentData reportServiceDependentData) { var periodisedValuesLookup = new PeriodisedValuesLookup(); if (fundingDataSources.Contains(FundingDataSources.FM35)) { periodisedValuesLookup[FundingDataSources.FM35] = BuildFm35Dictionary(reportServiceDependentData.Get <FM35Global>()); } if (fundingDataSources.Contains(FundingDataSources.FM81)) { periodisedValuesLookup[FundingDataSources.FM81] = BuildFm81Dictionary(reportServiceDependentData.Get <FM81Global>()); } if (fundingDataSources.Contains(FundingDataSources.FM25)) { periodisedValuesLookup[FundingDataSources.FM25] = BuildFm25Dictionary(reportServiceDependentData.Get <FM25Global>()); } if (fundingDataSources.Contains(FundingDataSources.FM36)) { periodisedValuesLookup[FundingDataSources.FM36] = BuildFm36Dictionary(reportServiceDependentData.Get <FM36Global>()); } if (fundingDataSources.Contains(FundingDataSources.FM99)) { periodisedValuesLookup[FundingDataSources.FM99] = BuildFm99Dictionary(reportServiceDependentData.Get <ALBGlobal>()); } if (fundingDataSources.Contains(FundingDataSources.EAS)) { periodisedValuesLookup[FundingDataSources.EAS] = BuildEASDictionary(reportServiceDependentData.Get <List <EasFundingLine> >()); } return(periodisedValuesLookup); }
public IEnumerable <DevolvedAdultEducationFundingSummaryReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData) { var message = reportServiceDependentData.Get <IMessage>(); var fm35 = reportServiceDependentData.Get <FM35Global>(); var referenceDataRoot = reportServiceDependentData.Get <ReferenceDataRoot>(); var easFundingLines = reportServiceDependentData.Get <List <EasFundingLine> >(); var sofCodeDictionary = BuildSofDictionary(referenceDataRoot.DevolvedPostocdes.McaGlaSofLookups); var organisationName = referenceDataRoot.Organisations.FirstOrDefault(o => o.UKPRN == reportServiceContext.Ukprn)?.Name ?? string.Empty; var orgVersion = referenceDataRoot.MetaDatas.ReferenceDataVersions.OrganisationsVersion.Version; var larsVersion = referenceDataRoot.MetaDatas.ReferenceDataVersions.LarsVersion.Version; var employersVersion = referenceDataRoot.MetaDatas.ReferenceDataVersions.Employers.Version; var postcodesVersion = referenceDataRoot.MetaDatas.ReferenceDataVersions.PostcodesVersion.Version; var filePreparationDate = message?.HeaderEntity?.CollectionDetailsEntity?.FilePreparationDate; DateTime dateTimeNowUtc = _dateTimeProvider.GetNowUtc(); DateTime dateTimeNowUk = _dateTimeProvider.ConvertUtcToUk(dateTimeNowUtc); var reportGeneratedAt = FormatReportGeneratedAtDateTime(dateTimeNowUk); var reportCurrentPeriod = reportServiceContext.ReturnPeriod > 12 ? 12 : reportServiceContext.ReturnPeriod; var models = new List <DevolvedAdultEducationFundingSummaryReportModel>(); foreach (var sofCode in _sofLearnDelFamCodes) { var mgaClaSof = sofCodeDictionary[sofCode]; var learningDeliveries = BuildLearningDeliveryDictionary(message, mgaClaSof?.SofCode); var periodisedValues = new PeriodisedValuesLookup { [FundingDataSources.FM35] = BuildPeriodisedValuesDictionary(fm35, learningDeliveries), [FundingDataSources.EAS] = BuildEASDictionary(easFundingLines, mgaClaSof?.SofCode) }; models.Add(new DevolvedAdultEducationFundingSummaryReportModel( mgaClaSof, reportServiceContext.Ukprn, organisationName, ExtractFileName(reportServiceContext.IlrReportingFilename), reportServiceContext.LastIlrFileUpdate, filePreparationDate, reportServiceContext.LastEasFileUpdate, reportServiceContext.EasReportingFilename, orgVersion, larsVersion, postcodesVersion, employersVersion, reportServiceContext.ServiceReleaseVersion, reportGeneratedAt, new List <IDevolvedAdultEducationFundingCategory> { new DevolvedAdultEducationFundingCategory(@"Adult Education Budget - Eligible for MCA/GLA funding (non-procured)", reportCurrentPeriod) .WithFundLineGroup(BuildIlrFm35FundLineGroup(reportCurrentPeriod, new [] { FundLineConstants.AdultEducationEligibleMCAGLANonProcured }, periodisedValues)) .WithFundLineGroup(BuildEasFm35FundLineGroup(reportCurrentPeriod, new [] { FundLineConstants.AdultEducationEligibleMCAGLANonProcured }, periodisedValues)), new DevolvedAdultEducationFundingCategory(@"Adult Education Budget - Eligible for MCA/GLA funding (procured)", reportCurrentPeriod) .WithFundLineGroup(BuildIlrFm35FundLineGroup(reportCurrentPeriod, new [] { FundLineConstants.AdultEducationEligibleMCAGLAProcured }, periodisedValues)) .WithFundLineGroup(BuildEasFm35FundLineGroup(reportCurrentPeriod, new [] { FundLineConstants.AdultEducationEligibleMCAGLAProcured }, periodisedValues)) } )); } return(models); }