Exemplo n.º 1
0
        private void calcCumulMins(work_period p)
        {
            //  If date modified is more than 35 days ago, do nothing
            DateTime day = p.Date;

            if (day < DateTime.Now.AddDays(-DAY_CUTOFF))
            {
                return;
            }

            //  Calculate extra minutes
            TimeSpan diff = ShiftInformation.CalcExtraTime(p.StartTime, p.EndTime, settings.RoundOT);

            diff = diff < TimeSpan.Zero ? TimeSpan.Zero : diff;

            //  Find cumulative minutes from before
            TimeSpan cumulMins = diff.Add(findCarryMins(wp, p.Date, DAY_CUTOFF));

            //  Set flag and reset minutes if >15
            if (cumulMins.TotalMinutes >= 15)
            {
                p.AddCumulativeOT = true;
                cumulMins         = cumulMins.Subtract(new TimeSpan(0, 15, 0));
            }
            else
            {
                p.AddCumulativeOT = false;
            }

            p.CumulativeMins = cumulMins;
        }
Exemplo n.º 2
0
        private void printMinutes(ref TextBox[,] grid, int dayNum, DateTime tStart)
        {
            //This work period is wrong
            int srchResult = workPeriods.BinarySearch(new work_period(tStart.AddDays(dayNum)),
                                                      work_period.CompareByDate());

            int         index = srchResult < 0 ? ~srchResult - 1 : srchResult;
            work_period p     = workPeriods[index];

            TimeSpan cumulMins = p != null ? p.CumulativeMins : TimeSpan.Zero;

            TimeSpan extraMins;

            if (srchResult >= 0 && p.IsValid())
            {
                extraMins = ShiftInformation.CalcExtraTime(p.StartTime, p.EndTime, settings.RoundOT);
            }
            else
            {
                extraMins = TimeSpan.Zero;
            }

            int column = dayNum * 2;

            grid[PhoenixOTSheetDims.RowsPerGrid - 2, column].Text =
                "+" + extraMins.TotalMinutes.ToString();
            grid[PhoenixOTSheetDims.RowsPerGrid - 2, column + 1].Text = "Extra mins";
            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column].Font     = new Font("Arial", STANDARD_FONT_SIZE, FontStyle.Bold);

            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column].Text     = cumulMins.TotalMinutes.ToString();
            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column + 1].Font = new Font("Arial", STANDARD_FONT_SIZE, FontStyle.Bold);
            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column + 1].Text = "Total mins";
        }
Exemplo n.º 3
0
        private void mtb_Start_Validating(object sender, CancelEventArgs e)
        {
            Debug.WriteLine("Validating start input");
            MaskedTextBox mtb = (MaskedTextBox)sender;

            mtb.Text = checkMinuteValue(mtb);

            TimeSpan ts;
            if (parseInputDate(mtb, out ts))
            {
                if (!keyPressed)
                {
                    return;
                }
                Debug.WriteLine("TS:" + ts.ToString());
                mtb.Text = ts.ToString();
                changeStartTime(ShiftInformation.CombineDateAndTime(Date, ts));
            }
            else
            {
                Debug.WriteLine("Validation fail");
            }
            checkTimes();
            updateOvertime();
            updateShiftPremiums();
            updateWashup();

            RowInterfaceEventArgs ev = new RowInterfaceEventArgs(period);
            LeaveTimeBoxEvent?.Invoke(this, ev);
        }
Exemplo n.º 4
0
        private void mtb_End_Validating(object sender, CancelEventArgs e) //NEED TO ENSURE CHANGES TO OT, PREMIUMS AND WASHUP ARE REFLECTED IN DATASOURCE!!!
        {
            MaskedTextBox mtb = (MaskedTextBox)sender;

            mtb.Text = checkMinuteValue(mtb);

            TimeSpan ts;
            if (parseInputDate(mtb, out ts))
            {
                if (!keyPressed)
                {
                    return;
                }
                changeEndTime(ShiftInformation.CombineDateAndTime(Date, ts));
                tryAutoSetStartTime();
                checkEndTime();
                checkTimes();
                updateOvertime();
                updateShiftPremiums();
                updateWashup();

                RowInterfaceEventArgs ev = new RowInterfaceEventArgs(period);
                LeaveTimeBoxEvent?.Invoke(this, ev);
            }
        }
Exemplo n.º 5
0
 private TimeSpan calcOvertime()
 {
     TimeSpan ot = ShiftInformation.CalcOvertime(period.StartTime, period.EndTime);
     TimeSpan lockedOT = ShiftInformation.LockTimeToInterval(ot, settings.RoundOT);
     //TODO: Continue trying to get OT to calculate correctly based on settings
     return ShiftInformation.LockTimeToInterval(
         ShiftInformation.CalcOvertime(period.StartTime, period.EndTime), settings.RoundOT);
 }
Exemplo n.º 6
0
 private bool tryAutoSetStartTime()
 {
     if (period.StartTime != DateTime.MinValue)
     {
         return false;
     }
     changeStartTime(ShiftInformation.CombineDateAndTime(period.Date, guessStartTime(period.EndTime)));
     return true;
 }
Exemplo n.º 7
0
        public static void _CORRECT_WASHUP(DateTime start, DateTime end, ref TimeSpan wash, string word)
        {
            TimeSpan val;

            if (!TimeSpan.TryParse(word, out val))
            {
                saveToLog("Washup time data updated");
                val = ShiftInformation.CalcWashupTime(start, end, ShiftInformation.LunchLength);
            }
            wash = val;
        }
Exemplo n.º 8
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox cb = (CheckBox)sender;
            //period.WashupTime = cb.Checked;

            if (cb.Checked)
            {
                changeWashupTime(ShiftInformation.CalcWashupTime(this.period.StartTime, this.period.EndTime, ShiftInformation.LunchLength));
                cb.BackColor = SystemColors.ControlDark;
            }
            else
            {
                changeWashupTime(TimeSpan.Zero);
                cb.BackColor = Control.DefaultBackColor;
            }
        }
Exemplo n.º 9
0
            public List <PremiumCode> GenerateCodes(List <work_period> wp, Settings settings)
            {
                List <PremiumCode> outputCodes = new List <PremiumCode>();

                for (int n = 0; n < wp.Count; ++n)
                {
                    work_period p = wp[n];

                    DateTime nextDay = p.Date.AddDays(1.0);
                    nextDay = new DateTime(nextDay.Year, nextDay.Month, nextDay.Day, 0, 0, 0);

                    PremiumCode pc = new PremiumCode(DEFAULT_CODE, p.Date);

                    if (p.Overtime <= TimeSpan.Zero)
                    {
                        continue;
                    }
                    else if ((nextDay.DayOfWeek == DayOfWeek.Sunday) &&
                             p.EndTime.Date == nextDay.Date)
                    {
                        pc.Hours = ShiftInformation.LockTimeToInterval(
                            ShiftInformation.CalcOvertime(p.StartTime,
                                                          nextDay), settings.RoundOT);

                        PremiumCode holidayOT = new PremiumCode(DEFAULT_CODE, nextDay);
                        holidayOT.Hours = ShiftInformation.LockTimeToInterval(
                            ShiftInformation.CalcHoursWorked(p.StartTime, p.EndTime,
                                                             ShiftInformation.LunchLength).Subtract(pc.Hours), settings.RoundOT);
                        findAndAddHours(holidayOT, outputCodes);
                    }
                    else
                    {
                        pc.Hours = p.Overtime;
                    }

                    if (pc.Hours > TimeSpan.Zero)
                    {
                        findAndAddHours(pc, outputCodes);
                    }
                }

                return(outputCodes);
            }
Exemplo n.º 10
0
        public static TimeSpan CalcWashupTime(DateTime start, DateTime end, TimeSpan lunch)
        {
            if (ShiftInformation.IsRestDay(start) ||
                StatHoliday.IsStatDay(start))
            {
                return(ShiftInformation.WashupTimeAmount);
            }
            TimeSpan washup = CalcHoursWorked(start, end.AddMinutes(WashupTimeAmount.TotalMinutes), lunch).Subtract(ShiftLength);

            if (washup < TimeSpan.Zero)
            {
                return(TimeSpan.Zero);
            }
            else if (washup > WashupTimeAmount)
            {
                return(WashupTimeAmount);
            }
            else
            {
                return(washup);
            }
        }
Exemplo n.º 11
0
            public List <PremiumCode> GenerateCodes(List <work_period> wp, Settings settings)
            {
                List <PremiumCode> outputcodes = new List <PremiumCode>();

                foreach (work_period p in wp)
                {
                    if (p.WashupTime <= TimeSpan.Zero ||
                        p.StartTime == DateTime.MinValue ||
                        p.EndTime == DateTime.MinValue)
                    {
                        continue;
                    }

                    TimeSpan washup    = ShiftInformation.CalcWashupTime(p.StartTime, p.EndTime, ShiftInformation.LunchLength);
                    DateTime washupEnd = p.EndTime + washup;
                    TimeSpan ot        = ShiftInformation.CalcOvertime(p.StartTime, p.EndTime);

                    if (ot >= ShiftInformation.ShiftLength) // 7.5 Hrs of OT or more
                    {
                        PremiumCode pc = new PremiumCode(DEFAULT_CODE, p.EndTime);
                        pc.EndDate = washupEnd;
                        pc.SetArrayHours(p.WashupTime, PremiumCode.HoursMultiplier.X200);

                        outputcodes.Add(pc);
                    }
                    else if (p.EndTime.DayOfWeek == DayOfWeek.Sunday &&
                             washupEnd.DayOfWeek == DayOfWeek.Sunday &&
                             settings.SplitSaturday) // Shift ends on a sunday
                    {
                        PremiumCode x20 = new PremiumCode(DEFAULT_CODE, p.EndTime);
                        x20.EndDate = washupEnd;
                        x20.SetArrayHours(p.WashupTime, PremiumCode.HoursMultiplier.X200);
                        outputcodes.Add(x20);
                    }
                    else if (washupEnd.DayOfWeek == DayOfWeek.Sunday)
                    {
                        DateTime cutoff = new DateTime(washupEnd.Year, washupEnd.Month, washupEnd.Day,
                                                       0, 0, 0);

                        PremiumCode x15 = new PremiumCode(DEFAULT_CODE, p.EndTime);
                        x15.EndDate = cutoff;
                        x15.SetArrayHours(cutoff - p.EndTime, PremiumCode.HoursMultiplier.X150);
                        outputcodes.Add(x15);

                        PremiumCode x20 = new PremiumCode(DEFAULT_CODE, cutoff);
                        x20.EndDate = washupEnd;
                        x20.SetArrayHours(washupEnd - cutoff, PremiumCode.HoursMultiplier.X200);
                        outputcodes.Add(x20);
                    }
                    else //Usual case
                    {
                        PremiumCode pc = new PremiumCode(DEFAULT_CODE, p.EndTime);
                        pc.EndDate = washupEnd;
                        pc.SetArrayHours(p.WashupTime, PremiumCode.HoursMultiplier.X150);

                        outputcodes.Add(pc);
                    }
                }

                return(outputcodes);
            }
Exemplo n.º 12
0
 private void updateWashup()
 {
     period.WashupTime = ShiftInformation.CalcWashupTime(period.StartTime, period.EndTime, ShiftInformation.LunchLength);
     cb_Washup.Checked = period.WashupTime > TimeSpan.Zero;
 }
Exemplo n.º 13
0
 private TimeSpan calcShiftPremium()
 {
     return ShiftInformation.LockTimeToInterval(
         ShiftInformation.CalcShiftPremium(period.StartTime, period.EndTime), settings.RoundOT);
 }