private void GetTotals(AppsIndicativeEarningsModel model) { model.TotalOnProgrammeEarnings = _totalBuilder.TotalRecords( model.AugustOnProgrammeEarnings, model.SeptemberOnProgrammeEarnings, model.OctoberOnProgrammeEarnings, model.NovemberOnProgrammeEarnings, model.DecemberOnProgrammeEarnings, model.JanuaryOnProgrammeEarnings, model.FebruaryOnProgrammeEarnings, model.MarchOnProgrammeEarnings, model.AprilOnProgrammeEarnings, model.MayOnProgrammeEarnings, model.JuneOnProgrammeEarnings, model.JulyOnProgrammeEarnings); model.TotalBalancingPaymentEarnings = _totalBuilder.TotalRecords( model.AugustBalancingPaymentEarnings, model.SeptemberBalancingPaymentEarnings, model.OctoberBalancingPaymentEarnings, model.NovemberBalancingPaymentEarnings, model.DecemberBalancingPaymentEarnings, model.JanuaryBalancingPaymentEarnings, model.FebruaryBalancingPaymentEarnings, model.MarchBalancingPaymentEarnings, model.AprilBalancingPaymentEarnings, model.MayBalancingPaymentEarnings, model.JuneBalancingPaymentEarnings, model.JulyBalancingPaymentEarnings); model.TotalAimCompletionEarnings = _totalBuilder.TotalRecords( model.AugustAimCompletionEarnings, model.SeptemberAimCompletionEarnings, model.OctoberAimCompletionEarnings, model.NovemberAimCompletionEarnings, model.DecemberAimCompletionEarnings, model.JanuaryAimCompletionEarnings, model.FebruaryAimCompletionEarnings, model.MarchAimCompletionEarnings, model.AprilAimCompletionEarnings, model.MayAimCompletionEarnings, model.JuneAimCompletionEarnings, model.JulyAimCompletionEarnings); model.TotalLearningSupportEarnings = _totalBuilder.TotalRecords( model.AugustLearningSupportEarnings, model.SeptemberLearningSupportEarnings, model.OctoberLearningSupportEarnings, model.NovemberLearningSupportEarnings, model.DecemberLearningSupportEarnings, model.JanuaryLearningSupportEarnings, model.FebruaryLearningSupportEarnings, model.MarchLearningSupportEarnings, model.AprilLearningSupportEarnings, model.MayLearningSupportEarnings, model.JuneLearningSupportEarnings, model.JulyLearningSupportEarnings); model.TotalEnglishMathsOnProgrammeEarnings = _totalBuilder.TotalRecords( model.AugustEnglishMathsOnProgrammeEarnings, model.SeptemberEnglishMathsOnProgrammeEarnings, model.OctoberEnglishMathsOnProgrammeEarnings, model.NovemberEnglishMathsOnProgrammeEarnings, model.DecemberEnglishMathsOnProgrammeEarnings, model.JanuaryEnglishMathsOnProgrammeEarnings, model.FebruaryEnglishMathsOnProgrammeEarnings, model.MarchEnglishMathsOnProgrammeEarnings, model.AprilEnglishMathsOnProgrammeEarnings, model.MayEnglishMathsOnProgrammeEarnings, model.JuneEnglishMathsOnProgrammeEarnings, model.JulyEnglishMathsOnProgrammeEarnings); model.TotalEnglishMathsBalancingPaymentEarnings = _totalBuilder.TotalRecords( model.AugustEnglishMathsBalancingPaymentEarnings, model.SeptemberEnglishMathsBalancingPaymentEarnings, model.OctoberEnglishMathsBalancingPaymentEarnings, model.NovemberEnglishMathsBalancingPaymentEarnings, model.DecemberEnglishMathsBalancingPaymentEarnings, model.JanuaryEnglishMathsBalancingPaymentEarnings, model.FebruaryEnglishMathsBalancingPaymentEarnings, model.MarchEnglishMathsBalancingPaymentEarnings, model.AprilEnglishMathsBalancingPaymentEarnings, model.MayEnglishMathsBalancingPaymentEarnings, model.JuneEnglishMathsBalancingPaymentEarnings, model.JulyEnglishMathsBalancingPaymentEarnings); model.TotalDisadvantageEarnings = _totalBuilder.TotalRecords( model.AugustDisadvantageEarnings, model.SeptemberDisadvantageEarnings, model.OctoberDisadvantageEarnings, model.NovemberDisadvantageEarnings, model.DecemberDisadvantageEarnings, model.JanuaryDisadvantageEarnings, model.FebruaryDisadvantageEarnings, model.MarchDisadvantageEarnings, model.AprilDisadvantageEarnings, model.MayDisadvantageEarnings, model.JuneDisadvantageEarnings, model.JulyDisadvantageEarnings); model.Total1618AdditionalPaymentForEmployers = _totalBuilder.TotalRecords( model.August1618AdditionalPaymentForEmployers, model.September1618AdditionalPaymentForEmployers, model.October1618AdditionalPaymentForEmployers, model.November1618AdditionalPaymentForEmployers, model.December1618AdditionalPaymentForEmployers, model.January1618AdditionalPaymentForEmployers, model.February1618AdditionalPaymentForEmployers, model.March1618AdditionalPaymentForEmployers, model.April1618AdditionalPaymentForEmployers, model.May1618AdditionalPaymentForEmployers, model.June1618AdditionalPaymentForEmployers, model.July1618AdditionalPaymentForEmployers); model.Total1618AdditionalPaymentForProviders = _totalBuilder.TotalRecords( model.August1618AdditionalPaymentForProviders, model.September1618AdditionalPaymentForProviders, model.October1618AdditionalPaymentForProviders, model.November1618AdditionalPaymentForProviders, model.December1618AdditionalPaymentForProviders, model.January1618AdditionalPaymentForProviders, model.February1618AdditionalPaymentForProviders, model.March1618AdditionalPaymentForProviders, model.April1618AdditionalPaymentForProviders, model.May1618AdditionalPaymentForProviders, model.June1618AdditionalPaymentForProviders, model.July1618AdditionalPaymentForProviders); model.TotalAdditionalPaymentsForApprentices = _totalBuilder.TotalRecords( model.AugustAdditionalPaymentsForApprentices, model.SeptemberAdditionalPaymentsForApprentices, model.OctoberAdditionalPaymentsForApprentices, model.NovemberAdditionalPaymentsForApprentices, model.DecemberAdditionalPaymentsForApprentices, model.JanuaryAdditionalPaymentsForApprentices, model.FebruaryAdditionalPaymentsForApprentices, model.MarchAdditionalPaymentsForApprentices, model.AprilAdditionalPaymentsForApprentices, model.MayAdditionalPaymentsForApprentices, model.JuneAdditionalPaymentsForApprentices, model.JulyAdditionalPaymentsForApprentices); model.Total1618FrameworkUpliftOnProgrammePayment = _totalBuilder.TotalRecords( model.August1618FrameworkUpliftOnProgrammePayment, model.September1618FrameworkUpliftOnProgrammePayment, model.October1618FrameworkUpliftOnProgrammePayment, model.November1618FrameworkUpliftOnProgrammePayment, model.December1618FrameworkUpliftOnProgrammePayment, model.January1618FrameworkUpliftOnProgrammePayment, model.February1618FrameworkUpliftOnProgrammePayment, model.March1618FrameworkUpliftOnProgrammePayment, model.April1618FrameworkUpliftOnProgrammePayment, model.May1618FrameworkUpliftOnProgrammePayment, model.June1618FrameworkUpliftOnProgrammePayment, model.July1618FrameworkUpliftOnProgrammePayment); model.Total1618FrameworkUpliftBalancingPayment = _totalBuilder.TotalRecords( model.August1618FrameworkUpliftBalancingPayment, model.September1618FrameworkUpliftBalancingPayment, model.October1618FrameworkUpliftBalancingPayment, model.November1618FrameworkUpliftBalancingPayment, model.December1618FrameworkUpliftBalancingPayment, model.January1618FrameworkUpliftBalancingPayment, model.February1618FrameworkUpliftBalancingPayment, model.March1618FrameworkUpliftBalancingPayment, model.April1618FrameworkUpliftBalancingPayment, model.May1618FrameworkUpliftBalancingPayment, model.June1618FrameworkUpliftBalancingPayment, model.July1618FrameworkUpliftBalancingPayment); model.Total1618FrameworkUpliftCompletionPayment = _totalBuilder.TotalRecords( model.August1618FrameworkUpliftCompletionPayment, model.September1618FrameworkUpliftCompletionPayment, model.October1618FrameworkUpliftCompletionPayment, model.November1618FrameworkUpliftCompletionPayment, model.December1618FrameworkUpliftCompletionPayment, model.January1618FrameworkUpliftCompletionPayment, model.February1618FrameworkUpliftCompletionPayment, model.March1618FrameworkUpliftCompletionPayment, model.April1618FrameworkUpliftCompletionPayment, model.May1618FrameworkUpliftCompletionPayment, model.June1618FrameworkUpliftCompletionPayment, model.July1618FrameworkUpliftCompletionPayment); }
private async Task <List <long> > GetUlnsForValidLearners( FM36Global fm36Data, List <RawEarning> rawEarnings, IReportServiceContext reportServiceContext, CancellationToken cancellationToken) { List <long> ulns = new List <long>(); foreach (FM36Learner fm36DataLearner in fm36Data.Learners) { foreach (LearningDelivery learningDelivery in fm36DataLearner.LearningDeliveries) { if (fm36DataLearner.PriceEpisodes != null) { List <PriceEpisode> priceEpisode = fm36DataLearner.PriceEpisodes.Where(x => x.PriceEpisodeValues.PriceEpisodeAimSeqNumber == learningDelivery.AimSeqNumber && x.PriceEpisodeValues.EpisodeStartDate > Constants.BeginningOfYear && x.PriceEpisodeValues.EpisodeStartDate < Constants.EndOfYear && string.Equals(x.PriceEpisodeValues.PriceEpisodeContractType, Constants.Fm36PriceEpisodeContractTypeLevyContract, StringComparison.OrdinalIgnoreCase)).ToList(); if (!priceEpisode.Any()) { _logger.LogWarning($"Can't find any price episodes for learner {fm36DataLearner.LearnRefNumber} with learning delivery aim sequence no. {learningDelivery.AimSeqNumber} skipping {nameof(DataMatchReport)} {nameof(RawEarning)} model"); continue; } foreach (PriceEpisode episode in priceEpisode) { RawEarning rawEarning = new RawEarning(); rawEarning.Uln = fm36DataLearner.ULN; rawEarning.LearnRefNumber = fm36DataLearner.LearnRefNumber; rawEarning.AimSeqNumber = learningDelivery.AimSeqNumber; rawEarning.Ukprn = fm36Data.UKPRN; rawEarning.EpisodeStartDate = episode.PriceEpisodeValues.EpisodeStartDate; rawEarning.EpisodeEffectiveTnpStartDate = episode.PriceEpisodeValues.EpisodeEffectiveTNPStartDate; rawEarning.EndDate = episode.PriceEpisodeValues.PriceEpisodeActualEndDate ?? episode.PriceEpisodeValues.PriceEpisodePlannedEndDate; rawEarning.Period = reportServiceContext.ReturnPeriod; rawEarning.ProgrammeType = learningDelivery.LearningDeliveryValues.ProgType; rawEarning.FrameworkCode = learningDelivery.LearningDeliveryValues.FworkCode; rawEarning.PathwayCode = learningDelivery.LearningDeliveryValues.PwayCode; rawEarning.StandardCode = learningDelivery.LearningDeliveryValues.StdCode; rawEarning.AgreedPrice = episode.PriceEpisodeValues.PriceEpisodeTotalTNPPrice; rawEarning.LearningDeliveryStartDate = learningDelivery.LearningDeliveryValues.LearnStartDate; rawEarning.PriceEpisodeIdentifier = episode.PriceEpisodeIdentifier; rawEarning.TransactionType01 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeOnProgPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType02 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeCompletionPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType03 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm3PriceEpisodeBalancePaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType04 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeFirstEmp1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType05 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeFirstProv1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType06 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeSecondEmp1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType07 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeSecondProv1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType08 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeApplic1618FrameworkUpliftOnProgPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType09 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeApplic1618FrameworkUpliftCompletionPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType10 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36LDApplic1618FrameworkUpliftBalancingPayment, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType11 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeFirstDisadvantagePaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType12 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeSecondDisadvantagePaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType15 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeLSFCashAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.TransactionType16 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeLearnerAdditionalPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); rawEarning.FirstIncentiveCensusDate = episode.PriceEpisodeValues.PriceEpisodeFirstAdditionalPaymentThresholdDate; rawEarning.SecondIncentiveCensusDate = episode.PriceEpisodeValues.PriceEpisodeSecondAdditionalPaymentThresholdDate; rawEarning.LearnerAdditionalPaymentsDate = episode.PriceEpisodeValues.PriceEpisodeLearnerAdditionalPaymentThresholdDate; rawEarnings.Add(rawEarning); } } } } //foreach (ILearner learner in message.Learners) //{ // FM36Learner fm36Entry = // fm36Data.Learners.SingleOrDefault(x => string.Equals(x.LearnRefNumber, learner.LearnRefNumber, StringComparison.OrdinalIgnoreCase)); // if (fm36Entry == null) // { // continue; // } // ulns.Add(learner.ULN); // ILearningDelivery[] learningDeliveries = learner.LearningDeliveries.Where(x => // x.FundModel == 36 && x.LearningDeliveryFAMs.Any(y => // string.Equals(y.LearnDelFAMType, Constants.Fm36LearnDelFAMTypeAct, StringComparison.OrdinalIgnoreCase) && // string.Equals(y.LearnDelFAMCode, Constants.Fm36LearnDelFAMCodeOne, StringComparison.OrdinalIgnoreCase))).ToArray(); // _logger.LogWarning($"Found {learningDeliveries.Length} FM36 {Constants.Fm36LearnDelFAMTypeAct} {Constants.Fm36LearnDelFAMCodeOne} learning deliveries for learner {learner.LearnRefNumber}"); // foreach (ILearningDelivery learnerLearningDelivery in learningDeliveries) // { // List<PriceEpisode> priceEpisode = fm36Entry.PriceEpisodes.Where(x => x.PriceEpisodeValues.PriceEpisodeAimSeqNumber == learnerLearningDelivery.AimSeqNumber && string.Equals(x.PriceEpisodeValues.PriceEpisodeContractType, Constants.Fm36PriceEpisodeContractTypeLevyContract, StringComparison.OrdinalIgnoreCase)).ToList(); // if (!priceEpisode.Any()) // { // _logger.LogWarning($"Can't find any price episodes for learner {learner.LearnRefNumber} with learning delivery aim sequence no. {learnerLearningDelivery.AimSeqNumber} skipping {nameof(DataMatchReport)} {nameof(RawEarning)} model"); // continue; // } // foreach (PriceEpisode episode in priceEpisode) // { // RawEarning rawEarning = new RawEarning(); // rawEarning.Uln = learner.ULN; // rawEarning.LearnRefNumber = learner.LearnRefNumber; // rawEarning.AimSeqNumber = learnerLearningDelivery.AimSeqNumber; // rawEarning.Ukprn = message.HeaderEntity.SourceEntity.UKPRN; // rawEarning.EpisodeStartDate = episode.PriceEpisodeValues.EpisodeStartDate; // rawEarning.EpisodeEffectiveTnpStartDate = // episode.PriceEpisodeValues.EpisodeEffectiveTNPStartDate; // rawEarning.EndDate = episode.PriceEpisodeValues.PriceEpisodeActualEndDate ?? // episode.PriceEpisodeValues.PriceEpisodePlannedEndDate; // rawEarning.Period = period; // rawEarning.ProgrammeType = learnerLearningDelivery.ProgTypeNullable; // rawEarning.FrameworkCode = learnerLearningDelivery.FworkCodeNullable; // rawEarning.PathwayCode = learnerLearningDelivery.PwayCodeNullable; // rawEarning.StandardCode = learnerLearningDelivery.StdCodeNullable; // rawEarning.AgreedPrice = episode.PriceEpisodeValues.PriceEpisodeTotalTNPPrice; // rawEarning.LearningDeliveryStartDate = learnerLearningDelivery.LearnStartDate; // rawEarning.PriceEpisodeIdentifier = episode.PriceEpisodeIdentifier; // rawEarning.TransactionType01 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeOnProgPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType02 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeCompletionPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType03 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm3PriceEpisodeBalancePaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType04 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeFirstEmp1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType05 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeFirstProv1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType06 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeSecondEmp1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType07 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeSecondProv1618PayAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType08 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeApplic1618FrameworkUpliftOnProgPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType09 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeApplic1618FrameworkUpliftCompletionPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType10 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36LDApplic1618FrameworkUpliftBalancingPayment, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType11 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeFirstDisadvantagePaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType12 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeSecondDisadvantagePaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType15 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeLSFCashAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.TransactionType16 = _totalBuilder.TotalRecords(episode.PriceEpisodePeriodisedValues.SingleOrDefault(att => string.Equals(att.AttributeName, Constants.Fm36PriceEpisodeLearnerAdditionalPaymentAttributeName, StringComparison.OrdinalIgnoreCase))); // rawEarning.FirstIncentiveCensusDate = episode.PriceEpisodeValues.PriceEpisodeFirstAdditionalPaymentThresholdDate; // rawEarning.SecondIncentiveCensusDate = episode.PriceEpisodeValues.PriceEpisodeSecondAdditionalPaymentThresholdDate; // rawEarning.LearnerAdditionalPaymentsDate = episode.PriceEpisodeValues.PriceEpisodeLearnerAdditionalPaymentThresholdDate; // rawEarnings.Add(rawEarning); // } // } //} return(ulns); }