public void CalculateCompletionEarningsThisFundingYear_Tests()
        {
            var aecApprenticeshipPriceEpisodePeriodisedValuesOne = new AecPriceEpisodePeriodisedValueBuilder()
                                                                   .With(ld => ld.LearnRefNumber, "LearningRefNumber")
                                                                   .With(a => a.AimSeqNumber, 1)
                                                                   .With(a => a.Period1, 10)
                                                                   .With(a => a.Period2, 20)
                                                                   .With(a => a.Period3, 30)
                                                                   .Build();


            var aecApprenticeshipPriceEpisodePeriodisedValuesTwo = new AecPriceEpisodePeriodisedValueBuilder()
                                                                   .With(ld => ld.LearnRefNumber, "LearningRefNumber")
                                                                   .With(a => a.AimSeqNumber, 2)
                                                                   .With(a => a.Period1, 10)
                                                                   .Build();

            var aecPriceEpisodePeriodisedValues = new List <AECApprenticeshipPriceEpisodePeriodisedValues>()
            {
                aecApprenticeshipPriceEpisodePeriodisedValuesOne,
                aecApprenticeshipPriceEpisodePeriodisedValuesTwo
            };

            var learningDelivery = new LearningDeliveryBuilder()
                                   .With(ld => ld.LearnRefNumber, "LearningRefNumber")
                                   .With(a => a.AimSeqNumber, 1)
                                   .Build();

            var completionEarningsThisFundingYear = NewBuilder().CalculateCompletionEarningsThisFundingYear(learningDelivery, aecPriceEpisodePeriodisedValues);

            completionEarningsThisFundingYear.Should().Be(60);
        }
Beispiel #2
0
        public void NonZeroCompletionEarningsFilter_Test()
        {
            var aecApprenticeshipPriceEpisodePeriodisedValuesOne = new AecPriceEpisodePeriodisedValueBuilder()
                                                                   .With(a => a.LearnRefNumber, "LearningRefNumber1")
                                                                   .With(a => a.Period1, 10)
                                                                   .With(a => a.AttributeName, "PriceEpisodeCompletionPayment")
                                                                   .Build();


            var aecApprenticeshipPriceEpisodePeriodisedValuesTwo = new AecPriceEpisodePeriodisedValueBuilder()
                                                                   .With(a => a.LearnRefNumber, "LearningRefNumber2")
                                                                   .With(a => a.Period1, 20)
                                                                   .With(a => a.AttributeName, "PriceEpisodeCompletionPayment")
                                                                   .Build();

            var aecApprenticeshipPriceEpisodePeriodisedValuesThree = new AecPriceEpisodePeriodisedValueBuilder()
                                                                     .With(a => a.LearnRefNumber, "LearningRefNumber3")
                                                                     .With(a => a.AttributeName, "PriceEpisodeBalancePayment")
                                                                     .Build();

            var aecPriceEpisodePeriodisedValues = new List <AECApprenticeshipPriceEpisodePeriodisedValues>()
            {
                aecApprenticeshipPriceEpisodePeriodisedValuesOne,
                aecApprenticeshipPriceEpisodePeriodisedValuesTwo,
                aecApprenticeshipPriceEpisodePeriodisedValuesThree
            };

            NewBuilder().NonZeroCompletionEarningsFilter(aecPriceEpisodePeriodisedValues, "LearningRefNumber1").Should().BeTrue();
            NewBuilder().NonZeroCompletionEarningsFilter(aecPriceEpisodePeriodisedValues, "LearningRefNumber2").Should().BeTrue();
            NewBuilder().NonZeroCompletionEarningsFilter(aecPriceEpisodePeriodisedValues, "LearningRefNumber3").Should().BeFalse();
        }
        public void BuildEarningsAndPayments()
        {
            var paymentOne = new PaymentBuilder()
                             .With <byte>(p => p.FundingSource, 2)
                             .With <byte>(p => p.TransactionType, 3)
                             .With(p => p.Amount, 10)
                             .With <short>(p => p.AcademicYear, 1920)
                             .With <byte>(p => p.DeliveryPeriod, 1)
                             .With <byte>(p => p.CollectionPeriod, 1).Build();

            var paymentTwo = new PaymentBuilder()
                             .With <byte>(p => p.FundingSource, 2)
                             .With <byte>(p => p.TransactionType, 2)
                             .With(p => p.Amount, 20)
                             .With <short>(p => p.AcademicYear, 1920)
                             .With <byte>(p => p.DeliveryPeriod, 1)
                             .With <byte>(p => p.CollectionPeriod, 1).Build();

            var paymentThree = new PaymentBuilder()
                               .With <byte>(p => p.TransactionType, 1)
                               .With(p => p.Amount, 30)
                               .With <short>(p => p.AcademicYear, 1920)
                               .With <byte>(p => p.DeliveryPeriod, 2)
                               .With <byte>(p => p.CollectionPeriod, 1).Build();

            var paymentFour = new PaymentBuilder()
                              .With <byte>(p => p.TransactionType, 3)
                              .With(p => p.Amount, 40)
                              .With <short>(p => p.AcademicYear, 1920)
                              .With <byte>(p => p.DeliveryPeriod, 2)
                              .With <byte>(p => p.CollectionPeriod, 2).Build();

            var paymentFive = new PaymentBuilder()
                              .With <byte>(p => p.TransactionType, 2)
                              .With(p => p.Amount, 50)
                              .With <short>(p => p.AcademicYear, 2021)
                              .With <byte>(p => p.DeliveryPeriod, 2)
                              .With <byte>(p => p.CollectionPeriod, 1).Build();

            var paymentSix = new PaymentBuilder()
                             .With <byte>(p => p.TransactionType, 3)
                             .With(p => p.Amount, 60)
                             .With <short>(p => p.AcademicYear, 2021)
                             .With <byte>(p => p.DeliveryPeriod, 2)
                             .With <byte>(p => p.CollectionPeriod, 2).Build();

            var allPayments = new List <Payment>()
            {
                paymentOne,
                paymentTwo,
                paymentThree,
                paymentFour,
                paymentFive,
                paymentSix
            };

            var filteredPayments = new List <Payment>()
            {
                paymentThree,
                paymentFour,
                paymentFive,
                paymentSix
            };

            var aecApprenticeshipPriceEpisodePeriodisedValuesOne = new AecPriceEpisodePeriodisedValueBuilder()
                                                                   .With(ld => ld.LearnRefNumber, "LearningRefNumber")
                                                                   .With(a => a.AimSeqNumber, 1)
                                                                   .With(a => a.Period1, 10)
                                                                   .With(a => a.Period2, 20)
                                                                   .With(a => a.Period3, 30)
                                                                   .Build();


            var aecApprenticeshipPriceEpisodePeriodisedValuesTwo = new AecPriceEpisodePeriodisedValueBuilder()
                                                                   .With(ld => ld.LearnRefNumber, "LearningRefNumber")
                                                                   .With(a => a.AimSeqNumber, 2)
                                                                   .With(a => a.Period1, 10)
                                                                   .Build();
            var aecPriceEpisodePeriodisedValues = new List <AECApprenticeshipPriceEpisodePeriodisedValues>()
            {
                aecApprenticeshipPriceEpisodePeriodisedValuesOne,
                aecApprenticeshipPriceEpisodePeriodisedValuesTwo
            };

            var appFinRecords = new List <AppFinRecord>()
            {
                new AppFindRecordBuilder().With(a => a.AFinCode, 1).With <int>(a => a.AFinAmount, 10).Build(),
                new AppFindRecordBuilder().With(a => a.AFinCode, 2).With <int>(a => a.AFinAmount, 100).Build(),
                new AppFindRecordBuilder().With(a => a.AFinCode, 3).With <int>(a => a.AFinAmount, 20).Build(),
                new AppFindRecordBuilder().With(a => a.AFinDate, new DateTime(2020, 07, 31)).With(a => a.AFinCode, 1)
                .With <int>(a => a.AFinAmount, 100).Build(),
            };

            var learningDelivery = new LearningDeliveryBuilder()
                                   .With(ld => ld.LearnRefNumber, "LearningRefNumber")
                                   .With(a => a.AimSeqNumber, 1)
                                   .With(ld => ld.AppFinRecords, appFinRecords)
                                   .Build();

            var earningsAndPayments = NewBuilder().BuildEarningsAndPayments(filteredPayments, allPayments, learningDelivery,
                                                                            aecPriceEpisodePeriodisedValues, _currentAcademicYear, _academicYearStart, _nextAcademicYearStart, _previousYearClosedReturnPeriod);

            earningsAndPayments.CoInvestmentPaymentsDueFromEmployer.August.Should().Be(50);
            earningsAndPayments.CoInvestmentPaymentsDueFromEmployer.September.Should().Be(60);
            earningsAndPayments.CompletionEarningThisFundingYear.Should().Be(60);
            earningsAndPayments.CompletionPaymentsThisFundingYear.Should().Be(50);
            earningsAndPayments.TotalCoInvestmentDueFromEmployerInPreviousFundingYears.Should().Be(70);
            earningsAndPayments.TotalCoInvestmentDueFromEmployerThisFundingYear.Should().Be(110);
            earningsAndPayments.TotalPMRPreviousFundingYears.Should().Be(100);
            earningsAndPayments.TotalPMRThisFundingYear.Should().Be(90);
            earningsAndPayments.EmployerCoInvestmentPercentage.Should().Be(10.00m);
            Math.Round(earningsAndPayments.PercentageOfCoInvestmentCollected, 2).Should().Be(105.56m);
        }