private void VerifyAdditionalGovtFundedEarnings(long ukprn,
                                                        long?uln,
                                                        string periodName,
                                                        DateTime periodDate,
                                                        int colIndex,
                                                        TableRow additionalEarningsRow)
        {
            if (additionalEarningsRow == null)
            {
                return;
            }

            var additionalEarnings = PaymentsDataHelper.GetPaymentsForPeriod(
                ukprn,
                uln,
                periodDate.Year,
                periodDate.Month,
                FundingSource.FullyFundedSfa,
                StepDefinitionsContext.DasScenario ?
                ContractType.ContractWithEmployer :
                ContractType.ContractWithSfa,
                EnvironmentVariables)
                                     ?? new PaymentEntity[0];

            var actualEarningsDue = additionalEarnings.Length == 0 ? 0m : additionalEarnings.Sum(p => p.Amount);

            var expectedPaymentDue = decimal.Parse(additionalEarningsRow[colIndex]);

            Assert.AreEqual(expectedPaymentDue, Math.Round(actualEarningsDue, 2), $"Expected additional earnings of {expectedPaymentDue} but earned a payment of {actualEarningsDue} for {periodName}");
        }
        private void VerifyEmployerCofinancePayments(long ukprn, long?uln, string periodName, DateTime periodDate, long accountId,
                                                     int colIndex, TableRow employerCofundRow, LearnerType learnersType)
        {
            if (employerCofundRow == null)
            {
                return;
            }

            var employerPaymentDate = periodDate.AddMonths(-1);

            var cofinancePayments = PaymentsDataHelper.GetAccountPaymentsForPeriod(
                ukprn,
                learnersType == LearnerType.ProgrammeOnlyNonDas ?  (long?)null : accountId,
                uln,
                employerPaymentDate.Year,
                employerPaymentDate.Month,
                FundingSource.CoInvestedEmployer,
                learnersType == LearnerType.ProgrammeOnlyNonDas ? ContractType.ContractWithSfa : ContractType.ContractWithEmployer,
                EnvironmentVariables)
                                    ?? new PaymentEntity[0];

            var actualEmployerPayment   = cofinancePayments.Sum(p => p.Amount);
            var expectedEmployerPayment = decimal.Parse(employerCofundRow[colIndex]);

            Assert.AreEqual(expectedEmployerPayment, Math.Round(actualEmployerPayment, 2), $"Expected a employer co-finance payment of {expectedEmployerPayment} but made a payment of {actualEmployerPayment} for {periodName}");
        }
        private void VerifyPaymentsDueByTransactionType(long ukprn,
                                                        string periodName,
                                                        DateTime periodDate,
                                                        int colIndex,
                                                        TransactionType[] paymentTypes,
                                                        TableRow paymentsRow,
                                                        long?accountId = null,
                                                        FundingSource?fundingSource = null)
        {
            if (paymentsRow == null)
            {
                return;
            }

            var paymentTypesFilter = Array.ConvertAll(paymentTypes, value => (int)value);

            var paymentsDueDate = periodDate.AddMonths(-1);

            var paymentsDue = PaymentsDataHelper.GetAccountPaymentsForPeriod(
                ukprn,
                accountId,
                null,
                paymentsDueDate.Year,
                paymentsDueDate.Month,
                fundingSource,
                StepDefinitionsContext.DasScenario
                    ? ContractType.ContractWithEmployer
                    : ContractType.ContractWithSfa,
                EnvironmentVariables);

            var actualPaymentDue   = paymentsDue.Length == 0 ? 0m : paymentsDue.Where(p => paymentTypesFilter.Contains(p.TransactionType)).Sum(p => p.Amount);
            var expectedPaymentDue = decimal.Parse(paymentsRow[colIndex]);

            Assert.AreEqual(expectedPaymentDue, Math.Round(actualPaymentDue, 2), $"Expected {string.Join(" and ",paymentTypes)} payment due of {expectedPaymentDue} but made a payment of {actualPaymentDue} for {periodName}");
        }
        private void VerifyGovtCofinanceNonLevyContractPayments(long ukprn,
                                                                long?uln,
                                                                string periodName,
                                                                DateTime periodDate,
                                                                int colIndex,
                                                                TableRow govtCofundRow)
        {
            if (govtCofundRow == null)
            {
                return;
            }

            var cofinancePayments = PaymentsDataHelper.GetPaymentsForPeriod(
                ukprn,
                uln,
                periodDate.Year,
                periodDate.Month,
                FundingSource.CoInvestedSfa,
                ContractType.ContractWithSfa,
                EnvironmentVariables)
                                    ?? new PaymentEntity[0];

            var actualGovtPayment   = cofinancePayments.Sum(p => p.Amount);
            var expectedGovtPayment = decimal.Parse(govtCofundRow[colIndex]);

            Assert.AreEqual(expectedGovtPayment, Math.Round(actualGovtPayment, 2), $"Expected a government co-finance payment of {expectedGovtPayment} but made a payment of {actualGovtPayment} for {periodName}");
        }
        private void VerifyLevyPayments(long ukprn,
                                        long?uln,
                                        string periodName,
                                        DateTime periodDate,
                                        long accountId,
                                        int colIndex,
                                        TableRow levyPaidRow)
        {
            if (levyPaidRow == null)
            {
                return;
            }

            var levyPaymentDate = periodDate.AddMonths(-1);

            var levyPayments = PaymentsDataHelper.GetAccountPaymentsForPeriod(
                ukprn,
                accountId,
                uln,
                levyPaymentDate.Year,
                levyPaymentDate.Month,
                FundingSource.Levy,
                ContractType.ContractWithEmployer,
                EnvironmentVariables)
                               ?? new PaymentEntity[0];

            var actualLevyPayment   = levyPayments.Length == 0 ? 0m : levyPayments.Sum(p => p.Amount);
            var expectedLevyPayment = decimal.Parse(levyPaidRow[colIndex]);

            Assert.AreEqual(expectedLevyPayment, Math.Round(actualLevyPayment, 2), $"Expected a levy payment of {expectedLevyPayment} but made a payment of {actualLevyPayment} for {periodName}");
        }
Пример #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");
            }
        }
Пример #7
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");
            }
        }
Пример #8
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");
            }
        }