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…
Building an offline estimate app with Expo led to several important considerations. Money is stored as an integer, with the number of decimals determined by the currency. For example, Japanese yen uses no decimals, while Kuwaiti dinar uses three. This requires a separate module to handle conversions between user input and stored data.
All calculations in the app are performed using integers, with rounding happening at a single known step. This ensures that totals, discounts, and taxes remain accurate, even when displayed on-screen or in a PDF.
Each document number is unique and incrementing, starting from EST-0008 after deletion of the previous document. Gaps in the numbering are acceptable, as documents keep their own copies of customer information, currency, and tax labels at the time of creation. This ensures consistency, even if the customer's details change later. A challenge remains in handling saved items with prices but no currency, which could be revisited as a product question.
The PDF preview and the actual PDF are created from the same document, but they may diverge if changes are made to one without updating the other. To prevent this, the preview and PDF template should always be updated together in a single commit. When printing, certain design elements may be lost, such as background colors in PDFs.
This requires checking the printed version for accuracy, particularly for long documents that may break across pages differently between A4 and US Letter formats. Arabic layouts will need special attention, as they mirror the entire layout rather than just changing text direction.
Sharing the PDF with a message is crucial, as estimates sent as plain PDFs can appear as spam. Adding a message to the share sheet in the Android platform can be achieved with a small patch to the sharing module. If a translated message is not available for a specific language, sharing the PDF alone without an English message is preferable. These solutions are straightforward, focusing on consistent representations and thorough testing to ensure a reliable offline estimate app experience.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to