added public holidays + updated templ to v0.3.960
Some checks failed
Tests / Run Go Tests (push) Failing after 1m33s

This commit is contained in:
2025-12-19 09:15:58 +01:00
parent 177fbdeb3f
commit f562ef2a33
16 changed files with 95 additions and 33 deletions

View File

@@ -143,9 +143,9 @@ func createReports(employes []models.User, startDate time.Time) []typstData {
endDate := startDate.AddDate(0, 1, -1)
var employeData []typstData
for _, employe := range employes {
if data, err := createEmployeReport(employe, startDate, endDate); err != nil {
slog.Warn("Error when creating employeReport", slog.Any("user", employe), slog.Any("error", err))
for _, employee := range employes {
if data, err := createEmployeReport(employee, startDate, endDate); err != nil {
slog.Warn("Error when creating employeReport", slog.Any("user", employee), slog.Any("error", err))
} else {
employeData = append(employeData, data)
}
@@ -154,7 +154,8 @@ func createReports(employes []models.User, startDate time.Time) []typstData {
}
func createEmployeReport(employee models.User, startDate, endDate time.Time) (typstData, error) {
targetHoursThisMonth := employee.ArbeitszeitProWocheFrac(.2) * time.Duration(helper.GetWorkingDays(startDate, endDate))
publicHolidays, err := models.GetHolidaysFromTo(startDate, endDate)
targetHoursThisMonth := employee.ArbeitszeitProWocheFrac(.2) * time.Duration(helper.GetWorkingDays(startDate, endDate)-len(publicHolidays))
workDaysThisMonth := models.GetDays(employee, startDate, endDate.AddDate(0, 0, 1), false)
slog.Debug("Baseline Working hours", "targetHours", targetHoursThisMonth.Hours())

View File

@@ -4,7 +4,7 @@ go 1.24.7
require github.com/lib/pq v1.10.9
require github.com/a-h/templ v0.3.943
require github.com/a-h/templ v0.3.960
require github.com/alexedwards/scs/v2 v2.8.0

View File

@@ -6,6 +6,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/a-h/templ v0.3.943 h1:o+mT/4yqhZ33F3ootBiHwaY4HM5EVaOJfIshvd5UNTY=
github.com/a-h/templ v0.3.943/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo=
github.com/a-h/templ v0.3.960 h1:trshEpGa8clF5cdI39iY4ZrZG8Z/QixyzEyUnA7feTM=
github.com/a-h/templ v0.3.960/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo=
github.com/alexedwards/scs/v2 v2.8.0 h1:h31yUYoycPuL0zt14c0gd+oqxfRwIj6SOjHdKRZxhEw=
github.com/alexedwards/scs/v2 v2.8.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=

View File

@@ -26,10 +26,9 @@ func (p ParamsParser) ParseIntListFallback(key string, delimiter string, fallbac
if !p.urlParams.Has(key) {
return fallback
}
paramList := p.urlParams.Get(key)
list := strings.Split(paramList, delimiter)
paramList := p.urlParams[key]
parsedList := make([]int, 0)
for _, item := range list {
for _, item := range paramList {
if parsedItem, err := strconv.Atoi(item); err == nil {
parsedList = append(parsedList, parsedItem)
}

View File

@@ -0,0 +1,53 @@
package models
import "time"
type PublicHoliday struct {
name string
date time.Time
}
func GetHolidaysFromTo(tsFrom, tsTo time.Time) ([]PublicHoliday, error) {
return make([]PublicHoliday, 0), nil
}
// Interface implementation
func (p *PublicHoliday) Date() time.Time {
return time.Now()
}
func (p *PublicHoliday) ToString() string {
return ""
}
func (p *PublicHoliday) IsWorkDay() bool {
return false
}
func (p *PublicHoliday) IsKurzArbeit() bool {
return false
}
func (p *PublicHoliday) GetDayProgress(User) int8 {
return 0
}
func (p *PublicHoliday) RequiresAction() bool {
return false
}
func (p *PublicHoliday) GetWorktime(User, WorktimeBase, bool) time.Duration {
return 0
}
func (p *PublicHoliday) GetPausetime(User, WorktimeBase, bool) time.Duration {
return 0
}
func (p *PublicHoliday) GetTimes(User, WorktimeBase, bool) (work, pause, overtime time.Duration) {
return 0, 0, 0
}
func (p *PublicHoliday) GetOvertime(User, WorktimeBase, bool) time.Duration {
return 0
}

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.960
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.960
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -116,7 +116,6 @@ func SettingsPage(status int) templ.Component {
templ_7745c5c3_Var4 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
user := ctx.Value("user").(models.User)
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.960
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -130,7 +130,6 @@ func CheckboxComponent(pNr int, label string) templ.Component {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
id := fmt.Sprintf("pdf-%d", pNr)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"inline-flex items-center\"><label class=\"flex items-center cursor-pointer relative\" for=\"")
if templ_7745c5c3_Err != nil {
@@ -290,7 +289,6 @@ func ColorDuration(d time.Duration, classes string) templ.Component {
templ_7745c5c3_Var11 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
color := ""
if d.Abs() < time.Minute {
color = "text-neutral-300"

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.960
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.960
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -37,7 +37,6 @@ func weekPicker(weekStart time.Time) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
year, kw := weekStart.ISOWeek()
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<form method=\"get\" class=\"flex flex-row gap-4 items-center justify-around\"><input type=\"date\" class=\"hidden\" name=\"submission_date\" value=\"")
if templ_7745c5c3_Err != nil {
@@ -177,7 +176,6 @@ func defaultWeekDayComponent(u models.User, day models.IWorkDay) templ.Component
return templ_7745c5c3_Err
}
if day.IsWorkDay() {
workDay, _ := day.(*models.WorkDay)
work, pause, _ := workDay.GetTimes(u, models.WorktimeBaseDay, false)
if !workDay.RequiresAction() {
@@ -260,7 +258,6 @@ func defaultWeekDayComponent(u models.User, day models.IWorkDay) templ.Component
}
}
} else {
absentDay, _ := day.(*models.Absence)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<div>")
if templ_7745c5c3_Err != nil {
@@ -344,7 +341,6 @@ func workWeekComponent(week models.WorkWeek, onlyAccept bool) templ.Component {
templ_7745c5c3_Var15 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
year, kw := week.WeekStart.ISOWeek()
progress := (float32(week.WorktimeVirtual.Hours()) / week.User.ArbeitszeitPerWoche) * 100
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<div class=\"employeComponent grid-sub responsive lg:divide-x-1 max-md:divide-y-1 @container\"><div class=\"grid-cell flex flex-col max-md:bg-neutral-300 gap-2\">")
@@ -501,7 +497,6 @@ func workWeekComponent(week models.WorkWeek, onlyAccept bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
week.CheckStatus()
method := "accept"
if !onlyAccept {

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.960
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -124,7 +124,6 @@ func timeGaugeComponent(progress int8, today bool) templ.Component {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
var bgColor string
switch {
case (0 > progress):
@@ -278,7 +277,6 @@ func absenceComponent(a *models.Absence, isKurzarbeit bool) templ.Component {
templ_7745c5c3_Var13 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
editBox := ""
if isKurzarbeit {
editBox = "edit-box"

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.960
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -37,7 +37,6 @@ func TimePage(workDays []models.WorkDay, lastSub time.Time) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
allDays := ctx.Value("days").([]models.IWorkDay)
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
@@ -104,7 +103,6 @@ func inputForm() templ.Component {
templ_7745c5c3_Var2 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
urlParams := ctx.Value("urlParams").(url.Values)
user := ctx.Value("user").(models.User)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<div class=\"grid-sub divide-x-1 bg-neutral-300 responsive\"><div class=\"grid-cell md:col-span-1 max-md:grid grid-cols-2\"><p class=\"font-bold uppercase\">")
@@ -232,7 +230,6 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
templ_7745c5c3_Var9 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
user := ctx.Value("user").(models.User)
justify := "justify-center"
if day.IsWorkDay() && len(day.(*models.WorkDay).Bookings) > 1 {
@@ -295,7 +292,6 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
return templ_7745c5c3_Err
}
if day.IsWorkDay() {
workDay, _ := day.(*models.WorkDay)
work, pause, overtime := workDay.GetTimes(user, models.WorktimeBaseDay, true)
work = workDay.GetWorktime(user, models.WorktimeBaseDay, false)
@@ -416,7 +412,6 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
return templ_7745c5c3_Err
}
if day.IsWorkDay() {
workDay, _ := day.(*models.WorkDay)
templ_7745c5c3_Err = newAbsenceComponent().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
@@ -457,7 +452,6 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
return templ_7745c5c3_Err
}
} else {
absentDay, _ := day.(*models.Absence)
templ_7745c5c3_Err = absenceComponent(absentDay, false).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {