예제 #1
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);
 }
예제 #2
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);
            }
예제 #3
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);
            }