Esempio n. 1
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");
            }
        }
Esempio n. 2
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");
            }
        }
Esempio n. 3
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");
            }
        }
Esempio n. 4
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));
        }
Esempio n. 5
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()));
        }
Esempio n. 6
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}");
        }
Esempio n. 7
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}");
        }
Esempio n. 8
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()));
        }
Esempio n. 9
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}");
        }
Esempio n. 10
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));
        }
        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}.");
            }
        }
Esempio n. 12
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");
            }
        }
Esempio n. 13
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);
        }