Repository navigation
feat(state): the energy ledger keeps hourly totals for four years - #1951
Merged
Merged
Conversation
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. |
frahlg
force-pushed
the
feat/ledger-hourly-four-years
branch
2 times, most recently
from
November 2, 2026 11:52
d6d8b88 to
871b79e
Compare
Skatteverket's refund of energy tax after battery storage is worked out hour by hour for a calendar year and may be claimed until three years after the year ends. With two years of hours, the start of an older year was already daily totals and counted as incomplete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
frahlg
force-pushed
the
feat/ledger-hourly-four-years
branch
from
November 2, 2026 14:52
871b79e to
f7952f5
Compare
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.
Stacked on #1950. Retarget to
masteronce #1950 merges.Why
Skatteverket's refund of energy tax after battery storage (#1950) is worked out hour by hour for one calendar year and may be claimed until three years after that year ends. The ledger kept hourly totals for two years and daily totals after that, so a year claimed late had its first months as daily totals, which the report counts as incomplete.
What
EnergyLedgerRetentiongoes from 2 × 365 days to 4 × 366 days: the hours of a year now last until its claim deadline, leap years included. Five-minute detail (30 days) and the daily tier after the hourly horizon are unchanged.Cost
The ledger stores about one hourly row per asset and flow (more only where an hour mixes qualities). A site with a grid meter, battery, solar, a charger and observed load has about ten flows, so roughly 88,000 rows a year. Two more years of hours adds about 175,000 rows, a few tens of MB in
history.db, instead of the same years as daily rows.Evidence
go test ./internal/state -run 'Ledger|Prune|Plain|Energy'andnode --test web/battery-return.test.mjspass. The prune tests use the constant, so they move with it. No conflict with #1751, the other open PR touchingenergy_ledger.go.🤖 Generated with Claude Code