small fixes and refactoring

This commit is contained in:
2025-04-10 09:11:17 +02:00
parent e60f19ee27
commit 19251eefed
10 changed files with 34 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
package models
import (
"arbeitszeitmessung/helper"
"database/sql"
"fmt"
"log"
@@ -161,16 +162,23 @@ func (b Booking) Save() {
}
func (b *Booking) GetBookingType() string {
debug := (helper.GetEnv("GO_ENV", "production") == "debug")
switch b.CheckInOut {
case 1: //manuelle Änderung
return "kommen"
case 3:
if(debug){
return "kommen manuell"
}
return "kommen"
case 2: //manuelle Änderung
return "gehen"
case 4:
if(debug){
return "gehen manuell"
case 255:
}
return "gehen"
case 254:
return "abgemeldet"
default:
return "Buchungs Typ unbekannt"
@@ -221,11 +229,11 @@ func (b *Booking) UpdateTime(newTime time.Time) {
// TODO: add check for time overlap
var newBooking Booking
newBooking.Timestamp = time.Date(b.Timestamp.Year(), b.Timestamp.Month(), b.Timestamp.Day(), hour, minute, 0, 0, time.Local)
newBooking.Timestamp = time.Date(b.Timestamp.Year(), b.Timestamp.Month(), b.Timestamp.Day(), hour, minute, 0, 0, b.Timestamp.Location())
if b.CheckInOut < 3 {
newBooking.CheckInOut = b.CheckInOut + 2
}
if b.CheckInOut == 255 {
if b.CheckInOut == 254 {
newBooking.CheckInOut = 4
}
b.Update(newBooking)