diff --git a/Backend/models/workDay.go b/Backend/models/workDay.go index e1fec9f..4477323 100644 --- a/Backend/models/workDay.go +++ b/Backend/models/workDay.go @@ -46,11 +46,10 @@ func (d *WorkDay) GetWorktimeAbsence() Absence { // Gets the time as is in the db (with corrected pause times) func (d *WorkDay) GetWorktime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration { - if includeKurzarbeit && d.IsKurzArbeit() && len(d.Bookings) > 0 { + if includeKurzarbeit && d.IsKurzArbeit() { //&& len(d.Bookings) > 0 return d.kurzArbeitAbsence.GetWorktime(u, base, true) } - work, pause := calcWorkPause(d.Bookings) - work, pause = correctWorkPause(work, pause) + work, _ := correctWorkPause(getWorkPause(d)) if (d.worktimeAbsece != Absence{}) { work += d.worktimeAbsece.GetWorktime(u, base, false) } @@ -59,7 +58,7 @@ func (d *WorkDay) GetWorktime(u User, base WorktimeBase, includeKurzarbeit bool) // Gets the corrected pause times based on db entries func (d *WorkDay) GetPausetime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration { - work, pause := calcWorkPause(d.Bookings) + work, pause := getWorkPause(d) work, pause = correctWorkPause(work, pause) return pause.Round(time.Minute) } @@ -81,6 +80,15 @@ func (d *WorkDay) GetTimes(u User, base WorktimeBase, includeKurzarbeit bool) (w return d.GetWorktime(u, base, includeKurzarbeit), d.GetPausetime(u, base, includeKurzarbeit), d.GetOvertime(u, base, includeKurzarbeit) } +func getWorkPause(d *WorkDay) (work, pause time.Duration) { + //if today calc, else take from db + if helper.IsSameDate(d.Date(), time.Now()) { + return calcWorkPause(d.Bookings) + } else { + return d.workTime, d.pauseTime + } +} + func calcWorkPause(bookings []Booking) (work, pause time.Duration) { var lastBooking Booking for _, b := range bookings { diff --git a/Backend/templates/reportPage.templ b/Backend/templates/reportPage.templ index cf1e1cb..83e9191 100644 --- a/Backend/templates/reportPage.templ +++ b/Backend/templates/reportPage.templ @@ -170,10 +170,12 @@ templ workDayWeekComponent(workDay *models.WorkDay) {
switch { - case !workDay.TimeFrom.Equal(workDay.TimeTo): + case !workDay.IsEmpty(): { workDay.TimeFrom.Format("15:04") } - { workDay.TimeTo.Format("15:04") } + case workDay.IsKurzArbeit(): + Kurzarbeit default:

Keine Anwesenheit

}