Exemple #1
0
        public void TimeCardRules_CalculateWeeklyOvertime_OneWeekOverTwoPayPeriods()
        {
            string    suffix    = "26";
            DateTime  startDate = DateTime.Parse("2001-02-01");         //This will create a pay period that splits a work week.
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);
            PayPeriod payP2     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate.AddDays(14));

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            TimeCardRules.RefreshCache();
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(10).AddHours(6), startDate.AddDays(10).AddHours(17), 0);
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(11).AddHours(6), startDate.AddDays(11).AddHours(17), 0);
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(12).AddHours(6), startDate.AddDays(12).AddHours(17), 0);
            //new pay period
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(14).AddHours(6), startDate.AddDays(14).AddHours(17), 0);

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            TimeCardRules.CalculateWeeklyOvertime(emp, payP2.DateStart, payP2.DateStop);
            //Validate
            List <TimeAdjust> resultList = TimeAdjusts.Refresh(emp.EmployeeNum, startDate, startDate.AddDays(28));

            Assert.IsFalse(resultList.Count < 1);
            TimeAdjust result = resultList[0];

            Assert.AreEqual(TimeSpan.FromHours(-4), result.RegHours);
            Assert.AreEqual(TimeSpan.FromHours(4), result.OTimeHours);
        }
Exemple #2
0
        public void TimeCardRules_CalculateWeeklyOvertime_OneWeekWorkWeekStartsOnWednesday()
        {
            string    suffix    = "27";
            DateTime  startDate = DateTime.Parse("2001-01-01");
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 3);
            TimeCardRules.RefreshCache();
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(0).AddHours(6), startDate.AddDays(0).AddHours(17), 0);
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(6), startDate.AddDays(1).AddHours(17), 0);
            //new work week
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(2).AddHours(6), startDate.AddDays(2).AddHours(17), 0);
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(3).AddHours(6), startDate.AddDays(3).AddHours(17), 0);
            long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(4).AddHours(6), startDate.AddDays(4).AddHours(17), 0);
            long clockEvent6 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(5).AddHours(6), startDate.AddDays(5).AddHours(17), 0);

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Validate
            TimeAdjust result = TimeAdjusts.Refresh(emp.EmployeeNum, startDate, startDate.AddDays(28))[0];

            Assert.AreEqual(TimeSpan.FromHours(-4), result.RegHours);
            Assert.AreEqual(TimeSpan.FromHours(4), result.OTimeHours);
        }