Exemplo n.º 1
0
        public override void AssertBreakdown(EarningsAndPaymentsBreakdown breakdown, IEnumerable <LearnerResults> submissionResults, EmployerAccountContext employerAccountContext)
        {
            var payments = GetPaymentsForBreakdown(breakdown, submissionResults)
                           .Where(p => p.FundingSource == FundingSource.Levy &&
                                  p.ContractType == ContractType.ContractWithEmployer && p.Amount <= 0)
                           .ToArray();

            foreach (var period in breakdown.EmployersLevyAccountCredited)
            {
                var employerPayments = payments.Where(p => p.EmployerAccountId == period.EmployerAccountId).ToList();

                var positivePayments = employerPayments.Select(x =>
                                                               new PaymentResult
                {
                    Amount            = x.Amount * -1,
                    CalculationPeriod = x.CalculationPeriod,
                    ContractType      = x.ContractType,
                    DeliveryPeriod    = x.DeliveryPeriod,
                    EmployerAccountId = x.EmployerAccountId,
                    FundingSource     = x.FundingSource,
                    TransactionType   = x.TransactionType
                });

                var prevPeriod = new EmployerAccountPeriodValue
                {
                    EmployerAccountId = period.EmployerAccountId,
                    PeriodName        = period.PeriodName.ToPeriodDateTime().AddMonths(-1).ToPeriodName(),
                    Value             = period.Value
                };

                AssertResultsForPeriod(prevPeriod, positivePayments.ToArray());
            }
        }
        public override void AssertBreakdown(EarningsAndPaymentsBreakdown breakdown, IEnumerable <LearnerResults> submissionResults, EmployerAccountContext employerAccountContext)
        {
            var payments = GetPaymentsForBreakdown(breakdown, submissionResults)
                           .Where(p => p.FundingSource == FundingSource.Levy && p.ContractType == ContractType.ContractWithEmployer && p.Amount >= 0)
                           .ToArray();

            foreach (var period in breakdown.EmployersLevyAccountDebited)
            {
                var employerPayments = payments.Where(p => p.EmployerAccountId == period.EmployerAccountId).ToArray();
                var prevPeriod       = new EmployerAccountPeriodValue
                {
                    EmployerAccountId = period.EmployerAccountId,
                    PeriodName        = period.PeriodName.ToPeriodDateTime().AddMonths(-1).ToPeriodName(),
                    Value             = period.Value
                };

                AssertResultsForPeriod(prevPeriod, employerPayments);
            }
        }
        public override void AssertBreakdown(EarningsAndPaymentsBreakdown breakdown, IEnumerable <LearnerResults> submissionResults, EmployerAccountContext employerAccountContext)
        {
            var allPayments = GetPaymentsForBreakdown(breakdown, submissionResults)
                              .Where(p => p.FundingSource == FundingSource.CoInvestedEmployer)
                              .ToArray();

            foreach (var period in breakdown.PaymentDueFromEmployers)
            {
                // Currently have to assume there is only 1 non-levy employer in spec as there is no way to tell employer if there is no commitment.
                var employerAccount     = employerAccountContext.EmployerAccounts.SingleOrDefault(a => a.Id == period.EmployerAccountId);
                var isDasEmployer       = employerAccount == null ? false : employerAccount.IsDasEmployer;
                var paymentsForEmployer = allPayments.Where(p => p.EmployerAccountId == period.EmployerAccountId || (!isDasEmployer && p.EmployerAccountId == 0)).ToArray();
                var prevPeriod          = new EmployerAccountPeriodValue
                {
                    EmployerAccountId = period.EmployerAccountId,
                    PeriodName        = period.PeriodName.ToPeriodDateTime().AddMonths(-1).ToPeriodName(),
                    Value             = period.Value
                };

                AssertResultsForPeriod(prevPeriod, paymentsForEmployer);
            }
        }