Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        private void FillRules()
        {
            TimeCardRules.RefreshCache();
            gridRules.BeginUpdate();
            gridRules.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Employee", 150);

            gridRules.Columns.Add(col);
            col = new ODGridColumn("OT after x Hours", 110);
            gridRules.Columns.Add(col);
            col = new ODGridColumn("OT after x Time", 70);
            gridRules.Columns.Add(col);
            gridRules.Rows.Clear();
            UI.ODGridRow row;
            for (int i = 0; i < TimeCardRules.Listt.Count; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                if (TimeCardRules.Listt[i].EmployeeNum == 0)
                {
                    row.Cells.Add(Lan.g(this, "All Employees"));
                }
                else
                {
                    Employee emp = Employees.GetEmp(TimeCardRules.Listt[i].EmployeeNum);
                    row.Cells.Add(emp.FName + " " + emp.LName);
                }
                row.Cells.Add(TimeCardRules.Listt[i].OverHoursPerDay.ToStringHmm());
                row.Cells.Add(TimeCardRules.Listt[i].AfterTimeOfDay.ToStringHmm());
                gridRules.Rows.Add(row);
            }
            gridRules.EndUpdate();
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        private void FormPayPeriods_FormClosing(object sender, FormClosingEventArgs e)
        {
            //validation on Form_Closing to account for if the user doesn't use the close button to close the form.
            string errors = TimeCardRules.ValidateOvertimeRules();

            if (!string.IsNullOrEmpty(errors))
            {
                errors = "Fix the following errors:\r\n" + errors;
                MessageBox.Show(errors);
                e.Cancel = true;
            }
            if (textADPCompanyCode.Text != "" && !Regex.IsMatch(textADPCompanyCode.Text, "^[a-zA-Z0-9]{2,3}$"))
            {
                MsgBox.Show(this, "ADP Company Code must be two or three alpha-numeric characters.\r\nFix or clear before continuing.");
                e.Cancel = true;
            }
            if (Prefs.UpdateString(PrefName.ADPCompanyCode, textADPCompanyCode.Text))
            {
                changed = true;
            }
            if (changed)
            {
                DataValid.SetInvalid(InvalidType.Employees, InvalidType.Prefs, InvalidType.TimeCardRules);
            }
        }
Ejemplo n.º 8
0
        public static void CreateAMTimeRule(long emp, TimeSpan beforeTime)
        {
            TimeCardRule tcr = new TimeCardRule();

            tcr.EmployeeNum     = emp;
            tcr.BeforeTimeOfDay = beforeTime;
            TimeCardRules.Insert(tcr);
            return;
        }
Ejemplo n.º 9
0
        public static void CreateHoursTimeRule(long emp, TimeSpan hoursPerDay)
        {
            TimeCardRule tcr = new TimeCardRule();

            tcr.EmployeeNum     = emp;
            tcr.OverHoursPerDay = hoursPerDay;
            TimeCardRules.Insert(tcr);
            return;
        }
Ejemplo n.º 10
0
        public static void CreatePMTimeRule(long emp, TimeSpan afterTime)
        {
            TimeCardRule tcr = new TimeCardRule();

            tcr.EmployeeNum    = emp;
            tcr.AfterTimeOfDay = afterTime;
            TimeCardRules.Insert(tcr);
            return;
        }
Ejemplo n.º 11
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (_isInsertMode)             //Creating new TimeCardRules, nothing to delete.
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Are you sure you want to delete this time card rule?"))
     {
         return;
     }
     TimeCardRules.Delete(_timeCardRule.TimeCardRuleNum);
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 12
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (timeCardRule.IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Are you sure you want to delete this time card rule?"))
     {
         return;
     }
     TimeCardRules.Delete(timeCardRule.TimeCardRuleNum);
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 13
0
        private void FillRules()
        {
            TimeCardRules.RefreshCache();
            //Start with a convenient sorting of all employees on top, followed by a last name sort.
            List <TimeCardRule> listSorted = TimeCardRules.GetDeepCopy().OrderBy(x => x.IsOvertimeExempt)
                                             .ThenBy(x => x.EmployeeNum != 0)
                                             .ThenBy(x => (Employees.GetEmp(x.EmployeeNum) ?? new Employee()).LName)
                                             .ToList();

            gridRules.BeginUpdate();
            gridRules.ListGridColumns.Clear();
            GridColumn col = new GridColumn("Employee", 150, GridSortingStrategy.StringCompare);

            gridRules.ListGridColumns.Add(col);
            col = new GridColumn("OT before x Time", 105, GridSortingStrategy.TimeParse);
            gridRules.ListGridColumns.Add(col);
            col = new GridColumn("OT after x Time", 100, GridSortingStrategy.TimeParse);
            gridRules.ListGridColumns.Add(col);
            col = new GridColumn("OT after x Hours", 110, GridSortingStrategy.TimeParse);
            gridRules.ListGridColumns.Add(col);
            col = new GridColumn("Min Clock In Time", 105, GridSortingStrategy.TimeParse);
            gridRules.ListGridColumns.Add(col);
            col = new GridColumn("Is OT Exempt", 100, HorizontalAlignment.Center, GridSortingStrategy.StringCompare);
            gridRules.ListGridColumns.Add(col);
            gridRules.ListGridRows.Clear();
            UI.GridRow row;
            for (int i = 0; i < listSorted.Count; i++)
            {
                row = new GridRow();
                if (listSorted[i].EmployeeNum == 0)
                {
                    row.Cells.Add(Lan.g(this, "All Employees"));
                }
                else
                {
                    Employee emp = Employees.GetEmp(listSorted[i].EmployeeNum);
                    row.Cells.Add(emp.FName + " " + emp.LName);
                }
                row.Cells.Add(listSorted[i].BeforeTimeOfDay.ToStringHmm());
                row.Cells.Add(listSorted[i].AfterTimeOfDay.ToStringHmm());
                row.Cells.Add(listSorted[i].OverHoursPerDay.ToStringHmm());
                row.Cells.Add(listSorted[i].MinClockInTime.ToStringHmm());
                row.Cells.Add(listSorted[i].IsOvertimeExempt ? "X" : "");
                row.Tag = listSorted[i];
                gridRules.ListGridRows.Add(row);
            }
            gridRules.EndUpdate();
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        private void butDeleteRules_Click(object sender, EventArgs e)
        {
            if (gridRules.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select one or more Rules to delete.");
                return;
            }
            if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Are you sure you want to delete all selected Rules?"))
            {
                return;
            }
            List <long> listTimeCardRuleNums = gridRules.SelectedTags <TimeCardRule>().Select(x => x.TimeCardRuleNum).ToList();

            TimeCardRules.DeleteMany(listTimeCardRuleNums);
            DataValid.SetInvalid(InvalidType.TimeCardRules);
            FillRules();
        }
Ejemplo n.º 16
0
        public void TimeCardRules_CalculateDailyOvertime_ForHoursWorkedBeforeACertainTime()
        {
            string    suffix    = "33";
            DateTime  startDate = DateTime.Parse("2001-01-01");
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            Prefs.UpdateBool(PrefName.TimeCardsMakesAdjustmentsForOverBreaks, true);
            TimeCardRuleT.CreateAMTimeRule(emp.EmployeeNum, TimeSpan.FromHours(7.5));
            TimeCardRules.RefreshCache();
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddHours(6), startDate.AddHours(16), 0);

            ClockEventT.InsertBreak(emp.EmployeeNum, startDate.AddHours(11), 40, 0);
            CalculateDailyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Validate
            Assert.AreEqual(TimeSpan.FromMinutes(-10), ClockEvents.GetOne(clockEvent1).AdjustAuto);
            Assert.AreEqual(TimeSpan.FromMinutes(90), ClockEvents.GetOne(clockEvent1).Rate2Auto);
        }
Ejemplo n.º 17
0
        public void TimeCardRules_CalculateDailyOvertime_WhileEmployeeClockedInTodayDuringPayPeriod()
        {
            DateTime  startDate = DateTime.Now.Date.AddDays(-1);
            Employee  emp       = EmployeeT.CreateEmployee("CalculateDailyWhileEmployeeClockedInDuringPayPeriod");
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            Prefs.UpdateBool(PrefName.TimeCardsMakesAdjustmentsForOverBreaks, true);
            Prefs.RefreshCache();
            TimeCardRules.RefreshCache();
            //10 hour day with 45 minute break
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddHours(8), startDate.AddHours(18));
            long break1      = ClockEventT.InsertBreak(emp.EmployeeNum, startDate.AddHours(12), 45);
            //Next day clock in, but have no clock out event yet.
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(8), DateTime.MinValue);

            CalculateDailyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Ensure that the 15 minutes was subtracted from the shift.
            Assert.AreEqual(TimeSpan.FromMinutes(-15), ClockEvents.GetOne(clockEvent1).AdjustAuto);
        }
Ejemplo n.º 18
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //Verify Data.
            if (listEmp.SelectedIndex < 0)
            {
                MsgBox.Show(this, "Please select an employee.");
                return;
            }
            TimeSpan overHoursPerDay = TimeSpan.Zero;

            if (textOverHoursPerDay.Text != "")
            {
                try {
                    if (textOverHoursPerDay.Text.Contains(":"))
                    {
                        overHoursPerDay = TimeSpan.Parse(textOverHoursPerDay.Text);
                    }
                    else
                    {
                        overHoursPerDay = TimeSpan.FromHours(PIn.Double(textOverHoursPerDay.Text));
                    }
                }
                catch {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
                if (overHoursPerDay == TimeSpan.Zero || overHoursPerDay.Days > 0)
                {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
            }
            TimeSpan afterTimeOfDay = TimeSpan.Zero;

            if (textAfterTimeOfDay.Text != "")
            {
                try {
                    afterTimeOfDay = DateTime.Parse(textAfterTimeOfDay.Text).TimeOfDay;
                }
                catch {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
                if (afterTimeOfDay == TimeSpan.Zero || afterTimeOfDay.Days > 0)
                {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
            }
            TimeSpan beforeTimeOfDay = TimeSpan.Zero;

            if (textBeforeTimeOfDay.Text != "")
            {
                try {
                    beforeTimeOfDay = DateTime.Parse(textBeforeTimeOfDay.Text).TimeOfDay;
                }
                catch {
                    MsgBox.Show(this, "Before time of day invalid.");
                    return;
                }
                if (beforeTimeOfDay == TimeSpan.Zero || beforeTimeOfDay.Days > 0)
                {
                    MsgBox.Show(this, "Before time of day invalid.");
                    return;
                }
            }
            TimeSpan minClockIn = TimeSpan.Zero;

            if (textClockInMin.Text != "")
            {
                try {
                    minClockIn = DateTime.Parse(textClockInMin.Text).TimeOfDay;
                }
                catch {
                    MsgBox.Show(this, "Earliest Clock in Time invalid.");
                    return;
                }
                if (minClockIn == TimeSpan.Zero || minClockIn.Days > 0)
                {
                    MsgBox.Show(this, "Earliest Clock in Time invalid.");
                    return;
                }
            }
            if (!checkIsOvertimeExempt.Checked &&
                overHoursPerDay == TimeSpan.Zero &&
                afterTimeOfDay == TimeSpan.Zero &&
                beforeTimeOfDay == TimeSpan.Zero &&
                minClockIn == TimeSpan.Zero)
            {
                MsgBox.Show(this, "Either is overtime exempt, over hours, after or before time of day or Clock In Min must be entered.");
                return;
            }
            //save-------------------------------------------------
            //You are allowed to insert multiple TimeCardRules at one time but can only edit one existing entry at a time.
            if (_isInsertMode)                           //Insert new entry for every list selection.
            {
                if (listEmp.SelectedIndices.Contains(0)) //TODO: Ask Cameron if it is ok to make time card rules that affect all clinics.
                {
                    listEmp.SelectedIndices.Clear();     //Limit to just 'All'
                    listEmp.SelectedIndices.Add(0);
                }
                List <TimeCardRule> listNewRules = new List <TimeCardRule>();
                foreach (int index in listEmp.SelectedIndices)
                {
                    _timeCardRule.EmployeeNum = 0;
                    if (index != 0)                                                        //Not 'All'
                    {
                        _timeCardRule.EmployeeNum = _listEmployees[index - 1].EmployeeNum; //-1 for All
                    }
                    _timeCardRule.OverHoursPerDay  = overHoursPerDay;
                    _timeCardRule.AfterTimeOfDay   = afterTimeOfDay;
                    _timeCardRule.BeforeTimeOfDay  = beforeTimeOfDay;
                    _timeCardRule.IsOvertimeExempt = checkIsOvertimeExempt.Checked;
                    _timeCardRule.MinClockInTime   = minClockIn;
                    listNewRules.Add(_timeCardRule.Clone());
                }
                TimeCardRules.InsertMany(listNewRules);
            }
            else              //Update single entry.
            {
                _timeCardRule.EmployeeNum = 0;
                int index = listEmp.SelectedIndex;
                if (index != 0)                                                        //Not 'All'
                {
                    _timeCardRule.EmployeeNum = _listEmployees[index - 1].EmployeeNum; //-1 for All
                }
                _timeCardRule.OverHoursPerDay  = overHoursPerDay;
                _timeCardRule.AfterTimeOfDay   = afterTimeOfDay;
                _timeCardRule.BeforeTimeOfDay  = beforeTimeOfDay;
                _timeCardRule.IsOvertimeExempt = checkIsOvertimeExempt.Checked;
                _timeCardRule.MinClockInTime   = minClockIn;
                TimeCardRules.Update(_timeCardRule);
            }
            DataValid.SetInvalid(InvalidType.TimeCardRules);
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 19
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //Verify Data.
            if (listEmployees.SelectedIndex < 0)
            {
                MsgBox.Show(this, "Please select an employee.");
                return;
            }
            TimeSpan overHoursPerDay = TimeSpan.Zero;

            if (textOverHoursPerDay.Text != "")
            {
                try {
                    if (textOverHoursPerDay.Text.Contains(":"))
                    {
                        overHoursPerDay = TimeSpan.Parse(textOverHoursPerDay.Text);
                    }
                    else
                    {
                        overHoursPerDay = TimeSpan.FromHours(PIn.Double(textOverHoursPerDay.Text));
                    }
                }
                catch {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
                if (overHoursPerDay == TimeSpan.Zero || overHoursPerDay.Days > 0)
                {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
            }
            TimeSpan afterTimeOfDay = TimeSpan.Zero;

            if (textAfterTimeOfDay.Text != "")
            {
                try {
                    afterTimeOfDay = DateTime.Parse(textAfterTimeOfDay.Text).TimeOfDay;
                }
                catch {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
                if (afterTimeOfDay == TimeSpan.Zero || afterTimeOfDay.Days > 0)
                {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
            }
            if (overHoursPerDay == TimeSpan.Zero && afterTimeOfDay == TimeSpan.Zero)
            {
                MsgBox.Show(this, "Hours or time of day must be entered.");
                return;
            }
            //save-------------------------------------------------
            if (listEmployees.SelectedIndex == 0)
            {
                timeCardRule.EmployeeNum = 0;              //All employees.
            }
            else
            {
                timeCardRule.EmployeeNum = Employees.ListShort[listEmployees.SelectedIndex - 1].EmployeeNum;
            }
            timeCardRule.OverHoursPerDay = overHoursPerDay;
            timeCardRule.AfterTimeOfDay  = afterTimeOfDay;
            if (timeCardRule.IsNew)
            {
                TimeCardRules.Insert(timeCardRule);
            }
            else
            {
                TimeCardRules.Update(timeCardRule);
            }
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 20
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //Verify Data.
            if (listEmp.SelectedIndex < 0)
            {
                MsgBox.Show(this, "Please select an employee.");
                return;
            }
            TimeSpan overHoursPerDay = TimeSpan.Zero;

            if (textOverHoursPerDay.Text != "")
            {
                try {
                    if (textOverHoursPerDay.Text.Contains(":"))
                    {
                        overHoursPerDay = TimeSpan.Parse(textOverHoursPerDay.Text);
                    }
                    else
                    {
                        overHoursPerDay = TimeSpan.FromHours(PIn.Double(textOverHoursPerDay.Text));
                    }
                }
                catch {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
                if (overHoursPerDay == TimeSpan.Zero || overHoursPerDay.Days > 0)
                {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
            }
            TimeSpan afterTimeOfDay = TimeSpan.Zero;

            if (textAfterTimeOfDay.Text != "")
            {
                try {
                    afterTimeOfDay = DateTime.Parse(textAfterTimeOfDay.Text).TimeOfDay;
                }
                catch {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
                if (afterTimeOfDay == TimeSpan.Zero || afterTimeOfDay.Days > 0)
                {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
            }
            TimeSpan beforeTimeOfDay = TimeSpan.Zero;

            if (textBeforeTimeOfDay.Text != "")
            {
                try {
                    beforeTimeOfDay = DateTime.Parse(textBeforeTimeOfDay.Text).TimeOfDay;
                }
                catch {
                    MsgBox.Show(this, "Before time of day invalid.");
                    return;
                }
                if (beforeTimeOfDay == TimeSpan.Zero || beforeTimeOfDay.Days > 0)
                {
                    MsgBox.Show(this, "Before time of day invalid.");
                    return;
                }
            }
            if (!checkIsOvertimeExempt.Checked && overHoursPerDay == TimeSpan.Zero && afterTimeOfDay == TimeSpan.Zero && beforeTimeOfDay == TimeSpan.Zero)
            {
                MsgBox.Show(this, "Either is overtime exempt, over hours, after or before time of day must be entered.");
                return;
            }
            //save-------------------------------------------------
            if (listEmp.SelectedIndex == 0)           //TODO: Ask Cameron if it is ok to make time card rules that affect all clinics.
            {
                timeCardRule.EmployeeNum = 0;         //All employees.
            }
            else
            {
                timeCardRule.EmployeeNum = _listEmployees[listEmp.SelectedIndex - 1].EmployeeNum;
            }
            timeCardRule.OverHoursPerDay  = overHoursPerDay;
            timeCardRule.AfterTimeOfDay   = afterTimeOfDay;
            timeCardRule.BeforeTimeOfDay  = beforeTimeOfDay;
            timeCardRule.IsOvertimeExempt = checkIsOvertimeExempt.Checked;
            if (timeCardRule.IsNew)
            {
                TimeCardRules.Insert(timeCardRule);
            }
            else
            {
                TimeCardRules.Update(timeCardRule);
            }
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 21
0
 ///<summary>Calculates daily adjustments for an employee. Used in order to keep the number of references to
 ///TimeCardRules.CalculateDailyOvertime low.</summary>
 ///<param name="emp">Employee that the daily overtime will be calculated for.</param>
 ///<param name="dateStart">The start date of the pay period.</param>
 ///<param name="dateStop">The end date of the pay period</param>
 private void CalculateDailyOvertime(Employee emp, DateTime dateStart, DateTime dateStop)
 {
     TimeCardRules.CalculateDailyOvertime(emp, dateStart, dateStop);
 }