Example #1
0
        public MonthlyRevenue ComputeMonthlyRevenue(string branchName, int year, int month)
        {
            var dateTime = new DateTime(year, month, 1);

            var oneTimeGames = gameRepository
                            .GetGames(branchName, dateTime.FirstDayOfMonth(), dateTime.LastDayOfMonth())
                            .Where(game => game.GamePaymentType == GamePaymentType.OneTime)
                            .ToList();

            var packageGames = oneTimeGames.Where(game => game.PackageType != PackageType.No_Package);
            var nonPackageGames = oneTimeGames.Where(game => game.PackageType == PackageType.No_Package);

            var membershipReCharges = membershipRepository.GetRecharges(branchName, dateTime.FirstDayOfMonth(), dateTime.LastDayOfMonth()).ToList();

            return new MonthlyRevenue
                       {
                           DateTime = dateTime,
                           NonMembershipGamesCount = oneTimeGames.Count,
                           MembershipRechargesCount = membershipReCharges.Count,
                           RevenueByNonPackageOneTimeGames = nonPackageGames.Sum(game => game.Price),
                           RevenueByPackageOneTimeGames = packageGames.Sum(game => game.Price),
                           RevenueByMembershipRecharges = membershipReCharges.Sum(recharge => recharge.Price),
                           EbMeterReading = dailySaleDetailsRepository.GetEbMeterReadingForTheMonth(branchName, year, month),
                           MonthlyExpense = monthlyExpensesRepository.GetMonthlyExpenses(branchName, month, year)
                       };
        }
        public void FirstDayOfMonth()
        {
            var dateTime1 = new DateTime(2013, 3, 22);
            var date1 = dateTime1.FirstDayOfMonth();
            var date2 = dateTime1.FirstDayOfMonth(DayOfWeek.Monday);

            Assert.AreEqual(new DateTime(2013, 3, 1), date1);
            Assert.AreEqual(new DateTime(2013, 3, 4), date2);
        }
 public void FirstDayOfMonthTest()
 {
     var date = new DateTime(2000, 1, 31, 23, 59, 59, 999);
     var expected = new DateTime(2000, 1, 1);
     var actual = date.FirstDayOfMonth();
     Assert.AreEqual(expected, actual);
 }
 public void eom_as_input_calcs_begin_and_end_properly()
 {
     var realLastDay = new DateTime(2012, 02, 29);
     var realFirstDay = new DateTime(2012, 02, 01);
     var today = new DateTime(2012, 02, 29);
     today.LastDayOfMonth().ShouldEqual(realLastDay.ToDate());
     today.FirstDayOfMonth().ShouldEqual(realFirstDay.ToDate());
 }
Example #5
0
        public static FullMonthToAView FullMonthToAViewFor(DateTime dateTime, IDocumentSession session)
        {
            var firstDayOfMonth = dateTime.FirstDayOfMonth();
            var weekDayOfFirstDayOfMonth = firstDayOfMonth.DayOfWeek;
            var firstDateToFind = firstDayOfMonth;
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Tuesday)
                firstDateToFind = firstDayOfMonth.AddDays(-1);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Wednesday)
                firstDateToFind = firstDayOfMonth.AddDays(-2);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Thursday)
                firstDateToFind = firstDayOfMonth.AddDays(-3);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Friday)
                firstDateToFind = firstDayOfMonth.AddDays(-4);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Saturday)
                firstDateToFind = firstDayOfMonth.AddDays(-5);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Sunday)
                firstDateToFind = firstDayOfMonth.AddDays(-6);

            var lastDayOfMonth = dateTime.LastDayOfMonth();
            var weekDayOfLastDayOfMonth = lastDayOfMonth.DayOfWeek;
            var lastDateToFind = lastDayOfMonth;
            if (weekDayOfLastDayOfMonth == DayOfWeek.Monday)
                lastDateToFind = lastDayOfMonth.AddDays(6);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Tuesday)
                lastDateToFind = lastDayOfMonth.AddDays(5);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Wednesday)
                lastDateToFind = lastDayOfMonth.AddDays(4);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Thursday)
                lastDateToFind = lastDayOfMonth.AddDays(3);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Friday)
                lastDateToFind = lastDayOfMonth.AddDays(2);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Saturday)
                lastDateToFind = lastDayOfMonth.AddDays(1);

            var bookings = session.Advanced.LuceneQuery<Booking>()
                .WhereBetweenOrEqual(x => x.Date, firstDateToFind, lastDateToFind)
                .ToList();
            return new FullMonthToAView(bookings, firstDateToFind, lastDateToFind);
        }
 public void FirstDayOfMonthTest()
 {
     var today = new DateTime(2014, 4, 28);
     today.FirstDayOfMonth().ShouldEqual("01/04/2014");
 }
Example #7
0
		public static CalendarRange Range(
			DateTime date,
			CalendarView vista,
			DayOfWeek firstDayOfWeek = DayOfWeek.Monday,
			DayOfWeek lastDayOfWeek = DayOfWeek.Sunday)
		{
			var selectedDate = date.Date;

			var firstDay = selectedDate.FirstDayOfWeek();

			if (vista == CalendarView.Day)
			{
				firstDay = date;
			}

			if (vista != CalendarView.Month)
			{
				var dates =
					Enumerable
						.Range(0, (int)vista)
						.Select(dayCount => firstDay.AddDays(dayCount))
						.ToList();

				return new CalendarRange(dates.First(), dates.Last());
			}

			var firstDayOfMonth = date.FirstDayOfMonth();
			var first = firstDayOfMonth.FirstDayOfWeek(firstDayOfWeek);

			var lastDayOfMonth = date.LastDayOfMonth();
			var last = lastDayOfMonth.LastDayOfWeek(lastDayOfWeek);

			return new CalendarRange(first, last);
		}
 public void middle_of_month_input_has_proper_first_day_of_month()
 {
     var realFirstDay = new DateTime(2012, 02, 01);
     var today = new DateTime(2012, 02, 03);
     today.FirstDayOfMonth().ShouldEqual(realFirstDay.ToDate());
 }
 public void first_day_of_month_for_date_is_same()
 {
     var today = new DateTime(2012, 02, 01);
     today.FirstDayOfMonth().ShouldEqual(today.ToDate());
 }
 public void first_day_of_month()
 {
     var date = new DateTime(2012, 6, 7);
     date.FirstDayOfMonth().ShouldEqual(new DateTime(2012, 6, 1).ToDate());
 }
 public void FirstDayOfMonth_Returns_Valid_Result(DateTime date, DateTime expectedDate)
 {
     Assert.That(date.FirstDayOfMonth(), Is.EqualTo(expectedDate));
 }
 protected override DateTime? _GetNextFromExact(DateTime knownGood)
 {
     return GetDayInMonth(knownGood.FirstDayOfMonth().AddMonths(Interval));
 }