Ejemplo n.º 1
0
        public Task DetermineVariations(ProviderVariationContext providerVariationContext, IEnumerable <string> fundingLineCodes)
        {
            Guard.ArgumentNotNull(providerVariationContext, nameof(providerVariationContext));

            PublishedProviderVersion priorState = providerVariationContext.PriorState;

            if (priorState == null ||
                priorState.Provider.Status == Closed ||
                providerVariationContext.UpdatedProvider.Status != Closed ||
                !providerVariationContext.UpdatedProvider.Successor.IsNullOrWhitespace())
            {
                return(Task.CompletedTask);
            }

            if (providerVariationContext.UpdatedTotalFunding != priorState.TotalFunding)
            {
                providerVariationContext.RecordErrors("Unable to run Closure variation as TotalFunding has changed during the refresh funding");

                return(Task.CompletedTask);
            }


            providerVariationContext.QueueVariationChange(new ZeroRemainingProfilesChange(providerVariationContext));
            providerVariationContext.QueueVariationChange(new ZeroInitialPaymentProfilesChange(providerVariationContext));
            providerVariationContext.QueueVariationChange(new ReAdjustFundingValuesForProfileValuesChange(providerVariationContext));

            return(Task.CompletedTask);
        }
        public async Task DetermineVariations(ProviderVariationContext providerVariationContext, IEnumerable <string> fundingLineCodes)
        {
            Guard.ArgumentNotNull(providerVariationContext, nameof(providerVariationContext));

            Provider updatedProvider = providerVariationContext.UpdatedProvider;

            string successorId = updatedProvider.Successor;

            PublishedProviderVersion priorState = providerVariationContext.PriorState;

            if (priorState == null ||
                priorState.Provider.Status == Closed ||
                updatedProvider.Status != Closed ||
                successorId.IsNullOrWhitespace())
            {
                return;
            }

            if (providerVariationContext.UpdatedTotalFunding != priorState.TotalFunding)
            {
                providerVariationContext.RecordErrors("Unable to run Closure with Successor variation as TotalFunding has changed during the refresh funding");

                return;
            }

            PublishedProvider successorProvider = await GetOrCreateSuccessorProvider(providerVariationContext, successorId);

            if (successorProvider == null)
            {
                providerVariationContext.RecordErrors($"Unable to run Closure with Successor variation as could not locate or create a successor provider with id:{successorId}");

                return;
            }

            string providerId = providerVariationContext.ProviderId;

            if (successorProvider.HasPredecessor(providerId))
            {
                return;
            }

            providerVariationContext.SuccessorRefreshState = successorProvider.Current;

            successorProvider.AddPredecessor(providerId);

            providerVariationContext.QueueVariationChange(new TransferRemainingProfilesToSuccessorChange(providerVariationContext));
            providerVariationContext.QueueVariationChange(new ReAdjustSuccessorFundingValuesForProfileValueChange(providerVariationContext));
            providerVariationContext.QueueVariationChange(new ZeroRemainingProfilesChange(providerVariationContext));
            providerVariationContext.QueueVariationChange(new ReAdjustFundingValuesForProfileValuesChange(providerVariationContext));
        }
Ejemplo n.º 3
0
        public Task DetermineVariations(ProviderVariationContext providerVariationContext, IEnumerable <string> fundingLineCodes)
        {
            Guard.ArgumentNotNull(providerVariationContext, nameof(providerVariationContext));

            PublishedProviderVersion priorState = providerVariationContext.PriorState;

            if (priorState == null ||
                priorState.Provider.Status == Closed ||
                providerVariationContext.UpdatedProvider.Status == Closed)
            {
                return(Task.CompletedTask);
            }

            providerVariationContext.QueueVariationChange(new AdjustDsgProfilesForUnderOverPaymentChange(providerVariationContext));
            providerVariationContext.QueueVariationChange(new ReAdjustFundingValuesForProfileValuesChange(providerVariationContext));

            return(Task.CompletedTask);
        }
Ejemplo n.º 4
0
        public async Task QueuesVariationChangesToBeAppliedLater()
        {
            IVariationChange changeOne   = NewChange();
            IVariationChange changeTwo   = NewChange();
            IVariationChange changeThree = NewChange();

            _variationContext.QueueVariationChange(changeThree);
            _variationContext.QueueVariationChange(changeOne);
            _variationContext.QueueVariationChange(changeTwo);

            await _variationContext.ApplyVariationChanges(_applyProviderVariations);

            Received.InOrder(async() =>
            {
                await changeThree.Apply(_applyProviderVariations);
                await changeOne.Apply(_applyProviderVariations);
                await changeTwo.Apply(_applyProviderVariations);
            });
        }
Ejemplo n.º 5
0
        public Task DetermineVariations(ProviderVariationContext providerVariationContext, IEnumerable <string> fundingLineCodes)
        {
            if (providerVariationContext.PriorState == null || providerVariationContext.UpdatedProvider == null)
            {
                return(Task.CompletedTask);
            }

            foreach (VariationCheck variationCheck in VariationChecks)
            {
                variationCheck.Run(providerVariationContext);
            }

            if (providerVariationContext.VariationReasons.AnyWithNullCheck())
            {
                providerVariationContext.QueueVariationChange(new MetaDataVariationsChange(providerVariationContext));
            }

            return(Task.CompletedTask);
        }
        public Task DetermineVariations(ProviderVariationContext providerVariationContext, IEnumerable <string> fundingLineCodes)
        {
            Guard.ArgumentNotNull(providerVariationContext, nameof(providerVariationContext));

            PublishedProviderVersion priorState = providerVariationContext.PriorState;

            if (priorState == null ||
                priorState.Provider.Status == Closed ||
                providerVariationContext.UpdatedProvider.Status == Closed ||
                providerVariationContext.UpdatedTotalFunding == priorState.TotalFunding)
            {
                return(Task.CompletedTask);
            }

            providerVariationContext.AddVariationReasons(VariationReason.FundingUpdated);

            providerVariationContext.QueueVariationChange(new MetaDataVariationsChange(providerVariationContext));

            return(Task.CompletedTask);
        }
Ejemplo n.º 7
0
        public Task DetermineVariations(ProviderVariationContext providerVariationContext,
                                        IEnumerable <string> fundingLineCodes)
        {
            Guard.ArgumentNotNull(providerVariationContext, nameof(providerVariationContext));

            PublishedProviderVersion priorState   = providerVariationContext.PriorState;
            PublishedProviderVersion refreshState = providerVariationContext.RefreshState;

            if (priorState == null ||
                providerVariationContext.ReleasedState == null ||
                priorState.Provider.Status == Closed ||
                providerVariationContext.UpdatedProvider.Status == Closed ||
                HasNoProfilingChanges(priorState, refreshState, providerVariationContext) ||
                HasNoPaidPeriods(providerVariationContext, priorState))
            {
                return(Task.CompletedTask);
            }

            providerVariationContext.QueueVariationChange(new ReProfileVariationChange(providerVariationContext));

            return(Task.CompletedTask);
        }
        public async Task DetermineVariations(ProviderVariationContext providerVariationContext, IEnumerable <string> fundingLineCodes)
        {
            Guard.ArgumentNotNull(providerVariationContext, nameof(providerVariationContext));

            Provider updatedProvider = providerVariationContext.UpdatedProvider;

            string successorId = updatedProvider.Successor;

            PublishedProviderVersion priorState = providerVariationContext.PriorState;

            if (priorState == null ||
                priorState.Provider.Status == Closed ||
                updatedProvider.Status != Closed ||
                successorId.IsNullOrWhitespace())
            {
                return;
            }

            PublishedProvider successorProvider = await GetOrCreateSuccessorProvider(providerVariationContext, successorId);

            if (successorProvider == null)
            {
                providerVariationContext.RecordErrors(
                    $"Unable to run Pupil Number Successor variation as could not locate or create a successor provider with id:{successorId}");

                return;
            }

            string providerId = providerVariationContext.ProviderId;

            providerVariationContext.SuccessorRefreshState = successorProvider.Current;

            successorProvider.AddPredecessor(providerId);

            providerVariationContext.QueueVariationChange(new MovePupilNumbersToSuccessorChange(providerVariationContext));
        }