public static long InsertWorkPeriod(long emp, DateTime start, DateTime stop) { ClockEvent ce = new ClockEvent(); ce.ClockStatus = TimeClockStatus.Home; ce.EmployeeNum = emp; ce.TimeDisplayed1 = start; ce.TimeEntered1 = start; ce.TimeDisplayed2 = stop; ce.TimeEntered2 = stop; ce.ClockEventNum = ClockEvents.Insert(ce); ClockEvents.Update(ce); //Updates TimeDisplayed1 because it defaults to now(). return(ce.ClockEventNum); }
public static long InsertBreak(long emp, DateTime start, int minutes) { ClockEvent ce = new ClockEvent(); ce.ClockStatus = TimeClockStatus.Break; ce.EmployeeNum = emp; ce.TimeDisplayed1 = start; ce.TimeEntered1 = start; ce.TimeDisplayed2 = start.AddMinutes(minutes); ce.TimeEntered2 = start.AddMinutes(minutes); ce.ClockEventNum = ClockEvents.Insert(ce); ClockEvents.Update(ce); //Updates TimeDisplayed1 because it defaults to now(). return(ce.ClockEventNum); }
public static long InsertWorkPeriod(long emp, DateTime start, DateTime stop, long clinicNum = 0, double adjustHours = 0) { ClockEvent ce = new ClockEvent(); ce.ClockStatus = TimeClockStatus.Home; ce.EmployeeNum = emp; ce.TimeDisplayed1 = start; ce.TimeEntered1 = start; ce.TimeDisplayed2 = stop; ce.TimeEntered2 = stop; ce.ClinicNum = clinicNum; ce.AdjustAuto = TimeSpan.FromHours(-adjustHours); ce.ClockEventNum = ClockEvents.Insert(ce); ClockEvents.Update(ce); //Updates TimeDisplayed1 because it defaults to now(). return(ce.ClockEventNum); }
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); }