// Todo take into account lunches and new days and missed clocks. // This required that it be sent an array of timestamps for 1 weeks pay private static TimeSheet CalculateHours(List <ClockStamp> timeStamps) { if (timeStamps.Count < 0) { return new TimeSheet { } } ; var timeSheet = new TimeSheet() { EmployeeId = timeStamps.First().EmployeeId }; var calcDate = DateTime.MinValue; var currentDate = DateTime.MinValue; var unAddedHours = 0m; foreach (var timeStamp in timeStamps) { // Need to do this but by day instead of by clock out if (timeStamp.In) { if (timeStamp.TimeStamp.Date > currentDate) { timeSheet = CalculateWorkDay(timeSheet, unAddedHours); unAddedHours = 0; } calcDate = timeStamp.TimeStamp; currentDate = timeStamp.TimeStamp.Date; continue; } var hoursForDay = RoundTimeStamp(timeSpan: timeStamp.TimeStamp - calcDate); unAddedHours += hoursForDay; } if (unAddedHours > 0) { timeSheet = CalculateWorkDay(timeSheet, unAddedHours); } return(timeSheet); }
private static string PrintPrettyHours(TimeSheet timeSheet) { return ($"Regular Hours = {timeSheet.RegularTime}\r\nOvertime = {timeSheet.OverTime}\r\nDoubletime = {timeSheet.DoubleTime}\r\n \r\n"); }