fix(tariff): reject stepped base combined with time/seasonal tiers

A stepped ("up-to") default card prices the whole stay as one total, so the V2
engine short-circuits to steppedFee and NEVER consults windowed cards — any
time/seasonal tiers would silently never fire. Found live: an active tariff had a
stepped base plus weekday-night + weekend tiers, and every 3h stay priced 600 ALL
regardless of hour/day because the tiers were dead.

- validateTariffV2 now rejects a stepped defaultCard combined with windowedCards,
  with an actionable message (switch the base to ladder/flat, or remove the tiers).
- Composer shows an inline red warning the moment base mode is stepped and tiers
  exist; publishing is blocked server-side regardless.
- ApiError now carries the server's problems[], so the publish error surfaces the
  SPECIFIC reason instead of a generic "invalid tariff structure".
- 2 new validation tests (55 pass).

Wiki: tariff, log.

Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
2026-06-20 14:03:22 +02:00
parent cc507f490f
commit 9a1feeeb20
8 changed files with 62 additions and 4 deletions
+8
View File
@@ -94,6 +94,14 @@ A card's body is **one of three mutually-exclusive shapes** — `flatMinor`, `bl
- A `steps` table **replaces** the `blocks` ladder and **forbids `dailyCapMinor`** (the top tier IS
the per-day cap). In V2 it is allowed **only on the `defaultCard`** — a whole-stay total can't be
sliced per-increment by a windowed card, so windowed/stepped don't compose.
- **A stepped base + time/seasonal tiers is REJECTED** (`validateTariffV2`, 2026-06-20). The engine
short-circuits to `steppedFee` on a stepped default card and never consults windowed cards, so any
tiers would **silently never fire**. Rather than publish dead tiers, validation refuses the combo
("time/seasonal tiers do not apply to an up-to-duration (stepped) base rate — remove the tiers, or
switch the base rate to an hourly ladder or flat price"); the composer also shows an inline red
warning the moment both are present. (Discovered live: an active version had a stepped base AND
weekday-night + weekend tiers; the tiers priced nothing — every 3h stay was the stepped 600
regardless of time. The `problems[]` array now surfaces through `ApiError` to the publish message.)
- Validation: ≥1 row, strictly-ascending positive `uptoMin`, non-negative integer totals (totals
need not be monotonic — an owner *may* price a longer stay cheaper).