removed and refactored virtual and real worktime
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user