🐛 Reject week keys that are not real ISO weeks

WeekDayKeys accepted W01 to W53 without checking that the year has that
week. Closing 2025-W53, a year with 52 weeks, closed the days of
2026-W01 under a second key and the balance counted them twice. The
computed Monday must now map back to the requested week key.
This commit is contained in:
2026-12-01 16:43:40 +01:00
parent 9f0700fa1c
commit 0bfacb7059
3 changed files with 35 additions and 2 deletions
+4 -1
View File
@@ -277,11 +277,14 @@ func TestCloseWeekWithoutSettingsFails(t *testing.T) {
func TestCloseWeekWithInvalidKeyFails(t *testing.T) {
e := setup(t)
for _, key := range []string{"", "2024-W3", "2024-w03", "2024-W54", "2024-03", "2024-W03x"} {
for _, key := range []string{"", "2024-W3", "2024-w03", "2024-W54", "2024-03", "2024-W03x", "2025-W53"} {
if _, err := CloseWeek(e.app, e.owner.Id, key, testNow); !errors.Is(err, ErrInvalidWeekKey) {
t.Errorf("%q: got %v, want ErrInvalidWeekKey", key, err)
}
}
if rows := e.rows("closed_weeks", ""); len(rows) != 0 {
t.Errorf("got %d closed weeks, want 0", len(rows))
}
}
func TestCloseWeekUsesSettingsEffectiveToday(t *testing.T) {