Exemple #1
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);
            }