dev/finalFixes #81
@@ -46,11 +46,10 @@ func (d *WorkDay) GetWorktimeAbsence() Absence {
|
||||
|
||||
// Gets the time as is in the db (with corrected pause times)
|
||||
func (d *WorkDay) GetWorktime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration {
|
||||
if includeKurzarbeit && d.IsKurzArbeit() && len(d.Bookings) > 0 {
|
||||
if includeKurzarbeit && d.IsKurzArbeit() { //&& len(d.Bookings) > 0
|
||||
return d.kurzArbeitAbsence.GetWorktime(u, base, true)
|
||||
}
|
||||
work, pause := calcWorkPause(d.Bookings)
|
||||
work, pause = correctWorkPause(work, pause)
|
||||
work, _ := correctWorkPause(getWorkPause(d))
|
||||
if (d.worktimeAbsece != Absence{}) {
|
||||
work += d.worktimeAbsece.GetWorktime(u, base, false)
|
||||
}
|
||||
@@ -59,7 +58,7 @@ func (d *WorkDay) GetWorktime(u User, base WorktimeBase, includeKurzarbeit bool)
|
||||
|
||||
// Gets the corrected pause times based on db entries
|
||||
func (d *WorkDay) GetPausetime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration {
|
||||
work, pause := calcWorkPause(d.Bookings)
|
||||
work, pause := getWorkPause(d)
|
||||
work, pause = correctWorkPause(work, pause)
|
||||
return pause.Round(time.Minute)
|
||||
}
|
||||
@@ -81,6 +80,15 @@ func (d *WorkDay) GetTimes(u User, base WorktimeBase, includeKurzarbeit bool) (w
|
||||
return d.GetWorktime(u, base, includeKurzarbeit), d.GetPausetime(u, base, includeKurzarbeit), d.GetOvertime(u, base, includeKurzarbeit)
|
||||
}
|
||||
|
||||
func getWorkPause(d *WorkDay) (work, pause time.Duration) {
|
||||
//if today calc, else take from db
|
||||
if helper.IsSameDate(d.Date(), time.Now()) {
|
||||
return calcWorkPause(d.Bookings)
|
||||
} else {
|
||||
return d.workTime, d.pauseTime
|
||||
}
|
||||
}
|
||||
|
||||
func calcWorkPause(bookings []Booking) (work, pause time.Duration) {
|
||||
var lastBooking Booking
|
||||
for _, b := range bookings {
|
||||
|
||||
@@ -170,10 +170,12 @@ templ workDayWeekComponent(workDay *models.WorkDay) {
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<span class="icon-[material-symbols-light--schedule-outline] flex-shrink-0"></span>
|
||||
switch {
|
||||
case !workDay.TimeFrom.Equal(workDay.TimeTo):
|
||||
case !workDay.IsEmpty():
|
||||
<span>{ workDay.TimeFrom.Format("15:04") }</span>
|
||||
<span>-</span>
|
||||
<span>{ workDay.TimeTo.Format("15:04") }</span>
|
||||
case workDay.IsKurzArbeit():
|
||||
<span>Kurzarbeit</span>
|
||||
default:
|
||||
<p>Keine Anwesenheit</p>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user