Repository navigation
fix(history): count the battery-storage tax figure in proportion - #1958
Merged
Merged
Conversation
The strict order counted the house's use of a battery as grid energy first and its export as other energy first, so a battery with solar almost never got a figure: the home box gave 0 for 2026. Now whatever leaves a battery, to the house or the grid, carries the grid's share of what it held, and energy enters after the battery's efficiency over the year, so losses are never refunded. Within an hour the charge mixes in before the discharge. The hourly bounds, complete-hour rules and per-battery accounts stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Why
Fredrik, 3 Nov 2026: the figure for Skatteverket's energy tax refund after battery storage (11 kap. 13 § LSE) gave nothing, and it should be simple to work out. The strict order from #1953 counted what the house took from a battery as grid energy first and the export as other energy first. With solar in the battery that leaves almost nothing. The home box shows 0 kWh for 2026.
The law and Skatteverket name no method. The owner must be able to show how the figure was reached, and the hourly CSV still does that.
What
Evidence (this Mac)
make verify: vet, tests and build clean.npm test: 900 pass.go/internal/batteryreturntests rewritten for the new rule: an emptied battery filled from the grid returns all it sends (9 + 9 kWh); what leaves carries the grid share (5 kWh at ⅓ → 1.67 kWh); the in-hour order (4/9 share → 2.22 kWh); half the export means half the return; a half-size battery returns half; a gap forgets only that battery's account. Stored solar sent out and grid energy used at home still return 0.web/served locally, read-only proxy to the home box. The tile renders "Counted with a 9.6 kWh battery that gave back 73 % of its charge." The figure there is still the box's old code.Note
#1956 (planner, open, not recommended for merge) starts from the strict order's account. If it goes ahead, it should follow this rule instead.
🤖 Generated with Claude Code