> ## Content Index
> Fetch the complete content index at: https://debugly.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# The Tax Total That Differed by a Cent on Rounding
- URL: https://debugly.dev/tax-rounded-per-line-vs-total/
- Published: 2026-10-09T18:10:00.000Z
- Updated: 2026-10-17T05:55:29.000Z
- Description: The invoice rounded each line and the filing rounded the sum, so the two disagreed on multi-item orders, and the difference was small per order and large…
- Author: Rohit Bhadani
- Tags: Ecommerce, Money, Accounting

Start at the off and you miss it. Start at the accountant's February and you miss how it arrived. The bug lived in the hand-off.

Strip the rounding order mismatch down and one property makes it small and total: each order differs by at most a cent, so no single order looks wrong, and the sum over a quarter is the amount the filing disagrees by.

I have since met the same mechanics in plenty of per-item rate applied to a rounded currency.

## Why the two methods disagree

The line rounding is the per item, and the per item is the round then the sum, and the sum is the invoice's total, and the total's rounding is the sum then the round, and the round is the different value, and the different value is the cent, and the cent is the accumulation, and the accumulation is the quarter's difference.

The difference is the rounding's direction, and the direction is the half up or the half even, and the two are the different rules, and the rules are the jurisdiction's, and the jurisdiction's is the required, and the required is the not the choice, and the not choice is the compliance, and the compliance is the fix's constraint.

The mismatch is the not the arithmetic's error, and the not error is the two valid methods, and the two valid are the disagreement, and the disagreement is the incident, and the incident is the reason the method should be the explicit decision, and the decision is the documented, and the documented is the fix.

## Why nobody noticed per order

The cent was the small, and the small was the invisible, and the invisible was the no complaint, and the no complaint was the customer's tolerance, and the tolerance was the pass, and the pass was the quarter, and the quarter was the thousands, and the thousands was the filing, and the filing was the comparison, and the comparison was the difference, and the difference was the accountant's, and the accountant's was the February, and the February was the late.

The per-order check is the not the detection, and the not detection is the aggregate, and the aggregate is the sum of the differences, and the sum is the visible, and the visible is the fix's entry, and the entry is the reconciliation, and the reconciliation is the discipline, because the individual order is the correct and the aggregate is the wrong.

This is the same representation discipline as [the money math that used a float](https://debugly.dev/reviewing-money-math-in-floats/), and the common root is the property, not the platform.

## The fix, in order

**Chose the rounding method explicitly and documented it.** The method was the line or the total, and the choice was the jurisdiction's requirement, and the requirement was the compliance, and the compliance was the fix, and the fix was the document, and the document was the discipline, because the implicit method is the two methods.

**Applied the same method in the invoice, the ledger and the filing.** The three were the consistent, and the consistent was the reconciliation's agreement, and the agreement was the fix, and the fix was the single implementation, and the implementation was the shared function, and the function was the discipline, because the three separate implementations are the three methods.

**Used integer minor units and a defined rounding rule.** The integer was the exact, and the exact was the arithmetic's safety, and the safety was the fix, and the rule was the half up or the half even, and the rule was the explicit, and the explicit was the discipline, because the language's default rounding is the surprise.

**Reconciled the sum of the lines against the total daily.** The comparison was the drift, and the drift was the alert, and the alert was the detection, and the detection was the fix, and the fix was the job, and the job was the discipline, because the quarterly reconciliation is the late detection and the late is the accumulated difference.

**Tested the multi-line orders with the awkward amounts.** The test was the three items at the awkward prices, and the awkward was the rounding's exposure, and the exposure was the catch, and the catch was the guard, and the guard was the prevention, and the prevention was the fix, because the single-line order never shows the difference.

## The takeaway

Rounding each line and then summing produces a different total from summing and then rounding, and the difference is at most a cent per order but accumulates across every order. Choose the method explicitly per the jurisdiction, use one shared implementation for the invoice, the ledger and the filing, work in integer minor units, and reconcile the daily aggregate.

The invoice totals and the tax filing disagreed by a cent on most multi-item orders, because the storefront rounded each line and the filing rounded the sum, and neither was arithmetically wrong. That is the whole pattern, and it is the part worth remembering.

---

Published on [debugly.dev](https://debugly.dev/) by [Rohit Bhadani](https://debugly.dev/about/) | Founder of [Krova Cloud](https://krova.cloud/?ref=debugly.dev)