fix: CloseWeek uses settings effective at close time, not week Monday

Settings configured mid-week (e.g. Thursday) have an effective_from
of that date. CloseWeek was looking up settings as-of Monday, which
predates the new settings row and fell back to the old default.

Now uses today's date for the settings lookup, so any settings change
made before closing the week is correctly reflected in expected_ms.
This commit is contained in:
2026-04-30 18:23:13 +02:00
parent e37458f513
commit 47dd2c9779

View File

@@ -94,9 +94,10 @@ func (s *WeekService) CloseWeek(ctx context.Context, weekKey string) (*domain.Cl
return nil, err return nil, err
} }
// Get settings at the start of the week (Monday) // Get settings effective at close time (today), not necessarily at the
mondayKey := dayKeys[0] // start of the week. This ensures settings changes made mid-week are
set, err := s.settings.Current(ctx, mondayKey) // reflected when the week is closed.
set, err := s.settings.Current(ctx, time.Now().In(s.tz).Format("2006-01-02"))
if err != nil { if err != nil {
return nil, ErrNoSettings return nil, ErrNoSettings
} }