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)); }
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; } 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)); }