예제 #1
0
          public bool Equals(PayPeriod p)
          {
              if ((object)p == null)
                  return false;

              return (Start.Equals(p.Start) && End.Equals(p.End));
          }
예제 #2
0
        public String getAllPayroll(TimeClockContext db, PayPeriod payp)
        {
            var employees = db.Employees;
            String retString = "";
            foreach (Employee emp in employees)
            {
                Timecard tc = db.Timecards.SingleOrDefault(time => time.PayPeriod.Equals(payp.Start) && time.EmployeeID.Equals(emp.EmployeeID));

                var lines = db.Lines.Where(l => l.TimecardID == tc.TimecardID);

                Dictionary<String, Double> lineInformation = new Dictionary<String, Double>();

                foreach (Line line in lines)
                {
                    string key = line.Punch.DepartmentID.ToString() + ", " + line.PayType.ExportValue;

                    if (lineInformation.ContainsKey(key))
                        lineInformation[key] += line.getMinutDuration();
                    else
                        lineInformation.Add(key, line.getMinutDuration());
                }

                foreach (String key in lineInformation.Keys)
                {
                    String payRollLine = emp.EmployeeID + ", " + key + ", " + lineInformation[key].ToString("F2");
                    retString += payRollLine + "\n";
                }
            }

            return retString;
        }
예제 #3
0
        public bool Equals(PayPeriod p)
        {
            if ((object)p == null)
            {
                return(false);
            }

            return(Start.Equals(p.Start) && End.Equals(p.End));
        }
예제 #4
0
        public static PayPeriod LookupPayPeriod(TimeClockContext db, int DepartmentID, DateTime time)
        {
            var seed = db.Departments.SingleOrDefault(d => d.DepartmentID == DepartmentID);

            DateTime seedDate = seed.PayPeriodSeed;
            int interval = seed.PayPeriodInterval;

            TimeSpan span = time.Subtract(seedDate);

            int count = (int)Math.Floor(span.TotalDays / (double)interval);

            PayPeriod payPeriod = new PayPeriod();
            payPeriod.Start = seedDate.AddDays(count * interval);

            payPeriod.End = seedDate.AddDays(((count + 1) * interval) - 1);

            return payPeriod;
        }
예제 #5
0
        public static PayPeriod LookupPayPeriod(TimeClockContext db, int DepartmentID, DateTime time)
        {
            var seed = db.Departments.SingleOrDefault(d => d.DepartmentID == DepartmentID);

            DateTime seedDate = seed.PayPeriodSeed;
            int      interval = seed.PayPeriodInterval;

            TimeSpan span = time.Subtract(seedDate);

            int count = (int)Math.Floor(span.TotalDays / (double)interval);

            PayPeriod payPeriod = new PayPeriod();

            payPeriod.Start = seedDate.AddDays(count * interval);

            payPeriod.End = seedDate.AddDays(((count + 1) * interval) - 1);

            return(payPeriod);
        }
예제 #6
0
        public static bool addLines(TimeClockContext db, Punch punch) 
        {
            // determine payperiod
            PayPeriod currentPayP = PayPeriodTools.LookupPayPeriod(db, punch.employee.department.DepartmentID, punch.OutTime.Value);
            Timecard currentTC = db.Timecards.SingleOrDefault(tc => tc.EmployeeID == punch.EmployeeID && tc.PayPeriod.Equals(currentPayP.Start));

            // check if we reach over payperiods
            if (punch.InTime.Subtract(currentPayP.Start).TotalMinutes < 0) // We started in the previous payperiod , solit the punch into two.
            {
                PayPeriod previousPayP = new PayPeriod()
                    {
                        Start = currentPayP.Start.Subtract(TimeSpan.FromDays(punch.employee.department.PayPeriodInterval)),
                        End = currentPayP.Start
                    };

                Timecard previousTC = db.Timecards.SingleOrDefault(tc => tc.EmployeeID == punch.EmployeeID && tc.PayPeriod.Equals(previousPayP.Start));

                bool first = addLinesTimecard(db, punch, previousTC, punch.InTime, previousPayP.End);
                bool second = addLinesTimecard(db, punch, currentTC, currentPayP.Start, punch.OutTime.Value);

                return first && second;
            }
            else if (punch.OutTime.Value.Subtract(currentPayP.End).TotalMinutes > 0) // We ended in the next payperiod - Not sure this will ever happen
            {
                PayPeriod nextPayP = new PayPeriod()
                    {
                        Start = currentPayP.End,
                        End = currentPayP.End.Add(TimeSpan.FromDays(punch.employee.department.PayPeriodInterval))
                    };
                Timecard nextTC = db.Timecards.SingleOrDefault(tc => tc.EmployeeID == punch.EmployeeID && tc.PayPeriod.Equals(nextPayP.Start));

                bool first = addLinesTimecard(db, punch, currentTC, punch.InTime, currentPayP.End);
                bool second = addLinesTimecard(db, punch, nextTC, nextPayP.Start, punch.OutTime.Value);

                return first && second;
            }
            else // No over lap, we just add the whole punch to the current Time card
            {
                return addLinesTimecard(db, punch, currentTC, punch.InTime, punch.OutTime.Value);
            }
            
        }
예제 #7
0
        public static bool addLines(TimeClockContext db, Punch punch)
        {
            // determine payperiod
            PayPeriod currentPayP = PayPeriodTools.LookupPayPeriod(db, punch.employee.department.DepartmentID, punch.OutTime.Value);
            Timecard  currentTC   = db.Timecards.SingleOrDefault(tc => tc.EmployeeID == punch.EmployeeID && tc.PayPeriod.Equals(currentPayP.Start));

            // check if we reach over payperiods
            if (punch.InTime.Subtract(currentPayP.Start).TotalMinutes < 0) // We started in the previous payperiod , solit the punch into two.
            {
                PayPeriod previousPayP = new PayPeriod()
                {
                    Start = currentPayP.Start.Subtract(TimeSpan.FromDays(punch.employee.department.PayPeriodInterval)),
                    End   = currentPayP.Start
                };

                Timecard previousTC = db.Timecards.SingleOrDefault(tc => tc.EmployeeID == punch.EmployeeID && tc.PayPeriod.Equals(previousPayP.Start));

                bool first  = addLinesTimecard(db, punch, previousTC, punch.InTime, previousPayP.End);
                bool second = addLinesTimecard(db, punch, currentTC, currentPayP.Start, punch.OutTime.Value);

                return(first && second);
            }
            else if (punch.OutTime.Value.Subtract(currentPayP.End).TotalMinutes > 0) // We ended in the next payperiod - Not sure this will ever happen
            {
                PayPeriod nextPayP = new PayPeriod()
                {
                    Start = currentPayP.End,
                    End   = currentPayP.End.Add(TimeSpan.FromDays(punch.employee.department.PayPeriodInterval))
                };
                Timecard nextTC = db.Timecards.SingleOrDefault(tc => tc.EmployeeID == punch.EmployeeID && tc.PayPeriod.Equals(nextPayP.Start));

                bool first  = addLinesTimecard(db, punch, currentTC, punch.InTime, currentPayP.End);
                bool second = addLinesTimecard(db, punch, nextTC, nextPayP.Start, punch.OutTime.Value);

                return(first && second);
            }
            else // No over lap, we just add the whole punch to the current Time card
            {
                return(addLinesTimecard(db, punch, currentTC, punch.InTime, punch.OutTime.Value));
            }
        }
예제 #8
0
        public String getAllPayroll(TimeClockContext db, PayPeriod payp)
        {
            var    employees = db.Employees;
            String retString = "";

            foreach (Employee emp in employees)
            {
                Timecard tc = db.Timecards.SingleOrDefault(time => time.PayPeriod.Equals(payp.Start) && time.EmployeeID.Equals(emp.EmployeeID));

                var lines = db.Lines.Where(l => l.TimecardID == tc.TimecardID);

                Dictionary <String, Double> lineInformation = new Dictionary <String, Double>();

                foreach (Line line in lines)
                {
                    string key = line.Punch.DepartmentID.ToString() + ", " + line.PayType.ExportValue;

                    if (lineInformation.ContainsKey(key))
                    {
                        lineInformation[key] += line.getMinutDuration();
                    }
                    else
                    {
                        lineInformation.Add(key, line.getMinutDuration());
                    }
                }

                foreach (String key in lineInformation.Keys)
                {
                    String payRollLine = emp.EmployeeID + ", " + key + ", " + lineInformation[key].ToString("F2");
                    retString += payRollLine + "\n";
                }
            }

            return(retString);
        }