Repository navigation
fix(kraken): scale exc-VAT applicableRates prices to inc-VAT from the agreement - #5418
Open
springfall2008 wants to merge 1 commit into
Open
springfall2008 wants to merge 1 commit into
springfall2008 wants to merge 1 commit into
Conversation
… agreement The GraphQL applicableRates fallback stored its single `value` as value_inc_vat. The BottlecapDave-derived EDF integration treats that value as exc-VAT, which would leave import rates 5% low on tariffs the REST products API cannot serve (EDF day/night tariffs, E.ON TOU and retired products). Take the VAT multiplier from the import agreement's standingCharge / preVatStandingCharge and scale import applicableRates values by it. It follows the rate in force - 1.0 during the Oct 2026 - Mar 2027 zero rate, 1.05 after - without date logic. Export is left unscaled. The multiplier is refreshed on every tariff discovery and cached across restarts. Fixes #5417 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The pricing basis remains independently unverified and the change has not been validated against a live affected account.
Review effort: Balanced
Findings: None
What changed in this PR
Updates Kraken’s GraphQL fallback to convert import prices from exclusive to inclusive VAT using agreement data.
Changes:
- Derives, caches, and applies an import VAT multiplier.
- Keeps export rates unscaled and adds regression tests.
- Documents the VAT-basis investigation.
| File | Description |
|---|---|
apps/predbat/kraken.py |
Implements VAT multiplier handling. |
apps/predbat/tests/test_kraken.py |
Tests derivation, scaling, and caching. |
tools/debug-journal.md |
Records investigation findings. |
.cspell/custom-dictionary-workspace.txt |
Adds the referenced author’s name. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5417
Problem
When REST cannot serve a tariff's rates, the Kraken component falls back to GraphQL
applicableRatesand stored its singlevalueasvalue_inc_vat. The BottlecapDave-derived EDF integration (stevekirtley/HomeAssistant-EDFEnergy) treats that value as exc-VAT and scales it up. On that basis Predbat's import rates are 5% low for tariffs that take the fallback every cycle: EDF day/night tariffs (#5166), E.ON TOU tariffs and products retired from the REST API.Tariffs served by REST are unaffected, as is export.
Fix
standingChargeandpreVatStandingChargeon the tariff. Both are on theTariffTypeinterface on EDF and E.ON (checked by live introspection).applicableRatesvalues are scaled by it. Export is passed 1.0.value_exc_vatis now the raw value, replacing the hardcoded/ 1.05. Nothing outsidekraken.pyreads it.No VAT rate or date is hardcoded: the multiplier is 1.0 during the GB zero-rate window (1 Oct 2026 – 31 Mar 2027) and 1.05 afterwards.
What reviewers should know
applicableRatesvalue against a bill. If it turns out to be inc-VAT, this PR would overstate fallback-path import rates by 5% from April.applicableStandingChargesis still assumed inc-VAT and is unverified either way.Testing
./run_all --test kraken --test kraken_authpasses. New tests cover the multiplier derivation and its guards, discovery storing and refreshing it, import-only scaling in the fallback, and the cache round trip including a cache written before the field existed. Pre-commit passes on the changed files. Not run against a live account.A debug journal row records the investigation, including the dead ends.
🤖 Generated with Claude Code