removed and refactored virtual and real worktime

This commit is contained in:
2025-12-12 06:31:03 +01:00
parent f73c2b1a96
commit 1ccc19b85c
12 changed files with 79 additions and 84 deletions

View File

@@ -49,6 +49,43 @@ func (a *Absence) IsMultiDay() bool {
return !a.DateFrom.Equal(a.DateTo)
}
func (a *Absence) GetWorktime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration {
switch base {
case WorktimeBaseDay:
if a.AbwesenheitTyp.WorkTime <= 0 && includeKurzarbeit {
return u.ArbeitszeitProTagFrac(1)
}
return u.ArbeitszeitProTagFrac(float32(a.AbwesenheitTyp.WorkTime) / 100)
case WorktimeBaseWeek:
if a.AbwesenheitTyp.WorkTime <= 0 && includeKurzarbeit {
return u.ArbeitszeitProTagFrac(0.2)
}
return u.ArbeitszeitProWocheFrac(0.2 * float32(a.AbwesenheitTyp.WorkTime) / 100)
}
return 0
}
func (a *Absence) GetPausetime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration {
return 0
}
func (a *Absence) GetOvertime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration {
if a.AbwesenheitTyp.WorkTime > 0 {
return 0
}
switch base {
case WorktimeBaseDay:
return -u.ArbeitszeitProTagFrac(1)
case WorktimeBaseWeek:
return -u.ArbeitszeitProWocheFrac(0.2)
}
return 0
}
func (a *Absence) GetTimes(u User, base WorktimeBase, includeKurzarbeit bool) (work, pause, overtime time.Duration) {
return a.GetWorktime(u, base, includeKurzarbeit), a.GetPausetime(u, base, includeKurzarbeit), a.GetOvertime(u, base, includeKurzarbeit)
}
func (a *Absence) GetWorktimeReal(u User, base WorktimeBase) time.Duration {
if a.AbwesenheitTyp.WorkTime <= 0 {
return 0
@@ -71,9 +108,9 @@ func (a *Absence) GetOvertimeReal(u User, base WorktimeBase) time.Duration {
}
switch base {
case WorktimeBaseDay:
return -u.ArbeitszeitProTag()
return -u.ArbeitszeitProTagFrac(1)
case WorktimeBaseWeek:
return -u.ArbeitszeitProWoche() / 5
return -u.ArbeitszeitProWocheFrac(0.2)
}
return 0
}