Disclosure: this article was created with the help of AI. AI tools drafted it from my codebase and project notes, and I edited it and checked it against the code before publishing. I'm the founder of the app it describes.
I'm building an estimate and invoice app for small trade businesses, crews of one to five people. The contractor writes an estimate, the customer opens a link, picks an option, signs and pays a deposit. Later the same numbers become an invoice.
So one price shows up in a lot of places: the editor, the customer's page, the PDF, the email, the signature record and the invoice. If two of them disagree by one cent, the customer has a reason to doubt the rest. This post is about how money works in that Rails 8 app: how it's stored, where it gets rounded, how tax and deposits are calculated, and why the total the browser shows doesn't count.
Integer cents and a currency code
Every amount in the database is an integer column that ends in _cents . The currency is its own column on the document.…