added worktime base to work time calculations
Some checks failed
Tests / Run Go Tests (push) Failing after 1m4s
Some checks failed
Tests / Run Go Tests (push) Failing after 1m4s
This commit is contained in:
@@ -49,6 +49,55 @@ func (a *Absence) IsMultiDay() bool {
|
||||
return !a.DateFrom.Equal(a.DateTo)
|
||||
}
|
||||
|
||||
func (a *Absence) GetWorktimeReal(u User, base WorktimeBase) time.Duration {
|
||||
if a.AbwesenheitTyp.WorkTime <= 1 {
|
||||
return 0
|
||||
}
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
return u.ArbeitszeitProTag()
|
||||
case WorktimeBaseWeek:
|
||||
return u.ArbeitszeitProWoche() / 5
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (a *Absence) GetPausetimeReal(u User, base WorktimeBase) time.Duration {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *Absence) GetOvertimeReal(u User, base WorktimeBase) time.Duration {
|
||||
if a.AbwesenheitTyp.WorkTime > 1 {
|
||||
return 0
|
||||
}
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
return -u.ArbeitszeitProTag()
|
||||
case WorktimeBaseWeek:
|
||||
return -u.ArbeitszeitProWoche() / 5
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *Absence) GetWorktimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
return a.GetWorktimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetPausetimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
return a.GetPausetimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetOvertimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
return a.GetOvertimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetTimesReal(u User, base WorktimeBase) (work, pause, overtime time.Duration) {
|
||||
return a.GetWorktimeReal(u, base), a.GetPausetimeReal(u, base), a.GetOvertimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetTimesVirtual(u User, base WorktimeBase) (work, pause, overtime time.Duration) {
|
||||
return a.GetWorktimeVirtual(u, base), a.GetPausetimeVirtual(u, base), a.GetOvertimeVirtual(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) TimeWorkVirtual(u User) time.Duration {
|
||||
return a.TimeWorkReal(u)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user