Ejemplo n.º 1
0
        public void GetEarningsForPeriod_OnlyMatchesCorrectAttributesAndPeriod()
        {
            var earningsAndPaymentsBuilder = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;
            var periodisedValuesForPayment = new List <ApprenticeshipPriceEpisodePeriodisedValues>
            {
                new ApprenticeshipPriceEpisodePeriodisedValues {
                    AttributeName = "ATTRIB1", Period_1 = 1
                },
                new ApprenticeshipPriceEpisodePeriodisedValues {
                    AttributeName = "ATTRIB2", Period_1 = 2
                },
                new ApprenticeshipPriceEpisodePeriodisedValues {
                    AttributeName = "ATTRIB4", Period_1 = 4
                },
                new ApprenticeshipPriceEpisodePeriodisedValues {
                    AttributeName = "ATTRIB2", Period_2 = 8
                },
            };
            var attributeTypes = new string[] { "attrib1", "attrib2" };

            var result =
                earningsAndPaymentsBuilder.GetEarningsForPeriod(periodisedValuesForPayment, attributeTypes, pvp => pvp.Period_1);

            result.Should().Be(3);
        }
Ejemplo n.º 2
0
        public void GetAttributesForTransactionTypeThrowsException()
        {
            var    earningsAndPaymentsBuilder = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;
            Action act = () => earningsAndPaymentsBuilder.GetAttributesForTransactionType(1);

            act.Should().Throw <ApplicationException>().Where(e => e.Message.Equals("Unexpected TransactionType [1]"));
        }
Ejemplo n.º 3
0
        public void MultiplePaymentPeriodsOnlyGenerateSingleEarningsLink()
        {
            var earningsAndPaymentsBuilder   = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;
            var paymentAndLearningDeliveries = new List <PaymentAndLearningDelivery>();
            var periodisedValuesForPayment   = new List <ApprenticeshipPriceEpisodePeriodisedValues>();

            var periodisedValuesType = typeof(ApprenticeshipPriceEpisodePeriodisedValues);

            for (int i = 1; i <= 14; i++)
            {
                paymentAndLearningDeliveries.Add(new PaymentAndLearningDelivery
                {
                    Payment = new Payment {
                        Amount = (decimal)Math.Pow(2, i), CollectionPeriod = (byte)i, TransactionType = 4
                    },
                    LearningDelivery = new AecLearningDelivery {
                        AimSequenceNumber = 123
                    }
                });
            }

            var periodisedValues = new ApprenticeshipPriceEpisodePeriodisedValues {
                AimSeqNumber = 123, AttributeName = "PriceEpisodeFirstEmp1618Pay", Period_1 = 100
            };

            periodisedValuesForPayment.Add(periodisedValues);

            var result = earningsAndPaymentsBuilder.Build(paymentAndLearningDeliveries, periodisedValuesForPayment);

            result.TotalPaymentsYearToDate.Should().Be((decimal)Math.Pow(2, 15) - 2);
            result.TotalEarnings.Should().Be(100);
        }
Ejemplo n.º 4
0
        public void GroupingByPaymentType()
        {
            var payments = new List <Payment>
            {
                new Payment {
                    LearnerReferenceNumber = "ABC", TransactionType = 4, LearningStartDate = new DateTime(2020, 01, 01), LearningAimProgrammeType = 1, LearningAimStandardCode = 2, LearningAimFrameworkCode = 3, LearningAimPathwayCode = 10
                },
                new Payment {
                    LearnerReferenceNumber = "ABC", TransactionType = 5, LearningStartDate = new DateTime(2020, 01, 01), LearningAimProgrammeType = 1, LearningAimStandardCode = 2, LearningAimFrameworkCode = 3, LearningAimPathwayCode = 11
                },
                new Payment {
                    LearnerReferenceNumber = "ABC", TransactionType = 6, LearningStartDate = new DateTime(2020, 01, 01), LearningAimProgrammeType = 1, LearningAimStandardCode = 2, LearningAimFrameworkCode = 3, LearningAimPathwayCode = 12
                },
                new Payment {
                    LearnerReferenceNumber = "ABC", TransactionType = 7, LearningStartDate = new DateTime(2020, 01, 01), LearningAimProgrammeType = 1, LearningAimStandardCode = 2, LearningAimFrameworkCode = 3, LearningAimPathwayCode = 13
                },
                new Payment {
                    LearnerReferenceNumber = "ABC", TransactionType = 16, LearningStartDate = new DateTime(2020, 01, 01), LearningAimProgrammeType = 1, LearningAimStandardCode = 2, LearningAimFrameworkCode = 3, LearningAimPathwayCode = 14
                },
            };

            var learners = new List <Learner>
            {
                new Learner {
                    LearnRefNumber = "ABC"
                }
            };


            var LearningDeliveries = new List <AecLearningDelivery>
            {
                new AecLearningDelivery {
                    LearnRefNumber = "ABC", LearnStartDate = new DateTime(2020, 01, 01), ProgType = 1, StdCode = 2, FworkCode = 3, PwayCode = 10, AimSequenceNumber = 1
                },
                new AecLearningDelivery {
                    LearnRefNumber = "ABC", LearnStartDate = new DateTime(2020, 01, 01), ProgType = 1, StdCode = 2, FworkCode = 3, PwayCode = 11, AimSequenceNumber = 2
                },
                new AecLearningDelivery {
                    LearnRefNumber = "ABC", LearnStartDate = new DateTime(2020, 01, 01), ProgType = 1, StdCode = 2, FworkCode = 3, PwayCode = 12, AimSequenceNumber = 3
                },
                new AecLearningDelivery {
                    LearnRefNumber = "ABC", LearnStartDate = new DateTime(2020, 01, 01), ProgType = 1, StdCode = 2, FworkCode = 3, PwayCode = 13, AimSequenceNumber = 4
                },
                new AecLearningDelivery {
                    LearnRefNumber = "ABC", LearnStartDate = new DateTime(2020, 01, 01), ProgType = 1, StdCode = 2, FworkCode = 3, PwayCode = 14, AimSequenceNumber = 5
                }
            };

            var periodisedValues = new List <ApprenticeshipPriceEpisodePeriodisedValues>();


            var paymentLineFormatter               = new PaymentLineFormatter() as IPaymentLineFormatter;
            var earningsAndPaymentsBuilder         = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;
            var appsAdditionalPaymentsModelBuilder = new AppsAdditionalPaymentsModelBuilder(paymentLineFormatter, earningsAndPaymentsBuilder);

            var results = appsAdditionalPaymentsModelBuilder.Build(payments, learners, LearningDeliveries, periodisedValues);

            results.Count().Should().Be(3);
        }
Ejemplo n.º 5
0
        public void GetAttributesForTransactionType(byte transType, string[] expected)
        {
            var earningsAndPaymentsBuilder = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;

            var result = earningsAndPaymentsBuilder.GetAttributesForTransactionType(transType);

            result.Should().BeEquivalentTo(expected);
        }
Ejemplo n.º 6
0
        public void GetEarningsForPeriod_EmptyArraysDontCrash()
        {
            var earningsAndPaymentsBuilder = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;
            var periodisedValuesForPayment = new List <ApprenticeshipPriceEpisodePeriodisedValues> {
            };
            var attributeTypes             = new string[] { };

            var result =
                earningsAndPaymentsBuilder.GetEarningsForPeriod(periodisedValuesForPayment, attributeTypes, pvp => pvp.Period_1);

            result.Should().Be(0);
        }
Ejemplo n.º 7
0
        public void BuildAssignsAcrossPeriods()
        {
            var earningsAndPaymentsBuilder   = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;
            var paymentAndLearningDeliveries = new List <PaymentAndLearningDelivery>();
            var periodisedValuesForPayment   = new List <ApprenticeshipPriceEpisodePeriodisedValues>();

            var periodisedValuesType = typeof(ApprenticeshipPriceEpisodePeriodisedValues);

            for (int i = 1; i <= 14; i++)
            {
                paymentAndLearningDeliveries.Add(new PaymentAndLearningDelivery
                {
                    Payment = new Payment {
                        Amount = (decimal)Math.Pow(2, i), CollectionPeriod = (byte)i, TransactionType = 4
                    },
                    LearningDelivery = new AecLearningDelivery {
                        AimSequenceNumber = i
                    }
                });
            }

            for (int i = 1; i <= 12; i++)
            {
                var periodisedValues = new ApprenticeshipPriceEpisodePeriodisedValues {
                    AimSeqNumber = i, AttributeName = "PriceEpisodeFirstEmp1618Pay"
                };

                PropertyInfo pvInstance = periodisedValuesType.GetProperty($"Period_{i}");
                pvInstance.SetValue(periodisedValues, (decimal)Math.Pow(2, i) + 1000);

                periodisedValuesForPayment.Add(periodisedValues);
            }

            var result = earningsAndPaymentsBuilder.Build(paymentAndLearningDeliveries, periodisedValuesForPayment);

            result.TotalPaymentsYearToDate.Should().Be((decimal)Math.Pow(2, 15) - 2);
            result.TotalEarnings.Should().Be((decimal)Math.Pow(2, 13) - 2 + 12000);
        }
        public async void TestAgainstRealDb()
        {
            var ilrConnectionString =
                "<ReplaceWithConnectionString>";
            var dasConnectionString =
                "<ReplaceWithConnectionString>";

            var collectionYear = 1920;
            var ukprn          = 10000055;

            SqlConnection ilrSqlFunc() => new SqlConnection(ilrConnectionString);
            SqlConnection dasSqlFunc() => new SqlConnection(dasConnectionString);

            var paymentsDataProvider            = new PaymentsDataProvider(dasSqlFunc) as IPaymentsDataProvider;
            var learnerDataProvider             = new LearnerDataProvider(ilrSqlFunc) as ILearnerDataProvider;
            var aecLearningDeliveryDataProvider = new AecLearningDeliveryDataProvider(ilrSqlFunc) as IAecLearningDeliveryDataProvider;
            var appsPriceEpisodePeriodisedValuesDataProvider = new AppsPriceEpisodePeriodisedValuesDataProvider(ilrSqlFunc) as IAppsPriceEpisodePeriodisedValuesDataProvider;

            var dataProvider = new AppsAdditionalPaymentsDataProvider(
                paymentsDataProvider,
                learnerDataProvider,
                aecLearningDeliveryDataProvider,
                appsPriceEpisodePeriodisedValuesDataProvider) as IAppsAdditionalPaymentsDataProvider;

            var cancellationToken    = new CancellationToken();
            var reportServiceContext = new Mock <IReportServiceContext>();

            reportServiceContext.Setup(rsc => rsc.CollectionYear).Returns(collectionYear);
            reportServiceContext.Setup(rsc => rsc.Ukprn).Returns(ukprn);

            var payments = await dataProvider.GetPaymentsAsync(reportServiceContext.Object, cancellationToken);

            payments.Should().NotBeNull();
            payments.Should().NotBeEmpty();

            var learners = await dataProvider.GetLearnersAsync(reportServiceContext.Object, cancellationToken);

            learners.Should().NotBeNull();
            learners.Should().NotBeEmpty();

            var aecLearningDeliveries = await dataProvider.GetAecLearningDeliveriesAsync(reportServiceContext.Object,
                                                                                         cancellationToken);

            aecLearningDeliveries.Should().NotBeNull();
            aecLearningDeliveries.Should().NotBeEmpty();

            var appPriceEpisodePeriodisedValues = await dataProvider.GetPriceEpisodesAsync(reportServiceContext.Object, cancellationToken);

            appPriceEpisodePeriodisedValues.Should().NotBeNull();
            appPriceEpisodePeriodisedValues.Should().NotBeEmpty();

            var paymentFundingLineFormatter = new PaymentLineFormatter() as IPaymentLineFormatter;
            var earningsAndPaymentsBuilder  = new EarningsAndPaymentsBuilder() as IEarningsAndPaymentsBuilder;

            var appsAdditionalPaymentsModelBuilder =
                new AppsAdditionalPaymentsModelBuilder(paymentFundingLineFormatter, earningsAndPaymentsBuilder) as IAppsAdditionalPaymentsModelBuilder;

            var results = appsAdditionalPaymentsModelBuilder.Build(payments, learners, aecLearningDeliveries, appPriceEpisodePeriodisedValues);

            results.Should().NotBeNull();
        }