Skip to content

feat: add sell_price_equals_buy_price for net metering (NL saldering) - #2

Merged
jdungen merged 1 commit into
mainfrom
claude/nl-sell-price-equals-buy-price
Jul 14, 2026
Merged

feat: add sell_price_equals_buy_price for net metering (NL saldering)#2
jdungen merged 1 commit into
mainfrom
claude/nl-sell-price-equals-buy-price

Conversation

@jdungen

@jdungen jdungen commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Why

Under net metering (Dutch "saldering", in force through 2026 — e.g. Tibber NL) every exported kWh offsets an imported one on the bill, so its effective value is the full buy price incl. markup, VAT and grid fees — not spot + export compensation. The optimizer undervalued exports, skewing charge/discharge decisions for NL users.

What

New opt-in price setting sell_price_equals_buy_price (default off — existing behavior unchanged). When enabled the sell price equals the buy price; the Export Compensation and Export Spot Multiplier fields are hidden in the UI and ignored.

  • PriceSettings + PriceManager: new flag; _calculate_sell_price returns _calculate_buy_price when set
  • settings_store: bootstrap default + schema migration so existing stores upgrade in place
  • API: sellPriceEqualsBuyPrice in the setup-complete payload, _PRICE_MAP, and live updates; PATCH /api/settings works via the existing electricity-price section pass-through
  • PRICE_REQUIRED_FIELDS extended (store-backed field, enforced by the contract test)
  • UI: "Sell price equals buy price (net metering / saldering)" toggle in the Price Calculation card (Settings page + setup wizard); the price preview and formula explanation update live

Verification

  • 1155 fast backend tests pass locally, including new PriceManager unit tests for the flag on/off
  • black + ruff clean
  • frontend npm run build and npm run lint clean (0 errors)

Independent of #1 (AC-coupled PV); both branch from main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JD7RhRSGxkW8zZirZQFRFC


Generated by Claude Code

Under net metering (Dutch "saldering", in force through 2026 — e.g.
Tibber NL) every exported kWh offsets an imported one on the bill, so
its effective value is the full buy price incl. markup, VAT and grid
fees — not spot + export compensation. The optimizer undervalued
exports, skewing charge/discharge decisions for NL users.

New opt-in price setting sell_price_equals_buy_price (default off, so
existing behavior is unchanged). When enabled the sell price formula
returns the buy price; the export compensation and export spot
multiplier fields are hidden in the UI and ignored.

- PriceSettings + PriceManager: new flag, _calculate_sell_price returns
  _calculate_buy_price when set
- settings_store: bootstrap default + schema migration for old stores
- API: setup-complete payload field sellPriceEqualsBuyPrice, PRICE_MAP,
  live updates; PATCH works via the existing section pass-through
- PRICE_REQUIRED_FIELDS extended (store-backed, per contract test)
- UI: toggle in Price Calculation (Settings + wizard), live preview
  shows sell = buy when enabled
- tests: PriceManager unit tests for flag on/off

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JD7RhRSGxkW8zZirZQFRFC
@jdungen
jdungen merged commit 31121f1 into main Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants