feat(fees): adult rates for 2026-07 to 2026-12, default 600

- Default adult monthly rate 700 -> 600 CZK
- 2026-07 and 2026-08 set to 0; 2026-09 through 2026-12 added at 600
- Single-session fee is capped at the month's rate, so a 0-rate month
  is free for one session as well
- Mirrored in Go and legacy Python; new calculate_fee parity fixtures

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 11:53:18 +02:00
co-authored by Claude Opus 5.5
parent 14cdbeac21
commit 2d8aada8d6
11 changed files with 85 additions and 21 deletions
+11 -8
View File
@@ -2,7 +2,7 @@
package fees
const (
AdultFeeDefault = 700 // CZK fallback for 2+ practices when month not in AdultFeeMonthlyRate
AdultFeeDefault = 600 // CZK fallback for 2+ practices when month not in AdultFeeMonthlyRate
AdultFeeSingle = 200 // CZK for exactly 1 practice
)
@@ -11,24 +11,27 @@ const (
var AdultFeeMonthlyRate = map[string]int{
"2025-09": 750, "2025-10": 750, "2025-11": 750, "2025-12": 750,
"2026-01": 750, "2026-02": 750, "2026-03": 350,
"2026-04": 700, "2026-05": 450, "2026-06": 600, "2026-07": 600, "2026-08": 600,
"2026-04": 700, "2026-05": 450, "2026-06": 600, "2026-07": 0, "2026-08": 0,
"2026-09": 600, "2026-10": 600, "2026-11": 600, "2026-12": 600,
}
// CalculateFee returns the adult fee in CZK for attendanceCount practices in
// the given monthKey (format "YYYY-MM").
//
// 0 practices → 0
// 1 practice → AdultFeeSingle (200)
// 1 practice → AdultFeeSingle (200), capped at the month's rate so a
// 0-rate month is free for everyone
// 2+ → AdultFeeMonthlyRate[monthKey] or AdultFeeDefault
func CalculateFee(attendanceCount int, monthKey string) int {
if attendanceCount == 0 {
return 0
}
rate, ok := AdultFeeMonthlyRate[monthKey]
if !ok {
rate = AdultFeeDefault
}
if attendanceCount == 1 {
return AdultFeeSingle
return min(AdultFeeSingle, rate)
}
if rate, ok := AdultFeeMonthlyRate[monthKey]; ok {
return rate
}
return AdultFeeDefault
return rate
}
+4 -2
View File
@@ -26,9 +26,11 @@ func TestCalculateFee(t *testing.T) {
// Zero attendance always returns 0.
{"zero short-circuits", 0, "2026-05", 0},
{"zero empty month", 0, "", 0},
// Single practice returns AdultFeeSingle regardless of month.
// Single practice returns AdultFeeSingle, capped at the month's rate.
{"single practice", 1, "2026-05", AdultFeeSingle},
{"single ignores monthKey", 1, "unknown", AdultFeeSingle},
{"single unknown month", 1, "unknown", AdultFeeSingle},
{"single in free month is free", 1, "2026-07", 0},
{"two in free month is free", 2, "2026-08", 0},
// Two+ practices for a configured month: must use the map value, not the default.
// Expected values are read from AdultFeeMonthlyRate so this test stays correct
// when rates are updated — the assertion verifies dispatch logic, not rate values.
@@ -0,0 +1,12 @@
{
"case": "one_session_free_july",
"func": "scripts.attendance.calculate_fee",
"captured_at": "2026-10-08",
"input": {
"attendance_count": 1,
"month_key": "2026-07"
},
"output": {
"fee": 0
}
}
@@ -1,12 +1,12 @@
{
"case": "two_sessions_default_fallback",
"func": "scripts.attendance.calculate_fee",
"captured_at": "2026-05-06",
"captured_at": "2026-10-08",
"input": {
"attendance_count": 2,
"month_key": "2099-01"
},
"output": {
"fee": 700
"fee": 600
}
}
@@ -0,0 +1,12 @@
{
"case": "two_sessions_free_july",
"func": "scripts.attendance.calculate_fee",
"captured_at": "2026-10-08",
"input": {
"attendance_count": 2,
"month_key": "2026-07"
},
"output": {
"fee": 0
}
}
@@ -0,0 +1,12 @@
{
"case": "two_sessions_october",
"func": "scripts.attendance.calculate_fee",
"captured_at": "2026-10-08",
"input": {
"attendance_count": 2,
"month_key": "2026-10"
},
"output": {
"fee": 600
}
}