Beispiel #1
0
        public async Task <ICollection <SummarisedActual> > Summarise(
            IEnumerable <SummarisedActual> inputSummarisedActuals,
            ISummarisationMessage summarisationMessage,
            ICollection <FcsContractAllocation> fcsContractAllocations,
            CancellationToken cancellationToken)
        {
            var providerActuals = _summarisationService.Summarise(fcsContractAllocations, inputSummarisedActuals.ToList()).ToList();

            var groupedActuals = inputSummarisedActuals?
                                 .GroupBy(x => x.OrganisationId, StringComparer.OrdinalIgnoreCase)
                                 .Select(sa => new
            {
                OrganisationId    = sa.Key,
                SummarisedActuals = sa.ToList()
            }).ToList();

            foreach (var group in groupedActuals)
            {
                _logger.LogInfo($"Summarisation Wrapper: Funding Data Removed Rule OrgId: {group.OrganisationId} Start");

                var actualsToCarry = await _providerFundingDataRemovedService.FundingDataRemovedAsync(group.OrganisationId, group.SummarisedActuals, summarisationMessage, cancellationToken);

                providerActuals.AddRange(actualsToCarry);

                _logger.LogInfo($"Summarisation Wrapper: Funding Data Removed  Rule OrgId: {group.OrganisationId} End");
            }

            return(providerActuals);
        }
        public async Task <ICollection <SummarisedActual> > Summarise(LearningProvider providerData, ICollection <CollectionPeriod> collectionPeriods, ICollection <FundingType> fundingTypes, ICollection <FcsContractAllocation> contractAllocations, ISummarisationMessage summarisationMessage, CancellationToken cancellationToken)
        {
            var providerActuals = new List <SummarisedActual>();

            foreach (var summarisationType in summarisationMessage.SummarisationTypes)
            {
                _logger.LogInfo($"Summarisation Wrapper: Summarising Data of UKPRN: {providerData.UKPRN}, Fundmodel {summarisationType} Start");

                var fundingStreams = fundingTypes?
                                     .Where(x => x.SummarisationType.Equals(summarisationType, StringComparison.OrdinalIgnoreCase))
                                     .SelectMany(fs => fs.FundingStreams)
                                     .ToList();

                var providerfundingstreamsContracts = await _providerContractsService.GetProviderContracts(providerData.UKPRN, fundingStreams, contractAllocations, cancellationToken);

                var summarisedData = _summarisationService.Summarise(providerfundingstreamsContracts.FundingStreams, providerData, providerfundingstreamsContracts.FcsContractAllocations, collectionPeriods, summarisationMessage);

                providerActuals.AddRange(summarisedData);

                _logger.LogInfo($"Summarisation Wrapper: Summarising Data of UKPRN: {providerData.UKPRN}, Fundmodel {summarisationType} End");
            }

            _logger.LogInfo($"Summarisation Wrapper: Funding Data Removed  Rule UKPRN: {providerData.UKPRN} Start");

            var organisationId = contractAllocations.Where(w => w.DeliveryUkprn == providerData.UKPRN).Select(s => s.DeliveryOrganisation).FirstOrDefault();

            var actualsToCarry = await _providerFundingDataRemovedService.FundingDataRemovedAsync(organisationId, providerActuals, summarisationMessage, cancellationToken);

            var fundingStreamPeriodCodesNotRequiredForActuals =
                GetFundingStreamsNotRequiredForCarryOver(summarisationMessage.CollectionYear,
                                                         summarisationMessage.CollectionMonth);

            var filteredActualsToCarry = actualsToCarry.Where(x => !fundingStreamPeriodCodesNotRequiredForActuals.Contains(x.FundingStreamPeriodCode)).ToList();

            providerActuals.AddRange(filteredActualsToCarry);

            _logger.LogInfo($"Summarisation Wrapper: Funding Data Removed  Rule UKPRN: {providerData.UKPRN} End");


            return(providerActuals);
        }
Beispiel #3
0
        public async Task <ICollection <SummarisedActual> > Summarise(TouchpointProviderFundingData providerData, ICollection <CollectionPeriod> collectionPeriods, ICollection <FundingType> fundingTypes, ICollection <FcsContractAllocation> contractAllocations, ISummarisationMessage summarisationMessage, CancellationToken cancellationToken)
        {
            var providerActuals = new List <SummarisedActual>();

            var provider = providerData.Provider;

            foreach (var summarisationType in summarisationMessage.SummarisationTypes)
            {
                _logger.LogInfo($"Summarisation Wrapper: Summarising Data of UKPRN: {providerData.Provider.UKPRN}, Fundmodel {summarisationType} Start");

                var fundingStreams = fundingTypes?
                                     .Where(x => x.SummarisationType.Equals(summarisationType, StringComparison.OrdinalIgnoreCase))
                                     .SelectMany(fs => fs.FundingStreams)
                                     .ToList();

                var providerfundingstreamsContracts = _providerContractsService.GetProviderContracts(provider.UKPRN, fundingStreams, contractAllocations, cancellationToken);

                var summarisedData = _summarisationService.Summarise(providerfundingstreamsContracts.FundingStreams, providerData, providerfundingstreamsContracts.FcsContractAllocations, collectionPeriods);

                providerActuals.AddRange(summarisedData);

                _logger.LogInfo($"Summarisation Wrapper: Summarising Data of UKPRN: {provider.UKPRN}, Fundmodel {summarisationType} End");
            }

            if (!summarisationMessage.ProcessType.Equals(ProcessTypeConstants.Payments, StringComparison.OrdinalIgnoreCase))
            {
                _logger.LogInfo($"Summarisation Wrapper: Funding Data Removed  Rule UKPRN: {provider.UKPRN} Start");

                var organisationId = providerActuals.Select(x => x.OrganisationId).FirstOrDefault();

                var actualsToCarry = await _providerFundingDataRemovedService.FundingDataRemovedAsync(organisationId, providerData.Provider.TouchpointId, providerActuals, summarisationMessage, cancellationToken);

                providerActuals.AddRange(actualsToCarry);

                _logger.LogInfo($"Summarisation Wrapper: Funding Data Removed  Rule UKPRN: {provider.UKPRN} End");
            }

            return(providerActuals);
        }
        public async Task <ICollection <SummarisedActual> > Summarise(LearningProvider providerData, ICollection <CollectionPeriod> collectionPeriods, ICollection <FundingType> fundingTypes, ICollection <FcsContractAllocation> contractAllocations, ISummarisationMessage summarisationMessage, CancellationToken cancellationToken)
        {
            var providerActuals = new List <SummarisedActual>();

            foreach (var summarisationType in summarisationMessage.SummarisationTypes)
            {
                _logger.LogInfo($"Summarisation Wrapper: Summarising Data of UKPRN: {providerData.UKPRN}, Fundmodel {summarisationType} Start");

                var fundingStreams = fundingTypes?
                                     .Where(x => x.SummarisationType.Equals(summarisationType, StringComparison.OrdinalIgnoreCase))
                                     .SelectMany(fs => fs.FundingStreams)
                                     .ToList();

                var providerfundingstreamsContracts = await _providerContractsService.GetProviderContracts(providerData.UKPRN, fundingStreams, contractAllocations, cancellationToken);

                var summarisedData = _summarisationService.Summarise(providerfundingstreamsContracts.FundingStreams, providerData, providerfundingstreamsContracts.FcsContractAllocations, collectionPeriods, summarisationMessage);

                providerActuals.AddRange(summarisedData);

                _logger.LogInfo($"Summarisation Wrapper: Summarising Data of UKPRN: {providerData.UKPRN}, Fundmodel {summarisationType} End");
            }

            return(providerActuals);
        }