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:
2026-02-12 16:46:57 +01:00
parent 8911165c4b
commit 46218f9bca
18 changed files with 365 additions and 178 deletions

View File

@@ -33,7 +33,7 @@ type User struct {
func GetUserFromSession(Session *scs.SessionManager, ctx context.Context) (User, error) {
var user User
var err error
if helper.GetEnv("GO_ENV", "production") == "debug" {
if helper.IsDebug() {
user, err = GetUserByPersonalNr(123)
} else {
if !Session.Exists(ctx, "user") {
@@ -50,15 +50,15 @@ func GetUserFromSession(Session *scs.SessionManager, ctx context.Context) (User,
}
// Returns the actual overtime for this moment
func (u *User) GetReportedOvertime() (time.Duration, error) {
func (u *User) GetReportedOvertime(startDate time.Time) (time.Duration, error) {
var overtime time.Duration
qStr, err := DB.Prepare("SELECT COALESCE(SUM(EXTRACT(EPOCH FROM ueberstunden) * 1000000000)::BIGINT, 0) AS total_ueberstunden_ns FROM wochen_report WHERE personal_nummer = $1;")
qStr, err := DB.Prepare("SELECT COALESCE(SUM(EXTRACT(EPOCH FROM ueberstunden) * 1000000000)::BIGINT, 0) AS total_ueberstunden_ns FROM wochen_report WHERE personal_nummer = $1 AND woche_start::DATE <= $2::DATE;")
if err != nil {
return 0, err
}
defer qStr.Close()
err = qStr.QueryRow(u.PersonalNummer).Scan(&overtime)
err = qStr.QueryRow(u.PersonalNummer, startDate).Scan(&overtime)
if err != nil {
return 0, err
}