fixed overtime calc issue
This commit is contained in:
@@ -94,7 +94,7 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
||||
if day.Date().Before(lastSub) {
|
||||
continue
|
||||
}
|
||||
aggregatedOvertime += day.GetOvertime(user, models.WorktimeBaseDay, false)
|
||||
aggregatedOvertime += day.GetOvertime(user, models.WorktimeBaseDay, true)
|
||||
}
|
||||
if reportedOvertime, err := user.GetReportedOvertime(); err == nil {
|
||||
user.Overtime = (reportedOvertime + aggregatedOvertime).Round(time.Minute)
|
||||
|
||||
@@ -28,7 +28,7 @@ func (c *CompoundDay) GetWorkDay() WorkDay {
|
||||
|
||||
// IsEmpty implements [IWorkDay].
|
||||
func (c *CompoundDay) IsEmpty() bool {
|
||||
return len(c.DayParts) > 0
|
||||
return len(c.DayParts) == 0
|
||||
}
|
||||
|
||||
// Date implements [IWorkDay].
|
||||
@@ -47,12 +47,16 @@ func (c *CompoundDay) GetDayProgress(u User) int8 {
|
||||
|
||||
// GetOvertime implements [IWorkDay].
|
||||
func (c *CompoundDay) GetOvertime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration {
|
||||
work := c.GetWorktime(u, base, includeKurzarbeit)
|
||||
var targetHours time.Duration
|
||||
|
||||
var overtime time.Duration
|
||||
for _, day := range c.DayParts {
|
||||
overtime += day.GetOvertime(u, base, includeKurzarbeit)
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
targetHours = u.ArbeitszeitProTagFrac(1)
|
||||
case WorktimeBaseWeek:
|
||||
targetHours = u.ArbeitszeitProWocheFrac(.2)
|
||||
}
|
||||
return overtime
|
||||
return (work - targetHours).Round(time.Minute)
|
||||
}
|
||||
|
||||
// GetPausetime implements [IWorkDay].
|
||||
|
||||
@@ -115,7 +115,7 @@ templ defaultDayComponent(day models.IWorkDay) {
|
||||
if pause > 0 {
|
||||
<p class="text-neutral-500 flex flex-row items-center"><span class="icon-[material-symbols-light--motion-photos-paused-outline]"></span>{ helper.FormatDuration(pause) }</p>
|
||||
}
|
||||
if overtime != 0 && day.IsEmpty() == false {
|
||||
if !day.IsEmpty() && overtime != 0 {
|
||||
<p class="text-neutral-500 flex flex-row items-center">
|
||||
<span class="icon-[material-symbols-light--more-time]"></span>
|
||||
{ helper.FormatDuration(overtime) }
|
||||
|
||||
@@ -346,7 +346,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if overtime != 0 && day.IsEmpty() == false {
|
||||
if !day.IsEmpty() && overtime != 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<p class=\"text-neutral-500 flex flex-row items-center\"><span class=\"icon-[material-symbols-light--more-time]\"></span> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
|
||||
Reference in New Issue
Block a user