public void ThenTheProviderEarningsAndPaymentsBreakDownForUlnAsFollows(string learnerId, Table earningAndPayments) { if (!SubmissionContext.HaveSubmissionsBeenDone) { SubmissionContext.SubmissionResults = SubmissionManager.SubmitIlrAndRunMonthEndAndCollateResults(SubmissionContext.IlrLearnerDetails, SubmissionContext.FirstSubmissionDate, LookupContext, EmployerAccountContext.EmployerAccounts, SubmissionContext.ContractTypes, SubmissionContext.EmploymentStatus, SubmissionContext.LearningSupportStatus); SubmissionContext.HaveSubmissionsBeenDone = true; } var breakdown = new LearnerEarningsAndPaymentsBreakdown { ProviderId = Defaults.ProviderId, // This may not be true in every case, need to check specs LearnerReferenceNumber = learnerId }; EarningsAndPaymentsContext.LearnerOverallEarningsAndPayments.Add(breakdown); EarningAndPaymentTableParser.ParseEarningsAndPaymentsTableIntoContext(breakdown, earningAndPayments); AssertResults(); }
public void ThenProviderEarningAndPaymentsBreakDownTo(string providerIdSuffix, Table earningAndPayments) { if (!SubmissionContext.HaveSubmissionsBeenDone) { SubmissionContext.SubmissionResults = SubmissionManager.SubmitIlrAndRunMonthEndAndCollateResults(SubmissionContext.IlrLearnerDetails, SubmissionContext.FirstSubmissionDate, LookupContext, EmployerAccountContext.EmployerAccounts, SubmissionContext.ContractTypes, SubmissionContext.EmploymentStatus, SubmissionContext.LearningSupportStatus); SubmissionContext.HaveSubmissionsBeenDone = true; } var providerBreakdown = EarningsAndPaymentsContext.OverallEarningsAndPayments.SingleOrDefault(x => x.ProviderId == "provider " + providerIdSuffix); if (providerBreakdown == null) { providerBreakdown = new EarningsAndPaymentsBreakdown { ProviderId = "provider " + providerIdSuffix }; EarningsAndPaymentsContext.OverallEarningsAndPayments.Add(providerBreakdown); } EarningAndPaymentTableParser.ParseEarningsAndPaymentsTableIntoContext(providerBreakdown, earningAndPayments); AssertResults(); }
private void CreatePreviousEarningsAndPayments(string providerName, string learnerRefererenceNumber, Table table, AimType paymentsAimType) { var learnerBreakdown = new EarningsAndPaymentsBreakdown { ProviderId = providerName }; EarningAndPaymentTableParser.ParseEarningsAndPaymentsTableIntoContext(learnerBreakdown, table); var learningDetails = SubmissionContext.HistoricalLearningDetails.Where(x => x.AimType == paymentsAimType && x.LearnerReference.Equals(learnerRefererenceNumber, StringComparison.InvariantCultureIgnoreCase)).Single(); long learnerUln; if (!string.IsNullOrEmpty(learningDetails.Uln)) { learnerUln = long.Parse(learningDetails.Uln); LookupContext.AddUln(learnerRefererenceNumber, learnerUln); } else { learnerUln = LookupContext.AddOrGetUln(learnerRefererenceNumber); } var provider = LookupContext.AddOrGetUkprn(learnerBreakdown.ProviderId); var commitment = CommitmentsContext.Commitments.FirstOrDefault(x => x.ProviderId == learnerBreakdown.ProviderId && x.LearnerId == learnerRefererenceNumber); foreach (var earned in learnerBreakdown.ProviderEarnedTotal) { var requiredPaymentId = Guid.NewGuid().ToString(); var month = int.Parse(earned.PeriodName.Substring(0, 2)); var year = int.Parse(earned.PeriodName.Substring(3, 2)) + 2000; var date = new DateTime(year, month, 1); var periodNumber = date.GetPeriodNumber(); var periodName = $"{TestEnvironment.Variables.OpaRulebaseYear}-R" + periodNumber.ToString("00"); if (earned.Value > 0) { PaymentsManager.SavePaymentDue(requiredPaymentId, provider, learnerUln, commitment, learnerRefererenceNumber, periodName, month, year, learningDetails.AimType == AimType.Programme ? (int)TransactionType.OnProgram : (int)TransactionType.OnProgrammeMathsAndEnglish , earned.Value, learningDetails); var levyPayment = learnerBreakdown.SfaLevyBudget.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (levyPayment != null && levyPayment.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, learningDetails.AimType == AimType.Programme ? (int)TransactionType.OnProgram : (int)TransactionType.OnProgrammeMathsAndEnglish, FundingSource.Levy, levyPayment.Value); } var earnedFromEmployer = learnerBreakdown.ProviderEarnedFromEmployers.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (earnedFromEmployer != null && earnedFromEmployer.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, learningDetails.AimType == AimType.Programme ? (int)TransactionType.OnProgram : (int)TransactionType.OnProgrammeMathsAndEnglish, FundingSource.CoInvestedEmployer, earnedFromEmployer.Value); } var coInvestedBySfaLevy = learnerBreakdown.SfaLevyCoFundBudget.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (coInvestedBySfaLevy != null && coInvestedBySfaLevy.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, learningDetails.AimType == AimType.Programme ? (int)TransactionType.OnProgram : (int)TransactionType.OnProgrammeMathsAndEnglish, FundingSource.CoInvestedSfa, coInvestedBySfaLevy.Value); } var coInvestedBySfaNonLevy = learnerBreakdown.SfaNonLevyCoFundBudget.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (coInvestedBySfaNonLevy != null && coInvestedBySfaNonLevy.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, learningDetails.AimType == AimType.Programme ? (int)TransactionType.OnProgram : (int)TransactionType.OnProgrammeMathsAndEnglish, FundingSource.CoInvestedSfa, coInvestedBySfaNonLevy.Value); } var aditionalPayments = learnerBreakdown.SfaLevyAdditionalPayments.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (aditionalPayments != null && aditionalPayments.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, learningDetails.AimType == AimType.Programme ? (int)TransactionType.OnProgram : (int)TransactionType.OnProgrammeMathsAndEnglish, FundingSource.FullyFundedSfa, aditionalPayments.Value); } } } }
public void GivenTheFollowingEarningsAndPaymentsHaveBeenMadeToTheProviderForLearner(string learnerName, Table table) { var learnerBreakdown = new EarningsAndPaymentsBreakdown { ProviderId = "provider " + Defaults.ProviderIdSuffix }; EarningAndPaymentTableParser.ParseEarningsAndPaymentsTableIntoContext(learnerBreakdown, table); var learner = LookupContext.AddOrGetUln(learnerName); var provider = LookupContext.AddOrGetUkprn(learnerBreakdown.ProviderId); var commitment = CommitmentsContext.Commitments.FirstOrDefault(); foreach (var earned in learnerBreakdown.ProviderEarnedTotal) { var requiredPaymentId = Guid.NewGuid().ToString(); var month = int.Parse(earned.PeriodName.Substring(0, 2)); var year = int.Parse(earned.PeriodName.Substring(3, 2)) + 2000; var date = new DateTime(year, month, 1); var periodNumber = date.GetPeriodNumber(); var periodName = $"1718-R" + periodNumber.ToString("00"); if (earned.Value > 0) { PaymentsManager.SavePaymentDue(requiredPaymentId, provider, learner, null, null, null, Defaults.StandardCode, commitment, learnerName, periodName, month, year, (int)TransactionType.OnProgram, commitment == null ? ContractType.ContractWithSfa : ContractType.ContractWithEmployer, earned.Value); var levyPayment = learnerBreakdown.SfaLevyBudget.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (levyPayment != null && levyPayment.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, (int)TransactionType.OnProgram, FundingSource.Levy, levyPayment.Value); } var earnedFromEmployer = learnerBreakdown.ProviderEarnedFromEmployers.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (earnedFromEmployer != null && earnedFromEmployer.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, (int)TransactionType.OnProgram, FundingSource.CoInvestedEmployer, earnedFromEmployer.Value); } var coInvestedBySfaLevy = learnerBreakdown.SfaLevyCoFundBudget.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (coInvestedBySfaLevy != null && coInvestedBySfaLevy.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, (int)TransactionType.OnProgram, FundingSource.CoInvestedSfa, coInvestedBySfaLevy.Value); } var coInvestedBySfaNonLevy = learnerBreakdown.SfaNonLevyCoFundBudget.Where(x => x.PeriodName == earned.PeriodName).SingleOrDefault(); if (coInvestedBySfaNonLevy != null && coInvestedBySfaNonLevy.Value > 0) { PaymentsManager.SavePayment(requiredPaymentId, periodName, month, year, (int)TransactionType.OnProgram, FundingSource.CoInvestedSfa, coInvestedBySfaNonLevy.Value); } } } }