feat: switch a one-time year to automatic renewal, price change notices #190

Sammanfogat
supernaut sammanfogade 7 incheckningar från feat/auto-renewal-and-price-change in i main 2026-10-19 22:53:20 +00:00
Ägare

What

  • Closes #103. An auto-renew checkout during a running one-time year switches to automatic renewal. The first payment sets up the mandate and pays the period that starts at the one-time period end. The Mollie subscription starts one interval later. The one-time subscription is closed, so a one-time extension paid after the switch is refunded. Withdrawal of the switch refunds it in full and keeps access to the one-time period end.
    • The switch opens once the one-time purchase's 14-day withdrawal period has passed and no paid one-time year is waiting to start. Until then it is refused with CONFLICT one_time_in_withdrawal_period (new contract reason), so the one-time purchase stays withdrawable.
  • Refs #160 (partial). A price_notice table (migration 0018) records each notice.
    • cli.js price notice <annual|monthly> <öre> <YYYY-MM-DD> lists the notices; --apply records them in one transaction. The amount must equal the released PLANS price. Personal plan only.
    • cli.js price sent <id|all> marks the mail sent. A notice applies only when its mail went out at least 30 days before the change; the table enforces it. An unsent notice closes as unsent and is logged for review. cli.js price cancel <id> closes an open notice.
    • The sweep sets the new amount on each Mollie subscription (PATCH /subscriptions/{id}) once the notice is in effect.
    • A renewal at the new amount is applied with its own VAT split. The old amount stays accepted for renewals, for a payment Mollie made before the update. Any other amount is parked as an orphan.
    • nextCharge reports the new amount from the effective date once the notice is sent. README documents the procedure.

Not in this PR (#160 stays open)

  • The notice mail. Billing has no mail channel; the operator sends it and runs price sent.
  • The pro-rata termination refund. The issue and the Terms read differently on when access ends and which part is refunded.

For bitborg-web

  • Show the one_time_in_withdrawal_period reason on the "Switch to automatic renewal" button: the switch opens once the 14-day withdrawal period of the one-time purchase has passed.

Operator steps

  • Run migrations (0018) before starting the new image.
  • Tag v0.20.0 after the merge.
## What - Closes #103. An auto-renew checkout during a running one-time year switches to automatic renewal. The first payment sets up the mandate and pays the period that starts at the one-time period end. The Mollie subscription starts one interval later. The one-time subscription is closed, so a one-time extension paid after the switch is refunded. Withdrawal of the switch refunds it in full and keeps access to the one-time period end. - The switch opens once the one-time purchase's 14-day withdrawal period has passed and no paid one-time year is waiting to start. Until then it is refused with CONFLICT `one_time_in_withdrawal_period` (new contract reason), so the one-time purchase stays withdrawable. - Refs #160 (partial). A `price_notice` table (migration 0018) records each notice. - `cli.js price notice <annual|monthly> <öre> <YYYY-MM-DD>` lists the notices; `--apply` records them in one transaction. The amount must equal the released `PLANS` price. Personal plan only. - `cli.js price sent <id|all>` marks the mail sent. A notice applies only when its mail went out at least 30 days before the change; the table enforces it. An unsent notice closes as `unsent` and is logged for review. `cli.js price cancel <id>` closes an open notice. - The sweep sets the new amount on each Mollie subscription (`PATCH /subscriptions/{id}`) once the notice is in effect. - A renewal at the new amount is applied with its own VAT split. The old amount stays accepted for renewals, for a payment Mollie made before the update. Any other amount is parked as an orphan. - `nextCharge` reports the new amount from the effective date once the notice is sent. README documents the procedure. ## Not in this PR (#160 stays open) - The notice mail. Billing has no mail channel; the operator sends it and runs `price sent`. - The pro-rata termination refund. The issue and the Terms read differently on when access ends and which part is refunded. ## For bitborg-web - Show the `one_time_in_withdrawal_period` reason on the "Switch to automatic renewal" button: the switch opens once the 14-day withdrawal period of the one-time purchase has passed. ## Operator steps - [ ] Run migrations (0018) before starting the new image. - [ ] Tag `v0.20.0` after the merge.
supernaut lade till 7 incheckningar 2026-10-19 19:11:11 +00:00
An auto-renew checkout during a running one-time period was refused. It
now starts a new subscription whose first paid period begins at the
one-time period end, so the remaining paid time is not charged twice.
The one-time subscription is replaced the way a stopped past due one
already is, which also refunds a one-time extension paid after the
switch.

Closes #103
A price change must reach the charges Mollie makes for existing
subscribers. The adapter refuses a canceled or completed subscription,
as the mandate move already does.

Refs #160
The Terms promise 30 days' notice before a price change, and billing
could not change the amount on a Mollie subscription. A price_notice row
records each notice. The 30-day minimum is a check constraint. The sweep
sets the new amount on the provider subscription once the notice is in
effect and closes the notice. A renewal at the new amount is applied
with its own VAT split instead of being parked as an orphan.

`cli.js price notice` records the notices and prints the recipients.
The notice mail and the pro-rata termination refund are not built yet.

Refs #160
Refs #103
The service withdraws only the newest subscription, so a switch inside
the one-time purchase's 14 days, or with a paid one-time year not yet
started, would leave that purchase without a withdrawal path.

Refs #103
fix(subscriptions): gate price notices on the sent mail and the plan price
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m24s
8af43199d4
The 30 days ran from when a notice was recorded, while the mail goes out
later by hand. A notice now applies only when `price sent` marked its
mail at least 30 days before the change; an unsent one closes as
`unsent` and is logged for review. The migration holds both minimums in
hours, as the code does.

`price notice` is a dry run unless `--apply`, records all notices in one
transaction, takes the price from PLANS and refuses another amount, and
covers the personal plan only. `price cancel` closes an open notice.

Refs #160
supernaut sammanfogade incheckning 87c3d8525f till main 2026-10-19 22:53:20 +00:00
supernaut tog bort grenen feat/auto-renewal-and-price-change 2026-10-19 22:53:20 +00:00
Logga in för att delta i denna konversation.
Inga granskare
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!190
Ingen beskrivning angiven.