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 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}");
        }