public WithdrawalByComplianceSteps(TestContext testContext) : base(testContext)
        {
            _testContext      = testContext;
            _fixture          = new Fixture();
            _connectionString = _testContext.SqlDatabase.DatabaseInfo.ConnectionString;

            _application    = _fixture.Create <IncentiveApplication>();
            _apprenticeship = _fixture
                              .Build <IncentiveApplicationApprenticeship>()
                              .With(a => a.IncentiveApplicationId, _application.Id)
                              .With(a => a.WithdrawnByCompliance, false)
                              .Create();

            _apprenticeship2 = _fixture
                               .Build <IncentiveApplicationApprenticeship>()
                               .With(a => a.IncentiveApplicationId, _application.Id)
                               .With(a => a.ULN, _apprenticeship.ULN)
                               .With(a => a.WithdrawnByCompliance, false)
                               .Create();

            _apprenticeshipIncentive = _fixture
                                       .Build <ApprenticeshipIncentive>()
                                       .With(i => i.IncentiveApplicationApprenticeshipId, _apprenticeship.Id)
                                       .With(i => i.AccountLegalEntityId, _application.AccountLegalEntityId)
                                       .With(i => i.AccountId, _application.AccountId)
                                       .With(i => i.ULN, _apprenticeship.ULN)
                                       .With(i => i.Status, IncentiveStatus.Active)
                                       .Create();

            _pendingPayment = _fixture
                              .Build <PendingPayment>()
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(i => i.AccountId, _apprenticeshipIncentive.AccountId)
                              .With(i => i.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                              .With(p => p.PaymentMadeDate, (DateTime?)null)
                              .Create();

            _paidPendingPayment = _fixture
                                  .Build <PendingPayment>()
                                  .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                                  .With(i => i.AccountId, _apprenticeshipIncentive.AccountId)
                                  .With(i => i.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                                  .Create();

            _payment = _fixture
                       .Build <Payment>()
                       .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                       .With(i => i.AccountId, _apprenticeshipIncentive.AccountId)
                       .With(i => i.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                       .With(p => p.PendingPaymentId, _paidPendingPayment.Id)
                       .Create();

            _pendingPaymentValidationResult = _fixture
                                              .Build <PendingPaymentValidationResult>()
                                              .With(p => p.PendingPaymentId, _pendingPayment.Id)
                                              .With(p => p.Step, "Invalid")
                                              .With(p => p.PeriodNumber, 1)
                                              .With(p => p.PaymentYear, 2021)
                                              .Create();
        }
Пример #2
0
        public void Then_a_validation_result_is_created_for_the_required_minimum_agreement_version(
            int?legalEntitySignedVersion, int?minimumRequiredVersion, bool validationResult)
        {
            // arrange
            var pendingPayment = _sut.PendingPayments.First();

            var legalEntity = Accounts.LegalEntity.Create(_fixture.Build <LegalEntityModel>()
                                                          .With(l => l.AccountLegalEntityId, pendingPayment.Account.AccountLegalEntityId)
                                                          .With(l => l.SignedAgreementVersion, legalEntitySignedVersion)
                                                          .Create());

            _account.AddLegalEntity(pendingPayment.Account.AccountLegalEntityId, legalEntity);

            _sutModel.MinimumAgreementVersion = new AgreementVersion(minimumRequiredVersion);

            _sut = Sut(_sutModel);

            // act
            _sut.ValidateMinimumRequiredAgreementVersion(pendingPayment.Id, _account, _collectionPeriod);

            // assert
            pendingPayment.PendingPaymentValidationResults.Count.Should().Be(1);
            var validationresult = pendingPayment.PendingPaymentValidationResults.First();

            validationresult.Step.Should().Be(ValidationStep.HasSignedMinVersion);
            validationresult.CollectionPeriod.Should().Be(_collectionPeriod);
            validationresult.Result.Should().Be(validationResult);
        }
        internal static ApprenticeshipIncentiveModel Map(this ApprenticeshipIncentive entity, IEnumerable <CollectionPeriod> collectionPeriods)
        {
            var apprenticeship = new Domain.ApprenticeshipIncentives.ValueTypes.Apprenticeship(
                entity.ApprenticeshipId,
                entity.FirstName,
                entity.LastName,
                entity.DateOfBirth,
                entity.ULN,
                entity.EmployerType,
                entity.CourseName
                );

            if (entity.UKPRN.HasValue)
            {
                apprenticeship.SetProvider(new Domain.ApprenticeshipIncentives.ValueTypes.Provider(entity.UKPRN.Value));
            }

            return(new ApprenticeshipIncentiveModel
            {
                Id = entity.Id,
                Account = new Domain.ApprenticeshipIncentives.ValueTypes.Account(entity.AccountId, entity.AccountLegalEntityId),
                Apprenticeship = apprenticeship,
                StartDate = entity.StartDate,
                ApplicationApprenticeshipId = entity.IncentiveApplicationApprenticeshipId,
                PendingPaymentModels = entity.PendingPayments.Map(collectionPeriods),
                PaymentModels = entity.Payments.Map(),
                ClawbackPaymentModels = entity.ClawbackPayments.Map(),
                RefreshedLearnerForEarnings = entity.RefreshedLearnerForEarnings,
                HasPossibleChangeOfCircumstances = entity.HasPossibleChangeOfCircumstances,
                PausePayments = entity.PausePayments,
                SubmittedDate = entity.SubmittedDate,
                SubmittedByEmail = entity.SubmittedByEmail,
                Status = entity.Status
            });
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _collectionYear  = _fixture.Create <short>();
            _collectionMonth = _fixture.Create <byte>();

            _collectionPeriod = new CollectionPeriod(1, _collectionMonth, _collectionYear, DateTime.Now, DateTime.Now, _collectionYear, true);

            _fixture.Build <PendingPaymentModel>().With(p => p.PendingPaymentValidationResultModels, new List <PendingPaymentValidationResultModel>()).Create();

            _sutModel = _fixture
                        .Build <ApprenticeshipIncentiveModel>()
                        .With(a => a.PendingPaymentModels, new List <PendingPaymentModel>()
            {
                _fixture.Build <PendingPaymentModel>().With(p => p.PendingPaymentValidationResultModels, new List <PendingPaymentValidationResultModel>()).Create()
            })
                        .Create();

            _sutModel.Apprenticeship.SetProvider(_fixture.Create <Provider>());

            _learner = Learner.New(
                Guid.NewGuid(),
                _sutModel.Id,
                _sutModel.Apprenticeship.Id,
                _sutModel.Apprenticeship.Provider.Ukprn,
                _sutModel.Apprenticeship.UniqueLearnerNumber);

            var submissionData = new SubmissionData();

            submissionData.SetSubmissionDate(DateTime.Now);
            _learner.SetSubmissionData(submissionData);

            _sut = Sut(_sutModel);
        }
Пример #5
0
        public RefreshLearnerDataSteps(TestContext testContext)
        {
            _testContext    = testContext;
            _fixture        = new Fixture();
            _startDate      = DateTime.Parse("2020-08-10");
            _submissionDate = DateTime.Parse("2020-11-09T16:53:17.293+00:00");
            _accountModel   = _fixture.Create <Data.Models.Account>();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.DateOfBirth, _startDate.AddYears(-26))
                                       .With(p => p.UKPRN, 10036143)
                                       .With(p => p.ULN, 9900084607)
                                       .With(p => p.ApprenticeshipId, 511526)
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .With(p => p.StartDate, _startDate)
                                       .Without(p => p.PendingPayments)
                                       .Without(p => p.Payments)
                                       .Create();

            _pendingPayments = new List <PendingPayment>
            {
                _fixture.Build <PendingPayment>()
                .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                .With(p => p.PeriodNumber, (byte?)2)      // current period
                .With(p => p.PaymentYear, (short?)2021)
                .With(p => p.DueDate, DateTime.Parse("2020-09-09"))
                .With(p => p.ClawedBack, false)
                .With(p => p.EarningType, EarningType.FirstPayment)
                .Without(p => p.PaymentMadeDate)
                .Create(),
                _fixture.Build <PendingPayment>()
                .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                .With(p => p.PeriodNumber, (byte?)2)      // future period
                .With(p => p.PaymentYear, (short?)2122)
                .With(p => p.DueDate, DateTime.Parse("2021-10-07"))
                .With(p => p.ClawedBack, false)
                .With(p => p.EarningType, EarningType.SecondPayment)
                .Without(p => p.PaymentMadeDate)
                .Create()
            };

            _apprenticeshipIncentive.PendingPayments = _pendingPayments;

            _payments = new List <Payment>
            {
                _fixture.Build <Payment>()
                .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                .With(p => p.PendingPaymentId, _pendingPayments.First().Id)
                .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                .Create(),
            };

            _apprenticeshipIncentive.Payments = _payments;
        }
        public async Task WhenAnEmployerHasSubmittedAnApplicationAndNotSuppliedBankDetails()
        {
            _applicationCutOffDate = DateTime.Today.AddDays(-10);

            _account           = TestContext.TestData.GetOrCreate <Account>();
            _account.VrfCaseId = null;
            _account.VrfCaseStatusLastUpdatedDateTime = null;
            _account.VrfCaseStatus = null;
            _account.VrfVendorId   = null;

            _application                           = TestContext.TestData.GetOrCreate <IncentiveApplication>();
            _application.AccountId                 = _account.Id;
            _application.AccountLegalEntityId      = _account.AccountLegalEntityId;
            _application.Status                    = Enums.IncentiveApplicationStatus.Submitted;
            _application.DateCreated               = _applicationCutOffDate.AddDays(-1);
            _application.DateSubmitted             = _applicationCutOffDate.AddDays(-1);
            _apprenticeship                        = TestContext.TestData.GetOrCreate <IncentiveApplicationApprenticeship>();
            _apprenticeship.IncentiveApplicationId = _application.Id;

            _apprenticeshipIncentive                      = TestContext.TestData.GetOrCreate <ApprenticeshipIncentive>();
            _apprenticeshipIncentive.AccountId            = _account.Id;
            _apprenticeshipIncentive.AccountLegalEntityId = _account.AccountLegalEntityId;
            _apprenticeshipIncentive.SubmittedDate        = _applicationCutOffDate.AddDays(-1);

            await SetupApprenticeshipIncentive();
        }
Пример #7
0
        public void Arrange()
        {
            _fixture = new Fixture();

            _collectionYear = _fixture.Create <short>();


            _collectionPeriod = new CollectionPeriod(1, _collectionYear);

            _accountLegalEntityId = _fixture.Create <long>();
            _account = Accounts.Account.Create(_fixture.Build <AccountModel>().Without(a => a.LegalEntityModels).Create());

            var startDate = DateTime.Now.Date;
            var dueDate   = startDate.AddDays(90).Date;

            _sutModel = _fixture
                        .Build <ApprenticeshipIncentiveModel>()
                        .With(a => a.Account, new Account(_account.Id, _accountLegalEntityId))
                        .With(a => a.StartDate, startDate)
                        .With(a => a.PendingPaymentModels, new List <PendingPaymentModel>()
            {
                _fixture.Build <PendingPaymentModel>()
                .With(p => p.DueDate, dueDate)
                .With(p => p.PendingPaymentValidationResultModels, new List <PendingPaymentValidationResultModel>())
                .With(p => p.Account, new Account(_account.Id, _accountLegalEntityId))
                .Create()
            })
                        .Create();

            _sutModel.Apprenticeship.SetProvider(_fixture.Create <Provider>());

            _sut = Sut(_sutModel);
        }
        public FakeLearnerMatchApiBuilder WithLearnerMatchingApi()
        {
            _accountModel = _fixture.Create <Account>();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .Create();


            _learnerMatchApiData = _fixture.Build <LearnerSubmissionDto>()
                                   .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                   .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                   .Create();

            _server
            .Given(
                Request
                .Create()
                .WithPath($"/api/v1.0/*/*")
                .UsingGet()
                )
            .RespondWith(Response.Create()
                         .WithStatusCode(HttpStatusCode.OK)
                         .WithHeader("Content-Type", "application/json")
                         .WithBodyAsJson(_learnerMatchApiData));

            return(this);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _sutModel = _fixture.Build <ApprenticeshipIncentiveModel>().With(p => p.HasPossibleChangeOfCircumstances, false).Create();

            _sut = Sut(_sutModel);
        }
        public static async Task <Incentive> Create(
            ApprenticeshipIncentive incentive,
            IIncentivePaymentProfilesService incentivePaymentProfilesService)
        {
            var paymentProfiles = await incentivePaymentProfilesService.Get();

            return(Create(incentive.Phase.Identifier, incentive.Apprenticeship.DateOfBirth, incentive.StartDate, paymentProfiles, incentive.BreakInLearnings));
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _sutModel = _fixture.Build <ApprenticeshipIncentiveModel>().With(x => x.RefreshedLearnerForEarnings, false).Create();

            _sut = Sut(_sutModel);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _sutModel = _fixture.Create <ApprenticeshipIncentiveModel>();
            _sutModel.PendingPaymentModels = new List <PendingPaymentModel>(_fixture.CreateMany <PendingPaymentModel>(3));

            _sut = Sut(_sutModel);
        }
Пример #13
0
        public async Task GivenAnAccountThatIsInEmployerIncentives()
        {
            _account = TestContext.TestData.GetOrCreate <Account>();
            _apprenticeshipIncentive                      = TestContext.TestData.GetOrCreate <ApprenticeshipIncentive>();
            _apprenticeshipIncentive.AccountId            = _account.Id;
            _apprenticeshipIncentive.AccountLegalEntityId = _account.AccountLegalEntityId;

            await SetupApprenticeshipIncentive();
        }
Пример #14
0
 private void RemoveDeletedClawbacks(ApprenticeshipIncentive updatedIncentive, ApprenticeshipIncentive existingIncentive)
 {
     foreach (var existingPayment in existingIncentive.ClawbackPayments)
     {
         if (!updatedIncentive.ClawbackPayments.Any(c => c.Id == existingPayment.Id))
         {
             _dbContext.ClawbackPayments.Remove(existingPayment);
         }
     }
 }
Пример #15
0
 private void RemoveDeletedBreaksInLearning(ApprenticeshipIncentive updatedIncentive, ApprenticeshipIncentive existingIncentive)
 {
     foreach (var breakInLearning in existingIncentive.BreakInLearnings)
     {
         if (updatedIncentive.BreakInLearnings.All(c => c.StartDate != breakInLearning.StartDate))
         {
             _dbContext.BreakInLearnings.Remove(breakInLearning);
         }
     }
 }
Пример #16
0
 private void RemoveDeletedPendingPayments(ApprenticeshipIncentive updatedIncentive, ApprenticeshipIncentive existingIncentive)
 {
     foreach (var existingPendingPayment in existingIncentive.PendingPayments)
     {
         if (updatedIncentive.PendingPayments.All(c => c.Id != existingPendingPayment.Id))
         {
             _dbContext.PendingPayments.Remove(existingPendingPayment);
         }
     }
 }
Пример #17
0
        public void Arrange()
        {
            _fixture          = new Fixture();
            _collectionPeriod = _fixture.Create <CollectionPeriod>();

            _fixture.Customize <PendingPaymentValidationResultModel>(x =>
                                                                     x.With(y => y.Result, true)
                                                                     .With(x => x.CollectionPeriod, _collectionPeriod));
            _sutModel = _fixture.Build <ApprenticeshipIncentiveModel>().With(x => x.PaymentModels, new List <PaymentModel>()).Create();

            _sut = Sut(_sutModel);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _collectionPeriod = new DateTime(2020, 10, 1);
            _plannedStartDate = _collectionPeriod.AddDays(5);

            _firstPaymentDaysAfterApprenticeshipStart  = 10;
            _secondPaymentDaysAfterApprenticeshipStart = 50;

            var under25PaymentProfiles = new List <PaymentProfile>
            {
                new PaymentProfile(_firstPaymentDaysAfterApprenticeshipStart, 100),
                new PaymentProfile(_secondPaymentDaysAfterApprenticeshipStart, 300)
            };

            var over25PaymentProfiles = new List <PaymentProfile>
            {
                new PaymentProfile(_firstPaymentDaysAfterApprenticeshipStart, 200),
                new PaymentProfile(_secondPaymentDaysAfterApprenticeshipStart, 400)
            };

            _paymentProfiles = new List <IncentivePaymentProfile>()
            {
                new IncentivePaymentProfile(Enums.IncentiveType.UnderTwentyFiveIncentive, under25PaymentProfiles),
                new IncentivePaymentProfile(IncentiveType.TwentyFiveOrOverIncentive, over25PaymentProfiles)
            };

            _collectionPeriods = new List <CollectionPeriod>()
            {
                new CollectionPeriod(1, (byte)_collectionPeriod.AddMonths(-1).Month, (short)_collectionPeriod.AddMonths(-1).Year, _collectionPeriod.AddMonths(-1).AddDays(1), _fixture.Create <DateTime>(), _fixture.Create <short>(), false),
                new CollectionPeriod(2, (byte)_collectionPeriod.AddMonths(1).Month, (short)_collectionPeriod.AddMonths(1).Year, _collectionPeriod.AddMonths(1).AddDays(1), _fixture.Create <DateTime>(), _fixture.Create <short>(), false),
                new CollectionPeriod(3, (byte)_collectionPeriod.AddMonths(2).Month, (short)_collectionPeriod.AddMonths(2).Year, _collectionPeriod.AddMonths(2).AddDays(1), _fixture.Create <DateTime>(), _fixture.Create <short>(), false)
            };

            _collectionCalendar = new CollectionCalendar(_collectionPeriods);

            _mockCollectionCalendarService = new Mock <ICollectionCalendarService>();
            _mockCollectionCalendarService.Setup(m => m.Get()).ReturnsAsync(_collectionCalendar);

            _mockPaymentProfilesService = new Mock <IIncentivePaymentProfilesService>();
            _mockPaymentProfilesService.Setup(m => m.Get()).ReturnsAsync(_paymentProfiles);

            _sutModel                       = _fixture.Create <ApprenticeshipIncentiveModel>();
            _apprenticehip                  = _sutModel.Apprenticeship;
            _sutModel.StartDate             = _plannedStartDate;
            _sutModel.PendingPaymentModels  = new List <PendingPaymentModel>();
            _sutModel.PaymentModels         = new List <PaymentModel>();
            _sutModel.ClawbackPaymentModels = new List <ClawbackPaymentModel>();
            _sut = Sut(_sutModel);
        }
Пример #19
0
        private void UpdateApprenticeshipIncentive(ApprenticeshipIncentive updatedIncentive, ApprenticeshipIncentive existingIncentive)
        {
            _dbContext.Entry(existingIncentive).CurrentValues.SetValues(updatedIncentive);

            RemoveDeletedClawbacks(updatedIncentive, existingIncentive);
            RemoveDeletedPayments(updatedIncentive, existingIncentive);
            RemoveDeletedPendingPayments(updatedIncentive, existingIncentive);

            foreach (var pendingPayment in updatedIncentive.PendingPayments)
            {
                var existingPendingPayment = existingIncentive.PendingPayments.SingleOrDefault(p => p.Id == pendingPayment.Id);

                if (existingPendingPayment != null)
                {
                    UpdatePendingPayment(pendingPayment, existingPendingPayment);
                }
                else
                {
                    _dbContext.PendingPayments.Add(pendingPayment);
                }
            }

            foreach (var payment in updatedIncentive.Payments)
            {
                var existingPayment = existingIncentive.Payments.SingleOrDefault(p => p.Id == payment.Id);

                if (existingPayment != null)
                {
                    _dbContext.Entry(existingPayment).CurrentValues.SetValues(payment);
                }
                else
                {
                    _dbContext.Payments.Add(payment);
                }
            }

            foreach (var clawback in updatedIncentive.ClawbackPayments)
            {
                var existingClawback = existingIncentive.ClawbackPayments.SingleOrDefault(p => p.Id == clawback.Id);

                if (existingClawback != null)
                {
                    _dbContext.Entry(existingClawback).CurrentValues.SetValues(clawback);
                }
                else
                {
                    _dbContext.ClawbackPayments.Add(clawback);
                }
            }
        }
        public MonthEndInProgressSteps(TestContext testContext) : base(testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();
            var today = new DateTime(2021, 1, 30);

            _accountModel = _fixture.Create <Account>();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .With(p => p.StartDate, today.AddDays(1))
                                       .With(p => p.DateOfBirth, today.AddYears(-20))
                                       .Create();
        }
        public void Arrange()
        {
            _fixture              = new Fixture();
            _accountId            = _fixture.Create <long>();
            _accountLegalEntityId = _fixture.Create <long>();
            var startDate       = DateTime.Now.Date;
            var collectionYear  = _fixture.Create <short>();
            var collectionMonth = _fixture.Create <byte>();

            _collectionPeriod = new CollectionPeriod(1, collectionYear);

            var legalEntityModels = new List <LegalEntityModel>
            {
                new LegalEntityModel {
                    Id = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _accountModel = new AccountModel {
                Id = _accountId, LegalEntityModels = legalEntityModels
            };
            _account = Account.Create(_accountModel);

            _sutModel = new ApprenticeshipIncentiveModel
            {
                Account              = new ApprenticeshipIncentives.ValueTypes.Account(_accountId, _accountLegalEntityId),
                StartDate            = startDate,
                PendingPaymentModels = new List <PendingPaymentModel>
                {
                    new PendingPaymentModel
                    {
                        Account = new ApprenticeshipIncentives.ValueTypes.Account(_accountId, _accountLegalEntityId),
                        DueDate = startDate.AddDays(90),
                        PendingPaymentValidationResultModels = new List <PendingPaymentValidationResultModel>
                        {
                            new PendingPaymentValidationResultModel {
                                CollectionPeriod = new CollectionPeriod(1, collectionYear), Result = false, Step = ValidationStep.HasBankDetails
                            },
                            new PendingPaymentValidationResultModel {
                                CollectionPeriod = new CollectionPeriod(2, collectionYear), Result = false, Step = ValidationStep.HasBankDetails
                            }
                        }
                    }
                }
            };

            _sut = ApprenticeshipIncentive.Get(_sutModel.Id, _sutModel);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _fixture.Build <PendingPaymentModel>().With(p => p.PendingPaymentValidationResultModels, new List <PendingPaymentValidationResultModel>()).Create();

            _sutModel = _fixture
                        .Build <ApprenticeshipIncentiveModel>()
                        .With(a => a.PendingPaymentModels, new List <PendingPaymentModel>()
            {
                _fixture.Build <PendingPaymentModel>().With(p => p.PendingPaymentValidationResultModels, new List <PendingPaymentValidationResultModel>()).Create()
            })
                        .With(a => a.PaymentModels, new List <PaymentModel>())
                        .Create();

            _mockCollectionCalendarService = new Mock <ICollectionCalendarService>();

            _sut = Sut(_sutModel);
        }
Пример #23
0
        public PausePaymentsSteps(TestContext testContext) : base(testContext)
        {
            _testContext      = testContext;
            _fixture          = new Fixture();
            _connectionString = _testContext.SqlDatabase.DatabaseInfo.ConnectionString;

            _application    = _fixture.Create <IncentiveApplication>();
            _apprenticeship = _fixture
                              .Build <IncentiveApplicationApprenticeship>()
                              .With(a => a.IncentiveApplicationId, _application.Id)
                              .Create();

            _apprenticeshipIncentive = _fixture
                                       .Build <ApprenticeshipIncentive>()
                                       .With(i => i.IncentiveApplicationApprenticeshipId, _apprenticeship.Id)
                                       .With(a => a.ULN, _apprenticeship.ULN)
                                       .With(a => a.AccountLegalEntityId, _application.AccountLegalEntityId)
                                       .With(i => i.PausePayments, false)
                                       .Create();
        }
        public ApprenticeshipIncentiveCreatedSteps(TestContext testContext) : base(testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();
            var today = new DateTime(2021, 6, 30);

            _accountModel = _fixture.Create <Account>();

            _applicationModel = _fixture.Build <IncentiveApplication>()
                                .With(p => p.Status, IncentiveApplicationStatus.InProgress)
                                .With(p => p.AccountId, _accountModel.Id)
                                .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                .Create();

            _apprenticeshipsModels = _fixture.Build <IncentiveApplicationApprenticeship>()
                                     .With(p => p.IncentiveApplicationId, _applicationModel.Id)
                                     .With(p => p.PlannedStartDate, today.AddMonths(-2))
                                     .With(p => p.DateOfBirth, today.AddYears(-20))
                                     .With(p => p.EarningsCalculated, false)
                                     .With(p => p.WithdrawnByCompliance, false)
                                     .With(p => p.WithdrawnByEmployer, false)
                                     .With(p => p.Phase, Phase.Phase1)
                                     .CreateMany(NumberOfApprenticeships).ToList();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.IncentiveApplicationApprenticeshipId, _apprenticeshipsModels.First().Id)
                                       .With(p => p.AccountId, _applicationModel.AccountId)
                                       .With(p => p.AccountLegalEntityId, _applicationModel.AccountLegalEntityId)
                                       .With(p => p.ApprenticeshipId, _apprenticeshipsModels.First().ApprenticeshipId)
                                       .With(p => p.StartDate, today.AddDays(1))
                                       .With(p => p.DateOfBirth, today.AddYears(-20))
                                       .With(p => p.Phase, Phase.Phase2)
                                       .Create();

            _pendingPayment = _fixture.Build <PendingPayment>()
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                              .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                              .Create();
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _collectionYear  = _fixture.Create <short>();
            _collectionMonth = _fixture.Create <byte>();

            _collectionPeriod = new CollectionPeriod(1, _collectionMonth, _collectionYear, DateTime.Now, DateTime.Now, _collectionYear, true);

            var startDate = DateTime.Now.Date;
            var dueDate   = startDate.AddDays(90).Date;

            _sutModel = _fixture
                        .Build <ApprenticeshipIncentiveModel>()
                        .With(a => a.StartDate, startDate)
                        .With(a => a.PendingPaymentModels, new List <PendingPaymentModel>()
            {
                _fixture.Build <PendingPaymentModel>()
                .With(p => p.DueDate, dueDate)
                .With(p => p.PendingPaymentValidationResultModels, new List <PendingPaymentValidationResultModel>()).Create()
            })
                        .Create();

            _sutModel.Apprenticeship.SetProvider(_fixture.Create <Provider>());

            _learnerModel = _fixture
                            .Build <LearnerModel>()
                            .With(l => l.DaysInLearnings, new List <DaysInLearning>()
            {
                new DaysInLearning(_collectionPeriod.PeriodNumber, _collectionPeriod.AcademicYear, 90)
            })
                            .Create();

            _learner = Learner.Get(_learnerModel);

            _sut = Sut(_sutModel);
        }
Пример #26
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>());

            _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.AcademicYear, _collectionPeriod.PeriodNumber);

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

            actualPayment.SubnominalCode.Should().Be(expectedSubnominalCode);
        }
Пример #27
0
        public LearningStoppedSteps(TestContext testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();

            _plannedStartDate = new DateTime(2020, 8, 1);
            _breakInLearning  = 15;
            _accountModel     = _fixture.Create <Account>();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.DateOfBirth, _plannedStartDate.AddYears(-24).AddMonths(-10)) // under 25
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .With(p => p.HasPossibleChangeOfCircumstances, false)
                                       .With(p => p.StartDate, new DateTime(2020, 11, 1))
                                       .With(p => p.Phase, Phase.Phase1)
                                       .Create();

            _pendingPayment = _fixture.Build <PendingPayment>()
                              .With(p => p.AccountId, _accountModel.Id)
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(p => p.DueDate, _plannedStartDate.AddMonths(1))
                              .With(p => p.ClawedBack, false)
                              .With(p => p.EarningType, EarningType.FirstPayment)
                              .Without(p => p.PaymentMadeDate)
                              .Create();

            _periodEndDate = DateTime.Today.AddDays(-10);

            _learner = _fixture
                       .Build <Learner>()
                       .With(p => p.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                       .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                       .With(p => p.ULN, _apprenticeshipIncentive.ULN)
                       .With(p => p.Ukprn, _apprenticeshipIncentive.UKPRN)
                       .With(p => p.LearningFound, true)
                       .With(p => p.StartDate, _plannedStartDate.AddDays(-10))
                       .Create();

            _learningPeriod1 = _fixture
                               .Build <LearningPeriod>()
                               .With(p => p.LearnerId, _learner.Id)
                               .With(p => p.StartDate, _plannedStartDate.AddDays(-20).AddDays(_breakInLearning * -1))
                               .With(p => p.EndDate, _plannedStartDate.AddDays(-10).AddDays(_breakInLearning * -1))
                               .Create();

            _stoppedLearnerMatchApiData = _fixture
                                          .Build <LearnerSubmissionDto>()
                                          .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                          .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                          .With(l => l.Training, new List <TrainingDto> {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _plannedStartDate)
                    .With(pe => pe.EndDate, _periodEndDate)
                    .Create()
                }
                      )
                .Create()
            }
                                                )
                                          .Create();

            _resumedLearnerMatchApiData = _fixture
                                          .Build <LearnerSubmissionDto>()
                                          .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                          .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                          .With(l => l.Training, new List <TrainingDto> {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _plannedStartDate)
                    .With(pe => pe.EndDate, DateTime.Today.AddDays(10))
                    .Create()
                }
                      )
                .Create()
            }
                                                )
                                          .Create();

            _resumedLearnerWithBreakInLearningMatchApiData = _fixture
                                                             .Build <LearnerSubmissionDto>()
                                                             .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                                             .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                                             .With(l => l.Training, new List <TrainingDto> {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _plannedStartDate)
                    .With(pe => pe.EndDate, DateTime.Today.AddDays(_breakInLearning * -1))
                    .Create(),
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, DateTime.Today)
                    .With(pe => pe.EndDate, DateTime.Today.AddDays(10))
                    .Create()
                }
                      )
                .Create()
            }
                                                                   )
                                                             .Create();

            _apprenticeshipBreakInLearning = _fixture
                                             .Build <ApprenticeshipBreakInLearning>()
                                             .With(b => b.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                                             .With(b => b.StartDate, _plannedStartDate.AddDays(_breakInLearning * -1))
                                             .With(b => b.EndDate, (DateTime?)null)
                                             .Create();

            _resumedLearnerWithIncorrectlyRecordedBreakInLearningMatchApiData = _fixture
                                                                                .Build <LearnerSubmissionDto>()
                                                                                .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                                                                .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                                                                .With(l => l.Training, new List <TrainingDto>
            {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId,
                              _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _apprenticeshipBreakInLearning.StartDate)
                    .With(pe => pe.EndDate, DateTime.Today.AddMonths(12))
                    .Create(),
                }
                      )
                .Create()
            }
                                                                                      )
                                                                                .Create();
        }
Пример #28
0
 private ApprenticeshipIncentive Sut(ApprenticeshipIncentiveModel model)
 {
     return(ApprenticeshipIncentive.Get(model.Id, model));
 }
Пример #29
0
        public LearningResumedSteps(TestContext testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();

            _plannedStartDate = new DateTime(2020, 11, 10);
            _breakInLearning  = 15;
            _accountModel     = _fixture.Create <Account>();
            _periodNumber     = 1;

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.DateOfBirth, new DateTime(1995, 10, 15)) // under 25
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .With(p => p.HasPossibleChangeOfCircumstances, false)
                                       .With(p => p.StartDate, _plannedStartDate)
                                       .With(p => p.RefreshedLearnerForEarnings, true)
                                       .With(p => p.PausePayments, false)
                                       .With(p => p.Status, IncentiveStatus.Stopped)
                                       .With(p => p.BreakInLearnings, new List <ApprenticeshipBreakInLearning>())
                                       .With(p => p.Phase, Phase.Phase1)
                                       .Create();

            _apprenticeshipBreakInLearning = _fixture
                                             .Build <ApprenticeshipBreakInLearning>()
                                             .With(b => b.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                                             .With(b => b.StartDate, new DateTime(2021, 02, 08))
                                             .With(b => b.EndDate, (DateTime?)null)
                                             .Create();

            _pendingPayment = _fixture.Build <PendingPayment>()
                              .With(p => p.AccountId, _accountModel.Id)
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(p => p.DueDate, new DateTime(2021, 02, 07))
                              .With(p => p.ClawedBack, false)
                              .With(p => p.EarningType, EarningType.FirstPayment)
                              .With(p => p.PaymentYear, (short)2021)
                              .With(p => p.PeriodNumber, (byte)7)
                              .With(p => p.Amount, 750)
                              .Without(p => p.PaymentMadeDate)
                              .Create();

            _payment = _fixture.Build <Payment>()
                       .With(d => d.PendingPaymentId, _pendingPayment.Id)
                       .With(d => d.AccountId, _accountModel.Id)
                       .With(d => d.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                       .With(d => d.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                       .With(d => d.PaymentPeriod, _pendingPayment.PeriodNumber)
                       .With(d => d.PaymentYear, _pendingPayment.PaymentYear)
                       .With(d => d.PaidDate, _pendingPayment.DueDate)
                       .With(d => d.Amount, _pendingPayment.Amount)
                       .Create();

            _clawbackPayment = _fixture.Build <ClawbackPayment>()
                               .With(d => d.PendingPaymentId, _pendingPayment.Id)
                               .With(d => d.PaymentId, _payment.Id)
                               .With(d => d.DateClawbackSent, _pendingPayment.DueDate.AddDays(5))
                               .With(d => d.AccountId, _accountModel.Id)
                               .With(d => d.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                               .With(d => d.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                               .With(d => d.CollectionPeriod, _pendingPayment.PeriodNumber)
                               .With(d => d.CollectionPeriodYear, _pendingPayment.PaymentYear)
                               .Create();
        }
Пример #30
0
 public ApprenticeshipIncentive Build()
 {
     return(ApprenticeshipIncentive.Get(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel));
 }