Exemplo n.º 1
0
        public async Task <IEnumerable <string> > GenerateAsync(
            IReportServiceContext reportServiceContext,
            IReportServiceDependentData reportsDependentData,
            CancellationToken cancellationToken)
        {
            var fundingSummaryReportModel = _devolvedFundingSummaryReportBuilder.Build(reportServiceContext, reportsDependentData);

            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Excel);

            using (var workbook = _excelService.NewWorkbook())
            {
                workbook.Worksheets.Clear();

                foreach (var reportModel in fundingSummaryReportModel)
                {
                    var worksheet = _excelService.GetWorksheetFromWorkbook(workbook, reportModel.SofLookup.SofCode);

                    _devolvedFundingSummaryReportRenderService.Render(reportModel, worksheet);
                }

                await _excelService.SaveWorkbookAsync(workbook, fileName, reportServiceContext.Container, cancellationToken);
            }

            return(new[] { fileName });
        }
Exemplo n.º 2
0
        public IFrmSummaryReport Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message       = reportServiceDependentData.Get <IMessage>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();
            var organisationNameDictionary = referenceData.Organisations.ToDictionary(x => x.UKPRN, x => x.Name);
            var orgName = organisationNameDictionary.GetValueOrDefault(reportServiceContext.Ukprn);

            return(new FrmSummaryReportModel(BuildHeader(
                                                 orgName,
                                                 reportServiceContext.Ukprn.ToString(),
                                                 reportServiceContext.OriginalFilename.Split('/').Last(),
                                                 reportServiceContext.LastIlrFileUpdate,
                                                 message.HeaderEntity.SourceEntity.ProtectiveMarkingString)));
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <string> > GenerateAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportsDependentData, CancellationToken cancellationToken)
        {
            var ilrValidationErrors = reportsDependentData.Get <List <ValidationError> >();

            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Csv);

            var validationErrorRows = _validationSchemaErrorsReportBuilder.Build(ilrValidationErrors);

            await _csvService.WriteAsync <ValidationErrorRow, ValidationErrorMapper>(validationErrorRows, fileName, reportServiceContext.Container, cancellationToken);

            await _frontEndValidationReport.GenerateAsync(reportServiceContext, validationErrorRows, true, cancellationToken);

            return(new[] { fileName });
        }
Exemplo n.º 4
0
        public IEnumerable <MainOccupancyReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message       = reportServiceDependentData.Get <IMessage>();
            var fm35          = reportServiceDependentData.Get <FM35Global>();
            var fm25          = reportServiceDependentData.Get <FM25Global>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var larsLearningDeliveries = BuildLarsLearningDeliveryDictionary(referenceData);
            var fm35LearningDeliveries = BuildFm35LearningDeliveryDictionary(fm35);
            var fm25Learners           = BuildFm25LearnerDictionary(fm25);

            var models = new List <MainOccupancyReportModel>();

            foreach (var learner in message?.Learners?.Where(l => l != null) ?? Enumerable.Empty <ILearner>())
            {
                foreach (var learningDelivery in learner.LearningDeliveries?.Where(ld => ld != null) ?? Enumerable.Empty <ILearningDelivery>())
                {
                    if (FundModelLearningDeliveryFilter(learningDelivery, FundModelConstants.FM35))
                    {
                        var fm35LearningDelivery           = fm35LearningDeliveries.GetValueOrDefault(learner.LearnRefNumber).GetValueOrDefault(learningDelivery.AimSeqNumber);
                        var larsLearningDelivery           = larsLearningDeliveries.GetValueOrDefault(learningDelivery.LearnAimRef);
                        var larsFrameworkAim               = larsLearningDelivery?.LARSFrameworks?.FirstOrDefault(lf => lf.LARSFrameworkAim.LearnAimRef.CaseInsensitiveEquals(learningDelivery.LearnAimRef))?.LARSFrameworkAim ?? new LARSFrameworkAim();
                        var providerSpecLearnerMonitoring  = _ilrModelMapper.MapProviderSpecLearnerMonitorings(learner.ProviderSpecLearnerMonitorings);
                        var providerSpecDeliveryMonitoring = _ilrModelMapper.MapProviderSpecDeliveryMonitorings(learningDelivery.ProviderSpecDeliveryMonitorings);
                        var learningDeliveryFams           = _ilrModelMapper.MapLearningDeliveryFAMs(learningDelivery.LearningDeliveryFAMs);
                        var periodisedValues               = BuildFm35PeriodisedValuesModel(fm35LearningDelivery?.LearningDeliveryPeriodisedValues);

                        var traineeshipWorkPlacementOrWorPreparation =
                            fm35LearningDelivery?.LearningDeliveryValue?.TrnWorkPlaceAim == true ||
                            fm35LearningDelivery?.LearningDeliveryValue?.TrnWorkPrepAim == true
                                ? ReportingConstants.Yes
                                : ReportingConstants.No;

                        var higherApprenticeshipPrescribedHeAim = fm35LearningDelivery?.LearningDeliveryValue?.PrscHEAim == true ? ReportingConstants.Yes : ReportingConstants.No;

                        var fundModelAgnosticModel = new FundModelAgnosticModel()
                        {
                            AimSequenceNumber      = learningDelivery.AimSeqNumber,
                            AimType                = learningDelivery.AimType,
                            CompStatus             = learningDelivery.CompStatus,
                            FundModel              = learningDelivery.FundModel,
                            ApplicableFundingRate  = fm35LearningDelivery?.LearningDeliveryValue?.ApplicWeightFundRate,
                            FundLine               = fm35LearningDelivery?.LearningDeliveryValue?.FundLine,
                            LearningActualEndDate  = learningDelivery.LearnActEndDateNullable,
                            LearningPlannedEndDate = learningDelivery.LearnPlanEndDate,
                            LearningStartDate      = learningDelivery.LearnStartDate,
                        };

                        models.Add(new MainOccupancyReportModel()
                        {
                            Learner = learner,
                            ProviderSpecLearnerMonitoring = providerSpecLearnerMonitoring,
                            LearningDelivery = learningDelivery,
                            ProviderSpecDeliveryMonitoring = providerSpecDeliveryMonitoring,
                            LearningDeliveryFAMs           = learningDeliveryFams,
                            Fm35LearningDelivery           = fm35LearningDelivery?.LearningDeliveryValue,
                            LarsLearningDelivery           = larsLearningDelivery,
                            PeriodisedValues       = periodisedValues,
                            FundModelAgnosticModel = fundModelAgnosticModel,
                            TraineeshipWorkPlacementOrWorkPreparation = traineeshipWorkPlacementOrWorPreparation,
                            HigherApprenticeshipPrescribedHeAim       = higherApprenticeshipPrescribedHeAim,
                            LarsFrameworkAim = larsFrameworkAim
                        });
                    }
                }

                if (learner.LearningDeliveries?.Any(ld => FundModelLearningDeliveryFilter(ld, FundModelConstants.FM25)) == true)
                {
                    var fm25Learner = fm25Learners.GetValueOrDefault(learner.LearnRefNumber);
                    var providerSpecLearnerMonitoring = _ilrModelMapper.MapProviderSpecLearnerMonitorings(learner.ProviderSpecLearnerMonitorings);
                    var periodisedValues = BuildFm25PeriodisedValuesModel(fm25Learner?.LearnerPeriodisedValues);

                    var fundModelAgnosticModel = new FundModelAgnosticModel()
                    {
                        FundModel             = FundModelConstants.FM25,
                        ApplicableFundingRate = fm25Learner?.NatRate,
                        FundLine = fm25Learner?.FundLine,
                        LearningActualEndDate  = fm25Learner?.LearnerActEndDate,
                        LearningPlannedEndDate = fm25Learner?.LearnerPlanEndDate,
                        LearningStartDate      = fm25Learner?.LearnerStartDate,
                    };

                    models.Add(new MainOccupancyReportModel()
                    {
                        Learner = learner,
                        ProviderSpecLearnerMonitoring = providerSpecLearnerMonitoring,
                        PeriodisedValues       = periodisedValues,
                        FundModelAgnosticModel = fundModelAgnosticModel,
                    });
                }
            }

            return(Order(models));
        }
        public async Task <IEnumerable <string> > GenerateAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportsDependentData, CancellationToken cancellationToken)
        {
            ILooseMessage          ilrMessage          = reportsDependentData.Get <ILooseMessage>();
            ReferenceDataRoot      ilrReferenceData    = reportsDependentData.Get <ReferenceDataRoot>();
            List <ValidationError> ilrValidationErrors = reportsDependentData.Get <List <ValidationError> >();

            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Csv);

            var validationErrorRows = _validationErrorsReportBuilder.Build(ilrValidationErrors, ilrMessage, ilrReferenceData.MetaDatas.ValidationErrors);

            await _csvService.WriteAsync <ValidationErrorRow, ValidationErrorMapper>(validationErrorRows, fileName, reportServiceContext.Container, cancellationToken);

            await _frontEndValidationReport.GenerateAsync(reportServiceContext, validationErrorRows, false, cancellationToken);

            return(new[] { fileName });
        }
Exemplo n.º 6
0
        public IEnumerable <MathsAndEnglishReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message = reportServiceDependentData.Get <IMessage>();
            var fm25    = reportServiceDependentData.Get <FM25Global>();

            var fm25LearnerDictionary = BuildFm25LearnerDictionary(fm25);

            var models = new List <MathsAndEnglishReportModel>();

            foreach (var learner in message?.Learners ?? Enumerable.Empty <ILearner>())
            {
                var fm25Learner = fm25LearnerDictionary.GetValueOrDefault(learner.LearnRefNumber);

                if (Filter(learner, fm25Learner))
                {
                    models.Add(new MathsAndEnglishReportModel()
                    {
                        Learner     = learner,
                        FM25Learner = fm25Learner,
                    });
                }
            }

            return(Order(models));
        }
        public HighNeedsStudentSummaryReportModel Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message           = reportServiceDependentData.Get <IMessage>();
            var fm25Data          = reportServiceDependentData.Get <FM25Global>();
            var referenceDataRoot = reportServiceDependentData.Get <ReferenceDataRoot>();

            var organisationName = referenceDataRoot.Organisations.FirstOrDefault(o => o.UKPRN == reportServiceContext.Ukprn)?.Name ?? string.Empty;
            var learners         = message?.Learners ?? Enumerable.Empty <ILearner>();
            var model            = new HighNeedsStudentSummaryReportModel();

            var applicableLearners = learners.Where(LearnerFilter).ToList();
            var applicableStudyProgrammeLearners = fm25Data.Learners?.Where(x => x.StartFund == true && StudyProgrammePredicate(x)).ToList();
            var applicableTLevelLearners         = fm25Data.Learners?.Where(x => x.StartFund == true && TLevelPredicate(x)).ToList();

            // Header
            BuildHeader(reportServiceContext, model, organisationName);

            // Body
            model.StudyProgramme = BuildBody(applicableStudyProgrammeLearners, applicableLearners);
            model.TLevel         = BuildBody(applicableTLevelLearners, applicableLearners);

            // Footer
            BuildFooter(model, referenceDataRoot.MetaDatas.ReferenceDataVersions, reportServiceContext.ServiceReleaseVersion, message?.HeaderEntity.CollectionDetailsEntity.FilePreparationDate);

            return(model);
        }
Exemplo n.º 8
0
        public IEnumerable <NonContractedAppsActivityReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message       = reportServiceDependentData.Get <IMessage>();
            var fm36Data      = reportServiceDependentData.Get <FM36Global>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var censusEndDates = referenceData.MetaDatas.CollectionDates.CensusDates.ToDictionary(p => p.Period, e => (DateTime?)e.End);
            var larsLearningDeliveryDictionary   = BuildLARSDictionary(referenceData.LARSLearningDeliveries);
            var fundingStreamPeriodCodesForUkprn = BuildFcsFundingStreamPeriodCodes(referenceData.FCSContractAllocations);

            var fm36LearnerModel = BuildFm36Learners(message, fm36Data, fundingStreamPeriodCodesForUkprn);

            var reportRows = BuildReportRows(fm36LearnerModel, larsLearningDeliveryDictionary, censusEndDates);

            return(reportRows);
        }
        public IEnumerable <Frm08ReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var models       = new List <Frm08ReportModel>();
            var returnPeriod = reportServiceContext.ReturnPeriodName;

            var message       = reportServiceDependentData.Get <IMessage>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var organisationNameDictionary = referenceData.Organisations.ToDictionary(x => x.UKPRN, x => x.Name);

            var learnAimDictionary = referenceData.LARSLearningDeliveries.ToDictionary(x => x.LearnAimRef, x => x, StringComparer.OrdinalIgnoreCase);

            var orgName = organisationNameDictionary.GetValueOrDefault(reportServiceContext.Ukprn);

            var pausedDeliveries = message.Learners
                                   ?.SelectMany(l => l.LearningDeliveries.Where(ld =>
                                                                                ld.CompStatus == _pausedCompStatus &&
                                                                                !ExcludedDelivery(ld, referenceData.LARSLearningDeliveries) &&
                                                                                !_excludedFundModel.Contains(ld.FundModel) &&
                                                                                FundModel99Rule(ld))
                                                .Select(ld => new { Learner = l, LearningDelivery = ld }));

            var currentReturnEndDate = referenceData.MetaDatas.CollectionDates.ReturnPeriods.FirstOrDefault(d =>
                                                                                                            reportServiceContext.SubmissionDateTimeUtc >= d.Start &&
                                                                                                            reportServiceContext.SubmissionDateTimeUtc <= d.End).End;

            if (pausedDeliveries == null)
            {
                return(Enumerable.Empty <Frm08ReportModel>());
            }

            foreach (var delivery in pausedDeliveries)
            {
                var restartDelivery = GetRestartDelivery(delivery.LearningDelivery, delivery.Learner);

                if (restartDelivery != null)
                {
                    continue;
                }

                var learnActEndDate = delivery.LearningDelivery.LearnActEndDateNullable;

                if (learnActEndDate.HasValue && DaysBetween(learnActEndDate.Value, currentReturnEndDate) >= 365)
                {
                    var advancedLoansIndicator = RetrieveFamCodeForType(delivery.LearningDelivery.LearningDeliveryFAMs, ADLLearnDelFamType);
                    var sofCode      = RetrieveFamCodeForType(delivery.LearningDelivery.LearningDeliveryFAMs, SOFLearnDelFamType);
                    var resIndicator = RetrieveFamCodeForType(delivery.LearningDelivery.LearningDeliveryFAMs, RESLearnDelFamType);

                    var pmOrgName = organisationNameDictionary.GetValueOrDefault(delivery.Learner.PMUKPRNNullable
                                                                                 .GetValueOrDefault());
                    var prevOrgName = organisationNameDictionary.GetValueOrDefault(delivery.Learner.PrevUKPRNNullable
                                                                                   .GetValueOrDefault());
                    var partnerOrgName = organisationNameDictionary.GetValueOrDefault(delivery.LearningDelivery.PartnerUKPRNNullable.GetValueOrDefault());
                    var learnAim       = learnAimDictionary.GetValueOrDefault(delivery.LearningDelivery.LearnAimRef);

                    models.Add(new Frm08ReportModel
                    {
                        Return                 = returnPeriod,
                        UKPRN                  = reportServiceContext.Ukprn,
                        OrgName                = orgName,
                        PartnerUKPRN           = delivery.LearningDelivery.PartnerUKPRNNullable,
                        PartnerOrgName         = partnerOrgName,
                        PrevUKPRN              = delivery.Learner.PrevUKPRNNullable,
                        PrevOrgName            = prevOrgName,
                        PMUKPRN                = delivery.Learner.PMUKPRNNullable,
                        PMOrgName              = pmOrgName,
                        ULN                    = delivery.Learner.ULN,
                        LearnRefNumber         = delivery.Learner.LearnRefNumber,
                        SWSupAimId             = delivery.LearningDelivery.SWSupAimId,
                        LearnAimRef            = delivery.LearningDelivery.LearnAimRef,
                        LearnAimTitle          = learnAim.LearnAimRefTitle,
                        AimSeqNumber           = delivery.LearningDelivery.AimSeqNumber,
                        AimTypeCode            = delivery.LearningDelivery.AimType,
                        LearnAimType           = learnAim.LearnAimRefTypeDesc,
                        StdCode                = delivery.LearningDelivery.StdCodeNullable,
                        FworkCode              = delivery.LearningDelivery.FworkCodeNullable,
                        PwayCode               = delivery.LearningDelivery.PwayCodeNullable,
                        ProgType               = delivery.LearningDelivery.ProgTypeNullable,
                        LearnStartDate         = delivery.LearningDelivery.LearnStartDate,
                        OrigLearnStartDate     = delivery.LearningDelivery.OrigLearnStartDateNullable,
                        LearnPlanEndDate       = delivery.LearningDelivery.LearnPlanEndDate,
                        LearnActEndDate        = delivery.LearningDelivery.LearnActEndDateNullable,
                        CompStatus             = delivery.LearningDelivery.CompStatus,
                        Outcome                = delivery.LearningDelivery.OutcomeNullable,
                        FundModel              = delivery.LearningDelivery.FundModel,
                        SOFCode                = sofCode,
                        AdvancedLoansIndicator = advancedLoansIndicator,
                        ResIndicator           = resIndicator,
                        ProvSpecLearnDelMon    = ProviderSpecDeliveryMonitorings(delivery.LearningDelivery.ProviderSpecDeliveryMonitorings),
                        ProvSpecDelMon         = ProviderSpecLearningMonitorings(delivery.Learner.ProviderSpecLearnerMonitorings),
                        PriorLearnFundAdj      = delivery.LearningDelivery.PriorLearnFundAdjNullable,
                        OtherFundAdj           = delivery.LearningDelivery.OtherFundAdjNullable,
                    });
                }
            }

            return(models);
        }
        public IEnumerable <HighNeedsStudentDetailReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message = reportServiceDependentData.Get <IMessage>();
            var fm25    = reportServiceDependentData.Get <FM25Global>();

            var fm25LearnerDictionary = BuildFm25LearnerDictionary(fm25);

            var models = new List <HighNeedsStudentDetailReportModel>();

            foreach (var learner in message?.Learners ?? Enumerable.Empty <ILearner>())
            {
                var fm25Learner = fm25LearnerDictionary.GetValueOrDefault(learner.LearnRefNumber);

                if (Filter(learner, fm25Learner))
                {
                    var ehc = FamCodeForType(learner.LearnerFAMs, LearnerFAMTypeConstants.EHC);
                    var hns = FamCodeForType(learner.LearnerFAMs, LearnerFAMTypeConstants.HNS);

                    models.Add(new HighNeedsStudentDetailReportModel()
                    {
                        Learner                        = learner,
                        FM25Learner                    = fm25Learner,
                        DerivedFundline                = _derivedFundLineDictionary.GetValueOrDefault(fm25Learner.FundLine),
                        StudentsWithAnEhcp             = StudentWithAnEhcp(ehc),
                        StudentsWithoutAnEhcp          = StudentWithoutAnEhcp(ehc),
                        HighNeedsStudentsWithoutAnEhcp = HighNeedsStudentWithoutAnEhcp(hns, ehc),
                        StudentsWithAnEhcpAndHns       = StudentWithAnEhcpAndHns(hns, ehc),
                        StudentWithAnEhcpAndNotHns     = StudentWithAnEhcpAndNotHns(hns, ehc),
                    });
                }
            }

            return(Order(models));
        }
        public CommunityLearningReportModel Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message       = reportServiceDependentData.Get <IMessage>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var headerData = BuildHeaderData(reportServiceContext, referenceData);
            var footerData = BuildFooterData(reportServiceContext, message, referenceData);

            var categoryData = BuildCategoryData(message);

            return(BuildModel(categoryData, headerData, footerData));
        }
Exemplo n.º 12
0
        public FundingClaimReportModel Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message           = reportServiceDependentData.Get <IMessage>();
            var fm25Data          = reportServiceDependentData.Get <FM25Global>();
            var referenceDataRoot = reportServiceDependentData.Get <ReferenceDataRoot>();

            var referenceDateFilter = RetrieveReportFilterValueFromContext <DateTime?>(reportServiceContext, ReportNameConstants.SixteenNineteenFundingClaim, ReportingConstants.ReferenceDateFilterPropertyName);

            var organisation = referenceDataRoot.Organisations.FirstOrDefault(o => o.UKPRN == reportServiceContext.Ukprn);
            var learners     = message?.Learners ?? Enumerable.Empty <ILearner>();

            var model = new FundingClaimReportModel();

            var applicableLearners = FilterLearners(learners);

            // Header
            var referenceDate = referenceDateFilter.HasValue ? referenceDateFilter.Value.ShortDateStringFormat() : "(ALL)";

            BuildHeader(reportServiceContext, model, organisation, referenceDate);

            // Body
            BuildBody(model, fm25Data.Learners, applicableLearners, referenceDateFilter);

            // Footer
            BuildFooter(model, referenceDataRoot.MetaDatas.ReferenceDataVersions, reportServiceContext.ServiceReleaseVersion, message?.HeaderEntity.CollectionDetailsEntity.FilePreparationDate);

            return(model);
        }
Exemplo n.º 13
0
        public IEnumerable <Frm06ReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var models = new List <Frm06ReportModel>();

            var frmLearners   = reportServiceDependentData.Get <FrmReferenceData>();
            var message       = reportServiceDependentData.Get <IMessage>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();
            var organisationNameDictionary = referenceData.Organisations.ToDictionary(x => x.UKPRN, x => x.Name);
            var learnAimDictionary         = referenceData.LARSLearningDeliveries.ToDictionary(x => x.LearnAimRef, x => x, StringComparer.OrdinalIgnoreCase);

            var currentLearnersHashSet = BuildCurrentYearLearnerHashSet(message);

            var returnPeriod = reportServiceContext.ReturnPeriodName;

            foreach (var learner in frmLearners?.Frm06Learners ?? Enumerable.Empty <FrmLearner>())
            {
                var key = new FrmLearnerKey
                {
                    FworkCodeNullable = learner.FworkCodeNullable,
                    LearnAimRef       = learner.LearnAimRef,
                    LearnRefNumber    = learner.LearnRefNumber,
                    LearnStartDate    = learner.LearnStartDate,
                    ProgTypeNullable  = learner.ProgTypeNullable
                };

                if (!currentLearnersHashSet.Contains(key))
                {
                    var advancedLoansIndicator = RetrieveFamCodeForType(learner.LearningDeliveryFAMs, ADLLearnDelFamType);
                    var devolvedIndicator      = RetrieveFamCodeForType(learner.LearningDeliveryFAMs, SOFLearnDelFamType);
                    var resIndicator           = RetrieveFamCodeForType(learner.LearningDeliveryFAMs, RESLearnDelFamType);
                    var sofCode     = RetrieveFamCodeForType(learner.LearningDeliveryFAMs, SOFLearnDelFamType);
                    var pmOrgName   = organisationNameDictionary.GetValueOrDefault(Convert.ToInt32(learner.PMUKPRN.GetValueOrDefault()));
                    var prevOrgName = organisationNameDictionary.GetValueOrDefault(Convert.ToInt32(learner.PrevUKPRN.GetValueOrDefault()));
                    var learnAim    = learnAimDictionary.GetValueOrDefault(learner.LearnAimRef);

                    models.Add(new Frm06ReportModel
                    {
                        UKPRN              = learner.UKPRN,
                        PrevOrgName        = prevOrgName,
                        PMOrgName          = pmOrgName,
                        AimTypeCode        = learner.AimType,
                        LearningAimType    = learnAim?.LearnAimRefTypeDesc,
                        FundingModel       = learner.FundModel,
                        OrigLearnStartDate = learner.OrigLearnStartDate,
                        SOFCode            = sofCode,
                        Return             = returnPeriod,
                        OrgName            = learner.OrgName,
                        FworkCode          = learner.FworkCodeNullable,
                        LearnAimTitle      = learner.LearnAimTitle,
                        LearnAimRef        = learner.LearnAimRef,
                        LearnRefNumber     = learner.LearnRefNumber,
                        LearnStartDate     = learner.LearnStartDate,
                        ProgType           = learner.ProgTypeNullable,
                        StdCode            = learner.StdCodeNullable,
                        ULN = learner.ULN,
                        AdvancedLoansIndicator = advancedLoansIndicator,
                        AimSeqNumber           = learner.AimSeqNumber,
                        CompStatus             = learner.CompStatus,
                        LearnActEndDate        = learner.LearnActEndDate,
                        LearnPlanEndDate       = learner.LearnPlanEndDate,
                        OtherFundAdj           = learner.OtherFundAdj,
                        Outcome             = learner.Outcome,
                        PMUKPRN             = learner.PMUKPRN,
                        PartnerUKPRN        = learner.PartnerUKPRN,
                        PartnerOrgName      = learner.PartnerOrgName,
                        PriorLearnFundAdj   = learner.PriorLearnFundAdj,
                        PrevUKPRN           = learner.PrevUKPRN,
                        PwayCode            = learner.PwayCodeNullable,
                        ResIndicator        = resIndicator,
                        SWSupAimId          = learner.SWSupAimId,
                        ProvSpecLearnDelMon = BuildProvSpecLearnDelMons(learner?.ProvSpecDeliveryMonitorings),
                        ProvSpecDelMon      = BuildProvSpecLearnDelMons(learner?.ProviderSpecLearnerMonitorings)
                    });
                }
            }

            return(models?.Where(LearningDeliveryFilter));
        }
        public IEnumerable <TrailblazerEmployerIncentivesReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var fm81 = reportServiceDependentData.Get <FM81Global>();

            var employerIds      = BuildFm81EmployersCollection(fm81);
            var periodisedValues = BuildFm81PeriodisedValuesList(fm81).ToList();

            var reportModels = employerIds
                               .Select(
                empId =>
                new TrailblazerEmployerIncentivesReportModel
            {
                EmployerIdentifier            = empId,
                AugustSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 0, empId),
                August1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 0, empId),
                AugustAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 0, empId),

                SeptemberSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 1, empId),
                September1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 1, empId),
                SeptemberAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 1, empId),

                OctoberSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 2, empId),
                October1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 2, empId),
                OctoberAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 2, empId),

                NovemberSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 3, empId),
                November1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 3, empId),
                NovemberAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 3, empId),

                DecemberSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 4, empId),
                December1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 4, empId),
                DecemberAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 4, empId),

                JanuarySmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 5, empId),
                January1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 5, empId),
                JanuaryAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 5, empId),

                FebruarySmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 6, empId),
                February1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 6, empId),
                FebruaryAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 6, empId),

                MarchSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 7, empId),
                March1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 7, empId),
                MarchAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 7, empId),

                AprilSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 8, empId),
                April1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 8, empId),
                AprilAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 8, empId),

                MaySmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 9, empId),
                May1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 9, empId),
                MayAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 9, empId),

                JuneSmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 10, empId),
                June1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 10, empId),
                JuneAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 10, empId),

                JulySmallEmployerIncentive  = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81SmallBusPayment, 11, empId),
                July1618ApprenticeIncentive = CalculatePaymentValue(periodisedValues, new[] { AttributeConstants.Fm81YoungAppFirstPayment, AttributeConstants.Fm81YoungAppSecondPayment }, 11, empId),
                JulyAchievementPayment      = CalculatePaymentValue(periodisedValues, AttributeConstants.Fm81AchPayment, 11, empId),
            });

            return(Order(reportModels));
        }
        public async Task <IEnumerable <string> > GenerateExcelAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportsDependentData, CancellationToken cancellationToken, int?fisInfoRowIndexToDelete = null)
        {
            var model = _modelBuilder.Build(reportServiceContext, reportsDependentData);

            return(new[]
            {
                await WriteWorkbookAsync(
                    reportServiceContext,
                    model,
                    TemplateFileName,
                    DataSource,
                    fisInfoRowIndexToDelete,
                    cancellationToken)
            });
        }
Exemplo n.º 16
0
        public async Task <IEnumerable <string> > GenerateAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportsDependentData, CancellationToken cancellationToken)
        {
            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Excel);

            var reportsToBeGenerated = _frmReports.Where(x => reportServiceContext.Tasks.Contains(x.TaskName, StringComparer.OrdinalIgnoreCase));

            using (var workbook = _excelService.NewWorkbook())
            {
                workbook.Worksheets.Clear();
                List <IFrmSummary> rows = new List <IFrmSummary>();
                var summaryWorksheet    = _excelService.GetWorksheetFromWorkbook(workbook, SummaryName);

                foreach (var frmReport in reportsToBeGenerated)
                {
                    rows.Add(frmReport.Generate(workbook, reportServiceContext, reportsDependentData, cancellationToken));
                }

                var frmSummaryReport = _frmSummaryReportModelBuilder.Build(reportServiceContext, reportsDependentData);
                frmSummaryReport.SummaryTable = rows;
                _frmSummaryReportRenderService.Render(frmSummaryReport, summaryWorksheet);

                await _excelService.SaveWorkbookAsync(workbook, fileName, reportServiceContext.Container, cancellationToken);
            }

            return(new[] { fileName });
        }
        public IEnumerable <DevolvedAdultEducationOccupancyReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message       = reportServiceDependentData.Get <IMessage>();
            var fm35          = reportServiceDependentData.Get <FM35Global>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var sofCodesDictionary = BuildSofDictionary(referenceData.DevolvedPostocdes.McaGlaSofLookups);

            var larsLearningDeliveries = BuildLarsLearningDeliveryDictionary(referenceData);
            var fm35LearningDeliveries = BuildFm35LearningDeliveryDictionary(fm35);
            var postcodes     = BuildPostcodesDictionary(referenceData);
            var organisations = referenceData.Organisations.ToDictionary(x => x.UKPRN, x => x.Name);

            var models = new List <DevolvedAdultEducationOccupancyReportModel>();

            foreach (var learner in message?.Learners?.Where(l => l != null) ?? Enumerable.Empty <ILearner>())
            {
                foreach (var learningDelivery in learner.LearningDeliveries?.Where(LearningDeliveryReportFilter) ?? Enumerable.Empty <ILearningDelivery>())
                {
                    var fm35LearningDelivery           = fm35LearningDeliveries.GetValueOrDefault(learner.LearnRefNumber).GetValueOrDefault(learningDelivery.AimSeqNumber);
                    var larsLearningDelivery           = larsLearningDeliveries.GetValueOrDefault(learningDelivery.LearnAimRef);
                    var providerSpecLearnerMonitoring  = _ilrModelMapper.MapProviderSpecLearnerMonitorings(learner.ProviderSpecLearnerMonitorings);
                    var providerSpecDeliveryMonitoring = _ilrModelMapper.MapProviderSpecDeliveryMonitorings(learningDelivery.ProviderSpecDeliveryMonitorings);
                    var learningDeliveryFams           = _ilrModelMapper.MapLearningDeliveryFAMs(learningDelivery.LearningDeliveryFAMs);
                    var periodisedValues = BuildFm35PeriodisedValuesModel(fm35LearningDelivery?.LearningDeliveryPeriodisedValues);
                    var mcaGlaShortCode  = sofCodesDictionary.GetValueOrDefault(learningDeliveryFams.SOF);
                    var entitlementValue = larsLearningDelivery.LARSLearningDeliveryCategories.Any(c =>
                                                                                                   (c.EffectiveFrom <= learningDelivery.LearnStartDate && (c.EffectiveTo ?? DateTime.MaxValue) >=
                                                                                                    learningDelivery.LearnStartDate) && _categoryRefs.Contains(c.CategoryRef))
                        ? ReportingConstants.Yes
                        : ReportingConstants.No;
                    var partnerProvider = organisations.GetValueOrDefault(learningDelivery.PartnerUKPRNNullable.GetValueOrDefault());

                    var learnerEmploymentStatus     = learner.LearnerEmploymentStatuses?.Where(l => l.DateEmpStatApp <= learningDelivery.LearnStartDate).OrderByDescending(d => d.DateEmpStatApp).FirstOrDefault() ?? new MessageLearnerLearnerEmploymentStatus();
                    var employmentStatusMonitorings = _ilrModelMapper.MapEmploymentStatusMonitorings(learnerEmploymentStatus.EmploymentStatusMonitorings);

                    var lsdPostcode        = postcodes.GetValueOrDefault(learningDelivery.LSDPostcode);
                    var localAuthorityCode = lsdPostcode?.ONSData?
                                             .FirstOrDefault(od => learningDelivery.LearnStartDate >= od.EffectiveFrom && learningDelivery.LearnStartDate <= (od.EffectiveTo ?? DateTime.MaxValue))?
                                             .LocalAuthority;

                    models.Add(new DevolvedAdultEducationOccupancyReportModel()
                    {
                        Learner = learner,
                        LearnerEmploymentStatus       = learnerEmploymentStatus,
                        EmploymentStatusMonitorings   = employmentStatusMonitorings,
                        ProviderSpecLearnerMonitoring = providerSpecLearnerMonitoring,
                        LearningDelivery = learningDelivery,
                        ProviderSpecDeliveryMonitoring = providerSpecDeliveryMonitoring,
                        LearningDeliveryFAMs           = learningDeliveryFams,
                        Fm35LearningDelivery           = fm35LearningDelivery?.LearningDeliveryValue,
                        LarsLearningDelivery           = larsLearningDelivery,
                        PeriodisedValues             = periodisedValues,
                        McaGlaShortCode              = mcaGlaShortCode,
                        EntitlementCategoryLevel2Or3 = entitlementValue,
                        PartnershipProviderName      = partnerProvider,
                        LocalAuthorityCode           = localAuthorityCode
                    });
                }
            }

            return(Order(models));
        }
        public IEnumerable <TrailblazerOccupancyReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message       = reportServiceDependentData.Get <IMessage>();
            var fm81          = reportServiceDependentData.Get <FM81Global>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var larsLearningDeliveries         = BuildLarsLearningDeliveryDictionary(referenceData);
            var fm81LearningDeliveryDictionary = BuildFm81LearningDeliveryDictionary(fm81);

            var models = new List <TrailblazerOccupancyReportModel>();

            foreach (var learner in message?.Learners?.Where(l => l != null) ?? Enumerable.Empty <ILearner>())
            {
                foreach (var learningDelivery in learner.LearningDeliveries ?? Enumerable.Empty <ILearningDelivery>())
                {
                    if (Filter(learningDelivery))
                    {
                        var larsLearningDelivery           = larsLearningDeliveries.GetValueOrDefault(learningDelivery.LearnAimRef);
                        var providerSpecLearnerMonitoring  = _ilrModelMapper.MapProviderSpecLearnerMonitorings(learner.ProviderSpecLearnerMonitorings);
                        var providerSpecDeliveryMonitoring = _ilrModelMapper.MapProviderSpecDeliveryMonitorings(learningDelivery.ProviderSpecDeliveryMonitorings);
                        var learningDeliveryFams           = _ilrModelMapper.MapLearningDeliveryFAMs(learningDelivery.LearningDeliveryFAMs);
                        var fm81LearningDelivery           = fm81LearningDeliveryDictionary.GetValueOrDefault(learner.LearnRefNumber).GetValueOrDefault(learningDelivery.AimSeqNumber);
                        var appFinRecord     = BuildAppFinRecordModel(learningDelivery);
                        var periodisedValues = BuildFm81PeriodisedValuesModel(fm81LearningDelivery?.LearningDeliveryPeriodisedValues);

                        models.Add(new TrailblazerOccupancyReportModel()
                        {
                            Learner                        = learner,
                            LearningDelivery               = learningDelivery,
                            LarsLearningDelivery           = larsLearningDelivery,
                            ProviderSpecLearnerMonitoring  = providerSpecLearnerMonitoring,
                            ProviderSpecDeliveryMonitoring = providerSpecDeliveryMonitoring,
                            LearningDeliveryFAMs           = learningDeliveryFams,
                            Fm81LearningDelivery           = fm81LearningDelivery?.LearningDeliveryValues,
                            AppFinRecord                   = appFinRecord,
                            PeriodisedValues               = periodisedValues,
                        });
                    }
                }
            }

            return(Order(models));
        }
Exemplo n.º 19
0
        public IEnumerable <SummaryOfFundingByStudentReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message = reportServiceDependentData.Get <IMessage>();
            var fm25    = reportServiceDependentData.Get <FM25Global>();

            var fm25LearnerDictionary = BuildFm25LearnerDictionary(fm25);

            var models = new List <SummaryOfFundingByStudentReportModel>();

            foreach (var learner in message?.Learners ?? Enumerable.Empty <ILearner>())
            {
                var fm25Learner = fm25LearnerDictionary.GetValueOrDefault(learner.LearnRefNumber);

                if (Filter(learner, fm25Learner))
                {
                    int?nonTLevelPlanLearnHours    = null;
                    int?nonTLevelPlanEEPHours      = null;
                    int?nonTLeveltotalPlannedHours = null;
                    int?tLevelPlannedHours         = null;

                    if (fm25Learner.TLevelStudent ?? false)
                    {
                        tLevelPlannedHours = TLevelPlannedHours(learner);
                    }
                    else
                    {
                        nonTLevelPlanLearnHours    = learner.PlanLearnHoursNullable;
                        nonTLevelPlanEEPHours      = learner.PlanEEPHoursNullable;
                        nonTLeveltotalPlannedHours = (learner.PlanLearnHoursNullable ?? 0) + (learner.PlanEEPHoursNullable ?? 0);
                    }

                    models.Add(new SummaryOfFundingByStudentReportModel()
                    {
                        Learner                    = learner,
                        FM25Learner                = fm25Learner,
                        NonTLevelPlanLearnHours    = nonTLevelPlanLearnHours,
                        NonTLevelPlanEEPHours      = nonTLevelPlanEEPHours,
                        NonTLevelTotalPlannedHours = nonTLeveltotalPlannedHours,
                        TLevelPlannedHours         = tLevelPlannedHours
                    });
                }
            }

            return(Order(models));
        }
Exemplo n.º 20
0
        public async Task <IEnumerable <string> > GenerateAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportsDependentData, CancellationToken cancellationToken)
        {
            var filenames = await GenerateExcelAsync(reportServiceContext, reportsDependentData, cancellationToken);

            return(filenames);
        }
        public IEnumerable <AppsIndicativeEarningsReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message  = reportServiceDependentData.Get <IMessage>();
            var fm36Data = reportServiceDependentData.Get <FM36Global>();
            var appsIndicativeEarningsModels = new List <AppsIndicativeEarningsReportModel>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();
            IDictionary <string, LARSLearningDelivery> larsLearningDeliveries = BuildLarsLearningDeliveryDictionary(referenceData);
            IDictionary <int, LARSStandard>            larsStandards          = BuildLarsStandardDictionary(referenceData);
            IDictionary <string, FM36Learner>          fm36Learners           = BuildFm36LearnerDeliveryDictionary(fm36Data);

            foreach (var learner in message?.Learners?.Where(l => l != null) ?? Enumerable.Empty <ILearner>())
            {
                FM36Learner fm36Learner = fm36Learners.GetValueOrDefault(learner.LearnRefNumber);

                foreach (var learningDelivery in learner.LearningDeliveries ?? Enumerable.Empty <ILearningDelivery>())
                {
                    if (learningDelivery.FundModel != FundModelConstants.FM36)
                    {
                        continue;
                    }

                    LARSLearningDelivery larsDelivery         = larsLearningDeliveries.GetValueOrDefault(learningDelivery.LearnAimRef);
                    LearningDelivery     fm36LearningDelivery = fm36Learner?.LearningDeliveries?.FirstOrDefault(x => x.AimSeqNumber == learningDelivery.AimSeqNumber);
                    string larsStandard = null;

                    if (learningDelivery.StdCodeNullable != null)
                    {
                        larsStandard = larsStandards.GetValueOrDefault(learningDelivery.StdCodeNullable.Value)?.NotionalEndLevel ?? "NA";
                    }

                    if (fm36Learner?.PriceEpisodes.Any() ?? false)
                    {
                        List <PriceEpisode> episodesInRange = fm36Learner.PriceEpisodes
                                                              .Where(p => p.PriceEpisodeValues.EpisodeStartDate >= ReportingConstants.BeginningOfYear &&
                                                                     p.PriceEpisodeValues.EpisodeStartDate <= ReportingConstants.EndOfYear &&
                                                                     learningDelivery.AimSeqNumber == p.PriceEpisodeValues.PriceEpisodeAimSeqNumber)
                                                              .ToList();

                        if (episodesInRange.Any())
                        {
                            DateTime earliestEpisodeDate = episodesInRange.Select(x => x.PriceEpisodeValues.EpisodeStartDate ?? DateTime.MaxValue).Min();

                            foreach (PriceEpisode episodeAttribute in episodesInRange)
                            {
                                appsIndicativeEarningsModels.Add(BuildLineModel(learner,
                                                                                learningDelivery,
                                                                                fm36LearningDelivery,
                                                                                episodeAttribute,
                                                                                larsDelivery,
                                                                                larsStandard,
                                                                                episodeAttribute.PriceEpisodeValues.EpisodeStartDate == earliestEpisodeDate,
                                                                                true));
                            }
                            continue;
                        }
                    }

                    appsIndicativeEarningsModels.Add(BuildLineModel(learner,
                                                                    learningDelivery,
                                                                    fm36LearningDelivery,
                                                                    null,
                                                                    larsDelivery,
                                                                    larsStandard,
                                                                    false,
                                                                    false));
                }
            }

            return(appsIndicativeEarningsModels
                   .OrderBy(x => x.LearnRefNumber)
                   .ThenByDescending(x => x.AimSeqNumber)
                   .ThenByDescending(x => x.PriceEpisodeStartDate));
        }
Exemplo n.º 22
0
        public IEnumerable <Frm15ReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var models       = new List <Frm15ReportModel>();
            var returnPeriod = reportServiceContext.ReturnPeriodName;

            var message       = reportServiceDependentData.Get <IMessage>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var organisationNameDictionary = referenceData.Organisations.ToDictionary(x => x.UKPRN, x => x.Name);

            var learnAimDictionary = referenceData.LARSLearningDeliveries.ToDictionary(x => x.LearnAimRef, x => x, StringComparer.OrdinalIgnoreCase);

            var orgName = organisationNameDictionary.GetValueOrDefault(reportServiceContext.Ukprn);

            var deliveries = message.Learners
                             ?.SelectMany(l => l.LearningDeliveries.Where(ld =>
                                                                          ld.FundModel == _includedFundModel &&
                                                                          ld.ProgTypeNullable == _includedProgType &&
                                                                          ld.AimType == _includedAimType &&
                                                                          ld.CompStatus == _includedCompStatus &&
                                                                          ld.EPAOrgID == null).Select(ld => new { Learner = l, LearningDelivery = ld }));

            var currentReturnEndDate = referenceData.MetaDatas.CollectionDates.ReturnPeriods.FirstOrDefault(d => reportServiceContext.SubmissionDateTimeUtc >= d.Start && reportServiceContext.SubmissionDateTimeUtc <= d.End).End;

            if (deliveries == null)
            {
                return(Enumerable.Empty <Frm15ReportModel>());
            }

            foreach (var delivery in deliveries)
            {
                if ((delivery.LearningDelivery.LearnPlanEndDate > currentReturnEndDate && DaysBetween(currentReturnEndDate, delivery.LearningDelivery.LearnPlanEndDate) <= 90) || currentReturnEndDate > delivery.LearningDelivery.LearnPlanEndDate)
                {
                    var aFinAmount = delivery.LearningDelivery.AppFinRecords
                                     ?.OrderByDescending(afr => afr.AFinDate).FirstOrDefault(afr => afr.AFinType == AFinTypeTNP && afr.AFinCode == AFinCode)?.AFinAmount;

                    var paymentsReceived = delivery.LearningDelivery.AppFinRecords
                                           ?.Where(afr => afr.AFinType == AFinTypePMR && afr.AFinCode == AFinCode)
                                           .Sum(afr => afr.AFinAmount);

                    var advancedLoansIndicator = RetrieveFamCodeForType(delivery.LearningDelivery.LearningDeliveryFAMs, ADLLearnDelFamType);
                    var devolvedIndicator      = RetrieveFamCodeForType(delivery.LearningDelivery.LearningDeliveryFAMs, SOFLearnDelFamType);
                    var resIndicator           = RetrieveFamCodeForType(delivery.LearningDelivery.LearningDeliveryFAMs, RESLearnDelFamType);
                    var sofCode = RetrieveFamCodeForType(delivery.LearningDelivery.LearningDeliveryFAMs, SOFLearnDelFamType);

                    var pmOrgName = organisationNameDictionary.GetValueOrDefault(
                        delivery.Learner.PMUKPRNNullable.GetValueOrDefault());
                    var prevOrgName = organisationNameDictionary.GetValueOrDefault(delivery.Learner.PrevUKPRNNullable
                                                                                   .GetValueOrDefault());
                    var partnerOrgName = organisationNameDictionary.GetValueOrDefault(delivery.LearningDelivery.PartnerUKPRNNullable.GetValueOrDefault());
                    var learnAim       = learnAimDictionary.GetValueOrDefault(delivery.LearningDelivery.LearnAimRef);

                    models.Add(new Frm15ReportModel
                    {
                        Return                         = returnPeriod,
                        UKPRN                          = reportServiceContext.Ukprn,
                        OrgName                        = orgName,
                        PartnerUKPRN                   = delivery.LearningDelivery.PartnerUKPRNNullable,
                        PartnerOrgName                 = partnerOrgName,
                        PrevUKPRN                      = delivery.Learner.PrevUKPRNNullable,
                        PrevOrgName                    = prevOrgName,
                        PMUKPRN                        = delivery.Learner.PMUKPRNNullable,
                        PMOrgName                      = pmOrgName,
                        ULN                            = delivery.Learner.ULN,
                        LearnRefNumber                 = delivery.Learner.LearnRefNumber,
                        SWSupAimId                     = delivery.LearningDelivery.SWSupAimId,
                        LearnAimRef                    = delivery.LearningDelivery.LearnAimRef,
                        LearnAimTitle                  = learnAim.LearnAimRefTitle,
                        AimSeqNumber                   = delivery.LearningDelivery.AimSeqNumber,
                        AimTypeCode                    = delivery.LearningDelivery.AimType,
                        LearnAimType                   = learnAim.LearnAimRefTypeDesc,
                        StdCode                        = delivery.LearningDelivery.StdCodeNullable,
                        FworkCode                      = delivery.LearningDelivery.FworkCodeNullable,
                        PwayCode                       = delivery.LearningDelivery.PwayCodeNullable,
                        ProgType                       = delivery.LearningDelivery.ProgTypeNullable,
                        LearnStartDate                 = delivery.LearningDelivery.LearnStartDate,
                        OrigLearnStartDate             = delivery.LearningDelivery.OrigLearnStartDateNullable,
                        LearnPlanEndDate               = delivery.LearningDelivery.LearnPlanEndDate,
                        LearnActEndDate                = delivery.LearningDelivery.LearnActEndDateNullable,
                        CompStatus                     = delivery.LearningDelivery.CompStatus,
                        Outcome                        = delivery.LearningDelivery.OutcomeNullable,
                        FundModel                      = delivery.LearningDelivery.FundModel,
                        SOFCode                        = sofCode,
                        AdvancedLoansIndicator         = advancedLoansIndicator,
                        ResIndicator                   = resIndicator,
                        ProvSpecLearnDelMon            = ProviderSpecDeliveryMonitorings(delivery.LearningDelivery.ProviderSpecDeliveryMonitorings),
                        ProvSpecDelMon                 = ProviderSpecLearningMonitorings(delivery.Learner.ProviderSpecLearnerMonitorings),
                        PriorLearnFundAdj              = delivery.LearningDelivery.PriorLearnFundAdjNullable,
                        OtherFundAdj                   = delivery.LearningDelivery.OtherFundAdjNullable,
                        EPAOrgId                       = delivery.LearningDelivery.EPAOrgID,
                        TotalNegotiatedAssessmentPrice = aFinAmount,
                        AssessmentPaymentReceived      = paymentsReceived
                    });
                }
            }

            return(models);
        }
        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 RuleViolationSummaryReportModel Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            ILooseMessage          looseMessage      = reportServiceDependentData.Get <ILooseMessage>();
            ReferenceDataRoot      referenceDataRoot = reportServiceDependentData.Get <ReferenceDataRoot>();
            List <ValidationError> validationErrors  = reportServiceDependentData.Get <List <ValidationError> >();

            var validationErrorMessageDictionary = referenceDataRoot.MetaDatas.ValidationErrors.ToDictionary(ve => ve.RuleName, ve => ve.Message, StringComparer.OrdinalIgnoreCase);
            var model            = new RuleViolationSummaryReportModel();
            var organisation     = referenceDataRoot.Organisations.FirstOrDefault(o => o.UKPRN == reportServiceContext.Ukprn);
            var organisationName = organisation?.Name ?? string.Empty;

            DateTime dateTimeNowUtc    = _dateTimeProvider.GetNowUtc();
            DateTime dateTimeNowUk     = _dateTimeProvider.ConvertUtcToUk(dateTimeNowUtc);
            var      reportGeneratedAt = "Report generated at: " + FormatReportGeneratedAtDateTime(dateTimeNowUk);
            var      looseLearners     = looseMessage?.Learners?.ToList() ?? new List <ILooseLearner>();
            var      looseLearnerDestinationAndProgressions = looseMessage?.LearnerDestinationAndProgressions?.ToList() ?? new List <ILooseLearnerDestinationAndProgression>();

            // Header
            model.ProviderName = $"Provider: {organisationName}";
            model.Ukprn        = $"UKPRN: {reportServiceContext.Ukprn}";
            model.IlrFile      = $"ILR File: {ExtractFileName(reportServiceContext.IlrReportingFilename)}";
            model.Year         = ReportingConstants.Year;

            // body
            var validationErrorsList        = validationErrors.Where(x => x.Severity.CaseInsensitiveEquals(Error)).ToList();
            var validationErrorWarningsList = validationErrors.Where(x => x.Severity.CaseInsensitiveEquals(Warning)).ToList();

            var learnRefNumbersWithErrors   = new HashSet <string>(validationErrorsList.Select(x => x.LearnerReferenceNumber), StringComparer.OrdinalIgnoreCase);
            var learnRefNumbersWithWarnings = new HashSet <string>(validationErrorWarningsList.Select(x => x.LearnerReferenceNumber), StringComparer.OrdinalIgnoreCase);

            var validLearners   = looseLearners.Where(l => !learnRefNumbersWithErrors.Contains(l.LearnRefNumber)).ToList();
            var invalidLearners = looseLearners.Where(l => learnRefNumbersWithErrors.Contains(l.LearnRefNumber)).ToList();

            var validLearnerDestinationAndProgressions   = looseLearnerDestinationAndProgressions.Where(ldp => !learnRefNumbersWithErrors.Contains(ldp.LearnRefNumber)).ToList();
            var invalidLearnerDestinationAndProgressions = looseLearnerDestinationAndProgressions.Where(ldp => learnRefNumbersWithErrors.Contains(ldp.LearnRefNumber)).ToList();

            model.TotalNoOfErrors   = validationErrorsList.Count;
            model.TotalNoOfWarnings = validationErrorWarningsList.Count;

            model.TotalNoOfLearners             = looseLearners.DistinctByCount(x => x.LearnRefNumber);
            model.TotalNoOfLearnersWithWarnings = learnRefNumbersWithWarnings.Count(l => !learnRefNumbersWithErrors.Contains(l));

            var learningDeliveries = looseLearners.Where(x => x.LearningDeliveries != null).SelectMany(x => x.LearningDeliveries).ToList();

            model.FullyValidLearners = new RuleViolationsTotalModel
            {
                Total                   = validLearners.DistinctByCount(x => x.LearnRefNumber),
                Apprenticeships         = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM36),
                Funded1619              = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM25),
                AdultSkilledFunded      = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM35),
                CommunityLearningFunded = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM10),
                ESFFunded               = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM70),
                OtherAdultFunded        = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM81),
                Other1619Funded         = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM82),
                NonFunded               = LearnersWithFundModelLearningDeliveryFundModelCount(validLearners, FundModelConstants.FM99)
            };

            model.InvalidLearners = new RuleViolationsTotalModel
            {
                Total                   = invalidLearners.DistinctByCount(x => x.LearnRefNumber),
                Apprenticeships         = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM36),
                Funded1619              = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM25),
                AdultSkilledFunded      = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM35),
                CommunityLearningFunded = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM10),
                ESFFunded               = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM70),
                OtherAdultFunded        = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM81),
                Other1619Funded         = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM82),
                NonFunded               = LearnersWithFundModelLearningDeliveryFundModelCount(invalidLearners, FundModelConstants.FM99)
            };

            model.LearningDeliveries = new RuleViolationsTotalModel
            {
                Total                          = learningDeliveries.Count,
                Apprenticeships                = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM36),
                Funded1619                     = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM25),
                AdultSkilledFunded             = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM35),
                CommunityLearningFunded        = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM10),
                ESFFunded                      = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM70),
                OtherAdultFunded               = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM81),
                Other1619Funded                = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM82),
                NonFunded                      = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM99),
                AdvancedLoanLearningDeliveries = GetLearningDeliveriesFundModelWithFAMCount(learningDeliveries, FundModelConstants.FM99, LearningDeliveryFAMTypeConstants.ADL),
            };

            model.LearnerDestinationProgressionSummary = new LearnerDestinationProgressionSummary()
            {
                Total = looseLearnerDestinationAndProgressions.Count,
                ValidLearnerDestinationProgressions   = validLearnerDestinationAndProgressions.Count,
                InValidLearnerDestinationProgressions = invalidLearnerDestinationAndProgressions.Count,
            };

            model.Errors   = GetValidationErrorMessageModels(validationErrorsList, validationErrorMessageDictionary);
            model.Warnings = GetValidationErrorMessageModels(validationErrorWarningsList, validationErrorMessageDictionary);

            // Footer
            model.ReportGeneratedAt     = reportGeneratedAt;
            model.ApplicationVersion    = reportServiceContext.ServiceReleaseVersion;
            model.OrganisationData      = referenceDataRoot.MetaDatas.ReferenceDataVersions.OrganisationsVersion.Version;
            model.LargeEmployerData     = referenceDataRoot.MetaDatas.ReferenceDataVersions.Employers.Version;
            model.LarsData              = referenceDataRoot.MetaDatas.ReferenceDataVersions.LarsVersion.Version;
            model.PostcodeData          = referenceDataRoot.MetaDatas.ReferenceDataVersions.PostcodesVersion.Version;
            model.FilePreparationDate   = FormatFilePreparationDate(looseMessage?.HeaderEntity.CollectionDetailsEntity.FilePreparationDate);
            model.CampusIdData          = referenceDataRoot.MetaDatas.ReferenceDataVersions.CampusIdentifierVersion.Version;
            model.DevolvedPostcodesData = referenceDataRoot.MetaDatas.ReferenceDataVersions.DevolvedPostcodesVersion?.Version;
            return(model);
        }
Exemplo n.º 25
0
        public AEBSTFFundingSummaryReportModel Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message           = reportServiceDependentData.Get <IMessage>();
            var referenceDataRoot = reportServiceDependentData.Get <ReferenceDataRoot>();

            var periodisedValues = _periodisedValuesLookupProvider.Provide(FundingDataSources, reportServiceDependentData);

            var reportCurrentPeriod = reportServiceContext.ReturnPeriod > 12 ? 12 : reportServiceContext.ReturnPeriod;

            var description = "ESFA AEB - Short Term Funding Initiative";

            return(new AEBSTFFundingSummaryReportModel(
                       BuildHeaderData(reportServiceContext, referenceDataRoot),
                       new List <IFundingCategory>()
            {
                new FundingCategory(
                    @"ESFA Adult Education Budget - Short Term Funding Initiatives", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory($@"{description} 1", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrStfiFundLineGroup($@"{description} 1", reportCurrentPeriod, new [] { FundLineConstants.STFI1 }, periodisedValues))
                    .WithFundLineGroup(BuildEasStfiFundLineGroup($@"{description} 1", reportCurrentPeriod, new [] { FundLineConstants.STFI1 }, periodisedValues)),
                    new FundingSubCategory($@"{description} 2", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrStfiFundLineGroup($@"{description} 2", reportCurrentPeriod, new [] { FundLineConstants.STFI2 }, periodisedValues))
                    .WithFundLineGroup(BuildEasStfiFundLineGroup($@"{description} 2", reportCurrentPeriod, new [] { FundLineConstants.STFI2 }, periodisedValues)),
                    new FundingSubCategory($@"{description} 3", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrStfiFundLineGroup($@"{description} 3", reportCurrentPeriod, new [] { FundLineConstants.STFI3 }, periodisedValues))
                    .WithFundLineGroup(BuildEasStfiFundLineGroup($@"{description} 3", reportCurrentPeriod, new [] { FundLineConstants.STFI3 }, periodisedValues)),
                    new FundingSubCategory($@"{description} 4", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrStfiFundLineGroup($@"{description} 4", reportCurrentPeriod, new [] { FundLineConstants.STFI4 }, periodisedValues))
                    .WithFundLineGroup(BuildEasStfiFundLineGroup($@"{description} 4", reportCurrentPeriod, new [] { FundLineConstants.STFI4 }, periodisedValues))
                })
            },
                       BuildFooterData(reportServiceContext, message, referenceDataRoot)));
        }
        public async Task <IReportServiceContext> MutateAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData, CancellationToken cancellationToken)
        {
            await AddIlrReportingFilename(reportServiceContext, cancellationToken);
            await AddEasReportingFilename(reportServiceContext, reportServiceDependentData, cancellationToken);

            return(reportServiceContext);
        }
        public async Task <IEnumerable <string> > GenerateAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportsDependentData, CancellationToken cancellationToken)
        {
            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Csv);

            var model = _modelBuilder.Build(reportServiceContext, reportsDependentData);

            await _csvService.WriteAsync <TModel, TClassMap>(model, fileName, reportServiceContext.Container, cancellationToken);

            return(new[] { fileName });
        }
        private async Task AddEasReportingFilename(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData, CancellationToken cancellationToken)
        {
            var referenceDataEASFile = new EasFileDetails();

            if (reportServiceDependentData.Contains <ReferenceDataRoot>())
            {
                referenceDataEASFile = reportServiceDependentData.Get <ReferenceDataRoot>()?.MetaDatas.ReferenceDataVersions.EasFileDetails;
            }

            var easFileName = !string.IsNullOrWhiteSpace(referenceDataEASFile?.FileName) && referenceDataEASFile.FileName != _defaultEASValue?Path.GetFileName(referenceDataEASFile?.FileName) : _defaultEASValue;

            reportServiceContext.EasReportingFilename = easFileName;

            if (referenceDataEASFile?.UploadDateTime != null)
            {
                var easLastUpdated = (DateTime)referenceDataEASFile?.UploadDateTime.Value;

                reportServiceContext.LastEasFileUpdate = _dateTimeProvider.ConvertUtcToUk(easLastUpdated).ToString(ReportServiceConstants.LastFileUpdateDateTimeFormat);
            }

            if (referenceDataEASFile?.UploadDateTime == null)
            {
                reportServiceContext.LastEasFileUpdate = _defaultEASValue;
            }
        }
        public FundingSummaryReportModel Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var message           = reportServiceDependentData.Get <IMessage>();
            var referenceDataRoot = reportServiceDependentData.Get <ReferenceDataRoot>();

            var periodisedValues = _periodisedValuesLookupProvider.Provide(FundingDataSources, reportServiceDependentData);

            var reportCurrentPeriod = reportServiceContext.ReturnPeriod > 12 ? 12 : reportServiceContext.ReturnPeriod;

            return(new FundingSummaryReportModel(
                       BuildHeaderData(reportServiceContext, referenceDataRoot),
                       new List <IFundingCategory>()
            {
                new FundingCategory(
                    @"Carry-in Apprenticeships Budget (for starts before 1 May 2017 and non-procured delivery)", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory(@"16-18 Apprenticeship Frameworks for starts before 1 May 2017", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("16-18", "Apprenticeship Frameworks", reportCurrentPeriod, new [] { FundLineConstants.Apprenticeship1618 }, periodisedValues))
                    .WithFundLineGroup(BuildEasFm35FundLineGroup("16-18", "Apprenticeship Frameworks", reportCurrentPeriod, new [] { FundLineConstants.EasApprenticeship1618 }, periodisedValues)),
                    new FundingSubCategory(@"16-18 Trailblazer Apprenticeships for starts before 1 May 2017", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrTrailblazerApprenticeshipsFundLineGroup("16-18", reportCurrentPeriod, new [] { FundLineConstants.TrailblazerApprenticeship1618 }, periodisedValues))
                    .WithFundLineGroup(BuildEasAuthorisedClaimsExcessLearningSupportFundLineGroup("16-18", "Trailblazer Apprenticeships", reportCurrentPeriod, new [] { FundLineConstants.EasTrailblazerApprenticeship1618 }, periodisedValues)),
                    new FundingSubCategory(@"16-18 Non-Levy Contracted Apprenticeships - Non-procured delivery", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrNonLevyApprenticeshipsFundLineGroup("16-18", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship1618NonProcured }, periodisedValues))
                    .WithFundLineGroup(BuildEasNonLevyApprenticeshipsFundLineGroup("16-18", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship1618NonProcured }, periodisedValues)),
                    new FundingSubCategory(@"19-23 Apprenticeship Frameworks for starts before 1 May 2017", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("19-23", "Apprenticeship Frameworks", reportCurrentPeriod, new [] { FundLineConstants.Apprenticeship1923 }, periodisedValues))
                    .WithFundLineGroup(BuildEasFm35FundLineGroup("19-23", "Apprenticeship Frameworks", reportCurrentPeriod, new [] { FundLineConstants.EasApprenticeship1923 }, periodisedValues)),
                    new FundingSubCategory(@"19-23 Trailblazer Apprenticeships for starts before 1 May 2017", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrTrailblazerApprenticeshipsFundLineGroup("19-23", reportCurrentPeriod, new [] { FundLineConstants.TrailblazerApprenticeship1923 }, periodisedValues))
                    .WithFundLineGroup(BuildEasAuthorisedClaimsExcessLearningSupportFundLineGroup("19-23", "Trailblazer Apprenticeships", reportCurrentPeriod, new [] { FundLineConstants.EasTrailblazerApprenticeship1923 }, periodisedValues)),
                    new FundingSubCategory(@"24+ Apprenticeship Frameworks for starts before 1 May 2017", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("24+", "Apprenticeship Frameworks", reportCurrentPeriod, new [] { FundLineConstants.Apprenticeship24Plus }, periodisedValues))
                    .WithFundLineGroup(BuildEasFm35FundLineGroup("24+", "Apprenticeship Frameworks", reportCurrentPeriod, new [] { FundLineConstants.EasApprenticeship24Plus }, periodisedValues)),
                    new FundingSubCategory(@"24+ Trailblazer Apprenticeships for starts before 1 May 2017", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrTrailblazerApprenticeshipsFundLineGroup("24+", reportCurrentPeriod, new [] { FundLineConstants.TrailblazerApprenticeship24Plus }, periodisedValues))
                    .WithFundLineGroup(BuildEasAuthorisedClaimsExcessLearningSupportFundLineGroup("24+", "Trailblazer Apprenticeships", reportCurrentPeriod, new [] { FundLineConstants.EasTrailblazerApprenticeship24Plus }, periodisedValues)),
                    new FundingSubCategory(@"Adult Non-Levy Contracted Apprenticeships - Non-procured delivery", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrNonLevyApprenticeshipsFundLineGroup("Adult", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship19PlusNonProcured }, periodisedValues))
                    .WithFundLineGroup(BuildEasNonLevyApprenticeshipsFundLineGroup("Adult", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship19PlusNonProcured }, periodisedValues))
                }),
                new FundingCategory(
                    "Apprenticeships – Employers on Apprenticeship Service", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("16-18 Apprenticeship (Employer on App Service)", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrLevyApprenticeshipsFundLineGroup("16-18", "Apprenticeship (Employer on App Service)", reportCurrentPeriod, new [] { FundLineConstants.ApprenticeshipEmployerOnAppService1618 }, periodisedValues))
                    .WithFundLineGroup(BuildEasLevyApprenticeshipsFundLineGroup("16-18", "Apprenticeship (Employer on App Service)", reportCurrentPeriod, new[] { FundLineConstants.EasLevyApprenticeship1618, FundLineConstants.EasNonLevyApprenticeshipEmployerOnAppService1618 }, periodisedValues)),
                    new FundingSubCategory("Adult Apprenticeship (Employer on App Service)", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrLevyApprenticeshipsFundLineGroup("Adult", "Apprenticeship (Employer on App Service)", reportCurrentPeriod, new [] { FundLineConstants.ApprenticeshipEmployerOnAppService19Plus }, periodisedValues))
                    .WithFundLineGroup(BuildEasLevyApprenticeshipsFundLineGroup("Adult", "Apprenticeship (Employer on App Service)", reportCurrentPeriod, new [] { FundLineConstants.EasLevyApprenticeship19Plus, FundLineConstants.EasNonLevyApprenticeshipEmployerOnAppService19Plus }, periodisedValues)),
                }),
                new FundingCategory(
                    "16-18 Non-Levy Contracted Apprenticeships Budget - Procured delivery", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("16-18 Non-Levy Contracted Apprenticeships", reportCurrentPeriod)
                    .WithFundLineGroup(BuildNonLevyContractedApprenticeshipsFundLineGroup("16-18", "Non-Levy Contracted Apprenticeships", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship1618Procured }, periodisedValues))
                    .WithFundLineGroup(BuildEasLevyApprenticeshipsFundLineGroup("16-18", "Non-Levy Contracted Apprenticeships", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship1618Procured }, periodisedValues)),
                }),
                new FundingCategory(
                    "Adult Non-Levy Contracted Apprenticeships Budget - Procured delivery", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("Adult Non-Levy Contracted Apprenticeships", reportCurrentPeriod)
                    .WithFundLineGroup(BuildNonLevyContractedApprenticeshipsFundLineGroup("Adult", "Non-Levy Contracted Apprenticeships", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship19PlusProcured }, periodisedValues))
                    .WithFundLineGroup(BuildEasLevyApprenticeshipsFundLineGroup("Adult", "Non-Levy Contracted Apprenticeships", reportCurrentPeriod, new [] { FundLineConstants.NonLevyApprenticeship19PlusProcured }, periodisedValues)),
                }),
                new FundingCategory(
                    "16-18 Traineeships Budget", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("16-18 Traineeships", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm25FundLineGroup(reportCurrentPeriod, periodisedValues))
                    .WithFundLineGroup(BuildEasFm25FundLineGroup(reportCurrentPeriod, periodisedValues))
                }),
                new FundingCategory(
                    "19-24 Traineeships - Non-procured delivery", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("19-24 Traineeships", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("19-24", "Traineeships", reportCurrentPeriod, new [] { FundLineConstants.Traineeship1924, FundLineConstants.Traineeship1924NonProcured }, periodisedValues))
                    .WithFundLineGroup(BuildEasAuthorisedClaimsExcessLearningSupportFundLineGroup("19-24", "Traineeships", reportCurrentPeriod, new [] { FundLineConstants.EasTraineeships1924NonProcured }, periodisedValues)),
                }),
                new FundingCategory(
                    "19-24 Traineeships - Procured delivery from 1 Nov 2017", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("19-24 Traineeships", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("19-24", "Traineeships", reportCurrentPeriod, new [] { FundLineConstants.Traineeship1924ProcuredFromNov2017 }, periodisedValues))
                    .WithFundLineGroup(BuildEasAuthorisedClaimsExcessLearningSupportFundLineGroup("19-24", "Traineeships", reportCurrentPeriod, new [] { FundLineConstants.EasTraineeships1924ProcuredFromNov2017 }, periodisedValues)),
                }),
                new FundingCategory("19-24 Traineeships - 2020 Procurement", reportCurrentPeriod,
                                    new List <IFundingSubCategory>
                {
                    new FundingSubCategory("19-24 Traineeships", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("19-24", "Traineeships", reportCurrentPeriod, new [] { FundLineConstants.Traineeship19242020Procurement }, periodisedValues))
                    .WithFundLineGroup(BuildEasAuthorisedClaimsExcessLearningSupportFundLineGroup("19-24", "Traineeships", reportCurrentPeriod, new [] { FundLineConstants.EasTraineeship19242020Procurement }, periodisedValues))
                }),
                new FundingCategory(
                    "ESFA Adult Education Budget – Non-procured delivery", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("ESFA AEB – Adult Skills (non-procured)", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("ESFA", "AEB - Adult Skills (non-procured)", reportCurrentPeriod, new [] { FundLineConstants.AebOtherLearningNonProcured }, periodisedValues))
                    .WithFundLineGroup(BuildEasAebFundLineGroup("ESFA", "AEB - Adult Skills (non-procured)", reportCurrentPeriod, new [] { FundLineConstants.EasAebAdultSkillsNonProcured }, periodisedValues))
                },
                    AdultEducationBudgetNote),
                new FundingCategory(
                    "ESFA Adult Education Budget – Procured delivery from 1 Nov 2017 ", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("ESFA AEB – Adult Skills (procured from Nov 2017)", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("ESFA", "AEB - Adult Skills (procured from Nov 2017)", reportCurrentPeriod, new [] { FundLineConstants.AebOtherLearningProcuredFromNov2017 }, periodisedValues))
                    .WithFundLineGroup(BuildEasAebFundLineGroup("ESFA", "AEB - Adult Skills (procured from Nov 2017)", reportCurrentPeriod, new [] { FundLineConstants.EasAebAdultSkillsProcuredFromNov2017 }, periodisedValues))
                },
                    AdultEducationBudgetNote),
                new FundingCategory("ESFA AEB – COVID-19 Skills Offer – Non-procured delivery", reportCurrentPeriod,
                                    new List <IFundingSubCategory>
                {
                    new FundingSubCategory("ESFA AEB – COVID-19 Skills Offer (non-procured)", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("ESFA", "AEB – COVID-19 Skills Offer (non-procured)", reportCurrentPeriod, new [] { FundLineConstants.AebCovidSkillsOfferNonProcured }, periodisedValues))
                    .WithFundLineGroup(BuildEasCovidFundLineGroup("ESFA", "AEB – COVID-19 Skills Offer (non-procured)", reportCurrentPeriod, new [] { FundLineConstants.EasAebCovidSkillsOfferNonProcured }, periodisedValues))
                }),

                //---------------------------------------------------------------------
                // ESFA AEB COVID-19 Skills Offer - Procured
                //---------------------------------------------------------------------
                new FundingCategory("ESFA AEB – COVID-19 Skills Offer – Procured delivery", reportCurrentPeriod,
                                    new List <IFundingSubCategory>
                {
                    new FundingSubCategory("ESFA AEB – COVID-19 Skills Offer (procured)", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm35FundLineGroup("ESFA", "AEB – COVID-19 Skills Offer (procured)", reportCurrentPeriod, new [] { FundLineConstants.AebCovidSkillsOfferProcured }, periodisedValues))
                    .WithFundLineGroup(BuildEasCovidFundLineGroup("ESFA", "AEB – COVID-19 Skills Offer (procured)", reportCurrentPeriod, new [] { FundLineConstants.EasAebCovidSkillsOfferProcured }, periodisedValues))
                }),
                new FundingCategory(
                    "Advanced Loans Bursary Budget", reportCurrentPeriod,
                    new List <IFundingSubCategory>()
                {
                    new FundingSubCategory("Advanced Loans Bursary", reportCurrentPeriod)
                    .WithFundLineGroup(BuildIlrFm99FundLineGroup(reportCurrentPeriod, periodisedValues))
                    .WithFundLineGroup(BuildEasFm99FundLineGroup(reportCurrentPeriod, periodisedValues))
                })
            },
                       BuildFooterData(reportServiceContext, message, referenceDataRoot)));
        }
Exemplo n.º 30
0
        public IEnumerable <Frm07ReportModel> Build(IReportServiceContext reportServiceContext, IReportServiceDependentData reportServiceDependentData)
        {
            var models       = new List <Frm07ReportModel>();
            var returnPeriod = reportServiceContext.ReturnPeriodName;

            var message       = reportServiceDependentData.Get <IMessage>();
            var referenceData = reportServiceDependentData.Get <ReferenceDataRoot>();

            var organisationNameDictionary = referenceData.Organisations.ToDictionary(k => k.UKPRN, v => v.Name);
            var learnAimDictionary         = referenceData.LARSLearningDeliveries.ToDictionary(k => k.LearnAimRef, v => v, StringComparer.OrdinalIgnoreCase);
            var sofCodeDictionary          = referenceData.DevolvedPostocdes.McaGlaSofLookups.Where(l => DevolvedCodes.Contains(l.SofCode)).ToDictionary(k => k.SofCode, v => v.McaGlaShortCode);
            var mcaDictionary = referenceData.McaDevolvedContracts.ToDictionary(k => k.McaGlaShortCode, v => v.Ukprn,
                                                                                StringComparer.OrdinalIgnoreCase);

            var orgName = organisationNameDictionary.GetValueOrDefault(reportServiceContext.Ukprn);

            var pausedDeliveries = message.Learners
                                   ?.SelectMany(l => l.LearningDeliveries.Where(ld =>
                                                                                ld.CompStatus == _pausedCompStatus &&
                                                                                !ExcludedDelivery(ld, referenceData.LARSLearningDeliveries) &&
                                                                                FundModel99Rule(ld) &&
                                                                                !_excludedFundModel.Contains(ld.FundModel))
                                                .Select(ld => new { Learner = l, LearningDelivery = ld }));

            if (pausedDeliveries == null)
            {
                return(models);
            }

            var learnerDeliveries = pausedDeliveries.GroupBy(x => x.Learner);

            foreach (var deliverySet in learnerDeliveries)
            {
                foreach (var delivery in deliverySet.OrderByDescending(x => x.LearningDelivery.LearnStartDate))
                {
                    var restartDelivery = GetRestartDelivery(delivery.LearningDelivery, delivery.Learner);

                    if (restartDelivery != null)
                    {
                        var pmOrgName   = organisationNameDictionary.GetValueOrDefault(delivery.Learner.PMUKPRNNullable.GetValueOrDefault());
                        var prevOrgName = organisationNameDictionary.GetValueOrDefault(delivery.Learner.PrevUKPRNNullable.GetValueOrDefault());

                        models.Add(BuildModelForLearningDelivery(reportServiceContext, restartDelivery, delivery.Learner, sofCodeDictionary, mcaDictionary, organisationNameDictionary, learnAimDictionary, returnPeriod, orgName, pmOrgName, prevOrgName));
                    }
                }
            }

            return(models);
        }