Debug Invoice Totals That Are Off by One Cent
Last updated: November 29, 2026
Quick Overview
Merchants report that QuickBooks invoices sometimes show line item taxes that do not add up to the invoice tax total, and some totals differ by one cent from their calculator. Find the likely causes and implement a calculation that is exact and consistent.
Intuit
November 29, 20260
0
0 solved
Merchants report that QuickBooks invoices sometimes show line item taxes that do not add up to the invoice tax total, and some totals differ by one cent from their calculator. Find the likely causes and implement a calculation that is exact and consistent.
Off-by-a-cent bugs are a classic in financial software, and at Intuit they generate support tickets and accountant distrust. The interviewer checks that you identify binary floating point and inconsistent rounding order as causes, use decimal arithmetic, and allocate rounded tax so the parts sum to the whole.
What the Interviewer Expects
- Explain why binary floats cannot represent most decimal amounts exactly
- Use Decimal constructed from strings, or integer cents
- Pick an explicit rounding mode and apply it at defined points
- Allocate a rounded header tax to lines so the parts sum exactly
- Write regression tests from the reported invoices
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Some jurisdictions require tax per line rather than per invoice. How does the code change?
- How would you migrate existing invoices stored as floats without changing what customers already saw?
- Why is banker's rounding sometimes used and when would it be wrong here?
- How would you test this exhaustively?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Given line items (qty, unit_price) and a tax rate, compute the subtotal, a tax total, per-line taxes that sum exactly to the tax total, and the grand total. All money is rounded to cents with half-u...
High-Level Design
Causes I would look for first:
- Floats:
0.1 + 0.2is0.30000000000000004, and errors accumulate across lines. - Rounding at different points: rounding each line's tax and summing gives a differ...