public async Task Then_paid_earnings_after_stop_date_that_have_not_been_sent_are_removed()
        {
            var collectionYear   = (short)2021;
            var collectionPeriod = (byte)6;
            //Arrange
            var pendingPayment = _sutModel.PendingPaymentModels.First();

            pendingPayment.PendingPaymentValidationResultModels = new List <PendingPaymentValidationResultModel>();
            pendingPayment.PendingPaymentValidationResultModels.Add(_fixture.Build <PendingPaymentValidationResultModel>().With(x => x.CollectionPeriod, new CollectionPeriod(collectionPeriod, collectionYear)).With(x => x.Result, true).Create());
            _sut.CreatePayment(pendingPayment.Id, new CollectionPeriod(collectionPeriod, collectionYear));

            pendingPayment = _sutModel.PendingPaymentModels.Last();
            pendingPayment.PendingPaymentValidationResultModels = new List <PendingPaymentValidationResultModel>();
            pendingPayment.PendingPaymentValidationResultModels.Add(_fixture.Build <PendingPaymentValidationResultModel>().With(x => x.CollectionPeriod, new CollectionPeriod(collectionPeriod, collectionYear)).With(x => x.Result, true).Create());
            _sut.CreatePayment(pendingPayment.Id, new CollectionPeriod(collectionPeriod, collectionYear));

            var expectedPaymentHashCode = _sutModel.PendingPaymentModels.First().GetHashCode();

            //Act
            await _sut.SetChangeOfCircumstances(_learner, _mockCollectionCalendarService.Object);

            //Assert
            _sutModel.PendingPaymentModels.Count.Should().Be(1);
            _sutModel.PendingPaymentModels.First().GetHashCode().Should().Be(expectedPaymentHashCode);
        }
Ejemplo n.º 2
0
        public void Then_an_exception_is_thrown_when_the_pending_payment_does_not_exist()
        {
            // act
            Action result = () => _sut.CreatePayment(Guid.NewGuid(), _collectionPeriod);

            // assert
            result.Should().Throw <ArgumentException>().WithMessage("Pending payment does not exist.");
        }
Ejemplo n.º 3
0
        public async Task Then_earnings_with_sent_payments_are_clawed_back_when_the_collection_period_has_changed()
        {
            // arrange
            await _sut.CalculateEarnings(_mockPaymentProfilesService.Object, _mockCollectionCalendarService.Object);

            byte  collectionPeriod = 6;
            short collectionYear   = 2020;
            var   pendingPayment   = _sutModel.PendingPaymentModels.Single(x => x.EarningType == EarningType.FirstPayment);

            pendingPayment.PendingPaymentValidationResultModels = new List <PendingPaymentValidationResultModel>();
            pendingPayment.PendingPaymentValidationResultModels.Add(_fixture.Build <PendingPaymentValidationResultModel>().With(x => x.CollectionPeriod, new CollectionPeriod(collectionPeriod, collectionYear)).With(x => x.Result, true).Create());
            _sut.CreatePayment(pendingPayment.Id, new CollectionPeriod(collectionPeriod, collectionYear));
            _sutModel.PaymentModels.First().PaidDate = DateTime.Now;

            _collectionPeriods.Add(new CollectionCalendarPeriod(new CollectionPeriod(4, _fixture.Create <short>()), (byte)_collectionPeriod.AddMonths(3).Month, (short)_collectionPeriod.AddMonths(3).Year, _collectionPeriod.AddMonths(3).AddDays(1), _fixture.Create <DateTime>(), true, false));

            // act
            _sut.SetStartDate(_plannedStartDate.AddMonths(1));
            await _sut.CalculateEarnings(_mockPaymentProfilesService.Object, _mockCollectionCalendarService.Object);

            // assert
            pendingPayment.ClawedBack.Should().BeTrue();
            _sutModel.PendingPaymentModels.Count(x => x.EarningType == EarningType.FirstPayment).Should().Be(2);
        }
Ejemplo n.º 4
0
        public void Then_the_payment_is_created(DateTime dob, DateTime plannedStartDate, ApprenticeshipEmployerType employerType, SubnominalCode expectedSubnominalCode)
        {
            // arrange
            var apprenticeship = new Apprenticeship(_fixture.Create <long>(), _fixture.Create <string>(),
                                                    _fixture.Create <string>(), dob, _fixture.Create <long>(), employerType, _fixture.Create <string>(), _fixture.Create <DateTime>());

            _sutModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                        .With(x => x.StartDate, plannedStartDate)
                        .With(x => x.Apprenticeship, apprenticeship)
                        .With(x => x.PaymentModels, new List <PaymentModel>()).Create();

            _sut = Sut(_sutModel);

            var pendingPayment = _sut.PendingPayments.First();

            // act
            _sut.CreatePayment(pendingPayment.Id, _collectionPeriod);

            // assert
            _sut.Payments.Count.Should().Be(1);
            var actualPayment = _sut.Payments.First();

            actualPayment.SubnominalCode.Should().Be(expectedSubnominalCode);
        }