askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
denominations.json · 3.2 KB · 31 lines
| 1 | { |
| 2 | "name": "denominations", |
| 3 | "title": "Denominations", |
| 4 | "version": 1, |
| 5 | "description": "What a unit of value IS: its code, what kind of thing it is, and how finely it divides. Amounts everywhere are stored as an integer count of the smallest unit (150000 USD minor = 1,500.00; 5000000 BTC minor = 0.05 BTC), and this collection is what tells the system where the decimal point goes -- see object_money.py. That is the generalization of this codebase's founding 'money is integer cents' rule: cents were always USD minor units. A business holds value in more than one denomination at once -- a bank balance, bitcoin, a stablecoin, a box of cash, gift cards, possibly a weight of metal -- and they divide differently (JPY has no minor unit at all; ETH has eighteen places). Kept as DATA rather than a code table so an operator can add a gift-card program, a loyalty point, or a barter unit without a deploy. Reconciled against a private predecessor-system audit (not part of this repo): its Currency model carried the same fiat/crypto/metal/commodity split and a per-currency decimal_places, but stored every amount in one fixed 8-decimal column -- a schema that could declare more precision than it could hold. Integer minor units have neither failure: exact by construction, no ceiling, no rounding dust on ordinary dollars.", |
| 6 | "fields": [ |
| 7 | {"name": "id"}, |
| 8 | {"name": "code", "type": "text", "required": true, "label": "Code", |
| 9 | "maxlength": 20, |
| 10 | "help": "USD, JPY, BTC, USDC, XAU, or your own (GIFT-ACME, POINTS). Compared case-insensitively."}, |
| 11 | {"name": "name", "type": "text", "required": true, "label": "Name"}, |
| 12 | {"name": "symbol", "type": "text", "label": "Symbol", "maxlength": 8, |
| 13 | "help": "Optional display prefix ($, EUR). Purely cosmetic -- the code is the identity."}, |
| 14 | {"name": "kind", "type": "enum", "default": "fiat", "label": "Kind", |
| 15 | "enum": ["fiat", "crypto", "stablecoin", "metal", "commodity", "points", "other"], |
| 16 | "help": "What class of thing this is. Drives valuation and tax treatment later (crypto disposals are lot-tracked in most jurisdictions; metals are often taxed as collectibles), and nothing today."}, |
| 17 | {"name": "scale", "type": "integer", "required": true, "default": "2", |
| 18 | "label": "Decimal Places", |
| 19 | "help": "How many decimal places the unit divides into: 2 for USD, 0 for JPY, 8 for BTC (satoshis), 18 for ETH, 4 for a troy ounce of gold by convention. Amounts are stored as integers of the smallest unit, so this is what makes 150000 mean 1,500.00 rather than 150,000."}, |
| 20 | {"name": "is_system", "type": "boolean", "default": "false", "label": "Built-in", |
| 21 | "help": "Seeded denominations everyone shares. Operator-defined ones (a gift-card program, a loyalty point) are ordinary rows."}, |
| 22 | {"name": "notes", "type": "textarea", "label": "Notes"}, |
| 23 | {"name": "owner_id", "type": "text", "label": "Owner"}, |
| 24 | {"name": "created_at", "type": "datetime", "read_only": true, "label": "Created"} |
| 25 | ], |
| 26 | "search": {"fields": ["code", "name"]}, |
| 27 | "forms": {"default": {"fields": ["code", "name", "symbol", "kind", "scale", "notes"]}}, |
| 28 | "views": {"list_mode": "table", |
| 29 | "list_fields": ["code", "name", "kind", "scale"], |
| 30 | "filter_fields": ["kind"]} |
| 31 | } |