public void WhenAnAgreedPriceOf(decimal agreedPrice) { //get months value var plannedCensusMonths = ScenarioContext.Current.Get <int>("plannedCensusMonths"); StepDefinitionsContext.SetDefaultProvider(); var provider = StepDefinitionsContext.GetDefaultProvider(); var startDate = new DateTime(2016, 08, 15); var ilrStartDate = startDate.NextCensusDate(); var plannedEndDate = startDate.AddMonths(plannedCensusMonths - 1).NextCensusDate(); DateTime?actualEndDate = null; if (ScenarioContext.Current.ContainsKey("actualCensusMonths")) { var actualCensusMonths = ScenarioContext.Current.Get <int>("actualCensusMonths"); int variation; if (actualCensusMonths < plannedCensusMonths) { variation = (plannedCensusMonths - actualCensusMonths) * -1; } else { variation = actualCensusMonths - plannedCensusMonths; } actualEndDate = plannedEndDate.AddMonths(variation); } var learner = StepDefinitionsContext.CreateLearner(agreedPrice, startDate, plannedEndDate, actualEndDate, Enums.CompletionStatus.Completed); // Store spec values in context StepDefinitionsContext.AddProviderLearner(provider, learner); //set a default employer StepDefinitionsContext.ReferenceDataContext.SetDefaultEmployer( new Dictionary <string, decimal> { { "All", int.MaxValue } }); // Setup reference data SetupReferenceData(); // Process months SubmitIlr(provider, ilrStartDate.GetAcademicYear(), actualEndDate ?? plannedEndDate, new ProcessService(new TestLogger())); }
protected void SetupEarningsData(Provider provider, Learner learner) { StepDefinitionsContext.AddProviderLearner(provider, learner); //set a default employer StepDefinitionsContext.ReferenceDataContext.SetDefaultEmployer( new Dictionary <string, decimal> { { "All", int.MaxValue } }); //setup committment and employer ref data SetupReferenceData(); SetupValidLearnersData(provider.Ukprn, learner); }
protected void SetupContexLearners(Table table) { if (table.Header.Contains("Employment Status") && StepDefinitionsContext.ReferenceDataContext.EmploymentStatuses == null) { PopulateEmploymentStatuses(table); } for (var rowIndex = 0; rowIndex < table.RowCount; rowIndex++) { var provider = table.ContainsColumn("Provider") ? table.Rows[rowIndex]["Provider"] : "provider"; if (table.Header.Contains("LearnDelFAM") && !string.IsNullOrEmpty(table.Rows[rowIndex]["LearnDelFAM"])) { var famValue = table.Rows[rowIndex]["LearnDelFAM"]; var famCode = new LearningDeliveryFam { FamType = famValue.Substring(0, 3), FamCode = int.Parse(famValue.Substring(3)) }; StepDefinitionsContext.ReferenceDataContext.AddLearningDeliveryFam(famCode); } var learningDelivery = new LearningDelivery { LearningDeliveryFams = StepDefinitionsContext.ReferenceDataContext.LearningDeliveryFams, LearnerType = table.Header.Contains("learner type") ? GetLearnerType(table.Rows[rowIndex]["learner type"]) : LearnerType.ProgrammeOnlyDas, StartDate = DateTime.Parse(table.Rows[rowIndex]["start date"]), PlannedEndDate = table.Header.Contains("planned end date") ? DateTime.Parse(table.Rows[rowIndex]["planned end date"]) : DateTime.Parse(table.Rows[rowIndex]["start date"]).AddMonths(12), ActualEndDate = !table.Header.Contains("actual end date") || string.IsNullOrWhiteSpace(table.Rows[rowIndex]["actual end date"]) ? null : (DateTime?)DateTime.Parse(table.Rows[rowIndex]["actual end date"]), CompletionStatus = table.Header.Contains("completion status") ? IlrTranslator.TranslateCompletionStatus(table.Rows[rowIndex]["completion status"]) : CompletionStatus.Continuing, FrameworkCode = table.Rows[rowIndex].Value <int>("framework code") > 0 ? table.Rows[rowIndex].Value <int>("framework code") : IlrBuilder.Defaults.FrameworkCode, ProgrammeType = table.Rows[rowIndex].Value <int>("programme type") > 0 ? table.Rows[rowIndex].Value <int>("programme type") : IlrBuilder.Defaults.ProgrammeType, PathwayCode = table.Rows[rowIndex].Value <int>("pathway code") > 0 ? table.Rows[rowIndex].Value <int>("pathway code") : IlrBuilder.Defaults.PathwayCode, Type = table.Rows[rowIndex].Contains("aim type") ? GetAimType(table.Rows[rowIndex].Value <string>("aim type")) : Enums.AimType.Programme }; var standardCode = table.Rows[rowIndex].Value <int>("standard code") > 0 ? table.Rows[rowIndex].Value <int>("standard code") : IlrBuilder.Defaults.StandardCode; learningDelivery.StandardCode = learningDelivery.FrameworkCode > 0 && learningDelivery.PathwayCode > 0 && learningDelivery.ProgrammeType > 0 ? 0 : standardCode; var priceEpisodes = SetupPriceEpisodes(table, rowIndex, learningDelivery.StandardCode); learningDelivery.PriceEpisodes = priceEpisodes.ToArray(); Learner learner = null; if (table.Rows[rowIndex].ContainsKey("ULN")) { var learners = StepDefinitionsContext.GetProvider(provider).Learners; if (learners != null) { learner = learners.SingleOrDefault(x => x.Name == table.Rows[rowIndex]["ULN"]); } } if (learner == null) { learner = new Learner(); learner.Name = table.Rows[rowIndex].ContainsKey("ULN") ? table.Rows[rowIndex]["ULN"] : string.Empty; if (table.Rows[rowIndex].ContainsKey("ULN")) { learner.Uln = GetUln(learner.Name, table.Rows[rowIndex]["ULN"]); } else { learner.Uln = GetUln(learner.Name, string.Empty); } learner.LearnRefNumber = $"{StepDefinitionsContext.GetProvider(provider).Ukprn}-{rowIndex+1}"; learner.DateOfBirth = GetDateOfBirth(learningDelivery.LearnerType, learningDelivery.StartDate); learner.EmploymentStatuses = StepDefinitionsContext.ReferenceDataContext.EmploymentStatuses; StepDefinitionsContext.AddProviderLearner(provider, learner); } learner.LearningDeliveries.Add(learningDelivery); } }