Business processes / 2 / 12
Money and rounding
A shop sells in so'm and issues e-invoices with 12% VAT. With prices as floating-point numbers, a payment of exactly the right amount fails an equality check. Amounts become integers in minor units with a currency, and then the real questions start: which rounding rule, where to round (per line or per invoice), how to split an amount without losing a tiyin, how to convert at a rate you can still prove a week later, and why formatting belongs only at the very edge.
- 13 min
- Intermediate
- 12 steps
- Difference, tiyin
- 0
- Mismatched documents
- 0 /day
- Refund shortfall, tiyin
- 0
- request
- reply
- redelivery
- duplicate
- lost
- call: the reply returns on the same line
- async: no waiting
Numbers are a model scenario, not measurements
The real request
Checkout → Order serviceRequest
POST /v1/orders HTTP/1.1
Host: shop.example.com
Authorization: hidden
{
"items": [
{ "sku": "TEA-250", "price": 119990.1, "qty": 23 }
],
"total": 359970.3
}
Response
HTTP/1.1 201 Created
{ "order_id": "o_7714", "status": 4"awaiting_payment" }
price— 19 990.10 so'm, sent as a JSON number, so it becomes a binary float.qty— A count: an integer, no problem here.total— Computed on the client and again on the server, both with floats.status— The order waits until a payment of exactly this total arrives.
Build it yourselfCheat sheetCompare lessons
Course: 74 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes
11 Case studies