public void SetPaymentPeriod(CollectionCalendar collectionCalendar) { var period = collectionCalendar.GetPeriod(DueDate); Model.PeriodNumber = period.PeriodNumber; Model.PaymentYear = period.AcademicYear; }
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); }
public async Task <GetActiveCollectionPeriodResponse> Handle(GetActiveCollectionPeriodRequest query, CancellationToken cancellationToken = default) { var activePeriod = new CollectionCalendar(await _queryRepository.GetAll()).GetActivePeriod(); return(new GetActiveCollectionPeriodResponse(new Abstractions.DTOs.Queries.ApprenticeshipIncentives.CollectionPeriodDto() { CollectionPeriodNumber = activePeriod.PeriodNumber, CollectionYear = activePeriod.AcademicYear })); }
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); }
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(); testDate = DateTime.Now; var period1 = new CollectionCalendarPeriod(new CollectionPeriod(1, _fixture.Create <short>()), (byte)testDate.AddMonths(13).Month, (short)testDate.AddMonths(13).Year, testDate.AddMonths(13), _fixture.Create <DateTime>(), false, false); var period2 = new CollectionCalendarPeriod(new CollectionPeriod(2, _fixture.Create <short>()), (byte)testDate.Month, (short)testDate.Year, testDate, _fixture.Create <DateTime>(), false, false); var period3 = new CollectionCalendarPeriod(new CollectionPeriod(3, _fixture.Create <short>()), (byte)testDate.AddMonths(-13).Month, (short)testDate.AddMonths(-13).Year, testDate.AddMonths(-13), _fixture.Create <DateTime>(), false, false); _collectionPeriods = new List <CollectionCalendarPeriod>() { period1, period2, period3 }; _sut = new CollectionCalendar(_collectionPeriods); }
public void SetPaymentPeriod(CollectionCalendar collectionCalendar) { Model.CollectionPeriod = collectionCalendar.GetPeriod(DueDate)?.CollectionPeriod; }
private void AddPendingPaymentsAndClawbackWhereRequired(ValueObjects.Payment payment, CollectionCalendar collectionCalendar) { var pendingPayment = PendingPayment.New( Guid.NewGuid(), Model.Account, Model.Id, payment.Amount, payment.PaymentDate, DateTime.Now, payment.EarningType); pendingPayment.SetPaymentPeriod(collectionCalendar); var existingPendingPayment = PendingPayments.SingleOrDefault(x => x.EarningType == pendingPayment.EarningType && !x.ClawedBack); if (existingPendingPayment == null) { Model.PendingPaymentModels.Add(pendingPayment.GetModel()); return; } if (ExistingPendingPaymentHasBeenPaid(existingPendingPayment)) { if (!existingPendingPayment.RequiresNewPayment(pendingPayment)) { return; } AddClawback(existingPendingPayment, collectionCalendar.GetActivePeriod()); Model.PendingPaymentModels.Add(pendingPayment.GetModel()); return; } RemoveUnpaidPaymentIfExists(existingPendingPayment); if (!existingPendingPayment.Equals(pendingPayment)) { var existingPendingPaymentModel = existingPendingPayment.GetModel(); if (Model.PendingPaymentModels.Remove(existingPendingPaymentModel)) { AddEvent(new PendingPaymentDeleted(Model.Account.Id, Model.Account.AccountLegalEntityId, Model.Apprenticeship.UniqueLearnerNumber, existingPendingPaymentModel)); } Model.PendingPaymentModels.Add(pendingPayment.GetModel()); } }