Things I got careful about while building an offline estimate app with Expo
Lately I've been building Tarifo, an Android app for people who price a job before doing it: plumbers, electricians, painters, cleaners, freelancers. You write the estimate at the customer's place, send it as a PDF on WhatsApp or by e-mail, and turn it into an invoice when they say yes.
There's no account and no backend. Everything happens on the phone, and it has to work with no signal, because a job often gets priced in a basement or on a roof. It also ships in 20 languages and 53 currencies, which is where most of the interesting problems came from.
Here are the few things I ended up being strict about.
Money is an integer, and the currency decides the decimals
Two decimals feels like a safe default until you meet the Japanese yen (no decimals) or the Kuwaiti dinar (three). So amounts are stored as integers in minor units, and the number of decimals comes from the currency itself. You don't need a table for that, the platform already knows:
new Intl.NumberFormat('en', { style: 'currency', currency: 'JPY' }) .resolvedOptions().maximumFractionDigits // 0 Every conversion between "what the user typed" and "what we store" goes through one module. Nothing else in the app is allowed to multiply by 100. Totals, discounts and tax are computed on integers, and rounding happens once, at a known step. That's what makes a 12-line estimate add up to the same cent on screen and in the PDF.
A document number is never given back
If estimate EST-0007 gets deleted, the next one is still EST-0008. The number is taken from a counter when the document is created, and it never goes back into the pool. Gaps are fine. Two documents with the same number are not, especially once one of them is an invoice.
A document keeps its own copy of the customer
An estimate you sent last month should look exactly the same next month, even if you've since fixed the customer's address, changed your default currency or renamed your tax. So each document stores its own copy of the customer, its currency and its tax label as they were when it was made. It doesn't point at the live records.
There's one case I haven't solved yet: saved items have a price but no currency, so switching your profile currency quietly reinterprets them. I've left that as an open product question instead of guessing.
The PDF is the same document, drawn a second time
While you type, the app shows a live preview made of React Native views. The PDF comes from an HTML template. Same document, two renderers, and they drift apart the first time you change one and forget the other. My only real rule here: the preview and the PDF template change in the same commit, every time.
A few things only show up once it's printed:
- Printers drop background colours. A nice coloured header turns into white text on white paper, so the PDF header has no fill.
- A4 and US Letter break pages in different places, and the preview doesn't show where a page will break, so long documents have to be checked on both.
- Arabic mirrors the whole layout, not just the text direction, and the PDF has to follow.
Sharing a PDF with an actual message
Most estimates go out on WhatsApp, and a PDF arriving with no text looks like spam. Android's share sheet can carry a message and a subject along with the file (EXTRA_TEXT, EXTRA_SUBJECT), but the Expo sharing module didn't pass them through. A small patch adds message and subject, and I keep it alive across version bumps. If a language doesn't have a translated message yet, the app shares the PDF alone rather than an English sentence.
None of this is clever. It's mostly picking the boring representation early and writing the rule down somewhere the next change will see it.
If you're curious, the site has a couple of guides I wrote along the way, like how to write an estimate and how to price a job. Happy to answer questions about any of the above in the comments.