private AccountingPeriod BaseAddNextMonth() { var allPeriods = new AccountingPeriods(this.Strategy.Session).Extent(); allPeriods.Filter.AddEquals(this.Meta.Frequency, new TimeFrequencies(this.Strategy.Session).Month); allPeriods.AddSort(this.Meta.FromDate.RoleType, SortDirection.Descending); var mostRecentMonth = allPeriods.First; var newMonth = new AccountingPeriodBuilder(this.Strategy.Session) .WithPeriodNumber(mostRecentMonth.PeriodNumber + 1) .WithFrequency(new TimeFrequencies(this.Strategy.Session).Month) .Build(); if (newMonth.PeriodNumber < 13) { newMonth.FromDate = mostRecentMonth.FromDate.AddMonths(1).Date; newMonth.ThroughDate = mostRecentMonth.FromDate.AddMonths(2).AddSeconds(-1).Date; } else { newMonth.FromDate = mostRecentMonth.FromDate; newMonth.ThroughDate = mostRecentMonth.ThroughDate; } if (newMonth.PeriodNumber == 4 || newMonth.PeriodNumber == 7 || newMonth.PeriodNumber == 10) { newMonth.Parent = this.BaseAddNextQuarter(mostRecentMonth.Parent); } else { newMonth.Parent = mostRecentMonth.Parent; } return(newMonth); }