fix: weekbased calculation pdf report
with this change the time calculations for pdf reports should be better line with the reports send as "week_report"
This commit is contained in:
@@ -151,12 +151,21 @@ func (d *WorkDay) Type() DayType {
|
||||
return DayTypeWorkday
|
||||
}
|
||||
|
||||
func (d *WorkDay) GenerateKurzArbeitBookings(u User) (time.Time, time.Time) {
|
||||
func (d *WorkDay) GenerateKurzArbeitBookings(u User, weekBase WorktimeBase) (time.Time, time.Time) {
|
||||
var timeFrom, timeTo time.Time
|
||||
if d.GetWorktime(u, WorktimeBaseDay, false) >= u.ArbeitszeitProTag() {
|
||||
return timeFrom, timeTo
|
||||
}
|
||||
|
||||
if d.IsEmpty() {
|
||||
switch weekBase {
|
||||
case WorktimeBaseDay:
|
||||
return d.Day.Add(time.Hour * 8), d.Day.Add(time.Hour * 8).Add(u.ArbeitszeitProTag())
|
||||
case WorktimeBaseWeek:
|
||||
return d.Day.Add(time.Hour * 8), d.Day.Add(time.Hour * 8).Add(u.ArbeitszeitProWocheFrac(0.2))
|
||||
}
|
||||
}
|
||||
|
||||
timeFrom = d.Bookings[len(d.Bookings)-1].Timestamp.Add(time.Minute)
|
||||
timeTo = timeFrom.Add(u.ArbeitszeitProTag() - d.GetWorktime(u, WorktimeBaseDay, false))
|
||||
slog.Debug("Added duration as Kurzarbeit", "date", d.Date().String(), "duration", timeTo.Sub(timeFrom).String())
|
||||
@@ -169,7 +178,7 @@ func (d *WorkDay) GetKurzArbeit() *Absence {
|
||||
}
|
||||
|
||||
func (d *WorkDay) ToString() string {
|
||||
return fmt.Sprintf("WorkDay: %s with %d bookings and worktime: %s", d.Date().Format(time.DateOnly), len(d.Bookings), helper.FormatDuration(d.workTime))
|
||||
return fmt.Sprintf("WorkDay: %s with %d bookings and worktime: %s. Is KurzArbeit %v", d.Date().Format(time.DateOnly), len(d.Bookings), helper.FormatDuration(d.workTime), d.IsKurzArbeit())
|
||||
}
|
||||
|
||||
func (d *WorkDay) IsWorkDay() bool {
|
||||
|
||||
Reference in New Issue
Block a user