public override async Task GenerateReport(
            IReportServiceContext reportServiceContext,
            ZipArchive archive,
            CancellationToken cancellationToken)
        {
            DateTime dateTime         = _dateTimeProvider.ConvertUtcToUk(reportServiceContext.SubmissionDateTimeUtc);
            var      externalFileName = GetCustomFilename(reportServiceContext, $"{dateTime:yyyyMMdd-HHmmss}");
            var      summaryFileName  = GetCustomFilename(reportServiceContext, "Summary");
            var      fileName         = GetCustomFilename(reportServiceContext, "Download");

            // get the main base DAS payments data
            var appsMonthlyPaymentDasInfo =
                await _dasPaymentsProviderService.GetPaymentsInfoForAppsMonthlyPaymentReportAsync(
                    reportServiceContext.Ukprn, cancellationToken);

            // get the ILR data
            var appsMonthlyPaymentIlrInfo =
                await _ilrPeriodEndProviderService.GetILRInfoForAppsMonthlyPaymentReportAsync(
                    reportServiceContext.Ukprn, cancellationToken);

            // Get the earning data
            var learnerLevelViewFM36Info = await _fm36ProviderService.GetFM36DataForLearnerLevelView(
                reportServiceContext.Ukprn,
                cancellationToken);

            // Get the employer investment info
            var appsCoInvestmentIlrInfo = await _ilrPeriodEndProviderService.GetILRInfoForAppsCoInvestmentReportAsync(
                reportServiceContext.Ukprn,
                cancellationToken);

            // Get the datalock information
            var learnerLevelDatalockInfo = await _dasPaymentsProviderService.GetDASDataLockInfoAsync(
                reportServiceContext.Ukprn,
                cancellationToken);

            // Get the HBCP information
            var learnerLevelHBCPInfo = await _dasPaymentsProviderService.GetHBCPInfoAsync(
                reportServiceContext.Ukprn,
                cancellationToken);

            var paymentsDictionary            = BuildPaymentInfoDictionary(appsMonthlyPaymentDasInfo);
            var aECPriceEpisodeDictionary     = BuildAECPriceEpisodeDictionary(learnerLevelViewFM36Info?.AECApprenticeshipPriceEpisodePeriodisedValues);
            var aECLearningDeliveryDictionary = BuildAECLearningDeliveryDictionary(learnerLevelViewFM36Info?.AECLearningDeliveryPeriodisedValuesInfo);

            // Get the employer name information
            var apprenticeshipIds = appsMonthlyPaymentDasInfo.Payments.Select(p => p.ApprenticeshipId);
            var apprenticeshipIdLegalEntityNameDictionary = await _dasPaymentsProviderService.GetLegalEntityNameApprenticeshipIdDictionaryAsync(apprenticeshipIds, cancellationToken);

            // Build the Learner level view Report
            var learnerLevelViewModel = _modelBuilder.BuildLearnerLevelViewModelList(
                reportServiceContext.Ukprn,
                appsMonthlyPaymentIlrInfo,
                appsCoInvestmentIlrInfo,
                learnerLevelDatalockInfo,
                learnerLevelHBCPInfo,
                learnerLevelViewFM36Info,
                paymentsDictionary,
                aECPriceEpisodeDictionary,
                aECLearningDeliveryDictionary,
                apprenticeshipIdLegalEntityNameDictionary,
                reportServiceContext.ReturnPeriod).ToList();

            // Write the full file containing calculated data
            string learnerLevelViewCSV = await GetLearnerLevelViewCsv(learnerLevelViewModel, cancellationToken);

            await WriteAsync($"{externalFileName}.csv", learnerLevelViewCSV, reportServiceContext.Container, cancellationToken);

            // Write the abridged report file downloadable by the user
            string learnerLevelFinancialsRemovedCSV = await GetLearnerLevelFinancialsRemovedViewCsv(learnerLevelViewModel, cancellationToken);

            await WriteAsync($"{fileName}.csv", learnerLevelFinancialsRemovedCSV, reportServiceContext.Container, cancellationToken);

            // Create the summary file which will be used by the WebUI to display the summary view
            string summaryFile = CreateSummary(learnerLevelViewModel, cancellationToken);

            await WriteAsync($"{summaryFileName}.json", summaryFile, reportServiceContext.Container, cancellationToken);

            if (reportServiceContext.DataPersistFeatureEnabled)
            {
                Stopwatch stopWatchLog = new Stopwatch();
                stopWatchLog.Start();
                await _persistReportData.PersistReportDataAsync(
                    learnerLevelViewModel,
                    reportServiceContext.Ukprn,
                    reportServiceContext.ReturnPeriod,
                    TableNameConstants.LearnerLevelViewReport,
                    reportServiceContext.ReportDataConnectionString,
                    cancellationToken);

                _logger.LogDebug($"Performance-Learner Level View Report logging took - {stopWatchLog.ElapsedMilliseconds} ms ");
                stopWatchLog.Stop();
            }
            else
            {
                _logger.LogDebug(" Data Persist Feature is disabled.");
            }
        }
        public override async Task GenerateReport(
            IReportServiceContext reportServiceContext,
            ZipArchive archive,
            CancellationToken cancellationToken)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            var externalFileName = GetFilename(reportServiceContext);
            var fileName         = GetZipFilename(reportServiceContext);

            // get the main base DAS payments data
            var appsMonthlyPaymentDasInfo =
                await _dasPaymentsProviderService.GetPaymentsInfoForAppsMonthlyPaymentReportAsync(
                    reportServiceContext.Ukprn, cancellationToken);

            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport appsMonthlyPaymentDasInfo - {appsMonthlyPaymentDasInfo.Payments.Count} ");

            // get the DAS Earnings Event data
            var appsMonthlyPaymentDasEarningsInfo =
                await _dasPaymentsProviderService.GetEarningsInfoForAppsMonthlyPaymentReportAsync(
                    reportServiceContext.Ukprn, cancellationToken);

            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport appsMonthlyPaymentDasEarningsInfo - {appsMonthlyPaymentDasEarningsInfo.Earnings.Count} ");

            // get the ILR data
            var appsMonthlyPaymentIlrInfo =
                await _ilrPeriodEndProviderService.GetILRInfoForAppsMonthlyPaymentReportAsync(
                    reportServiceContext.Ukprn, cancellationToken);

            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport appsMonthlyPaymentIlrInfo - {appsMonthlyPaymentIlrInfo.Learners.Count} ");

            // Get the AEC data
            var appsMonthlyPaymentRulebaseInfo =
                await _fm36ProviderService.GetRulebaseDataForAppsMonthlyPaymentReportAsync(
                    reportServiceContext.Ukprn,
                    cancellationToken);

            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport appsMonthlyPaymentRulebaseInfo.priceEpisodes - {appsMonthlyPaymentRulebaseInfo.AecApprenticeshipPriceEpisodeInfoList.Count} ");
            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport appsMonthlyPaymentRulebaseInfo.learningDeliveries - {appsMonthlyPaymentRulebaseInfo.AecLearningDeliveryInfoList.Count} ");

            // Get the Fcs Contract data
            var appsMonthlyPaymentFcsInfo = await _fcsProviderService.GetContractAllocationNumberFSPCodeLookupAsync(reportServiceContext.Ukprn, cancellationToken);

            // Get the name's of the learning aims
            string[] learnAimRefs = appsMonthlyPaymentIlrInfo.Learners.SelectMany(x => x.LearningDeliveries)
                                    .Select(x => x.LearnAimRef).Distinct().ToArray();
            var appsMonthlyPaymentLarsLearningDeliveryInfos =
                await _larsProviderService.GetLarsLearningDeliveryInfoForAppsMonthlyPaymentReportAsync(
                    learnAimRefs,
                    cancellationToken);

            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport data gathering before model - {stopWatch.ElapsedMilliseconds} ms ");

            // Build the actual Apps Monthly Payment Report
            var appsMonthlyPaymentsModel = _modelBuilder.BuildAppsMonthlyPaymentModelList(
                appsMonthlyPaymentIlrInfo,
                appsMonthlyPaymentRulebaseInfo,
                appsMonthlyPaymentDasInfo,
                appsMonthlyPaymentDasEarningsInfo,
                appsMonthlyPaymentFcsInfo,
                appsMonthlyPaymentLarsLearningDeliveryInfos).ToList();

            string csv = await GetCsv(appsMonthlyPaymentsModel, cancellationToken);

            await _streamableKeyValuePersistenceService.SaveAsync($"{externalFileName}.csv", csv, cancellationToken);

            await WriteZipEntry(archive, $"{fileName}.csv", csv);

            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport before logging took - {stopWatch.ElapsedMilliseconds} ms ");

            if (reportServiceContext.DataPersistFeatureEnabled)
            {
                Stopwatch stopWatchLog = new Stopwatch();
                stopWatchLog.Start();
                await _persistReportData.PersistReportDataAsync(
                    appsMonthlyPaymentsModel,
                    reportServiceContext.Ukprn,
                    reportServiceContext.ReturnPeriod,
                    TableNameConstants.AppsMonthlyPayment,
                    reportServiceContext.ReportDataConnectionString,
                    cancellationToken);

                _logger.LogDebug($"Performance-AppsMonthlyPaymentReport logging took - {stopWatchLog.ElapsedMilliseconds} ms ");
                stopWatchLog.Stop();
            }
            else
            {
                _logger.LogDebug(" Data Persist Feature is disabled.");
            }

            stopWatch.Stop();
            _logger.LogDebug($"Performance-AppsMonthlyPaymentReport Total generation time - {stopWatch.ElapsedMilliseconds} ms ");
        }