Johan Alphonso Braga
WorkProjectsReadingStackCraftDesignStatusResume

Utilities

Ask anything

Elsewhere

GitHub

All projects

Products / 2026 / Live in the browser

Invoice Studio

Invoices and quotes for people who bill by hand: type the lines, print the PDF, send it. The arithmetic is done in whole pennies so the total always matches the lines.

Invoice Studio

01

The problem

Invoicing tools want a subscription and an account before they will produce a single document, and the ones that do not usually get the money wrong. Floating point cannot represent most decimal fractions, so 19.99 times three is 59.969999999999999, and a discount applied after tax is a different number from one applied before it.

02

How I approached it

Every amount is an integer number of minor units, so nothing can drift. The order of operations is the one a commercial invoice uses: line discount, then the invoice discount apportioned across the lines by largest remainder, then tax per line on what is left. Apportioning matters because tax is charged per line, and a discount subtracted only at the bottom leaves every line taxed on money the customer is not paying. The arithmetic lives in two modules that never touch the DOM, which is why it can be tested.

03

The outcome

A document that reconciles. The PDF is the browser's own print output against a deliberate print stylesheet rather than a PDF library, so the deliverable costs nothing to ship.

invoice-studio.johanthegoat.xyz Open in a new tab ↗
Next projectLux →