fix: wrong kurzarbeit calculation fixed #80
Some checks failed
Tests / Run Go Tests (push) Failing after 1m5s

This commit is contained in:
2026-02-15 18:16:12 +01:00
parent 7e54800bc3
commit 23896e4f08
3 changed files with 24 additions and 45 deletions

View File

@@ -31,6 +31,7 @@ type WorkWeek struct {
Overtime time.Duration
Status WeekStatus
WeekBase WorktimeBase
Kurzarbeit time.Duration
}
type WeekStatus int8
@@ -72,8 +73,13 @@ func (w *WorkWeek) PopulateWithDays(worktime time.Duration, overtime time.Durati
}
for _, day := range w.Days {
w.Worktime += day.GetWorktime(w.User, w.WeekBase, false)
w.WorktimeVirtual += day.GetWorktime(w.User, w.WeekBase, true)
dWorkTime := day.GetWorktime(w.User, w.WeekBase, false)
dWorkTimeVirtual := day.GetWorktime(w.User, w.WeekBase, true)
if dWorkTime < dWorkTimeVirtual {
w.Kurzarbeit += dWorkTimeVirtual - dWorkTime
}
w.Worktime += dWorkTime
w.WorktimeVirtual += dWorkTimeVirtual
slog.Debug("Calculated Worktime", "Day", day.ToString(), "worktime", w.Worktime.String())
}
slog.Debug("Got worktime for user", "worktime", w.Worktime.String(), "virtualWorkTime", w.WorktimeVirtual.String())