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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user