If you build tools for Filipino sellers, sooner or later you store prices in pesos. And sooner or later someone sees ₱99.99999 on a receipt. This is a short set of rules I follow so that never happens.
Rule 1: store centavos as integers
Floats are fine for science, not for money. Store 9999 instead of 99.99.
price_centavos = 9999 # ₱99.99 display = f"₱{price_centavos / 100:,.2f}" - Addition and subtraction stay exact.
- Database columns can be plain integers.
- Formatting happens only at the very end.
Rule 2: per-1000 rates need extra precision
Social media service panels usually price "per 1000" units, and the rate can be tiny, like ₱0.13 per 1000 views. Multiply that by a quantity of 250 and you get fractions of a centavo.
- Store the rate in micro-pesos (₱1 = 1,000,000) or use Python's
Decimal. - Compute the order total, then round once to whole centavos.
- Use banker's rounding or always round up, but pick one and document it.
from decimal import Decimal, ROUND_HALF_UP rate_per_1000 = Decimal("0.13") qty = 250 total = (rate_per_1000 * qty / 1000).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP) Rule 3: show the customer the same number you charge
- Calculate totals on the server, not only in the browser.
- Show the rounded total before checkout.
- Save the rate and the rounded total on the order row, so later price changes never rewrite history.
Rule 4: think about GCash and Maya amounts
E-wallet top-ups are usually whole pesos. If balances are kept in centavos, allow a small leftover balance rather than forcing odd top-up amounts.
Where this comes from
I ran into all of these while looking at peso-priced catalogues like the BoostingPH services list, where per-1000 rates range from fractions of a peso to a few hundred. The same rules apply to any reseller app in the Philippines.
More on the business side at BoostingPH.
Written by MD Fozla Rabbi, SEO Specialist.
