dev/finalFixes #81

Merged
tom_trgr merged 14 commits from dev/finalFixes into main 2026-03-01 10:11:45 +01:00
3 changed files with 10 additions and 10 deletions
Showing only changes of commit 10df10a606 - Show all commits

View File

@@ -13,35 +13,35 @@ var testBookingType = models.BookingType{
var testBookings8hrs = []models.Booking{{ var testBookings8hrs = []models.Booking{{
CardUID: "aaaa-aaaa", CardUID: "aaaa-aaaa",
CheckInOut: 1, CheckInOut: 1,
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType, BookingType: testBookingType,
}, { }, {
CardUID: "aaaa-aaaa", CardUID: "aaaa-aaaa",
CheckInOut: 2, CheckInOut: 2,
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:00")), Timestamp: time.Date(2025, 01, 01, 16, 0, 0, 0, time.UTC),
BookingType: testBookingType, BookingType: testBookingType,
}} }}
var testBookings6hrs = []models.Booking{{ var testBookings6hrs = []models.Booking{{
CardUID: "aaaa-aaaa", CardUID: "aaaa-aaaa",
CheckInOut: 1, CheckInOut: 1,
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType, BookingType: testBookingType,
}, { }, {
CardUID: "aaaa-aaaa", CardUID: "aaaa-aaaa",
CheckInOut: 2, CheckInOut: 2,
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 14:00")), Timestamp: time.Date(2025, 01, 01, 14, 0, 0, 0, time.UTC),
BookingType: testBookingType, BookingType: testBookingType,
}} }}
var testBookings10hrs = []models.Booking{{ var testBookings10hrs = []models.Booking{{
CardUID: "aaaa-aaaa", CardUID: "aaaa-aaaa",
CheckInOut: 1, CheckInOut: 1,
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType, BookingType: testBookingType,
}, { }, {
CardUID: "aaaa-aaaa", CardUID: "aaaa-aaaa",
CheckInOut: 2, CheckInOut: 2,
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 18:00")), Timestamp: time.Date(2025, 01, 01, 18, 0, 0, 0, time.UTC),
BookingType: testBookingType, BookingType: testBookingType,
}} }}

View File

@@ -85,7 +85,7 @@ func (d *WorkDay) GetTimes(u User, base WorktimeBase, includeKurzarbeit bool) (w
func getWorkPause(d *WorkDay) (work, pause time.Duration) { func getWorkPause(d *WorkDay) (work, pause time.Duration) {
//if today calc, else take from db //if today calc, else take from db
if helper.IsSameDate(d.Date(), time.Now()) { if d.workTime == 0 && d.pauseTime == 0 && len(d.Bookings) > 0 {
return calcWorkPause(d.Bookings) return calcWorkPause(d.Bookings)
} else { } else {
return d.workTime, d.pauseTime return d.workTime, d.pauseTime

View File

@@ -16,10 +16,10 @@ func CatchError[T any](val T, err error) T {
} }
var testWorkDay = models.WorkDay{ var testWorkDay = models.WorkDay{
Day: CatchError(time.Parse(time.DateOnly, "2025-01-01")), Day: time.Date(2025, 01, 01, 0, 0, 0, 0, time.Local),
Bookings: testBookings8hrs, Bookings: testBookings8hrs,
TimeFrom: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), TimeFrom: time.Date(2025, 01, 01, 8, 0, 0, 0, time.Local),
TimeTo: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:30")), TimeTo: time.Date(2025, 01, 01, 16, 30, 0, 0, time.Local),
} }
func TestWorkdayWorktimeDay(t *testing.T) { func TestWorkdayWorktimeDay(t *testing.T) {