fix(billing): count the grace period in calendar days #155

Stängd
öppnade 2026-10-12 14:16:25 +00:00 av supernaut · 0 kommentarer
Ägare

The grace end is periodEnd + 8 * DAY_MS in milliseconds (src/billing.ts, in toStatus for graceEndsAt and in isDue in the sweep).

periodEnd is 1 ms before Amsterdam midnight. Across the last Sunday of March a day has 23 hours, so the sum lands at 00:59:59.999 the next day.

Failing case: a period ends on 25 March. The grace should end at the end of 2 April. It ends at 00:59:59.999 on 3 April, so the portal shows 3 April and access ends almost an hour late. Periods that end about 22 to 28 March are affected. The October change errs early by one hour, still on the right day.

Fix: count the grace in calendar days. Amsterdam midnight of the period-end day plus 9 days, minus 1 ms. Use the same helper at both call sites. Add a test with a period that ends on 25 March.

The grace end is `periodEnd + 8 * DAY_MS` in milliseconds (`src/billing.ts`, in `toStatus` for `graceEndsAt` and in `isDue` in the sweep). `periodEnd` is 1 ms before Amsterdam midnight. Across the last Sunday of March a day has 23 hours, so the sum lands at 00:59:59.999 the next day. Failing case: a period ends on 25 March. The grace should end at the end of 2 April. It ends at 00:59:59.999 on 3 April, so the portal shows 3 April and access ends almost an hour late. Periods that end about 22 to 28 March are affected. The October change errs early by one hour, still on the right day. Fix: count the grace in calendar days. Amsterdam midnight of the period-end day plus 9 days, minus 1 ms. Use the same helper at both call sites. Add a test with a period that ends on 25 March.
supernaut lade till detta till projektet Bitborg Payment 2026-10-12 14:16:40 +00:00
supernaut refererade till detta ärende från en incheckning 2026-10-13 19:35:59 +00:00
Logga in för att delta i denna konversation.
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-payment#155
Ingen beskrivning angiven.