Ejemplo n.º 1
0
 public void Arrange()
 {
     _sut     = new ApprenticeshipIncentiveFactory();
     _fixture = new Fixture();
     _id      = _fixture.Create <Guid>();
     _model   = _fixture.Create <ApprenticeshipIncentiveModel>();
 }
Ejemplo n.º 2
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 void Arrange()
        {
            _fixture = new Fixture();

            var collectionPeriods = new List <CollectionCalendarPeriod>()
            {
                new CollectionCalendarPeriod(new CollectionPeriod(1, _fixture.Create <short>()), _fixture.Create <byte>(), _fixture.Create <short>(), _fixture.Create <DateTime>(), _fixture.Create <DateTime>(), true, false),
            };
            var collectionCalendar = new CollectionCalendar(collectionPeriods);

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

            _sutModel = _fixture.Build <ApprenticeshipIncentiveModel>().With(x => x.Status, IncentiveStatus.Active).Create();
            _sutModel.PendingPaymentModels = new List <PendingPaymentModel>();
            _sutModel.PendingPaymentModels.Add(_fixture.Build <PendingPaymentModel>().With(x => x.DueDate, new DateTime(2021, 1, 1)).With(x => x.ClawedBack, false).With(x => x.PaymentMadeDate, (DateTime?)null).Create());
            _sutModel.PendingPaymentModels.Add(_fixture.Build <PendingPaymentModel>().With(x => x.DueDate, new DateTime(2021, 2, 28)).With(x => x.ClawedBack, false).With(x => x.PaymentMadeDate, (DateTime?)null).Create());
            _sutModel.PaymentModels         = new List <PaymentModel>();
            _sutModel.ClawbackPaymentModels = new List <ClawbackPaymentModel>();
            _sut = Sut(_sutModel);

            var learningData = new LearningData(true);

            learningData.SetIsStopped(new LearningStoppedStatus(true, _sutModel.PendingPaymentModels.Last().DueDate.AddDays(-1)));
            var submissionData = new SubmissionData();

            submissionData.SetSubmissionDate(DateTime.Now);
            submissionData.SetLearningData(learningData);
            _learner = Learner.New(_fixture.Create <Guid>(), _sutModel.Id, _fixture.Create <long>(), _fixture.Create <long>(), _fixture.Create <long>());
            _learner.SetSubmissionData(submissionData);
        }
        private void AddUpdateAndRemovePendingPaymentsAndValidationResults(ApprenticeshipIncentiveModel expected)
        {
            expected.PendingPaymentModels.First().PendingPaymentValidationResultModels.First().Result
                = !expected.PendingPaymentModels.First().PendingPaymentValidationResultModels.First().Result;
            expected.PendingPaymentModels.First().Amount -= 250;
            expected.PaymentModels.First().Amount        -= 250;
            var newPendingPayment = _fixture.Build <PendingPaymentModel>()
                                    .With(x => x.ApprenticeshipIncentiveId, expected.Id)
                                    .With(x => x.PaymentYear, _collectionPeriod.PeriodNumber)
                                    .With(x => x.PeriodNumber, _collectionPeriod.PeriodNumber)
                                    .Without(x => x.PendingPaymentValidationResultModels)
                                    .Create();

            var cp = new CollectionPeriod(_collectionPeriod.PeriodNumber, _collectionPeriod.CalendarMonth,
                                          _collectionPeriod.CalendarYear,
                                          _collectionPeriod.EIScheduledOpenDateUTC, _collectionPeriod.CensusDate,
                                          Convert.ToInt16(_collectionPeriod.AcademicYear), true);

            expected.PendingPaymentModels.Last().PendingPaymentValidationResultModels
            .Remove(expected.PendingPaymentModels.Last().PendingPaymentValidationResultModels.First());
            expected.PendingPaymentModels.Last().PendingPaymentValidationResultModels.Add(
                _fixture.Build <PendingPaymentValidationResultModel>()
                .With(x => x.CollectionPeriod, cp)
                .Create()
                );

            newPendingPayment.PendingPaymentValidationResultModels.Add(
                _fixture.Build <PendingPaymentValidationResultModel>()
                .With(x => x.CollectionPeriod, cp)
                .Create()
                );

            expected.PendingPaymentModels.Add(newPendingPayment);
        }
Ejemplo n.º 5
0
        private void AddUpdateAndRemovePendingPaymentsAndValidationResults(ApprenticeshipIncentiveModel expected)
        {
            expected.PendingPaymentModels.First().PendingPaymentValidationResultModels.First().Result
                = !expected.PendingPaymentModels.First().PendingPaymentValidationResultModels.First().Result;
            expected.PendingPaymentModels.First().Amount -= 250;
            expected.PaymentModels.First().Amount        -= 250;
            var newPendingPayment = _fixture.Build <PendingPaymentModel>()
                                    .With(x => x.ApprenticeshipIncentiveId, expected.Id)
                                    .With(x => x.CollectionPeriod, new Domain.ValueObjects.CollectionPeriod(_collectionCalendarPeriod.PeriodNumber, Convert.ToInt16(_collectionCalendarPeriod.AcademicYear)))
                                    .Without(x => x.PendingPaymentValidationResultModels)
                                    .Create();

            var cp = new Domain.ValueObjects.CollectionPeriod(_collectionCalendarPeriod.PeriodNumber, Convert.ToInt16(_collectionCalendarPeriod.AcademicYear));

            expected.PendingPaymentModels.Last().PendingPaymentValidationResultModels
            .Remove(expected.PendingPaymentModels.Last().PendingPaymentValidationResultModels.First());
            expected.PendingPaymentModels.Last().PendingPaymentValidationResultModels.Add(
                _fixture.Build <PendingPaymentValidationResultModel>()
                .With(x => x.CollectionPeriod, cp)
                .Create()
                );

            newPendingPayment.PendingPaymentValidationResultModels.Add(
                _fixture.Build <PendingPaymentValidationResultModel>()
                .With(x => x.CollectionPeriod, cp)
                .Create()
                );

            expected.PendingPaymentModels.Add(newPendingPayment);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _sut = _fixture.Create <LearnerSubmissionDto>();

            _apprenticeshipIncentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                                            .With(p => p.Apprenticeship, _fixture.Create <Apprenticeship>())
                                            .Create();

            _incentive = new ApprenticeshipIncentiveFactory().GetExisting(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel);

            _testTrainingDto           = _sut.Training.First();
            _testTrainingDto.Reference = "ZPROG001";

            _testTrainingDto.PriceEpisodes.Clear();

            _testPriceEpisode1Dto = _fixture.Create <PriceEpisodeDto>();
            _testPriceEpisode1Dto.Periods.First().ApprenticeshipId = _apprenticeshipIncentiveModel.Apprenticeship.Id;
            _testTrainingDto.PriceEpisodes.Add(_testPriceEpisode1Dto);

            _testPriceEpisode2Dto         = _fixture.Create <PriceEpisodeDto>();
            _testPriceEpisode2Dto.EndDate = null;
            // probbaly not valid data but add multiple apprenticeship periods by price episode just in case
            _testPriceEpisode2Dto.Periods.ToList().ForEach(p => p.ApprenticeshipId = _apprenticeshipIncentiveModel.Apprenticeship.Id);
            _testTrainingDto.PriceEpisodes.Add(_testPriceEpisode2Dto);

            _testTrainingDto.PriceEpisodes.Add(_fixture.Create <PriceEpisodeDto>()); // non matching

            _testPriceEpisode3Dto           = _fixture.Create <PriceEpisodeDto>();   // duplicate
            _testPriceEpisode3Dto.StartDate = _testPriceEpisode1Dto.StartDate;
            _testPriceEpisode3Dto.EndDate   = _testPriceEpisode1Dto.EndDate;
            _testPriceEpisode3Dto.Periods.First().ApprenticeshipId = _apprenticeshipIncentiveModel.Apprenticeship.Id;
            _testTrainingDto.PriceEpisodes.Add(_testPriceEpisode3Dto);
        }
Ejemplo n.º 7
0
        public void Arrange()
        {
            _fixture = new Fixture();

            _startDate = DateTime.Now;
            var dueDate = _startDate.AddMonths(1);

            var pendingPaymentModel = _fixture
                                      .Build <PendingPaymentModel>()
                                      .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                                      .With(p => p.DueDate, dueDate)
                                      .Create();

            _apprenticeshipIncentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                                            .With(p => p.Apprenticeship, _fixture.Create <Apprenticeship>())
                                            .With(p => p.PendingPaymentModels, new List <PendingPaymentModel> {
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, dueDate.AddMonths(1))
                .With(pp => pp.PaymentYear, (short?)null)
                .Create(),
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, dueDate.AddMonths(2))
                .With(pp => pp.PaymentYear, (short?)null)
                .Create(),
                pendingPaymentModel
            })
                                            .Create();

            _incentive = new ApprenticeshipIncentiveFactory().GetExisting(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel);
        }
 internal static ApprenticeshipIncentive Map(this ApprenticeshipIncentiveModel model)
 {
     return(new ApprenticeshipIncentive
     {
         Id = model.Id,
         AccountId = model.Account.Id,
         ApprenticeshipId = model.Apprenticeship.Id,
         FirstName = model.Apprenticeship.FirstName,
         LastName = model.Apprenticeship.LastName,
         DateOfBirth = model.Apprenticeship.DateOfBirth,
         ULN = model.Apprenticeship.UniqueLearnerNumber,
         UKPRN = model.Apprenticeship.Provider?.Ukprn,
         EmployerType = model.Apprenticeship.EmployerType,
         StartDate = model.StartDate,
         IncentiveApplicationApprenticeshipId = model.ApplicationApprenticeshipId,
         PendingPayments = model.PendingPaymentModels.Map(),
         Payments = model.PaymentModels.Map(),
         ClawbackPayments = model.ClawbackPaymentModels.Map(),
         RefreshedLearnerForEarnings = model.RefreshedLearnerForEarnings,
         HasPossibleChangeOfCircumstances = model.HasPossibleChangeOfCircumstances,
         AccountLegalEntityId = model.Account.AccountLegalEntityId,
         PausePayments = model.PausePayments,
         SubmittedDate = model.SubmittedDate,
         SubmittedByEmail = model.SubmittedByEmail,
         CourseName = model.Apprenticeship.CourseName,
         Status = model.Status
     });
 }
Ejemplo n.º 9
0
        public void Arrange()
        {
            _fixture = new Fixture();

            _collectionYear = _fixture.Create <short>();

            _collectionPeriod = new CollectionPeriod(1, _collectionYear);

            _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 submisssionData = new SubmissionData();

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

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

            _sut          = _fixture.Create <LearnerSubmissionDto>();
            _startDate    = DateTime.Now.AddMonths(-1);
            _endDate      = DateTime.Today.AddDays(-1);
            _periodNumber = 3;

            _apprenticeshipIncentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                                            .With(p => p.Apprenticeship, _fixture.Create <Apprenticeship>())
                                            .Create();
            _incentive = new ApprenticeshipIncentiveFactory().GetExisting(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel);

            _testTrainingDto           = _sut.Training.First();
            _testTrainingDto.Reference = "ZPROG001";

            _testPriceEpisodeDto           = _testTrainingDto.PriceEpisodes.First();
            _testPriceEpisodeDto.StartDate = _startDate;
            _testPriceEpisodeDto.EndDate   = _endDate;

            _testPeriodDto = _testPriceEpisodeDto.Periods.First();

            _testPeriodDto.ApprenticeshipId = _apprenticeshipIncentiveModel.Apprenticeship.Id;
            _testPeriodDto.Period           = _periodNumber;
            _testPeriodDto.IsPayable        = true;
        }
        public void Arrange()
        {
            _fixture = new Fixture();

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

            _sut = Sut(_sutModel);
        }
        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);
        }
Ejemplo n.º 14
0
        public async Task Update(ApprenticeshipIncentiveModel apprenticeshipIncentive)
        {
            var updatedIncentive = apprenticeshipIncentive.Map();

            var existingIncentive = await _dbContext.ApprenticeshipIncentives.FirstOrDefaultAsync(x => x.Id == updatedIncentive.Id);

            if (existingIncentive != null)
            {
                UpdateApprenticeshipIncentive(updatedIncentive, existingIncentive);
            }
        }
Ejemplo n.º 15
0
 public StartDateChanged(
     Guid apprenticeshipIncentiveId,
     DateTime previousStartDate,
     DateTime newStartDate,
     ApprenticeshipIncentiveModel model)
 {
     ApprenticeshipIncentiveId = apprenticeshipIncentiveId;
     PreviousStartDate         = previousStartDate;
     NewStartDate = newStartDate;
     Model        = model;
 }
Ejemplo n.º 16
0
 public PaymentsPaused(
     long accountId,
     long accountLegalEntityId,
     ApprenticeshipIncentiveModel model,
     ServiceRequest serviceRequest)
 {
     AccountLegalEntityId = accountLegalEntityId;
     AccountId            = accountId;
     Model          = model;
     ServiceRequest = serviceRequest;
 }
        public void Arrange()
        {
            _fixture = new Fixture();

            _mockIncentiveDomainRepository = new Mock <IApprenticeshipIncentiveDomainRepository>();
            _mockLearnerDomainRepository   = new Mock <ILearnerDomainRepository>();

            var collectionPeriods = new List <CollectionCalendarPeriod>()
            {
                new CollectionCalendarPeriod(new Domain.ValueObjects.CollectionPeriod(1, _fixture.Create <short>()), _fixture.Create <byte>(), _fixture.Create <short>(), _fixture.Create <DateTime>(), _fixture.Create <DateTime>(), true, false),
            };
            var collectionCalendar = new Domain.ValueObjects.CollectionCalendar(collectionPeriods);

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

            _incentiveModel = _fixture
                              .Build <ApprenticeshipIncentiveModel>()
                              .With(p => p.Apprenticeship,
                                    new Apprenticeship(
                                        _fixture.Create <long>(),
                                        _fixture.Create <string>(),
                                        _fixture.Create <string>(),
                                        DateTime.Today.AddYears(-26),
                                        _fixture.Create <long>(),
                                        ApprenticeshipEmployerType.Levy,
                                        _fixture.Create <string>(),
                                        _fixture.Create <DateTime>()
                                        ))
                              .With(p => p.StartDate, DateTime.Today)
                              .With(p => p.Status, Enums.IncentiveStatus.Active)
                              .With(p => p.HasPossibleChangeOfCircumstances, true)
                              .With(p => p.Phase, new IncentivePhase(Phase.Phase1))
                              .With(p => p.MinimumAgreementVersion, new AgreementVersion(_fixture.Create <int>()))
                              .With(p => p.PendingPaymentModels, new List <PendingPaymentModel>())
                              .Create();
            _incentiveModel.Apprenticeship.SetProvider(_fixture.Create <Provider>());
            _incentiveModel.HasPossibleChangeOfCircumstances = true;
            var incentive = new ApprenticeshipIncentiveFactory().GetExisting(_incentiveModel.Id, _incentiveModel);

            _fixture.Register(() => incentive);

            _sut = new LearnerChangeOfCircumstanceCommandHandler(_mockIncentiveDomainRepository.Object, _mockLearnerDomainRepository.Object, _mockCollectionCalendarService.Object);

            _incentive = _fixture.Create <Domain.ApprenticeshipIncentives.ApprenticeshipIncentive>();
            _learner   = new LearnerFactory().GetExisting(
                _fixture.Build <LearnerModel>()
                .With(x => x.SubmissionData, _fixture.Create <SubmissionData>())
                .With(x => x.ApprenticeshipIncentiveId, _incentive.Id)
                .Create());

            _mockIncentiveDomainRepository.Setup(x => x.Find(incentive.Id)).ReturnsAsync(_incentive);
            _mockLearnerDomainRepository.Setup(m => m.GetOrCreate(incentive)).ReturnsAsync(_learner);
        }
Ejemplo n.º 18
0
 public MinimumAgreementVersionChanged(
     Guid apprenticeshipIncentiveId,
     int?previousAgreementVersion,
     int newAgreementVersion,
     ApprenticeshipIncentiveModel model)
 {
     ApprenticeshipIncentiveId = apprenticeshipIncentiveId;
     PreviousAgreementVersion  = previousAgreementVersion;
     NewAgreementVersion       = newAgreementVersion;
     Model = model;
 }
Ejemplo n.º 19
0
        public void Arrange()
        {
            _fixture = new Fixture();

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

            _firstPaymentDaysAfterApprenticeshipStart  = 10;
            _secondPaymentDaysAfterApprenticeshipStart = 50;

            _paymentProfiles = new IncentivePaymentProfileListBuilder()
                               .WithIncentivePaymentProfiles(
                new List <IncentivePaymentProfile>()
            {
                new IncentivePaymentProfile(
                    new IncentivePhase(Phase.Phase2),
                    new List <PaymentProfile>
                {
                    new PaymentProfile(IncentiveType.UnderTwentyFiveIncentive, _firstPaymentDaysAfterApprenticeshipStart, 100),
                    new PaymentProfile(IncentiveType.UnderTwentyFiveIncentive, _secondPaymentDaysAfterApprenticeshipStart, 300),
                    new PaymentProfile(IncentiveType.TwentyFiveOrOverIncentive, _firstPaymentDaysAfterApprenticeshipStart, 200),
                    new PaymentProfile(IncentiveType.TwentyFiveOrOverIncentive, _secondPaymentDaysAfterApprenticeshipStart, 400)
                }
                    )
            })
                               .Build();

            _collectionPeriods = new List <CollectionCalendarPeriod>()
            {
                new CollectionCalendarPeriod(new CollectionPeriod(1, _fixture.Create <short>()), (byte)_collectionPeriod.AddMonths(-1).Month, (short)_collectionPeriod.AddMonths(-1).Year, _collectionPeriod.AddMonths(-1).AddDays(1), _fixture.Create <DateTime>(), false, false),
                new CollectionCalendarPeriod(new CollectionPeriod(2, _fixture.Create <short>()), (byte)_collectionPeriod.AddMonths(1).Month, (short)_collectionPeriod.AddMonths(1).Year, _collectionPeriod.AddMonths(1).AddDays(1), _fixture.Create <DateTime>(), false, false),
                new CollectionCalendarPeriod(new CollectionPeriod(3, _fixture.Create <short>()), (byte)_collectionPeriod.AddMonths(2).Month, (short)_collectionPeriod.AddMonths(2).Year, _collectionPeriod.AddMonths(2).AddDays(1), _fixture.Create <DateTime>(), false, 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.Build <ApprenticeshipIncentiveModel>()
                        .With(x => x.Status, IncentiveStatus.Active)
                        .With(x => x.Phase, new IncentivePhase(Phase.Phase2))
                        .Create();
            _apprenticehip                  = _sutModel.Apprenticeship;
            _sutModel.StartDate             = _plannedStartDate;
            _sutModel.PendingPaymentModels  = new List <PendingPaymentModel>();
            _sutModel.PaymentModels         = new List <PaymentModel>();
            _sutModel.ClawbackPaymentModels = new List <ClawbackPaymentModel>();
            _sut = Sut(_sutModel);
        }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
        public void Arrange()
        {
            _fixture = new Fixture();

            _dueDate = DateTime.Now.AddMonths(-1);
            short paymentYear = (short)DateTime.Now.Year;

            _periodNumber = _fixture.Create <byte>();

            _nextPendingPaymentDue = _fixture.Build <PendingPaymentModel>()
                                     .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                                     .With(pp => pp.PaymentYear, paymentYear)
                                     .With(pp => pp.PeriodNumber, _periodNumber)
                                     .With(pp => pp.DueDate, _dueDate)// earliest
                                     .Create();

            _apprenticeshipIncentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                                            .With(a => a.PendingPaymentModels, new List <PendingPaymentModel>()
            {
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, _dueDate.AddMonths(1))
                .With(pp => pp.PaymentYear, (short?)null)
                .Create(),
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, _dueDate.AddMonths(2))
                .With(pp => pp.PaymentYear, (short?)null)
                .Create(),
                _nextPendingPaymentDue
            })
                                            .Create();

            _incentive = new ApprenticeshipIncentiveFactory().GetExisting(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel);

            _sut       = _fixture.Create <LearnerSubmissionDto>();
            _startTime = _dueDate.AddDays(-10);

            _testTrainingDto           = _sut.Training.First();
            _testTrainingDto.Reference = "ZPROG001";

            _testPriceEpisodeDto           = _testTrainingDto.PriceEpisodes.First();
            _testPriceEpisodeDto.StartDate = _startTime;
            _testPriceEpisodeDto.EndDate   = _dueDate.AddDays(10);

            _testPeriodDto = _testPriceEpisodeDto.Periods.First();

            _testPeriodDto.ApprenticeshipId = _incentive.Apprenticeship.Id;
            _testPeriodDto.IsPayable        = false;
            _testPeriodDto.Period           = _periodNumber;
        }
        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);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _sut          = _fixture.Create <LearnerSubmissionDto>();
            _startDate    = DateTime.Now;
            _endDate      = _startDate.AddMonths(2);
            _periodNumber = 3;
            var dueDate = _startDate.AddMonths(1);

            var pendingPaymentModel = _fixture
                                      .Build <PendingPaymentModel>()
                                      .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                                      .With(p => p.DueDate, dueDate)
                                      .Create();

            _apprenticeshipIncentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                                            .With(p => p.Apprenticeship, _fixture.Create <Apprenticeship>())
                                            .With(p => p.PendingPaymentModels, new List <PendingPaymentModel> {
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, dueDate.AddMonths(1))
                .With(pp => pp.CollectionPeriod, (Domain.ValueObjects.CollectionPeriod)null)
                .Create(),
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, dueDate.AddMonths(2))
                .With(pp => pp.CollectionPeriod, (Domain.ValueObjects.CollectionPeriod)null)
                .Create(),
                pendingPaymentModel
            })
                                            .Create();

            _incentive      = new ApprenticeshipIncentiveFactory().GetExisting(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel);
            _pendingPayment = _incentive.PendingPayments.Single(p => p.Id == pendingPaymentModel.Id);

            _testTrainingDto           = _sut.Training.First();
            _testTrainingDto.Reference = "ZPROG001";

            _testPriceEpisodeDto           = _testTrainingDto.PriceEpisodes.First();
            _testPriceEpisodeDto.StartDate = _startDate;
            _testPriceEpisodeDto.EndDate   = _endDate;

            _testPeriodDto = _testPriceEpisodeDto.Periods.First();

            _testPeriodDto.ApprenticeshipId = _apprenticeshipIncentiveModel.Apprenticeship.Id;
            _testPeriodDto.Period           = _periodNumber;
            _testPeriodDto.IsPayable        = true;
        }
Ejemplo n.º 24
0
        public async Task Delete(ApprenticeshipIncentiveModel apprenticeshipIncentive)
        {
            var deletedIncentive = apprenticeshipIncentive.Map();

            var existingIncentive = await _dbContext.ApprenticeshipIncentives.FirstOrDefaultAsync(x => x.Id == deletedIncentive.Id);

            foreach (var pendingPayment in existingIncentive.PendingPayments)
            {
                foreach (var validationResult in pendingPayment.ValidationResults)
                {
                    _dbContext.Remove(validationResult);
                }
                _dbContext.Remove(pendingPayment);
            }
        }
        public void Arrange()
        {
            _fixture       = new Fixture();
            _testStartDate = _fixture.Create <DateTime>();
            _censusDate    = _testStartDate.AddDays(5);

            _mockApprenticeshipIncentiveDomainRepository = new Mock <IApprenticeshipIncentiveDomainRepository>();
            _mockLearnerDomainRepository = new Mock <ILearnerDomainRepository>();
            _mockLearnerService          = new Mock <ILearnerService>();
            _mockLogger = new Mock <ILogger <RefreshLearnerCommandHandler> >();

            var apprenticeship = _fixture.Create <Apprenticeship>();

            apprenticeship.SetProvider(_fixture.Create <Provider>());

            _incentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                              .With(p => p.Apprenticeship, apprenticeship)
                              .Create();

            _apprenticeshipIncentiveId = _incentiveModel.Id;
            _apprenticeshipIncentive   = new ApprenticeshipIncentiveFactory().GetExisting(_incentiveModel.Id, _incentiveModel);

            _mockApprenticeshipIncentiveDomainRepository
            .Setup(m => m.Find(_apprenticeshipIncentiveId))
            .ReturnsAsync(_apprenticeshipIncentive);

            _learnerSubmissionDto = _fixture.Create <LearnerSubmissionDto>();

            _mockLearnerService
            .Setup(m => m.Get(It.IsAny <Learner>()))
            .ReturnsAsync(_learnerSubmissionDto);

            _mockApprenticeshipIncentiveDomainRepository
            .Setup(m => m.Find(_apprenticeshipIncentiveId))
            .ReturnsAsync(_apprenticeshipIncentive);

            _learner = new LearnerFactory().GetExisting(_fixture.Create <LearnerModel>());

            _mockLearnerDomainRepository
            .Setup(m => m.GetOrCreate(_apprenticeshipIncentive))
            .ReturnsAsync(_learner);

            _sut = new RefreshLearnerCommandHandler(
                _mockLogger.Object,
                _mockApprenticeshipIncentiveDomainRepository.Object,
                _mockLearnerService.Object,
                _mockLearnerDomainRepository.Object);
        }
        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);
        }
        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);
        }
Ejemplo n.º 29
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);
        }
Ejemplo n.º 30
0
 private ApprenticeshipIncentive Sut(ApprenticeshipIncentiveModel model)
 {
     return(ApprenticeshipIncentive.Get(model.Id, model));
 }