Skip to content

fix(billing): show the cent Orb rounds up on per-metric charges - #7495

Open
macko911 wants to merge 1 commit into
masterfrom
matej/orb-amount-rounding
Open

macko911 wants to merge 1 commit into
masterfrom
matej/orb-amount-rounding

Conversation

@macko911

@macko911 macko911 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Context

orbAmountToCents reads money off Orb's decimal strings by taking the first two digits after the point. Invoice fields arrive already rounded to two decimals, so that was fine there.

The costs endpoint is not. It answers in full float precision, where two cents arrives as 0.01999999999999999872 — and dropping the extra digits makes that one cent. That endpoint feeds the per-metric Charges column on the billing page, which every customer has seen since #7364. So affected accounts are shown a cent less than Orb bills them.

Changes

  • Round half-up on the third decimal instead of truncating, still reading digits off the string rather than via Number(x) * 100.
  • Carry the rounding into the whole part, so 0.999 is a dollar rather than 99 cents.

Testing

Covers the real Orb value that exposed this (0.01999999999999999872 → 2 cents), the half-up boundary either side (19.994 / 19.995), and the carries 0.999 and 1.999.

Checked against live Orb for all ten pay-as-you-go accounts. Six showed a connections charge a cent below the matching invoice line; all ten agree after the fix. To see it on the billing page, open Usage for an account whose usage lands near a cent boundary and compare the Charges column against the Orb invoice.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

The costs endpoint answers in full float precision, so two cents arrives
as 0.01999999999999999872 and taking the first two decimal digits made
it one. That put the metric charges a cent under the invoice and left
the usage column unable to add up to the headline it sits beneath.

Invoice fields are already given to two decimals, so this only moves the
per-metric charges — the one caller reading a full-precision figure. All
ten live pay-as-you-go accounts now reconcile: metric charges plus the
minimum row equal the amount due, exactly.
@macko911
macko911 force-pushed the matej/orb-amount-rounding branch from 1c58403 to 5003797 Compare September 14, 2026 13:09
@macko911
macko911 marked this pull request as ready for review September 14, 2026 13:17
@macko911
macko911 requested a review from ErickRDev September 14, 2026 13:17
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