Exemplo n.º 1
0
        public void WhenMonthlyPaymentProcessRunsForTheFollowingIlrData(Table table)
        {
            // Setup reference data
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            SetupContexLearners(table);

            var provider = StepDefinitionsContext.GetDefaultProvider();

            provider.Ukprn = long.Parse(table.Rows[0]["UKPRN"]);
            var learner = provider.Learners[0];


            var startDate = StepDefinitionsContext.GetIlrStartDate().NextCensusDate();

            SetupValidLearnersData(provider.Ukprn, learner);

            var dueAmount = learner.LearningDelivery.PriceEpisodes[0].TotalPrice * 0.8m / 12;


            EarningsDataHelper.SavePeriodisedValuesForUkprn(provider.Ukprn,
                                                            learner.LearnRefNumber,
                                                            new Dictionary <int, decimal> {
                { 1, dueAmount }
            },
                                                            learner.LearningDelivery.PriceEpisodes[0].Id,
                                                            environmentVariables);

            //Run the month end
            RunMonthEnd(startDate);
        }
Exemplo n.º 2
0
        public void ThenAEmployerAmountIsExpected(decimal paymentDueFromEmployer)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            //Get the due amount
            var employerPaymentEntity = PaymentsDataHelper.GetPaymentsForPeriod(
                StepDefinitionsContext.GetDefaultProvider().Ukprn,
                null,
                2017,
                09,
                FundingSource.CoInvestedEmployer,
                ContractType.ContractWithEmployer,
                environmentVariables)
                                        .FirstOrDefault();

            if (paymentDueFromEmployer != 0)
            {
                Assert.IsNotNull(employerPaymentEntity, "Expected employer amount for the period but nothing found");
                Assert.AreEqual(paymentDueFromEmployer, employerPaymentEntity.Amount, $"Expected employer amount of {paymentDueFromEmployer} for period R01 but found {employerPaymentEntity.Amount}");
            }
            else
            {
                Assert.IsNull(employerPaymentEntity, "There was no expected employer amount for the period but employer amount data found");
            }
        }
Exemplo n.º 3
0
        public void GivenProviderHasPreviouslyEarnedInPeriod(decimal previousAmount)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            StepDefinitionsContext.SetDefaultProvider();

            var provider = StepDefinitionsContext.GetDefaultProvider();
            var learner  = StepDefinitionsContext.CreateLearner(15000, new DateTime(2017, 08, 01), new DateTime(2018, 07, 01));

            SetupEarningsData(provider, learner);

            var committment = StepDefinitionsContext.ReferenceDataContext.Commitments.First();
            var account     = StepDefinitionsContext.ReferenceDataContext.Employers.First(x => x.Name == committment.Employer);

            //Save the previous earning
            EarningsDataHelper.SaveEarnedAmount(
                provider.Ukprn,
                committment.Id,
                account.AccountId,
                learner,
                "1617-R01",
                08,
                2017,
                1,
                previousAmount,
                environmentVariables);
        }
Exemplo n.º 4
0
        public void ThenALevyPaymentIsMade(decimal levyAccountDebit)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            //Get the due amount
            var levyEntity = PaymentsDataHelper.GetPaymentsForPeriod(
                StepDefinitionsContext.GetDefaultProvider().Ukprn,
                null,
                2017,
                09,
                FundingSource.Levy,
                ContractType.ContractWithEmployer,
                environmentVariables)
                             .FirstOrDefault();

            if (levyAccountDebit != 0)
            {
                Assert.IsNotNull(levyEntity, "Expected Levy earning for the period but nothing found");
                Assert.AreEqual(levyAccountDebit, levyEntity.Amount, $"Expected earning of {levyAccountDebit} for period R01 but found {levyEntity.Amount}");
            }
            else
            {
                Assert.IsNull(levyEntity, "There was no expected levy amount for the period but levy amount data found");
            }
        }
        private void ProcessMonths(DateTime start)
        {
            var processService = new ProcessService(new TestLogger());

            var periodId       = 1;
            var date           = start.NextCensusDate();
            var endDate        = StepDefinitionsContext.GetIlrEndDate();
            var lastCensusDate = endDate.NextCensusDate();

            while (date <= lastCensusDate)
            {
                var period = date.GetPeriod();

                SetupPeriodReferenceData(date);

                UpdateAccountsBalances(period);

                var academicYear = date.GetAcademicYear();

                SetupEnvironmentVariablesForMonth(date, academicYear, ref periodId);

                foreach (var provider in StepDefinitionsContext.Providers)
                {
                    SubmitIlr(provider,
                              academicYear,
                              date,
                              processService);
                }

                SubmitMonthEnd(date, processService);

                date = date.AddDays(15).NextCensusDate();
            }
        }
Exemplo n.º 6
0
        public void ThenAGovernmentPaymentIsMade(decimal paidBySfa)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            //Get the due amount
            var governmentDueEntity = PaymentsDataHelper.GetPaymentsForPeriod(
                StepDefinitionsContext.GetDefaultProvider().Ukprn,
                null,
                2017,
                09,
                FundingSource.CoInvestedSfa,
                ContractType.ContractWithEmployer,
                environmentVariables)
                                      .FirstOrDefault();

            if (paidBySfa != 0)
            {
                Assert.IsNotNull(governmentDueEntity, "Expected goverment due for the period but nothing found");
                Assert.AreEqual(paidBySfa, governmentDueEntity.Amount, $"Expected government payment of {paidBySfa} for period R01 but found {governmentDueEntity.Amount}");
            }
            else
            {
                Assert.IsNull(governmentDueEntity, "There was no expected goverment due amount for the period but data was found");
            }
        }
Exemplo n.º 7
0
        public void ThenADataLockErrorMessageWillBeProduced(string errorCode)
        {
            var provider = StepDefinitionsContext.GetDefaultProvider();

            var validationError = ValidationErrorsDataHelper.GetValidationErrors(provider.Ukprn, EnvironmentVariables);

            Assert.IsNotNull(validationError, "There is no validation error entity present");
            Assert.IsTrue(validationError.Any(x => x.RuleId == errorCode));
        }
Exemplo n.º 8
0
        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()));
        }
Exemplo n.º 9
0
 protected void SetupContextProviders(Table table)
 {
     if (table.ContainsColumn("Provider"))
     {
         for (var rowIndex = 0; rowIndex < table.RowCount; rowIndex++)
         {
             StepDefinitionsContext.AddProvider(table.Rows[rowIndex]["Provider"]);
         }
     }
     else
     {
         StepDefinitionsContext.SetDefaultProvider();
     }
 }
Exemplo n.º 10
0
        public void ThenTheCompletionPaymentIs(decimal completionPayment)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            var learner = StepDefinitionsContext.GetDefaultProvider().Learners.First();
            var output  = LearnerDataHelper.GetOpaApprenticeshipPriceEpisode(StepDefinitionsContext.GetDefaultProvider().Ukprn,
                                                                             learner.LearnRefNumber,
                                                                             learner.LearningDelivery.StartDate,
                                                                             learner.LearningDelivery.PlannedEndDate,
                                                                             environmentVariables);


            Assert.IsNotNull(output, $"Expected AE Learning Delivery but nothing found");
            Assert.AreEqual(completionPayment, output.PriceEpisodeCompletionElement, $"Expected completion payment of {completionPayment} but found {output.PriceEpisodeCompletionElement}");
        }
Exemplo n.º 11
0
        public void ThenTheMonthlyEarningsIs(decimal monthlyEarnings)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            var learner = StepDefinitionsContext.GetDefaultProvider().Learners.First();
            var output  = LearnerDataHelper.GetOpaApprenticeshipPriceEpisode(StepDefinitionsContext.GetDefaultProvider().Ukprn,
                                                                             learner.LearnRefNumber,
                                                                             learner.LearningDelivery.StartDate,
                                                                             learner.LearningDelivery.PlannedEndDate,
                                                                             environmentVariables);


            Assert.IsNotNull(output, $"Expected AE Learning Delivery but nothing found");
            Assert.AreEqual(monthlyEarnings, output.PriceEpisodeInstalmentValue, $"Expected monthly installment of {monthlyEarnings} but found {output.PriceEpisodeInstalmentValue}");
        }
Exemplo n.º 12
0
        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);
        }
        private void ProcessIlrFileSubmissions(Table table, DateTime?firstSubmissionDate = null)
        {
            SetupContextProviders(table);
            SetupContexLearners(table);

            AddScenarioReferenceData();

            var startDate = firstSubmissionDate ?? StepDefinitionsContext.GetIlrStartDate().NextCensusDate();

            if (firstSubmissionDate != null)
            {
                ScenarioContext.Current.Add("firstSubmissionDate", firstSubmissionDate);
            }

            ProcessMonths(startDate);
        }
Exemplo n.º 14
0
        public void WhenAndIlrIsSubmittedWithTheFollowingData(Table table)
        {
            SetupContexLearners(table);

            var provider = StepDefinitionsContext.GetDefaultProvider();

            var startDate = StepDefinitionsContext.GetIlrStartDate().NextCensusDate();

            //Update the UKPRN to the one from ILR as this is the one which will be in the validation error table
            provider.Ukprn = long.Parse(table.Rows[0]["UKPRN"]);

            SubmitIlr(provider,
                      startDate.GetAcademicYear(),
                      startDate.NextCensusDate(),
                      new ProcessService(new TestLogger()));
        }
Exemplo n.º 15
0
        public void ThenTheBalancingPaymentIs(decimal balancingPayment)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            var learner      = StepDefinitionsContext.GetDefaultProvider().Learners.First();
            var endDate      = learner.LearningDelivery.ActualEndDate ?? learner.LearningDelivery.PlannedEndDate;
            var periodNumber = endDate.GetPeriodNumber();

            var output = EarningsDataHelper.GetBalancingPaymentForUkprn(StepDefinitionsContext.GetDefaultProvider().Ukprn,
                                                                        $"Period_{periodNumber}",
                                                                        environmentVariables);


            Assert.IsNotNull(output, $"Expected balancing payment value but nothing found");
            Assert.AreEqual(balancingPayment, output, $"Expected balancing payment of {balancingPayment} but found {output}");
        }
Exemplo n.º 16
0
        public void ThenTheDataLockStatusWillBeAsFollows(Table table)
        {
            var date    = StepDefinitionsContext.GetIlrStartDate().NextCensusDate();
            var endDate = StepDefinitionsContext.GetIlrEndDate();

            while (date <= endDate)
            {
                var period = date.GetPeriod();

                foreach (var provider in StepDefinitionsContext.Providers)
                {
                    VerifyProviderDataLockMatchesForPeriod(period, table, provider);
                }

                date = date.AddDays(15).NextCensusDate();
            }
        }
Exemplo n.º 17
0
        public void WhenAPaymentIsDue(decimal dueAmount)
        {
            // Setup reference data
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();
            var provider             = StepDefinitionsContext.GetDefaultProvider();
            var learner = provider.Learners[0];

            //save the periodiosed values
            EarningsDataHelper.SavePeriodisedValuesForUkprn(StepDefinitionsContext.GetDefaultProvider().Ukprn,
                                                            learner.LearnRefNumber,
                                                            new Dictionary <int, decimal> {
                { 1, dueAmount }
            },
                                                            learner.LearningDelivery.PriceEpisodes[0].Id,
                                                            environmentVariables);

            RunMonthEnd(new DateTime(2017, 09, 01));
        }
        private void VerifyEarningsForPeriod(long ukprn, long?uln, string periodName, int colIndex, TableRow earnedRow)
        {
            if (earnedRow == null)
            {
                return;
            }

            var earnedByPeriod = StepDefinitionsContext.GetProviderEarnedByPeriod(ukprn, uln);

            if (!earnedByPeriod.ContainsKey(periodName))
            {
                Assert.Fail($"Expected value for period {periodName} but none found");
            }

            var expectedEarning = decimal.Parse(earnedRow[colIndex]);

            Assert.IsTrue(earnedByPeriod.ContainsKey(periodName), $"Expected earning for period {periodName} but none found");
            Assert.AreEqual(expectedEarning, Math.Round(earnedByPeriod[periodName], 2), $"Expected earning of {expectedEarning} for period {periodName} but found {earnedByPeriod[periodName]}");
        }
Exemplo n.º 19
0
        public void ThenAPaymentIsDue(decimal dueAmount)
        {
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            //Get the due amount
            var earning = PaymentsDueDataHelper.GetPaymentsDueForPeriod(
                StepDefinitionsContext.GetDefaultProvider().Ukprn,
                2017,
                09,
                environmentVariables)
                          .FirstOrDefault();

            if (dueAmount != 0)
            {
                Assert.IsNotNull(earning, "Expected earning for the period but nothing found");
                Assert.AreEqual(dueAmount, earning.AmountDue, $"Expected earning of {dueAmount} for period R01 but found {earning.AmountDue}");
            }
            else
            {
                Assert.IsNull(earning, "There was no expected earning for the period but earnigs data found");
            }
        }
        public void ThenTheFollowingCappingWillApplyToThePriceEpisodes(Table table)
        {
            for (var rowIndex = 0; rowIndex < table.RowCount; rowIndex++)
            {
                var provider = table.Rows[rowIndex].Contains("provider")
                    ? StepDefinitionsContext.GetProvider(table.Rows[rowIndex].Value <string>("provider"))
                    : StepDefinitionsContext.GetDefaultProvider();

                var priceEpisode                = provider.GetPriceEpisode(table.Rows[rowIndex].Value <string>("price episode"));
                var expectedNegotiatedPrice     = table.Rows[rowIndex].Value <decimal>("negotiated price");
                var expectedPreviousFunding     = table.Rows[rowIndex].Value <decimal>("previous funding paid");
                var expectedPriceAboveCap       = table.Rows[rowIndex].Value <decimal>("price above cap");
                var expectedPriceForSfaPayments = table.Rows[rowIndex].Value <decimal>("effective price for SFA payments");

                var actualPriceEpisode = LearnerDataHelper.GetOpaApprenticeshipPriceEpisode(provider.Ukprn, priceEpisode.Id, EnvironmentVariables);

                Assert.AreEqual(expectedNegotiatedPrice, actualPriceEpisode.PriceEpisodeTotalTNPPrice, $"Expecting a total negotiated price of {expectedNegotiatedPrice} for pride episode {priceEpisode.DataLockMatchKey} but found {actualPriceEpisode.PriceEpisodeTotalTNPPrice}.");
                Assert.AreEqual(expectedPreviousFunding, actualPriceEpisode.PriceEpisodePreviousEarnings, $"Expecting previous funding of {expectedPreviousFunding} for pride episode {priceEpisode.DataLockMatchKey} but found {actualPriceEpisode.PriceEpisodePreviousEarnings}.");
                Assert.AreEqual(expectedPriceAboveCap, actualPriceEpisode.PriceEpisodeUpperLimitAdjustment, $"Expecting a price above cap of {expectedPriceAboveCap} for pride episode {priceEpisode.DataLockMatchKey} but found {actualPriceEpisode.PriceEpisodeUpperLimitAdjustment}.");
                Assert.AreEqual(expectedPriceForSfaPayments, actualPriceEpisode.PriceEpisodeUpperBandLimit, $"Expecting an effective price for SFA payments of {expectedPriceForSfaPayments} for pride episode {priceEpisode.DataLockMatchKey} but found {actualPriceEpisode.PriceEpisodeUpperBandLimit}.");
            }
        }
Exemplo n.º 21
0
        public void GivenTheAccountHasABalance(decimal employerLevyBalance)
        {
            // Setup reference data
            var environmentVariables = EnvironmentVariablesFactory.GetEnvironmentVariables();

            StepDefinitionsContext.SetDefaultProvider();

            var provider = StepDefinitionsContext.GetDefaultProvider();
            var learner  = StepDefinitionsContext.CreateLearner(15000, new DateTime(2017, 08, 01), new DateTime(2018, 08, 08));

            learner.LearningDelivery.PriceEpisodes[0].TotalPrice = 15000;
            learner.LearningDelivery.StandardCode = IlrBuilder.Defaults.StandardCode;

            //setup the data for learnig delivery,learner and earnings
            SetupEarningsData(provider, learner);

            var committment = StepDefinitionsContext.ReferenceDataContext.Commitments.First();
            var account     = StepDefinitionsContext.ReferenceDataContext.Employers.First(x => x.Name == committment.Employer);

            //Update the balance to the value passed in
            AccountDataHelper.UpdateAccountBalance(account.AccountId, employerLevyBalance, environmentVariables);
        }
Exemplo n.º 22
0
 public BaseStepDefinitions(StepDefinitionsContext stepDefinitionsContext)
 {
     StepDefinitionsContext = stepDefinitionsContext;
     EnvironmentVariables   = EnvironmentVariablesFactory.GetEnvironmentVariables();
 }
 public EarningAndPaymentsSteps(StepDefinitionsContext earningAndPaymentsContext)
     : base(earningAndPaymentsContext)
 {
 }
Exemplo n.º 24
0
 public DataLockStepDefinitions(StepDefinitionsContext context)
     : base(context)
 {
 }
Exemplo n.º 25
0
 public DataLockSteps(StepDefinitionsContext stepDefinitionsContext)
     : base(stepDefinitionsContext)
 {
 }
Exemplo n.º 26
0
        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);
            }
        }
Exemplo n.º 27
0
        private void SetupCommitments(Table table)
        {
            StepDefinitionsContext.ReferenceDataContext.SetDefaultEmployer(
                new Dictionary <string, decimal>
            {
                { "All", int.MaxValue }
            });

            var employer = StepDefinitionsContext.ReferenceDataContext.Employers[0];

            AccountDataHelper.CreateAccount(employer.AccountId, employer.AccountId.ToString(), 0.00m, EnvironmentVariables);

            foreach (var row in table.Rows)
            {
                var ukprn     = long.Parse(row["UKPRN"]);
                var startDate = DateTime.Parse(row["start date"]);


                var frameworkCode = table.Header.Contains("framework code")
                    ? int.Parse(row["framework code"])
                    : IlrBuilder.Defaults.FrameworkCode;
                var programmeType = table.Header.Contains("programme type")
                    ? int.Parse(row["programme type"])
                    : IlrBuilder.Defaults.ProgrammeType;
                var pathwayCode = table.Header.Contains("pathway code")
                    ? int.Parse(row["pathway code"])
                    : IlrBuilder.Defaults.PathwayCode;

                var standardCode = table.Header.Contains("standard code")
                    ? int.Parse(row["standard code"])
                    : IlrBuilder.Defaults.StandardCode;

                if (frameworkCode > 0 && programmeType > 0 && pathwayCode > 0)
                {
                    standardCode = 0;
                }

                var status = row.ContainsKey("status")
                    ? GetCommitmentStatusOrThrow(row["status"])
                    : CommitmentPaymentStatus.Active;

                StepDefinitionsContext.AddProvider("provider", ukprn);

                CommitmentDataHelper.CreateCommitment(
                    new CommitmentEntity
                {
                    CommitmentId             = long.Parse(IdentifierGenerator.GenerateIdentifier(6, false)),
                    Ukprn                    = ukprn,
                    Uln                      = long.Parse(row["ULN"]),
                    AccountId                = employer.AccountId.ToString(),
                    StartDate                = startDate,
                    EndDate                  = startDate.AddMonths(12),
                    AgreedCost               = decimal.Parse(row["agreed price"]),
                    StandardCode             = standardCode,
                    FrameworkCode            = frameworkCode,
                    ProgrammeType            = programmeType,
                    PathwayCode              = pathwayCode,
                    Priority                 = 1,
                    VersionId                = 1,
                    PaymentStatus            = (int)status,
                    PaymentStatusDescription = status.ToString(),
                    EffectiveFrom            = startDate
                },
                    EnvironmentVariables);
            }
        }