public int Execute() { Employee e= PayrollDatabase.GetEmployee(_empid); if (e != null) { HourlyClassification hc = e.Classification as HourlyClassification; if (hc != null) { TimeCard tc = new TimeCard() {Date = _date, Hours = _hours}; hc.AddTimeCard(tc); } else { throw new InvalidOperationException(); } } else { throw new InvalidOperationException("No such employee"); } return 1; }
/// <summary> /// /// </summary> /// <param name="timecard"></param> /// <returns></returns> private double CalculatePayForTimeCard(TimeCard timecard) { double overtimeHours = Math.Max(0.0, timecard.Hours - 8); double normalHours = timecard.Hours - overtimeHours; return _hourlyRate * normalHours + _hourlyRate * 1.5 * overtimeHours; }
private bool IsInPayPeriod(TimeCard timecard, Paycheck paycheck) { DateTime payPeriodEndDate = paycheck.PayPeriodEndDate; DateTime payPeriodStartDate = paycheck.PayPeriodStartDate; return timecard.Date >= payPeriodStartDate && timecard.Date <= payPeriodEndDate; }
public void AddTimeCard(TimeCard tc) { TimeCards.Add(tc); }