private string GetEmployerIdentifier(AECLearningDeliveryInfo aecLearningDeliveryInfo, byte transactionType) { if (aecLearningDeliveryInfo != null) { if (transactionType == Constants.DASPayments.TransactionType.First_16To18_Employer_Incentive) // 4 { return(aecLearningDeliveryInfo.LearnDelEmpIdFirstAdditionalPaymentThreshold?.ToString()); } if (transactionType == Constants.DASPayments.TransactionType.Second_16To18_Employer_Incentive) //6 { return(aecLearningDeliveryInfo.LearnDelEmpIdSecondAdditionalPaymentThreshold?.ToString()); } return(Generics.NotAvailable); } return(null); }
private string GetEmployerIdentifier(AECLearningDeliveryInfo aecLearningDeliveryInfo, DASPaymentInfo paymentInfo) { var identifier = 0; if (aecLearningDeliveryInfo != null) { if (paymentInfo.TransactionType == 4) { identifier = aecLearningDeliveryInfo.LearnDelEmpIdFirstAdditionalPaymentThreshold.GetValueOrDefault(); } if (paymentInfo.TransactionType == 6) { identifier = aecLearningDeliveryInfo.LearnDelEmpIdSecondAdditionalPaymentThreshold.GetValueOrDefault(); } } return(identifier == 0 ? "Not available" : identifier.ToString()); }
public IEnumerable <AppsAdditionalPaymentExtendedPaymentModel> BuildAdditionalPaymentsExtendedPaymentsModel( IDictionary <string, AppsAdditionalPaymentLearnerInfo> learnerDictionary, IList <AECLearningDeliveryInfo> rulebaseLearningDeliveries, IList <DASPaymentInfo> appsAdditionalPaymentDasPaymentsInfo, IDictionary <long, string> legalNameDictionary) { // Create a new payment model which includes the related data from the ILR return(appsAdditionalPaymentDasPaymentsInfo .Where(p => p != null) .Select(dasPaymentInfo => { AppsAdditionalPaymentLearnerInfo learner = null; AppsAdditionalPaymentLearningDeliveryInfo learningDelivery = null; AECLearningDeliveryInfo aecLearningDelivery = null; // lookup the related reference data for this payment learner = learnerDictionary.GetValueOrDefault(dasPaymentInfo?.LearnerReferenceNumber); if (learner != null) { learningDelivery = learner?.LearningDeliveries?.FirstOrDefault(x => x != null && x.ProgType == dasPaymentInfo.LearningAimProgrammeType && x.StdCode == dasPaymentInfo.LearningAimStandardCode && x.FworkCode == dasPaymentInfo.LearningAimFrameworkCode && x.PwayCode == dasPaymentInfo.LearningAimPathwayCode && x.LearnRefNumber.CaseInsensitiveEquals(dasPaymentInfo.LearnerReferenceNumber) && x.LearnAimRef.CaseInsensitiveEquals(dasPaymentInfo.LearningAimReference) && x.LearnStartDate == dasPaymentInfo.LearningStartDate); if (learningDelivery != null) { aecLearningDelivery = rulebaseLearningDeliveries?.FirstOrDefault(x => x != null && x.UKPRN == learningDelivery.UKPRN && x.LearnRefNumber.CaseInsensitiveEquals(learningDelivery.LearnRefNumber) && x.AimSeqNumber == learningDelivery.AimSeqNumber); } } // copy this payment's fields to the new extended payment model return new AppsAdditionalPaymentExtendedPaymentModel { // copy the reporting grouping fields PaymentLearnerReferenceNumber = dasPaymentInfo.LearnerReferenceNumber, PaymentUniqueLearnerNumber = dasPaymentInfo.LearnerUln, PaymentLearningStartDate = dasPaymentInfo.LearningStartDate, PaymentLearningAimFundingLineType = dasPaymentInfo.LearningAimFundingLineType, PaymentTypeOfAdditionalPayment = GetTypeOfAdditionalPayment(dasPaymentInfo.TransactionType), AppsServiceEmployerName = GetAppServiceEmployerName(dasPaymentInfo, legalNameDictionary), ilrEmployerIdentifier = aecLearningDelivery != null ? GetEmployerIdentifier(aecLearningDelivery, dasPaymentInfo.TransactionType) : null, // copy the remaining payment fields PaymentLearningAimProgrammeType = dasPaymentInfo.LearningAimProgrammeType, PaymentLearningAimStandardCode = dasPaymentInfo.LearningAimStandardCode, PaymentLearningAimFrameworkCode = dasPaymentInfo.LearningAimFrameworkCode, PaymentLearningAimPathwayCode = dasPaymentInfo.LearningAimPathwayCode, PaymentLearningAimReference = dasPaymentInfo.LearningAimReference, PaymentContractType = dasPaymentInfo.ContractType, PaymentFundingSource = dasPaymentInfo.FundingSource, PaymentTransactionType = dasPaymentInfo.TransactionType, PaymentAcademicYear = dasPaymentInfo.AcademicYear, PaymentCollectionPeriod = dasPaymentInfo.CollectionPeriod, //PaymentDeliveryPeriod = dasPaymentInfo.DeliveryPeriod, PaymentAmount = dasPaymentInfo.Amount, // copy the ilr fields ProviderSpecifiedLearnerMonitoringA = GetProviderSpecMonitor(learner, Generics.ProviderSpecifiedLearnerMonitoringA), ProviderSpecifiedLearnerMonitoringB = GetProviderSpecMonitor(learner, Generics.ProviderSpecifiedLearnerMonitoringB), }; })); }
public async Task <AppsAdditionalPaymentRulebaseInfo> GetFM36DataForAppsAdditionalPaymentReportAsync(int ukPrn, CancellationToken cancellationToken) { var appsAdditionalPaymentRulebaseInfo = new AppsAdditionalPaymentRulebaseInfo() { UkPrn = ukPrn, AECApprenticeshipPriceEpisodePeriodisedValues = new List <AECApprenticeshipPriceEpisodePeriodisedValuesInfo>(), AECLearningDeliveries = new List <AECLearningDeliveryInfo>() }; cancellationToken.ThrowIfCancellationRequested(); List <AEC_ApprenticeshipPriceEpisode> aecApprenticeshipPriceEpisodes; List <AEC_LearningDelivery> aecLearningDeliveries; using (var ilrContext = _ilrRulebaseContextFactory()) { aecApprenticeshipPriceEpisodes = await ilrContext.AEC_ApprenticeshipPriceEpisodes.Include(x => x.AEC_ApprenticeshipPriceEpisode_PeriodisedValues).Where(x => x.UKPRN == ukPrn).ToListAsync(cancellationToken); aecLearningDeliveries = await ilrContext.AEC_LearningDeliveries.Where(x => x.UKPRN == ukPrn).ToListAsync(cancellationToken); } foreach (var aecApprenticeshipPriceEpisode in aecApprenticeshipPriceEpisodes) { foreach (var aecApprenticeshipPriceEpisodePeriodisedValue in aecApprenticeshipPriceEpisode .AEC_ApprenticeshipPriceEpisode_PeriodisedValues) { var periodisedValue = new AECApprenticeshipPriceEpisodePeriodisedValuesInfo() { UKPRN = ukPrn, LearnRefNumber = aecApprenticeshipPriceEpisodePeriodisedValue.LearnRefNumber, AimSeqNumber = (int)aecApprenticeshipPriceEpisode.PriceEpisodeAimSeqNumber, AttributeName = aecApprenticeshipPriceEpisodePeriodisedValue.AttributeName, Periods = new[] { aecApprenticeshipPriceEpisodePeriodisedValue.Period_1.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_2.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_3.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_4.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_5.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_6.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_7.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_8.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_9.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_10.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_11.GetValueOrDefault(), aecApprenticeshipPriceEpisodePeriodisedValue.Period_12.GetValueOrDefault(), } }; appsAdditionalPaymentRulebaseInfo.AECApprenticeshipPriceEpisodePeriodisedValues.Add(periodisedValue); } } foreach (var aecLearningDelivery in aecLearningDeliveries) { var aecLearningDeliveryInfo = new AECLearningDeliveryInfo() { UKPRN = ukPrn, LearnRefNumber = aecLearningDelivery.LearnRefNumber, AimSeqNumber = aecLearningDelivery.AimSeqNumber, LearnDelEmpIdFirstAdditionalPaymentThreshold = aecLearningDelivery.LearnDelEmpIdFirstAdditionalPaymentThreshold, LearnDelEmpIdSecondAdditionalPaymentThreshold = aecLearningDelivery.LearnDelEmpIdSecondAdditionalPaymentThreshold }; appsAdditionalPaymentRulebaseInfo.AECLearningDeliveries.Add(aecLearningDeliveryInfo); } return(appsAdditionalPaymentRulebaseInfo); }