public async Task Creates_Period_End_Command_For_Each_Employer()
        {
            var periodEndMessage = new PeriodEndRunningEvent
            {
                CollectionPeriod = new CollectionPeriod
                {
                    AcademicYear = 1920,
                    Period       = 10
                },
                JobId = 1234
            };

            employerAccounts.Add(1234);
            employerAccounts.Add(5678);
            employerAccounts.Add(9012);
            var service  = mocker.Create <PeriodEndService>();
            var commands = await service.GenerateEmployerPeriodEndCommands(periodEndMessage);

            commands.Count.Should().Be(3);
            commands.Any(command => command.AccountId == 1234).Should().BeTrue();
            commands.Any(command => command.AccountId == 5678).Should().BeTrue();
            commands.Any(command => command.AccountId == 9012).Should().BeTrue();
        }
Example #2
0
        public async Task <List <ProcessLevyPaymentsOnMonthEndCommand> > GenerateEmployerPeriodEndCommands(PeriodEndRunningEvent message)
        {
            logger.LogInfo($"Sending requests to trigger month end for job: {message.JobId}");
            var employerPeriodEndCommands = new List <ProcessLevyPaymentsOnMonthEndCommand>();
            var accounts = await repository.GetEmployerAccounts(CancellationToken.None).ConfigureAwait(false);

            foreach (var account in accounts)
            {
                logger.LogDebug($"Triggering period end for account: {account}");
                employerPeriodEndCommands.Add(new ProcessLevyPaymentsOnMonthEndCommand
                {
                    AccountId        = account,
                    CollectionPeriod = message.CollectionPeriod,
                    JobId            = message.JobId,
                });
            }
            logger.LogInfo($"Finished sending requests to trigger month end for job: {message.JobId}");
            return(employerPeriodEndCommands);
        }