Skip to content

fix: round the cumulative price breakdown like its totals - #303

Merged
josecarneiro merged 2 commits into
mainfrom
fix/cumulative-breakdown-rounding
Oct 27, 2026
Merged

josecarneiro merged 2 commits into
mainfrom
fix/cumulative-breakdown-rounding

Conversation

@josecarneiro

@josecarneiro josecarneiro commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

computeCumulativeValue formatted each breakdown line at full precision. With a quantity normalised from a yearly consumption (1000 kWh / 12 = 83.333… kWh), the journey's cumulative price tooltip showed:

83.33 kWh kosten €28.33, durchschnittlich 34.00 cents/kWh.
Erste 83.333333 kWh * 34 cents/kWh = €28.333333333333

The same breakdown is rendered by the entity price table in 360.

This changes what the breakdown displays:

  • quantityUsed: rounded to 2 decimals (was up to 6)
  • totalAmountDecimal: precision: 2, useRealPrecision: false, the same as total
  • tierAmountDecimal (the tier's unit price) keeps its real precision, so 34.56 cents/kWh stays as it is
  • totalWithPrecision / subtotalWithPrecision are unchanged

Only display strings change. The tier amounts and totals are computed exactly as before.

The only existing expectations that change are the sub-cent tiers: 27.7255 cents → 27.73 cents and 10.866 cents → 10.87 cents. These now match total: '38.59 cents'. The rounded lines can differ from the rounded total by a cent (27.73 + 10.87 vs 38.59), as with any per-line rounding.

Changeset: minor. The strings a consumer may rely on change.

Jira: STABLE360-13364. The 360 entity app (^5.9.0) picks this up with the next release. journey-monorepo is pinned to 5.6.8 and gets it when it upgrades @epilot/pricing, which crosses the @epilot/sdk migration (5.8.0) and the i18next ^25 peer (5.9.0). That upgrade is a separate change.

Test plan

  • New test: graduated tiers at 1000 / 12 kWh → 50 kWh / 33.33 kWh, line totals €17.28 / €10.00, unit price 34.56 cents/kWh kept. It fails on main.
  • vitest run: 639 passing, and tsc --noEmit is clean (both also ran in the lefthook pre-commit)
  • eslint src/tiers: no new warnings (the 4 non-null-assertion warnings are on existing lines)

🤖 Generated with Claude Code

https://claude.ai/code/session_018ZVb2xHqHs2s2bUy7Ut25g

computeCumulativeValue formatted each breakdown line at full precision:
a quantity normalised from 1000 kWh a year showed as "83.333333 kWh"
with an amount of "€28.333333333333", next to a total rounded to the
cent. The journey's cumulative price tooltip and the entity price table
render these lines as they are.

quantityUsed is now rounded to 2 decimals and totalAmountDecimal to
2 decimals like `total`. tierAmountDecimal keeps the tier's real
precision, and the *WithPrecision totals are unchanged.

Refs STABLE360-13364

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ZVb2xHqHs2s2bUy7Ut25g
@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e2a0712

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@epilot/pricing Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jnmau jnmau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a breaking change in theory, so it should maybe be a minor version bump.

Otherwise, approved. ✅

The breakdown's display strings change, which a consumer could rely on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ZVb2xHqHs2s2bUy7Ut25g
@josecarneiro
josecarneiro merged commit dd0736b into main Oct 27, 2026
3 checks passed
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.

3 participants