Exemple #1
0
        public void TimeCardRules_CalculateWeeklyOvertime_OneWeekOverTwoPayPeriodsForDifferentClinicPreferences()
        {
            string    suffix    = "64";
            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();
            //Each of these are 11 hour days. Should have 4 hours of OT with clinic 3 in the second pay period and 11 hours for clinic 4.
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(10).AddHours(6), startDate.AddDays(10).AddHours(17), 0);       //Sun
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(11).AddHours(6), startDate.AddDays(11).AddHours(17), 1);       //Mon
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(12).AddHours(6), startDate.AddDays(12).AddHours(17), 2);       //Tue
            //new pay period
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(14).AddHours(6), startDate.AddDays(14).AddHours(17), 3);       //Wed
            long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(15).AddHours(6), startDate.AddDays(15).AddHours(17), 4);       //Thurs

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            TimeCardRules.CalculateWeeklyOvertime(emp, payP2.DateStart, payP2.DateStop);
            //Validate
            List <TimeAdjust> listAdjusts = TimeAdjusts.GetValidList(emp.EmployeeNum, startDate, startDate.AddDays(28)).OrderBy(x => x.OTimeHours).ToList();

            Assert.AreEqual(2, listAdjusts.Count);
            Assert.AreEqual(TimeSpan.FromHours(-4), listAdjusts[0].RegHours);
            Assert.AreEqual(3, listAdjusts[0].ClinicNum);
            Assert.AreEqual(TimeSpan.FromHours(4), listAdjusts[0].OTimeHours);
            Assert.AreEqual(TimeSpan.FromHours(-11), listAdjusts[1].RegHours);
            Assert.AreEqual(4, listAdjusts[1].ClinicNum);
            Assert.AreEqual(TimeSpan.FromHours(11), listAdjusts[1].OTimeHours);
        }
Exemple #2
0
        public void TimeCardRules_CalculateWeeklyOvertime_ForDifferentClinicsRealData()
        {
            string    suffix    = "66";
            DateTime  startDate = DateTime.Parse("2016-05-09");         //This will create a pay period that splits a work week.
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            TimeCardRules.RefreshCache();
            //Each of these are 11 hour days. Should have 4 hours of OT with clinic 3 in the second pay period and 11 hours for clinic 4.
            //Week 1 - 40.4 hours
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(0).AddHours(6), startDate.AddDays(0).AddHours(6 + 8), 0);             //Mon
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(6), startDate.AddDays(1).AddHours(6 + 8), 0);             //Tue
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(2).AddHours(6), startDate.AddDays(2).AddHours(6 + 8.76), 0, 0.06);    //Wed
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(3).AddHours(6), startDate.AddDays(3).AddHours(6 + 8.72), 0, 0.73);    //Thurs
            long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(4).AddHours(6), startDate.AddDays(4).AddHours(6 + 8.12), 0, 0.41);    //Fri
            //Week 2 - 41.23 hours
            long clockEvent6  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(7).AddHours(6), startDate.AddDays(7).AddHours(6 + 8.79), 0, 0.4);    //Mon
            long clockEvent7  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(8).AddHours(6), startDate.AddDays(8).AddHours(6 + 8.85), 0, 0.38);   //Tue
            long clockEvent8  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(9).AddHours(6), startDate.AddDays(9).AddHours(6 + 7.78), 0, 0.29);   //Wed
            long clockEvent9  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(10).AddHours(6), startDate.AddDays(10).AddHours(6 + 8.88), 0, 0.02); //Thurs
            long clockEvent10 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(11).AddHours(6), startDate.AddDays(11).AddHours(6 + 8.59), 0, 0.57); //Fri

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Validate
            List <TimeAdjust> listAdjusts = TimeAdjusts.GetValidList(emp.EmployeeNum, startDate, startDate.AddDays(28)).OrderBy(x => x.OTimeHours).ToList();

            Assert.AreEqual(2, listAdjusts.Count);
            Assert.AreEqual(TimeSpan.FromHours(-0.4), listAdjusts[0].RegHours);
            Assert.AreEqual(TimeSpan.FromHours(0.4), listAdjusts[0].OTimeHours);
            Assert.AreEqual(TimeSpan.FromHours(-1.23), listAdjusts[1].RegHours);
            Assert.AreEqual(TimeSpan.FromHours(1.23), listAdjusts[1].OTimeHours);
        }
Exemple #3
0
        public void TimeCardRules_CalculateWeeklyOvertime_ForDifferentClinics()
        {
            string    suffix    = "62";
            DateTime  startDate = DateTime.Parse("2001-01-01");
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            TimeCardRules.RefreshCache();
            //Each of these are 11 hour days. Should have 4 hours of OT with clinic 3 and 11 hours OT with clinic 4 the end of the pay period.
            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), 1);
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(2).AddHours(6), startDate.AddDays(2).AddHours(17), 2);
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(3).AddHours(6), startDate.AddDays(3).AddHours(17), 3);
            long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(4).AddHours(6), startDate.AddDays(4).AddHours(17), 4);

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Validate
            List <TimeAdjust> listAdjusts = TimeAdjusts.GetValidList(emp.EmployeeNum, startDate, startDate.AddDays(5)).OrderBy(x => x.OTimeHours).ToList();

            Assert.AreEqual(2, listAdjusts.Count);
            Assert.AreEqual(TimeSpan.FromHours(-4), listAdjusts[0].RegHours);
            Assert.AreEqual(3, listAdjusts[0].ClinicNum);
            Assert.AreEqual(TimeSpan.FromHours(4), listAdjusts[0].OTimeHours);
            Assert.AreEqual(TimeSpan.FromHours(-11), listAdjusts[1].RegHours);
            Assert.AreEqual(4, listAdjusts[1].ClinicNum);
            Assert.AreEqual(TimeSpan.FromHours(11), listAdjusts[1].OTimeHours);
        }
Exemple #4
0
        public void TimeCardRules_CalculateWeeklyOvertime_CalculationWithManualOvertime()
        {
            string    suffix    = "67";
            DateTime  startDate = DateTime.Parse("2016-03-14");
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            TimeCardRules.RefreshCache();
            //Each of these are 11 hour days. Should have 4 hours of OT with clinic 3 in the second pay period and 11 hours for clinic 4.
            //Week 1 - 40.13 (Note: These appear as they should after CalculateDaily is run.)
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(0).AddHours(6), startDate.AddDays(0).AddHours(6 + 8.06), 0);    //Mon
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(6), startDate.AddDays(1).AddHours(6 + 8), 0);       //Tue
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(2).AddHours(6), startDate.AddDays(2).AddHours(6 + 8.08), 0);    //Wed
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(3).AddHours(6), startDate.AddDays(3).AddHours(6 + 8), 0, 0.02); //Thurs
            long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(4).AddHours(6), startDate.AddDays(4).AddHours(6 + 8.01), 0);    //Fri
            //SATURDAY - 4.1 HRS OF OVERTIME
            ClockEvent ce = new ClockEvent();

            ce.ClinicNum      = 0;
            ce.ClockStatus    = TimeClockStatus.Home;
            ce.EmployeeNum    = emp.EmployeeNum;
            ce.OTimeHours     = TimeSpan.FromHours(4.1);
            ce.TimeDisplayed1 = new DateTime(startDate.Year, startDate.Month, startDate.AddDays(5).Day, 6, 54, 0);
            ce.TimeDisplayed2 = new DateTime(startDate.Year, startDate.Month, startDate.AddDays(5).Day, 11, 0, 0);
            ce.TimeEntered1   = ce.TimeDisplayed1;
            ce.TimeEntered2   = ce.TimeDisplayed2;
            ce.ClockEventNum  = ClockEvents.Insert(ce);
            ClockEvents.Update(ce);
            //Week 2 - 41.06
            long clockEvent6  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(7).AddHours(6), startDate.AddDays(7).AddHours(6 + 8.02), 0);   //Mon
            long clockEvent7  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(8).AddHours(6), startDate.AddDays(8).AddHours(6 + 8), 0);      //Tue
            long clockEvent8  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(9).AddHours(6), startDate.AddDays(9).AddHours(6 + 8), 0);      //Wed
            long clockEvent9  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(10).AddHours(6), startDate.AddDays(10).AddHours(6 + 9.04), 0); //Thurs
            long clockEvent10 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(11).AddHours(6), startDate.AddDays(11).AddHours(6 + 8), 0);    //Fri

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Validate
            List <TimeAdjust> listAdjusts = TimeAdjusts.GetValidList(emp.EmployeeNum, startDate, startDate.AddDays(28)).OrderBy(x => x.OTimeHours).ToList();

            Assert.AreEqual(2, listAdjusts.Count);
            Assert.AreEqual(TimeSpan.FromHours(-0.13), listAdjusts[0].RegHours);
            Assert.AreEqual(TimeSpan.FromHours(0.13), listAdjusts[0].OTimeHours);
            Assert.AreEqual(TimeSpan.FromHours(-1.06), listAdjusts[1].RegHours);
            Assert.AreEqual(TimeSpan.FromHours(1.06), listAdjusts[1].OTimeHours);
        }