Design
Currency Formatting
List of functions to manipulate and transform your JSON prices
COMMUNITY FEATURE
Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
v2.0+
:formatC(precisionOrFormat, targetCurrency)
v1.2.0+
| Params | Description | Type |
|---|---|---|
| precisionOrFormat | [optional] Number of decimals, or specific format - Integer : change default precision of the currency - M : print Major currency name without the number - L : prints number with currency symbol (by default) - LL : prints number with Major currency name |
Number |
| targetCurrency | [optional] target currency code (upper case). Ex: USD, EUR, ... It overwrites the global option options.currencyTarget |
String |
Examples
// With API options: {
// "lang": "en-us",
// "currency": {
// "source": "EUR",
// "target": "USD",
// "rates": {
// "EUR": 1,
// "USD": 2
// }
// }
// }
{d.value:formatC()} // input: "1000.456" → output: "$2,000.91"
{d.value:formatC('M')} // input: "1000.456" → output: "dollars"
{d.value:formatC('M')} // input: "1" → output: "dollar"
{d.value:formatC('L')} // input: "1000" → output: "$2,000.00"
{d.value:formatC('LL')} // input: "1000" → output: "2,000.00 dollars"
// With API options: {
// "lang": "fr-fr",
// "currency": {
// "source": "EUR",
// "target": "USD",
// "rates": {
// "EUR": 1,
// "USD": 2
// }
// }
// }
{d.value:formatC()} // input: "1000.456" → output: "2 000,91 $"
// With API options: {
// "lang": "fr-fr",
// "currency": {
// "source": "EUR",
// "target": "EUR",
// "rates": {
// "EUR": 1,
// "USD": 2
// }
// }
// }
{d.value:formatC()} // input: "1000.456" → output: "1 000,46 €"
:convCurr(target, source)
v1.2.0+
Convert from one currency to another
Exchange rates are included by default in Carbone but you can provide a new exchange rate
for one report in options.currencyRates of Carbone.render or globally with Carbone.set
convCurr() without parameters converts automatically from options.currencySource to options.currencyTarget.
If options.currencySource is undefined, no conversion will be performed.
| Params | Description | Type |
|---|---|---|
| target | [optional] convert to this currency ('EUR'). By default it equals options.currencyTarget |
String |
| source | [optional] currency of source data ('USD'). By default it equals options.currencySource |
String |
Examples
// With API options: {
// "currency": {
// "source": "EUR",
// "target": "USD",
// "rates": {
// "EUR": 1,
// "USD": 2
// }
// }
// }
{d.value:convCurr()} // input: 10 → output: 20
{d.value:convCurr()} // input: 1000 → output: 2000
{d.value:convCurr('EUR')} // input: 1000 → output: 1000
{d.value:convCurr('USD')} // input: 1000 → output: 2000
{d.value:convCurr('USD', 'USD')} // input: 1000 → output: 1000
Supported currencies
Carbone accepts the ISO 4217 codes below in formatC, convCurr, toWord and in the currencySource and currencyTarget render options.
The Decimals column is the number of decimals printed by formatC by default: JPY prints none, EUR prints two, JOD prints three. To print a different number of decimals, pass it to the formatter: {d.price:formatC(2)}.
| Code | Name | Symbol | Decimals |
|---|---|---|---|
ADA | Cardano | ADA | 8 |
AED | Emirati Dirham | .د.ب | 2 |
AFN | Afghan Afghani | ؋ | 2 |
ALL | Albanian lek | lek | 2 |
AMD | Armenian dram | 2 | |
ANG | Dutch Guilder | ƒ | 2 |
AOA | Angolan Kwanza | Kz | 2 |
ARS | Argentine peso | $ | 2 |
ATOM | Cosmos | ATOM | 8 |
AUD | Australian Dollar | $ | 2 |
AWG | Arubin florin | ƒ | 2 |
AZN | Azerbaijani manat | ман | 2 |
BAM | Bosnian Convertible Marka | KM | 2 |
BAT | Basic Attention Token | BAT | 8 |
BBD | Barbadian dollar | $ | 2 |
BCH | Bitcoin Cash | BCH | 8 |
BDT | Bangladeshi Taka | Tk | 2 |
BGN | Bulgarian lev | лв | 2 |
BHD | Bahraini Dinar | .د.ب or BD | 3 |
BIF | Burundian Franc | 0 | |
BMD | Bermudian dollar | $ | 2 |
BNB | Binance Coin | BNB | 8 |
BND | Bruneian Dollar | $ | 2 |
BOB | Bolivian Boliviano | $b | 2 |
BRL | Brazilian real | R$ | 2 |
BSD | Bahamian dollar | B$ | 2 |
BSV | Bitcoin SV | BSV | 8 |
BTC | Bitcoin | ₿ | 8 |
BTN | Bhutanese Ngultrum | Nu. | 2 |
BWP | Botswana Pula | P | 2 |
BYN | Belarusian ruble | р | 2 |
BZD | Belize dollar | BZ$ | 2 |
CAD | Canadian Dollar | $ | 2 |
CDF | Congolese Franc | FC | 2 |
CHF | Swiss Franc | CHF | 2 |
CLP | Chilean Peso | $ | 0 |
CNY | Yuan or chinese renminbi | ¥ | 2 |
COP | Colombian peso | $ | 2 |
CRC | Costa Rican colón | ₡ | 2 |
CRO | crypto.com | CRO | 8 |
CUC | Cuban convertible peso | $ | 2 |
CUP | Cuban peso | ₱ | 2 |
CVE | Cape Verdean Escudo | $ | 2 |
CZK | Czech koruna | Kč | 2 |
DASH | Dash | DASH | 8 |
DJF | Djiboutian Franc | fdj | 0 |
DKK | Danish krone | kr | 2 |
DOP | Dominican peso | $ | 2 |
DZD | Algerian Dinar | جد | 2 |
EGP | Egyptian Pound | £ | 2 |
EOS | EOS | EOS | 8 |
ERN | Eritrean nakfa | ናቕፋ | 2 |
ETB | Ethiopian Birr | Br | 2 |
ETC | Ethereum Classic | ETC | 8 |
ETH | Ether | Ξ | 9 |
EUR | Euros | € | 2 |
FJD | Fijian dollar | $ | 2 |
FKP | Falkland Island Pound | £ | 2 |
GBP | British Pound | £ | 2 |
GEL | Georgian lari | ლ | 2 |
GHS | Ghanaian Cedi | GH¢ | 2 |
GIP | Gibraltar pound | £ | 2 |
GMD | Gambian dalasi | 2 | |
GNF | Guinean Franc | 0 | |
GTQ | Guatemalan Quetzal | Q | 2 |
GYD | Guyanese dollar | $ | 2 |
HEDG | Hedge Trade | HEDG | 8 |
HKD | Hong Kong dollar | HK$ | 2 |
HNL | Honduran lempira | L | 2 |
HRK | Croatian kuna | kn | 2 |
HT | Huobi Token | HT | 8 |
HTG | Haitian gourde | G | 2 |
HUF | Hungarian forint | Ft | 2 |
IDR | Indonesian Rupiah | Rp | 2 |
ILS | Israeli Shekel | ₪ | 2 |
INR | Indian Rupee | ₹ | 2 |
IQD | Iraqi Dinar | ع.د | 3 |
IRR | Iranian Rial | 2 | |
ISK | Icelandic Krona | kr | 0 |
JMD | Jamaican dollar | J$ | 2 |
JOD | Jordanian Dinar | 3 | |
JPY | Japanese yen | ¥ | 0 |
KES | Kenyan Shilling | KSh | 2 |
KGS | Kyrgyzstani som | лв | 2 |
KHR | Cambodian Riel | ៛ | 2 |
KMF | Comoran Franc | 0 | |
KPW | North Korean won | ₩ | 2 |
KRW | South Korean won | ₩ | 0 |
KWD | Kuwaiti Dinar | ك | 3 |
KYD | Caymanian Dollar | $ | 2 |
KZT | Kazakhstani tenge | ₸ | 2 |
LAK | Lao or Laotian Kip | ₭ | 2 |
LBP | Lebanese Pound | ل.ل | 2 |
LEO | UNUS SED LEO | LEO | 8 |
LINK | ChainLink | LINK | 8 |
LKR | Sri Lankan Rupee | Rs | 2 |
LRD | Liberian Dollar | $ | 2 |
LSL | Lesotho loti | L or M | 2 |
LTC | Litecoin | LTC | 8 |
LTL | Lithuanian litas | Lt | 2 |
LYD | Libyan Dinar | د.ل | 3 |
MAD | Moroccan Dirham | م.د. | 2 |
MDL | Moldovan Leu | L | 2 |
MGA | Malagasy Ariary | Ar | 2 |
MIOTA | IOTA | MIOTA | 8 |
MKD | Macedonian Denar | ден | 2 |
MKR | MAKER | MKR | 8 |
MMK | Burmese Kyat | K | 2 |
MNT | Mongolian Tughrik | ₮ | 2 |
MOP | Macau Pataca | MOP$ | 2 |
MRO | Mauritanian Ouguiya | UM | 2 |
MRU | Mauritanian Ouguiya | UM | 2 |
MUR | Mauritian rupee | Rs | 2 |
MVR | Maldivian Rufiyaa | rf | 2 |
MWK | Malawian Kwacha | MK | 2 |
MXN | Mexico Peso | $ | 2 |
MYR | Malaysian Ringgit | RM | 2 |
MZN | Mozambican Metical | MT | 2 |
NAD | Namibian Dollar | $ | 2 |
NEO | Neo | NEO | 8 |
NGN | Nigerian Naira | ₦ | 2 |
NIO | Nicaraguan córdoba | C$ | 2 |
NOK | Norwegian krone | kr | 2 |
NPR | Nepalese Rupee | Rs | 2 |
NZD | New Zealand Dollar | $ | 2 |
OKB | OKB | OKB | 8 |
OMR | Omani Rial | ع.ر. | 3 |
ONT | Ontology | ONT | 8 |
PAB | Balboa panamérn | B/ | 2 |
PEN | Peruvian nuevo sol | S/ | 2 |
PGK | Papua New Guinean Kina | K | 2 |
PHP | Philippine Peso | ₱ | 2 |
PKR | Pakistani Rupee | Rs | 2 |
PLN | Polish złoty | zł | 2 |
PYG | Paraguayan guarani | ₲ | 0 |
QAR | Qatari Riyal | ق.ر | 2 |
RON | Romanian leu | lei | 2 |
RSD | Serbian Dinar | РСД | 2 |
RUB | Russian Rouble | ₽ | 2 |
RWF | Rwandan franc | FRw, RF, R₣ | 0 |
SAR | Saudi Arabian Riyal | ر.س | 2 |
SBD | Solomon Islander Dollar | SI$ | 2 |
SCR | Seychellois Rupee | Rs | 2 |
SDG | Sudanese Pound | 2 | |
SEK | Swedish krona | kr | 2 |
SGD | Singapore Dollar | $ | 2 |
SHP | Saint Helena Pound | £ | 2 |
SLE | Sierra Leonean Leone | Le | 2 |
SLL | Sierra Leonean Leone | Le | 2 |
SOS | Somali Shilling | S | 2 |
SRD | Surinamese dollar | $ | 2 |
SSP | South Sudanese pound | £ | 2 |
STN | São Tomé and Príncipe Dobra | Db | 2 |
SVC | Salvadoran Colón | ₡ | 2 |
SYP | Syrian Pound | £ | 2 |
SZL | Swazi Lilangeni | L or E | 2 |
THB | Thai Baht | ฿ | 2 |
TJS | Tajikistani somoni | 2 | |
TMT | Turkmenistan manat | T | 2 |
TND | Tunisian Dinar | 3 | |
TOP | Tongan Pa'anga | T$ | 2 |
TRX | Tron | TRX | 8 |
TRY | Turkish Lira | ₺ | 2 |
TTD | Trinidadian dollar | TT$ | 2 |
TWD | Taiwan New Dollar | NT$ | 2 |
TZS | Tanzanian Shilling | Sh | 2 |
UAH | Ukrainian Hryvnia | ₴ | 2 |
UGX | Ugandan Shilling | USh | 0 |
USD | US Dollar | $ | 2 |
USDC | USD Coin | USDC | 8 |
USDT | Tether | USDT | 8 |
UYU | Uruguayan peso | $U | 2 |
UZS | Uzbekistani som | лв | 2 |
VED | Venezuelan Bolívar Digital | Bs.D | 2 |
VEF | Venezuelan bolivar | Bs | 2 |
VES | Venezuelan Bolívar Soberano | Bs.S | 2 |
VET | VeChain | VET | 8 |
VND | Vietnamese Dong | ₫ | 0 |
VUV | Ni-Vanuatu Vatu | VT | 0 |
WST | Samoan Tālā | $ | 2 |
XAF | Central African CFA Franc | FCFA | 0 |
XCD | East Caribbean dollar | EC$ | 2 |
XCG | Caribbean Guilder | Cg | 2 |
XEM | NEM | XEM | 8 |
XLM | Stellar | XLM | 8 |
XMR | Monero | XMR | 8 |
XOF | CFA Franc | 0 | |
XPF | CFP Franc | 0 | |
XRP | Ripple | XRP | 8 |
XTZ | Tezos | XTZ | 8 |
YER | Yemeni Rial | 2 | |
ZAR | South African Rand | R | 2 |
ZEC | Zcash | ZEC | 8 |
ZMW | Zambian Kwacha | ZMK | 2 |
ZWD | Zimbabwean Dollar | Z$ | 2 |
ZWG | Zimbabwe Gold | ZiG | 2 |
Get inspired by one of our real-life examples: Ticket, Invoice or Bank statement