public void CalculateCompletionPaymentsInAcademicYear_Test() { var paymentOne = new PaymentBuilder() .With <byte>(p => p.TransactionType, 3) .With(p => p.Amount, 40) .With <short>(p => p.AcademicYear, 2020) .With <byte>(p => p.CollectionPeriod, 2).Build(); var paymentTwo = new PaymentBuilder() .With <byte>(p => p.TransactionType, 2) .With(p => p.Amount, 50) .With <short>(p => p.AcademicYear, 2021) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentThree = new PaymentBuilder() .With <byte>(p => p.TransactionType, 3) .With(p => p.Amount, 60) .With <short>(p => p.AcademicYear, 2021) .With <byte>(p => p.CollectionPeriod, 2).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree }; var completionEarningsThisFundingYear = NewBuilder().CalculateCompletionPaymentsInAcademicYear(payments, 2021); completionEarningsThisFundingYear.Should().Be(50); }
public void TotalCoInvestmentDueFromEmployerInPreviousFundingYears_Test() { var paymentOne = new PaymentBuilder() .With(p => p.Amount, 10) .With <short>(p => p.AcademicYear, 1819) .With <byte>(p => p.CollectionPeriod, 6).Build(); var paymentTwo = new PaymentBuilder() .With(p => p.Amount, 20) .With <short>(p => p.AcademicYear, 1920) .With <byte>(p => p.CollectionPeriod, 10).Build(); var paymentThree = new PaymentBuilder() .With(p => p.Amount, 30) .With <short>(p => p.AcademicYear, 1920) .With <byte>(p => p.CollectionPeriod, 12).Build(); var paymentFourToBeExcluded = new PaymentBuilder() .With <byte>(p => p.TransactionType, 3) .With(p => p.Amount, 40) .With <short>(p => p.AcademicYear, 1920) .With <byte>(p => p.CollectionPeriod, 13).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree, paymentFourToBeExcluded }; var totalCoInvestmentDueFromEmployerInPreviousFundingYears = NewBuilder().TotalCoInvestmentDueFromEmployerInPreviousFundingYears(payments, 12); totalCoInvestmentDueFromEmployerInPreviousFundingYears.Should().Be(60); }
public void EmployerCoInvestmentPaymentFilter_Test() { var paymentOne = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber1") .With <byte>(p => p.FundingSource, 3) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentTwo = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber2") .With <byte>(p => p.FundingSource, 3) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentThree = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber3") .With <byte>(p => p.FundingSource, 2) .With <byte>(p => p.CollectionPeriod, 1).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree }; NewBuilder().EmployerCoInvestmentPaymentFilter(payments, "LearningRefNumber1").Should().BeTrue(); NewBuilder().EmployerCoInvestmentPaymentFilter(payments, "LearningRefNumber2").Should().BeTrue(); NewBuilder().EmployerCoInvestmentPaymentFilter(payments, "LearningRefNumber3").Should().BeFalse(); }
/// <summary> /// Api for retriving Use Voucher - Use Voucher /// </summary> /// <param name="apipaymentvoucherusepostrequestcontent"></param> /// <returns>ApiPaymentVoucherUsePostOKResponseContent</returns> public async Task <IHttpActionResult> Post(Models.ApiPaymentVoucherUsePostRequestContent apipaymentvoucherusepostrequestcontent) { // TODO: implement Post -route: api / Payment / Voucher / Use / // var result = new ApiPaymentVoucherUsePostOKResponseContent(); //return Ok(result); var resultinPmtDetails = new VoucherPaymentDetails(); var securityData = new model.SecurityData(); object securityObj; Request.Properties.TryGetValue("securityData", out securityObj); securityData = (model.SecurityData)securityObj; // securityData.RadixxToken = "4caf1207-c744-417d-8053-5a835f7d6a00"; try { resultinPmtDetails = this._paymentTasks.AddVoucher(apipaymentvoucherusepostrequestcontent.VoucherRefNo.Trim(), apipaymentvoucherusepostrequestcontent.VoucherPin.Trim(), securityData); //this.UserSessionTasks.UserSession.VoucherSequenceNumber++; } //return this.VoucherInput(); catch (RadixxVoucherException ex) { throw new Exception(); } PaymentBuilder useVoucherBuilder = new PaymentBuilder(); return(Ok(useVoucherBuilder.BuildUseVoucherResponse(resultinPmtDetails))); }
public void CompletionPaymentFilter_Test() { var paymentOne = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber1") .With <byte>(p => p.TransactionType, 3) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentTwo = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber2") .With <byte>(p => p.TransactionType, 3) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentThree = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber3") .With <byte>(p => p.TransactionType, 2) .With <byte>(p => p.CollectionPeriod, 1).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree }; NewBuilder().CompletionPaymentFilter(payments, "LearningRefNumber1").Should().BeTrue(); NewBuilder().CompletionPaymentFilter(payments, "LearningRefNumber2").Should().BeTrue(); NewBuilder().CompletionPaymentFilter(payments, "LearningRefNumber3").Should().BeFalse(); }
/// <summary> /// Api for retriving Verify Voucher - Verify Voucher /// </summary> /// <param name="apipaymentvoucherverifypostrequestcontent"></param> /// <returns>ApiPaymentVoucherVerifyPostOKResponseContent</returns> public async Task <IHttpActionResult> Post(Models.ApiPaymentVoucherVerifyPostRequestContent requestContent) { // TODO: implement Post - route: api/Payment/Voucher/Verify/ // var result = new ApiPaymentVoucherVerifyPostOKResponseContent(); // return Ok(result); var result = new ApiPaymentVoucherVerifyPostRequestContent(); var resultinPrice = new Price(); //var vm = new UseVoucherViewModel { VoucherFormModel = formModel }; // voucher number and pin is expected to be in uppercase. Convert it here for convenience... requestContent.VoucherRefNo = requestContent.VoucherRefNo == null ? null : requestContent.VoucherRefNo.Trim().ToUpper(); requestContent.VoucherPin = requestContent.VoucherPin == null ? null : requestContent.VoucherPin.Trim().ToUpper(); var securityData = new model.SecurityData(); object securityObj; Request.Properties.TryGetValue("securityData", out securityObj); securityData = (model.SecurityData)securityObj; try { resultinPrice = this._paymentTasks.GetVoucherValue(requestContent.VoucherRefNo, requestContent.VoucherPin, securityData); } catch (RadixxVoucherException ex) { throw new Exception(); } var response = new PaymentBuilder().BuildVerifyVoucherResponse(resultinPrice, requestContent); return(Ok(response)); }
public async Task AddNewPaymentSetsId() { var repository = GetRepository(); var payment = new PaymentBuilder().WithDefaultValues().Build(); await repository.AddAsync(payment, CancellationToken.None); Assert.NotEqual(Guid.Empty, payment.Id); }
public async Task GetUserBalanceList_WithPaymentFromUser_ShouldReturnPositiveBalance() { var payment = new PaymentBuilder("Eric").WithPaymentLine("Eric", 10).Build(); await _paymentRepository.AddPaymentAsync(payment); var result = (await _sut.GetUserBalanceList()).ToArray(); result.Should().HaveCount(5); result.Select(e => e.Balance).Should().AllBeEquivalentTo(0); }
public async Task GetByIdReturnsExistingPayment() { var repository = GetRepository(); var payment = new PaymentBuilder().WithDefaultValues().Build(); await repository.AddAsync(payment, CancellationToken.None); var newPayment = await repository.GetByIdAsync <Payment>(payment.Id, CancellationToken.None); Assert.Equal(payment, newPayment); }
public async Task AddPayment_ShouldAddPayment() { var payment = new PaymentBuilder("TestUser") .WithDescription("TestExpense") .WithPaymentLine("TestUser", 10.5m) .Build(); await _paymentRepository.AddPaymentAsync(payment); var fetchedPayment = (await _paymentRepository.FindPaymentsPayedBy("TestUser")).Single(); fetchedPayment.Should().BeEquivalentTo(payment); }
public void BuildCoInvestmentPaymentsPerPeriodDictionary_Test() { var periodOneValue = 0m; var periodTwoValue = 0m; var paymentOne = new PaymentBuilder() .With <byte>(p => p.TransactionType, 1) .With(p => p.Amount, 30) .With <short>(p => p.AcademicYear, 2020) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentTwo = new PaymentBuilder() .With <byte>(p => p.TransactionType, 3) .With(p => p.Amount, 40) .With <short>(p => p.AcademicYear, 2020) .With <byte>(p => p.CollectionPeriod, 2).Build(); var paymentThree = new PaymentBuilder() .With <byte>(p => p.TransactionType, 2) .With(p => p.Amount, 50) .With <short>(p => p.AcademicYear, 2021) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentFour = new PaymentBuilder() .With <byte>(p => p.TransactionType, 3) .With(p => p.Amount, 60) .With <short>(p => p.AcademicYear, 2021) .With <byte>(p => p.CollectionPeriod, 2).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree, paymentFour }; var result = NewBuilder().BuildCoInvestmentPaymentsPerPeriodDictionary(payments, 2021); result.Count.Should().Be(2); result.TryGetValue(1, out periodOneValue); result.TryGetValue(2, out periodTwoValue); periodOneValue.Should().Be(50); periodTwoValue.Should().Be(60); }
public async Task FindPaymentsPayedFor_ShouldFilterPaymentsCorrectly() { var payment1 = new PaymentBuilder("Eric") .WithDescription("KFC") .WithPaymentLine("Eric", 10.5m) .WithPaymentLine("Kyle", 9.75m) .Build(); var payment2 = new PaymentBuilder("Stan") .WithDescription("Video Games") .WithPaymentLine("Token", 40m) .WithPaymentLine("Stan", 40m) .Build(); await _paymentRepository.AddPaymentsAsync(payment1, payment2); var insertedPayment = (await _paymentRepository.FindPaymentsPayedFor("Token")).ToArray(); insertedPayment.Should().HaveCount(1); insertedPayment[0].Should().BeEquivalentTo(payment2); }
public void FilterByFundingSourceAndTransactionType_Test() { var fundingSource = 3; var transactionTypes = new HashSet <int>() { 1, 2, 3 }; var paymentOne = new PaymentBuilder() .With <byte>(p => p.FundingSource, 3) .With <byte>(p => p.TransactionType, 3) .With(p => p.Amount, 10) .With <short>(p => p.AcademicYear, 2020) .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, 2020) .With <byte>(p => p.DeliveryPeriod, 1) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentThree = new PaymentBuilder() .With <byte>(p => p.FundingSource, 3) .With <byte>(p => p.TransactionType, 1) .With(p => p.Amount, 30) .With <short>(p => p.AcademicYear, 2020) .With <byte>(p => p.DeliveryPeriod, 2) .With <byte>(p => p.CollectionPeriod, 1).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree }; var filteredPayments = NewBuilder().FilterByFundingSourceAndTransactionType(payments, fundingSource, transactionTypes); filteredPayments.Count().Should().Be(2); }
public void GetEmployerCoInvestmentPercentage_ZeroAmount_Test() { var paymentOne = new PaymentBuilder() .With <byte>(p => p.TransactionType, 3) .With(p => p.Amount, 0) .With(p => p.SfaContributionPercentage, 0.9m).Build(); var paymentTwo = new PaymentBuilder() .With <byte>(p => p.TransactionType, 2) .With(p => p.Amount, 0) .With(p => p.SfaContributionPercentage, 0.95m).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo }; var employerCoInvestmentPercentage = NewBuilder().GetEmployerCoInvestmentPercentage(payments); employerCoInvestmentPercentage.Should().BeNull(); }
public void GetEarliestPaymentInfo_Should_Return_EarliestPayment() { var paymentOne = new PaymentBuilder().With <short>(p => p.AcademicYear, 1920).With <byte>(p => p.DeliveryPeriod, 1).With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentTwo = new PaymentBuilder().With <short>(p => p.AcademicYear, 2020).With <byte>(p => p.DeliveryPeriod, 1).With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentThree = new PaymentBuilder().With <short>(p => p.AcademicYear, 1920).With <byte>(p => p.DeliveryPeriod, 2).With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentFour = new PaymentBuilder().With <short>(p => p.AcademicYear, 1920).With <byte>(p => p.DeliveryPeriod, 2).With <byte>(p => p.CollectionPeriod, 2).Build(); var paymentFive = new PaymentBuilder().With <short>(p => p.AcademicYear, 2020).With <byte>(p => p.DeliveryPeriod, 2).With <byte>(p => p.CollectionPeriod, 1).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree, paymentFour, paymentFive, }; var builder = NewBuilder(); var earliestPayment = builder.GetEarliestPayment(payments); earliestPayment.Should().BeSameAs(paymentOne); }
public static InsertedData InsertTestData(IMongoDatabase database) { var insertedData = new InsertedData(); var eric = new User("Eric", "Eric Cartman"); var stan = new User("Stan", "Stan Marsh"); var kenny = new User("Kenny", "Kenny McCormick"); var kyle = new User("Kyle", "Kyle Broflovski"); var token = new User("Token", "Token Black", false); database.GetCollection <User>(CollectionNames.Users).InsertMany(new[] { eric, stan, kenny, kyle, token }); insertedData.InsertedUsers.Eric = eric; insertedData.InsertedUsers.Stan = stan; insertedData.InsertedUsers.Kenny = kenny; insertedData.InsertedUsers.Kyle = kyle; insertedData.InsertedUsers.Token = token; var payment1 = new PaymentBuilder("Eric") .WithDescription("Kentucky Fried Chicken") .WithPaymentLine("Eric", 7.5m) .WithPaymentLine("Stan", 7.5m) .WithPaymentLine("Kenny", 7.5m) .WithPaymentLine("Kyle", 7.5m) .Build(); var payment2 = new PaymentBuilder("Stan") .WithDescription("Comic books") .WithPaymentLine("Stan", 7.5m) .WithPaymentLine("Kyle", 10m) .Build(); database.GetCollection <Payment>(CollectionNames.Payments).InsertMany(new[] { payment1, payment2 }); insertedData.InsertedPayments.KFC = payment1; insertedData.InsertedPayments.ComicBooks = payment2; return(insertedData); }
public async Task GetUserBalanceList_WithMultiplePayments_ShouldCalculateBalancesCorrectly() { var payment1 = new PaymentBuilder("Eric") .WithPaymentLine("Eric", 10) .WithPaymentLine("Stan", 5) .WithPaymentLine("Kyle", 7.5m) .WithPaymentLine("Token", 15) .Build(); var payment2 = new PaymentBuilder("Token") .WithPaymentLine("Eric", 15) .WithPaymentLine("Token", 15) .Build(); var payment3 = new PaymentBuilder("Stan") .WithPaymentLine("Kenny", 3.33m) .WithPaymentLine("Eric", 3.33m) .WithPaymentLine("Kyle", 3.33m) .Build(); await _paymentRepository.AddPaymentsAsync(payment1, payment2, payment3); var result = (await _sut.GetUserBalanceList()).ToArray(); using (new AssertionScope()) { result.Should().HaveCount(5); result[0].User.Username.Should().Be("Eric"); result[0].Balance.Should().Be(9.17m); result[1].User.Username.Should().Be("Stan"); result[1].Balance.Should().Be(4.99m); result[2].User.Username.Should().Be("Token"); result[2].Balance.Should().Be(0); result[3].User.Username.Should().Be("Kenny"); result[3].Balance.Should().Be(-3.33m); result[4].User.Username.Should().Be("Kyle"); result[4].Balance.Should().Be(-10.83m); } }
public void GetRelevantLearners_Test() { var appFinRecordsPmr = new List <AppFinRecord>() { new AppFindRecordBuilder().With(a => a.AFinType, "PMR").With(a => a.AFinCode, 1).Build(), new AppFindRecordBuilder().With(a => a.AFinType, "PMR").With(a => a.AFinCode, 2).Build() }; var appFinRecordsNonPmr = new List <AppFinRecord>() { new AppFindRecordBuilder().With(a => a.AFinType, "TNP").With(a => a.AFinCode, 1).With <int>(a => a.AFinAmount, 10).Build(), }; var learningDeliveryOne = new LearningDeliveryBuilder() .With(ld => ld.LearnRefNumber, "LearningRefNumber1") .With(ld => ld.FundModel, 36) .With(a => a.AimSeqNumber, 1) .With(ld => ld.AppFinRecords, appFinRecordsPmr) .Build(); var learningDeliveryTwo = new LearningDeliveryBuilder() .With(ld => ld.LearnRefNumber, "LearningRefNumber2") .With(ld => ld.FundModel, 36) .With(a => a.AimSeqNumber, 2) .Build(); var nonPmrlearningDelivery = new LearningDeliveryBuilder() .With(ld => ld.LearnRefNumber, "LearningRefNumber3") .With(ld => ld.FundModel, 36) .With(ld => ld.AppFinRecords, appFinRecordsNonPmr) .Build(); var learningDeliveries = new List <LearningDelivery>() { learningDeliveryOne, learningDeliveryTwo, nonPmrlearningDelivery }; var nonPmrLearningDeliveries = new List <LearningDelivery> { nonPmrlearningDelivery }; var paymentOne = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber3") .With <byte>(p => p.FundingSource, 3) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentTwo = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber4") .With <byte>(p => p.FundingSource, 3) .With <byte>(p => p.CollectionPeriod, 1).Build(); var paymentThree = new PaymentBuilder() .With(p => p.LearnerReferenceNumber, "LearningRefNumber5") .With <byte>(p => p.FundingSource, 2) .With <byte>(p => p.CollectionPeriod, 1).Build(); var payments = new List <Payment>() { paymentOne, paymentTwo, paymentThree }; var learnerOne = new LearnerBuilder() .With(l => l.LearnRefNumber, "LearningRefNumber1") .With(l => l.LearningDeliveries, learningDeliveries) .Build(); var learnerTwo = new LearnerBuilder() .With(l => l.LearnRefNumber, "LearningRefNumber2") .With(l => l.LearningDeliveries, learningDeliveries) .Build(); var learnerThree = new LearnerBuilder() .With(l => l.LearnRefNumber, "LearningRefNumber3") .With(l => l.LearningDeliveries, nonPmrLearningDeliveries) .Build(); var learnerFour = new LearnerBuilder() .With(l => l.LearnRefNumber, "LearningRefNumber4") .Build(); var learnerFive = new LearnerBuilder() .With(l => l.LearnRefNumber, "LearningRefNumber5") .Build(); var learners = new List <Learner> { learnerOne, learnerTwo, learnerThree, learnerFour, learnerFive }; var relevantLearners = NewBuilder().GetRelevantLearners(learners, payments).ToList(); relevantLearners.Count().Should().Be(3); relevantLearners.Contains(learnerOne.LearnRefNumber).Should().BeTrue(); relevantLearners.Contains(learnerTwo.LearnRefNumber).Should().BeTrue(); relevantLearners.Contains(learnerThree.LearnRefNumber).Should().BeTrue(); relevantLearners.Contains(learnerFour.LearnRefNumber).Should().BeFalse(); relevantLearners.Contains(learnerFive.LearnRefNumber).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); }