Esempio n. 1
0
        public async Task MissedCNWPaymentEntriesAsync()
        {
            var weekSummaries = (await GetWeekSummariesAsync())
                                .Select(x => (x.WeekNo, x.WeekDate.Year))
                                .OrderBy(x => x.Year)
                                .ThenBy(x => x.WeekNo);

            var firstYear   = weekSummaries.Select(x => x.Year).First();
            var currentWeek = Utils.GetWeek(DateTime.UtcNow);
            var weeks       = new List <(int WeekNo, int Year)>();

            for (int y = firstYear; y <= DateTime.UtcNow.Year; y++)
            {
                var firstWeekNo = weekSummaries
                                  .Where(x => x.Year == y)
                                  .Select(x => x.WeekNo)
                                  .FirstOrDefault();

                int lastWeekno = y == DateTime.UtcNow.Year ? currentWeek : Utils.GetWeeksInYear(y);

                for (int i = firstWeekNo; i <= lastWeekno; i++)
                {
                    weeks.Add((i, y));
                }
            }

            var results = weekSummaries.Except(weeks);

            if (results.Any())
            {
                var missedEntries = new List <MissedEntries>();

                var data = new MissedEntries()
                {
                    Name  = "CNW Week",
                    Dates = results.Select(x => x.WeekNo.ToString()).ToArray()
                };

                missedEntries.Add(data);

                await remindersService.MissedEntriesAsync(missedEntries, "You have a missed CNW payment entry for");
            }
        }
Esempio n. 2
0
        public async Task MissedIncomeEntriesAsync()
        {
            var incomeStreams = new List <(string DateColumn, int WeekArrears, Categories CategoryType, string RecsBegan)>()
            {
                //(nameof(Income.AmazonWeekCommencing), 3, Categories.CWTL, "2019-08-07"),
                (nameof(Income.Date), 1, Categories.UberEats, "2019-08-07"),
                (nameof(Income.Date), 1, Categories.Flex, "2020-03-23")
            };

            var results = new List <MissedEntries>();

            foreach (var incomeStream in incomeStreams)
            {
                var entries = (
                    await incomeRepository.MissedIncomeEntriesAsync(
                        incomeStream.DateColumn,
                        incomeStream.WeekArrears,
                        incomeStream.CategoryType,
                        incomeStream.RecsBegan
                        )
                    );

                if (entries.Any())
                {
                    var data = new MissedEntries()
                    {
                        Name  = incomeStream.CategoryType.ToString(),
                        Dates = entries.Select(x => (x.Year + " Week: " + x.Week)).ToArray()
                    };

                    results.Add(data);
                }
            }

            await reminderService.MissedEntriesAsync(results, "You have a missed income entry for");
        }