コード例 #1
0
        private void GivenTheFundingDate(Action <FundingDateBuilder> setUp = null)
        {
            FundingDateBuilder fundingDateBuilder = new FundingDateBuilder();

            setUp?.Invoke(fundingDateBuilder);

            _fundingDate = fundingDateBuilder.Build();
        }
        public async Task <IActionResult> GetFundingDate(
            string fundingStreamId,
            string fundingPeriodId,
            string fundingLineId)
        {
            if (string.IsNullOrWhiteSpace(fundingStreamId))
            {
                _logger.Error("No funding stream Id was provided to GetFundingDate");

                return(new BadRequestObjectResult("Null or empty funding stream Id provided"));
            }

            if (string.IsNullOrWhiteSpace(fundingPeriodId))
            {
                _logger.Error("No funding period Id was provided to GetFundingDate");

                return(new BadRequestObjectResult("Null or empty funding period Id provided"));
            }

            if (string.IsNullOrWhiteSpace(fundingLineId))
            {
                _logger.Error("No funding line Id was provided to GetFundingDate");

                return(new BadRequestObjectResult("Null or empty funding line Id provided"));
            }

            string fundingDateId = $"fundingdate-{fundingStreamId}-{fundingPeriodId}-{fundingLineId}";

            FundingDate fundingDate = null;

            try
            {
                fundingDate = await _policyRepositoryPolicy.ExecuteAsync(() => _policyRepository.GetFundingDate(fundingDateId));
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"No funding Dates were found for funding stream id : {fundingStreamId}");
            }

            if (fundingDate == null)
            {
                _logger.Error($"No funding Dates were found for funding stream id : {fundingStreamId}");

                return(new NotFoundResult());
            }

            return(new OkObjectResult(fundingDate));
        }
        public async Task GetFundingDate_GivenFundingDate_ReturnsOkResult()
        {
            // Arrange
            ILogger logger = CreateLogger();

            string fundingDateId = $"fundingdate-{_fundingStreamId}-{_fundingPeriodId}-{_fundingLineId}";

            IPolicyRepository policyRepository = CreatePolicyRepository();

            policyRepository
            .GetFundingDate(fundingDateId)
            .Returns(NewFundingDate(_ => _.WithFundingStreamId(_fundingStreamId)));

            FundingDateService fundingDateService = CreateFundingDateService(logger: logger, policyRepository: policyRepository);

            // Act
            IActionResult result = await fundingDateService.GetFundingDate(_fundingStreamId, _fundingPeriodId, _fundingLineId);

            // Assert
            result
            .Should()
            .BeOfType <OkObjectResult>()
            .Which
            .Value
            .Should()
            .BeOfType <FundingDate>()
            .And
            .Should()
            .NotBeNull();

            FundingDate fundingDate = (result as OkObjectResult).Value as FundingDate;

            fundingDate
            .FundingStreamId
            .Should()
            .Be(_fundingStreamId);
        }
        public async Task ReProfilesFundingLineAndMapsResultsIntoProfileTotals()
        {
            ProfilePreviewRequest previewRequest = NewProfilePreviewRequest();

            string distributionPeriod = NewRandomString();

            ReProfileRequest expectedReProfileRequest = NewReProfileRequest(_ => _.WithFundingLineTotal(999)
                                                                            .WithExistingFundingLineTotal(1000)
                                                                            .WithExistingProfilePeriods(NewExistingProfilePeriod(exp =>
                                                                                                                                 exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                 .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                 .WithTypeValue("January")
                                                                                                                                 .WithValue(23)
                                                                                                                                 .WithYear(2021)
                                                                                                                                 .WithOccurrence(0)),
                                                                                                        NewExistingProfilePeriod(exp =>
                                                                                                                                 exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                 .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                 .WithTypeValue("January")
                                                                                                                                 .WithValue(24)
                                                                                                                                 .WithYear(2021)
                                                                                                                                 .WithOccurrence(1)),
                                                                                                        NewExistingProfilePeriod(exp =>
                                                                                                                                 exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                 .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                 .WithTypeValue("February")
                                                                                                                                 .WithValue(null)
                                                                                                                                 .WithYear(2021)
                                                                                                                                 .WithOccurrence(0)),
                                                                                                        NewExistingProfilePeriod(exp =>
                                                                                                                                 exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                 .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                 .WithTypeValue("March")
                                                                                                                                 .WithValue(null)
                                                                                                                                 .WithYear(2021)
                                                                                                                                 .WithOccurrence(0)),
                                                                                                        NewExistingProfilePeriod(exp =>
                                                                                                                                 exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                 .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                 .WithTypeValue("April")
                                                                                                                                 .WithValue(null)
                                                                                                                                 .WithYear(2021)
                                                                                                                                 .WithOccurrence(0)),
                                                                                                        NewExistingProfilePeriod(exp =>
                                                                                                                                 exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                 .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                 .WithTypeValue("May")
                                                                                                                                 .WithValue(null)
                                                                                                                                 .WithYear(2021)
                                                                                                                                 .WithOccurrence(0))
                                                                                                        ));
            ReProfileResponse expectedReProfileResponse = NewReProfileResponse(_ => _.WithCarryOverAmount(992)
                                                                               .WithDeliveryProfilePeriods(NewDeliveryProfilePeriod(exp =>
                                                                                                                                    exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                    .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                    .WithTypeValue("January")
                                                                                                                                    .WithValue(33)
                                                                                                                                    .WithYear(2021)
                                                                                                                                    .WithOccurrence(0)),
                                                                                                           NewDeliveryProfilePeriod(exp =>
                                                                                                                                    exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                    .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                    .WithTypeValue("January")
                                                                                                                                    .WithValue(34)
                                                                                                                                    .WithYear(2021)
                                                                                                                                    .WithOccurrence(1)),
                                                                                                           NewDeliveryProfilePeriod(exp =>
                                                                                                                                    exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                    .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                    .WithTypeValue("February")
                                                                                                                                    .WithValue(35)
                                                                                                                                    .WithYear(2021)
                                                                                                                                    .WithOccurrence(0)),
                                                                                                           NewDeliveryProfilePeriod(exp =>
                                                                                                                                    exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                    .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                    .WithTypeValue("March")
                                                                                                                                    .WithValue(36)
                                                                                                                                    .WithYear(2021)
                                                                                                                                    .WithOccurrence(0)),
                                                                                                           NewDeliveryProfilePeriod(exp =>
                                                                                                                                    exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                    .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                    .WithTypeValue("April")
                                                                                                                                    .WithValue(37)
                                                                                                                                    .WithYear(2021)
                                                                                                                                    .WithOccurrence(0)),
                                                                                                           NewDeliveryProfilePeriod(exp =>
                                                                                                                                    exp.WithDistributionPeriod(distributionPeriod)
                                                                                                                                    .WithPeriodType(PeriodType.CalendarMonth)
                                                                                                                                    .WithTypeValue("May")
                                                                                                                                    .WithValue(38)
                                                                                                                                    .WithYear(2021)
                                                                                                                                    .WithOccurrence(0))));

            DateTimeOffset expectedActualDateOne   = NewRandomDate();
            DateTimeOffset expectedActualDateTwo   = NewRandomDate();
            DateTimeOffset expectedActualDateThree = NewRandomDate();
            DateTimeOffset expectedActualDateFour  = NewRandomDate();

            FundingDate expectedFundingDate = NewFundingDate(_ => _.WithPatterns(NewFundingDatePattern(fdp =>
                                                                                                       fdp.WithOccurrence(0)
                                                                                                       .WithPeriod("January")
                                                                                                       .WithPeriodYear(2021)
                                                                                                       .WithPaymentDate(expectedActualDateOne)),
                                                                                 NewFundingDatePattern(fdp =>
                                                                                                       fdp.WithOccurrence(0)
                                                                                                       .WithPeriod("February")
                                                                                                       .WithPeriodYear(2021)
                                                                                                       .WithPaymentDate(expectedActualDateTwo)),
                                                                                 NewFundingDatePattern(fdp =>
                                                                                                       fdp.WithOccurrence(0)
                                                                                                       .WithPeriod("April")
                                                                                                       .WithPeriodYear(2021)
                                                                                                       .WithPaymentDate(expectedActualDateThree)),
                                                                                 NewFundingDatePattern(fdp =>
                                                                                                       fdp.WithOccurrence(0)
                                                                                                       .WithPeriod("May")
                                                                                                       .WithPeriodYear(2021)
                                                                                                       .WithPaymentDate(expectedActualDateFour)),
                                                                                 NewFundingDatePattern()));

            GivenTheReProfileRequest(previewRequest, expectedReProfileRequest);
            AndTheReProfileResponse(expectedReProfileRequest, expectedReProfileResponse);
            AndTheFundingDate(previewRequest, expectedFundingDate);

            OkObjectResult response = await WhenTheProfilePatternChangeIsPreviewed(previewRequest) as OkObjectResult;

            response?
            .Value
            .Should()
            .BeEquivalentTo(new [] {
                NewProfileTotal(_ => _.WithOccurrence(0)
                                .WithDistributionPeriod(distributionPeriod)
                                .WithValue(23)
                                .WithYear(2021)
                                .WithPeriodType("CalenderMonth")
                                .WithTypeValue("January")
                                .WithIsPaid(true)
                                .WithInstallmentNumber(1)
                                .WithActualDate(expectedActualDateOne)),
                NewProfileTotal(_ => _.WithOccurrence(1)
                                .WithDistributionPeriod(distributionPeriod)
                                .WithValue(24)
                                .WithYear(2021)
                                .WithPeriodType("CalenderMonth")
                                .WithTypeValue("January")
                                .WithIsPaid(true)
                                .WithInstallmentNumber(2)
                                .WithActualDate(null)),
                NewProfileTotal(_ => _.WithOccurrence(0)
                                .WithDistributionPeriod(distributionPeriod)
                                .WithValue(35)
                                .WithYear(2021)
                                .WithPeriodType("CalenderMonth")
                                .WithTypeValue("February")
                                .WithIsPaid(false)
                                .WithInstallmentNumber(3)
                                .WithActualDate(expectedActualDateTwo)),
                NewProfileTotal(_ => _.WithOccurrence(0)
                                .WithDistributionPeriod(distributionPeriod)
                                .WithValue(36)
                                .WithYear(2021)
                                .WithPeriodType("CalenderMonth")
                                .WithTypeValue("March")
                                .WithIsPaid(false)
                                .WithInstallmentNumber(4)
                                .WithActualDate(null)),
                NewProfileTotal(_ => _.WithOccurrence(0)
                                .WithDistributionPeriod(distributionPeriod)
                                .WithValue(37)
                                .WithYear(2021)
                                .WithPeriodType("CalenderMonth")
                                .WithTypeValue("April")
                                .WithIsPaid(false)
                                .WithInstallmentNumber(5)
                                .WithActualDate(expectedActualDateThree)),
                NewProfileTotal(_ => _.WithOccurrence(0)
                                .WithDistributionPeriod(distributionPeriod)
                                .WithValue(38)
                                .WithYear(2021)
                                .WithPeriodType("CalenderMonth")
                                .WithTypeValue("May")
                                .WithIsPaid(false)
                                .WithInstallmentNumber(6)
                                .WithActualDate(expectedActualDateFour))
            });
        }
 private void AndTheFundingDate(ProfilePreviewRequest previewRequest,
                                FundingDate fundingDate)
 => _policies.Setup(_ => _.GetFundingDate(previewRequest.FundingStreamId,
                                          previewRequest.FundingPeriodId,
                                          previewRequest.FundingLineCode))
 .ReturnsAsync(new ApiResponse <FundingDate>(HttpStatusCode.OK, fundingDate));
        public async Task <IActionResult> SaveFundingDate(
            string actionName,
            string controllerName,
            string fundingStreamId,
            string fundingPeriodId,
            string fundingLineId,
            FundingDateViewModel fundingDateViewModel)
        {
            if (string.IsNullOrWhiteSpace(fundingStreamId))
            {
                _logger.Error("No funding stream Id was provided to SaveFundingDate");

                return(new BadRequestObjectResult("Null or empty funding stream Id provided"));
            }

            if (string.IsNullOrWhiteSpace(fundingPeriodId))
            {
                _logger.Error("No funding period Id was provided to SaveFundingDate");

                return(new BadRequestObjectResult("Null or empty funding period Id provided"));
            }

            if (string.IsNullOrWhiteSpace(fundingLineId))
            {
                _logger.Error("No funding line Id was provided to SaveFundingDate");

                return(new BadRequestObjectResult("Null or empty funding line Id provided"));
            }

            if (fundingDateViewModel == null)
            {
                _logger.Error("No funding date view model was provided to SaveFundingDate");

                return(new BadRequestObjectResult("Null or empty funding date view model provided"));
            }

            FundingDate fundingDate = _mapper.Map <FundingDate>(
                fundingDateViewModel,
                opt =>
            {
                opt.Items[nameof(FundingDate.FundingStreamId)] = fundingStreamId;
                opt.Items[nameof(FundingDate.FundingPeriodId)] = fundingPeriodId;
                opt.Items[nameof(FundingDate.FundingLineId)]   = fundingLineId;
            });

            BadRequestObjectResult validationResult =
                (await _fundingDateValidator.ValidateAsync(fundingDate)).PopulateModelState();

            if (validationResult != null)
            {
                return(validationResult);
            }

            try
            {
                HttpStatusCode result = await _policyRepositoryPolicy.ExecuteAsync(
                    () => _policyRepository.SaveFundingDate(fundingDate));

                if (!result.IsSuccess())
                {
                    int statusCode = (int)result;

                    string errorMessage = $"Failed to save funding date for funding stream id: {fundingStreamId} and period id: {fundingPeriodId} and funding line id: {fundingLineId} to cosmos db with status {statusCode}";

                    _logger.Error(errorMessage);

                    return(new InternalServerErrorResult(errorMessage));
                }
            }
            catch (Exception exception)
            {
                string errorMessage = $"Exception occurred writing to funding date for funding stream id: {fundingStreamId} and period id: {fundingPeriodId} and funding line id: {fundingLineId} to cosmos db";

                _logger.Error(exception, errorMessage);

                return(new InternalServerErrorResult(errorMessage));
            }

            _logger.Information($"Successfully saved funding date for funding stream id: {fundingStreamId} and period id: {fundingPeriodId} and funding line id: {fundingLineId} to cosmos db");

            return(new CreatedAtActionResult(
                       actionName,
                       controllerName,
                       new { fundingStreamId, fundingPeriodId, fundingLineId }, string.Empty));
        }
        public async Task <HttpStatusCode> SaveFundingDate(FundingDate fundingDate)
        {
            Guard.ArgumentNotNull(fundingDate, nameof(fundingDate));

            return(await _cosmosRepository.UpsertAsync(fundingDate, fundingDate.Id, true));
        }
コード例 #8
0
        public async Task <IActionResult> GetPublishedProviderProfileTotalsForSpecificationForProviderForFundingLine(
            string specificationId,
            string providerId,
            string fundingStreamId,
            string fundingLineCode)
        {
            Guard.IsNullOrWhiteSpace(specificationId, nameof(specificationId));
            Guard.IsNullOrWhiteSpace(fundingStreamId, nameof(fundingStreamId));
            Guard.IsNullOrWhiteSpace(fundingLineCode, nameof(fundingLineCode));
            Guard.IsNullOrWhiteSpace(providerId, nameof(providerId));

            PublishedProviderVersion latestPublishedProviderVersion = await _resilience.ExecuteAsync(() =>
                                                                                                     _publishedFunding.GetLatestPublishedProviderVersionBySpecificationId(
                                                                                                         specificationId,
                                                                                                         fundingStreamId,
                                                                                                         providerId));

            if (latestPublishedProviderVersion == null)
            {
                return(new NotFoundResult());
            }

            IEnumerable <ProfileVariationPointer> profileVariationPointers
                = await _specificationService.GetProfileVariationPointers(specificationId);

            TemplateMetadataDistinctFundingLinesContents templateMetadataDistinctFundingLinesContents =
                await _policiesService.GetDistinctTemplateMetadataFundingLinesContents(
                    fundingStreamId,
                    latestPublishedProviderVersion.FundingPeriodId,
                    latestPublishedProviderVersion.TemplateVersion);

            IEnumerable <FundingStreamPeriodProfilePattern> fundingStreamPeriodProfilePatterns =
                await _profilingService.GetProfilePatternsForFundingStreamAndFundingPeriod(
                    latestPublishedProviderVersion.FundingStreamId,
                    latestPublishedProviderVersion.FundingPeriodId);

            (string profilePatternKey, string profilePatternName, string profilePatternDescription) =
                GetProfilePatternDetails(fundingLineCode, latestPublishedProviderVersion, fundingStreamPeriodProfilePatterns);

            FundingLineProfile fundingLineProfile = new FundingLineProfile
            {
                FundingLineCode = fundingLineCode,
                FundingLineName = templateMetadataDistinctFundingLinesContents?.FundingLines?
                                  .FirstOrDefault(_ => _.FundingLineCode == fundingLineCode)?.Name,
                ProfilePatternKey         = profilePatternKey,
                ProfilePatternName        = profilePatternName,
                ProfilePatternDescription = profilePatternDescription,
                ProviderId      = latestPublishedProviderVersion.ProviderId,
                UKPRN           = latestPublishedProviderVersion.Provider.UKPRN,
                ProviderName    = latestPublishedProviderVersion.Provider.Name,
                CarryOverAmount = latestPublishedProviderVersion.GetCarryOverTotalForFundingLine(fundingLineCode) ?? 0
            };

            ProfileVariationPointer currentProfileVariationPointer
                = profileVariationPointers?.SingleOrDefault(_ =>
                                                            _.FundingStreamId == fundingStreamId && _.FundingLineId == fundingLineCode);

            ProfileTotal[] profileTotals = new PaymentFundingLineProfileTotals(latestPublishedProviderVersion, fundingLineCode)
                                           .ToArray();

            fundingLineProfile.TotalAllocation = latestPublishedProviderVersion
                                                 .FundingLines
                                                 .Where(_ => _.Type == FundingLineType.Payment)
                                                 .SingleOrDefault(_ => _.FundingLineCode == fundingLineCode)
                                                 ?.Value;

            fundingLineProfile.ProfileTotalAmount = profileTotals.Sum(_ => _.Value);

            FundingDate fundingDate = await _policiesService.GetFundingDate(
                fundingStreamId,
                latestPublishedProviderVersion.FundingPeriodId,
                fundingLineCode);

            for (int index = 0; index < profileTotals.Count(); index++)
            {
                ProfileTotal profileTotal = profileTotals[index];
                profileTotal.InstallmentNumber = index + 1;

                profileTotal.IsPaid = IsProfileTotalPaid(currentProfileVariationPointer, profileTotal);

                profileTotal.ActualDate = fundingDate?.Patterns?.SingleOrDefault(_ =>
                                                                                 _.Occurrence == profileTotal.Occurrence &&
                                                                                 _.Period == profileTotal.TypeValue &&
                                                                                 _.PeriodYear == profileTotal.Year)?.PaymentDate;
            }

            fundingLineProfile.AmountAlreadyPaid = profileTotals.Where(_ => _.IsPaid).Sum(_ => _.Value);
            fundingLineProfile.RemainingAmount   = fundingLineProfile.TotalAllocation - fundingLineProfile.AmountAlreadyPaid;

            foreach (ProfileTotal profileTotal in profileTotals.Where(_ => !_.IsPaid))
            {
                profileTotal.ProfileRemainingPercentage = fundingLineProfile.TotalAllocation.HasValue && fundingLineProfile.TotalAllocation > 0 ?
                                                          profileTotal.Value / (fundingLineProfile.TotalAllocation - fundingLineProfile.AmountAlreadyPaid) * 100 : 0;
            }

            fundingLineProfile.ProfileTotals = profileTotals;

            fundingLineProfile.LastUpdatedDate = latestPublishedProviderVersion.GetLatestFundingLineDate(fundingLineCode);
            fundingLineProfile.LastUpdatedUser = latestPublishedProviderVersion.GetLatestFundingLineUser(fundingLineCode);

            return(new OkObjectResult(fundingLineProfile));
        }
コード例 #9
0
        public async Task <IActionResult> GetPreviousProfilesForSpecificationForProviderForFundingLine(
            string specificationId,
            string providerId,
            string fundingStreamId,
            string fundingLineCode)
        {
            List <FundingLineChange> fundingLineChanges = new List <FundingLineChange>();

            IEnumerable <PublishedProviderVersion> publishedProviderVersions = await _resilience.ExecuteAsync(() =>
                                                                                                              _publishedFunding.GetPublishedProviderVersionsForApproval(
                                                                                                                  specificationId,
                                                                                                                  fundingStreamId,
                                                                                                                  providerId));

            PublishedProviderVersion latestPublishedProviderVersion = publishedProviderVersions.FirstOrDefault();

            if (latestPublishedProviderVersion == null)
            {
                return(new NotFoundResult());
            }

            IEnumerable <PublishedProviderVersion> historyPublishedProviderVersions =
                publishedProviderVersions.Except(new[] { latestPublishedProviderVersion });

            IEnumerable <FundingStream> fundingStreams = await _policiesService.GetFundingStreams();

            foreach (PublishedProviderVersion publishedProviderVersion in historyPublishedProviderVersions)
            {
                if (publishedProviderVersion.GetFundingLineTotal(fundingLineCode)
                    != latestPublishedProviderVersion.GetFundingLineTotal(fundingLineCode) ||
                    publishedProviderVersion.GetCarryOverTotalForFundingLine(fundingLineCode)
                    != latestPublishedProviderVersion.GetCarryOverTotalForFundingLine(fundingLineCode))
                {
                    TemplateMetadataDistinctFundingLinesContents templateMetadataDistinctFundingLinesContents =
                        await _policiesService.GetDistinctTemplateMetadataFundingLinesContents(
                            fundingStreamId,
                            latestPublishedProviderVersion.FundingPeriodId,
                            latestPublishedProviderVersion.TemplateVersion);

                    FundingLineChange fundingLineChange = new FundingLineChange
                    {
                        FundingLineTotal         = latestPublishedProviderVersion.GetFundingLineTotal(fundingLineCode),
                        PreviousFundingLineTotal = publishedProviderVersion.GetFundingLineTotal(fundingLineCode),
                        FundingStreamName        = fundingStreams.SingleOrDefault(_ => _.Id == latestPublishedProviderVersion.FundingStreamId)?.Name,
                        FundingLineName          = templateMetadataDistinctFundingLinesContents?.FundingLines?
                                                   .FirstOrDefault(_ => _.FundingLineCode == fundingLineCode)?.Name,
                        CarryOverAmount = latestPublishedProviderVersion.GetCarryOverTotalForFundingLine(fundingLineCode),
                        LastUpdatedUser = latestPublishedProviderVersion.GetLatestFundingLineUser(fundingLineCode),
                        LastUpdatedDate = latestPublishedProviderVersion.GetLatestFundingLineDate(fundingLineCode),
                    };

                    ProfileTotal[] profileTotals = new PaymentFundingLineProfileTotals(latestPublishedProviderVersion, fundingLineCode).ToArray();

                    FundingDate fundingDate = await _policiesService.GetFundingDate(
                        fundingStreamId,
                        latestPublishedProviderVersion.FundingPeriodId,
                        fundingLineCode);

                    for (int index = 0; index < profileTotals.Count(); index++)
                    {
                        ProfileTotal profileTotal = profileTotals[index];
                        profileTotal.InstallmentNumber = index + 1;

                        profileTotal.ActualDate = fundingDate?.Patterns?.SingleOrDefault(_ =>
                                                                                         _.Occurrence == profileTotal.Occurrence &&
                                                                                         _.Period == profileTotal.TypeValue &&
                                                                                         _.PeriodYear == profileTotal.Year)?.PaymentDate;
                    }

                    fundingLineChange.ProfileTotals = profileTotals;
                    fundingLineChanges.Add(fundingLineChange);
                }

                latestPublishedProviderVersion = publishedProviderVersion;
            }

            return(new OkObjectResult(fundingLineChanges));
        }