# Membership fixes

## Renewal dates

`addMonths` used `setUTCMonth` with the original day of the month. JavaScript normalizes nonexistent dates by overflowing into the next month, so January 31 plus one month became March 3 in 2026. The helper now moves to day 1 of the target month and restores the original day capped at that month's last valid day. January 31 now renews February 28, or February 29 in a leap year. UTC time and the original input date are preserved.

## Multi-year discounts

The tier lookup used `years > tier.years`, excluding the exact thresholds. Two-year payments received no discount, and three-year payments received 5% instead of 10%. Using `>=` with the existing best-tier-first order applies 5% for two years and 10% for three or more years. A three-year small-shop invoice is now 49,950 cents instead of 52,725 cents.

## Verification

Public function signatures are unchanged. Added regression tests for month ends, leap years, quarterly and annual renewals, year rollover, reminder day counts, input immutability, UTC time preservation, zero and negative month offsets, exact discount thresholds, and invoice totals for both shop sizes. The original five tests passed before changes; all six added tests failed against the old implementation. After the fixes, `node --test` passes all 11 tests.
