LanguageValues and typesStandard typesMoney and banking
Currency
On this page
A currency, by its three-letter code: GBP.
Use it beside an amount, or to store which currency a customer pays in. An amount in a currency is a Money, which already holds one.
Shape
One of 170 values, such as Currency.aed, written AED. Details has them.
Example
Currency.gbptext.parse(raw, as: Currency) reads one from text that comes from outside. Text that isn't one at all fails malformed, such as pound, XYZ or XAU.
This operation gives one: money.currency.
Good to know
- Each value is its code in lower case.
alllists the variants, so the Albanian lek takes a trailing_:Currency.all_. - It lists active currencies. Old currencies you already hold, such as Croatian kuna, are still read, but gold (
XAU) and made-up codes aren't. ==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
A string, in a request, a response or json.write:
"GBP""HRK""JPY"
Details
Text form, storage, how it is shown, and operations
Currency is in the group Money and banking, and has been in Jadpo since 0.1.0.
Every value
Every value, each after Currency., with how it is written:
aed (AED), afn (AFN), all_ (ALL), amd (AMD), ang (ANG), aoa (AOA), ars (ARS), aud (AUD), awg (AWG), azn (AZN), bam (BAM), bbd (BBD), bdt (BDT), bgn (BGN), bhd (BHD), bif (BIF), bmd (BMD), bnd (BND), bob (BOB), bov (BOV), brl (BRL), bsd (BSD), btn (BTN), bwp (BWP), byn (BYN), bzd (BZD), cad (CAD), cdf (CDF), che (CHE), chf (CHF), chw (CHW), clf (CLF), clp (CLP), cny (CNY), cop (COP), cou (COU), crc (CRC), cuc (CUC), cup (CUP), cve (CVE), czk (CZK), djf (DJF), dkk (DKK), dop (DOP), dzd (DZD), egp (EGP), ern (ERN), etb (ETB), eur (EUR), fjd (FJD), fkp (FKP), gbp (GBP), gel (GEL), ghs (GHS), gip (GIP), gmd (GMD), gnf (GNF), gtq (GTQ), gyd (GYD), hkd (HKD), hnl (HNL), hrk (HRK), htg (HTG), huf (HUF), idr (IDR), ils (ILS), inr (INR), iqd (IQD), irr (IRR), isk (ISK), jmd (JMD), jod (JOD), jpy (JPY), kes (KES), kgs (KGS), khr (KHR), kmf (KMF), kpw (KPW), krw (KRW), kwd (KWD), kyd (KYD), kzt (KZT), lak (LAK), lbp (LBP), lkr (LKR), lrd (LRD), lsl (LSL), lyd (LYD), mad (MAD), mdl (MDL), mga (MGA), mkd (MKD), mmk (MMK), mnt (MNT), mop (MOP), mru (MRU), mur (MUR), mvr (MVR), mwk (MWK), mxn (MXN), mxv (MXV), myr (MYR), mzn (MZN), nad (NAD), ngn (NGN), nio (NIO), nok (NOK), npr (NPR), nzd (NZD), omr (OMR), pab (PAB), pen (PEN), pgk (PGK), php (PHP), pkr (PKR), pln (PLN), pyg (PYG), qar (QAR), ron (RON), rsd (RSD), rub (RUB), rwf (RWF), sar (SAR), sbd (SBD), scr (SCR), sdg (SDG), sek (SEK), sgd (SGD), shp (SHP), sle (SLE), sll (SLL), sos (SOS), srd (SRD), ssp (SSP), stn (STN), svc (SVC), syp (SYP), szl (SZL), thb (THB), tjs (TJS), tmt (TMT), tnd (TND), top (TOP), try (TRY), ttd (TTD), twd (TWD), tzs (TZS), uah (UAH), ugx (UGX), usd (USD), usn (USN), uyi (UYI), uyu (UYU), uyw (UYW), uzs (UZS), ved (VED), ves (VES), vnd (VND), vuv (VUV), wst (WST), xaf (XAF), xcd (XCD), xcg (XCG), xof (XOF), xpf (XPF), yer (YER), zar (ZAR), zmw (ZMW), zwg (ZWG), zwl (ZWL).
Text form
text.from writes one standard text form, the same form text.parse reads back: GBP, HRK and JPY.
How it is stored
It is stored in one column named for the field, of type text. HRK is stored as 'HRK'.
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
GBP |
British Pound |
HRK |
Croatian Kuna |
JPY |
Japanese Yen |
Operations
money.currency(value: Money) -> Currency: The currencyvalueis in.money.from_minor(amount: Int, currency: Currency) -> Money:amountminor units ofcurrency:money.from_minor(1050, Currency.gbp)is £10.50.money.of(amount: Decimal, currency: Currency) -> Money:amountmajor units ofcurrency, aDecimal:money.of(10.50, Currency.gbp)is £10.50. It fails withtoo_many_placesfor more places than the currency has (10.505 in pounds), unless the currency is written out and the amount proved to have no more.money.sum(items: List<Money>, currency: Currency) -> Money: The items added up incurrency, the zero an empty list gives. It fails withcurrency_mismatchfor an item in another currency, unless the items' type fixescurrency.
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-currency.md.Built from Jadpo main at aee2e8f.