public async Task ArrangeAsync()
        {
            var today = new DateTime(2021, 1, 30);

            _fixture = new Fixture();

            _collectionPeriods = new List <Domain.ValueObjects.CollectionCalendarPeriod>()
            {
                new CollectionCalendarPeriod(
                    new Domain.ValueObjects.CollectionPeriod(1, (short)today.Year),
                    (byte)today.Month,
                    (short)today.Year,
                    today.AddDays(-1),
                    today.AddDays(-1),
                    false,
                    false),
                new CollectionCalendarPeriod(
                    new Domain.ValueObjects.CollectionPeriod(1, (short)today.AddMonths(1).Year),
                    (byte)today.AddMonths(1).Month,
                    (short)today.AddMonths(1).Year,
                    today.AddMonths(1).AddDays(-1),
                    today.AddMonths(1).AddDays(-1),
                    false,
                    false)
            };
            _firstCollectionPeriod = _collectionPeriods.First().CollectionPeriod;

            _mockIncentiveDomainRespository      = new Mock <IApprenticeshipIncentiveDomainRepository>();
            _mockCollectionCalendarService       = new Mock <ICollectionCalendarService>();
            _mockIncentivePaymentProfilesService = new Mock <IIncentivePaymentProfilesService>();

            _incentive = await ApprenticeshipIncentiveCreator();

            _sut = new CreatePaymentCommandHandler(_mockIncentiveDomainRespository.Object);
        }
        public async Task Handle(UpdateCollectionPeriodCommand command, CancellationToken cancellationToken = default)
        {
            var collectionCalendar = await _collectionCalendarService.Get();

            var collectionPeriod = new Domain.ValueObjects.CollectionPeriod(command.PeriodNumber, command.AcademicYear);

            if (command.Active)
            {
                collectionCalendar.SetActive(collectionPeriod);

                await _collectionCalendarService.Save(collectionCalendar);
            }
        }
        private static Domain.ValueObjects.CollectionPeriod Map(this CollectionCalendarPeriod model)
        {
            if (model != null)
            {
                var period = new Domain.ValueObjects.CollectionPeriod(
                    model.PeriodNumber,
                    Convert.ToInt16(model.AcademicYear));

                return(period);
            }

            return(null);
        }
        private static DateTime?PaymentDate(
            PendingPayment pendingPayment,
            Payment payment,
            Domain.ValueObjects.CollectionPeriod nextActivePeriod)
        {
            if (payment != null)
            {
                if (payment.PaidDate != null)
                {
                    return(payment.PaidDate.Value);
                }
                return(payment.CalculatedDate);
            }

            var activePeriodDate = new DateTime(nextActivePeriod.OpenDate.Year, nextActivePeriod.OpenDate.Month, nextActivePeriod.OpenDate.Day);
            var paymentDueDate   = new DateTime(pendingPayment.DueDate.Year, pendingPayment.DueDate.Month, pendingPayment.DueDate.Day);

            if (paymentDueDate < activePeriodDate)
            {
                return(new DateTime(nextActivePeriod.CalendarYear, nextActivePeriod.CalendarMonth, 27));
            }
            return(pendingPayment.DueDate.AddMonths(1));
        }
Exemplo n.º 5
0
        public void Arrange()
        {
            _fixture = new Fixture();

            _mockIncentiveDomainRepository = new Mock <IApprenticeshipIncentiveDomainRepository>();
            _mockCollectionCalendarService = new Mock <ICollectionCalendarService>();

            _activePeriod = new Domain.ValueObjects.CollectionPeriod(2, 2020);
            _activePeriod.SetActive(true);

            var collectionPeriods = new List <Domain.ValueObjects.CollectionPeriod>()
            {
                new Domain.ValueObjects.CollectionPeriod(1, 2020),
                _activePeriod,
                new Domain.ValueObjects.CollectionPeriod(3, 2020)
            };

            _mockCollectionCalendarService.Setup(m => m.Get()).ReturnsAsync(new Domain.ValueObjects.CollectionCalendar(collectionPeriods));

            _fixture.Register(ApprenticeshipIncentiveCreator);

            _sut = new WithdrawCommandHandler(_mockIncentiveDomainRepository.Object, _mockCollectionCalendarService.Object);
        }