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)}.

CodeNameSymbolDecimals
ADACardanoADA8
AEDEmirati Dirham.د.ب2
AFNAfghan Afghani؋2
ALLAlbanian leklek2
AMDArmenian dram2
ANGDutch Guilderƒ2
AOAAngolan KwanzaKz2
ARSArgentine peso$2
ATOMCosmosATOM8
AUDAustralian Dollar$2
AWGArubin florinƒ2
AZNAzerbaijani manatман2
BAMBosnian Convertible MarkaKM2
BATBasic Attention TokenBAT8
BBDBarbadian dollar$2
BCHBitcoin CashBCH8
BDTBangladeshi TakaTk2
BGNBulgarian levлв2
BHDBahraini Dinar.د.ب or BD3
BIFBurundian Franc0
BMDBermudian dollar$2
BNBBinance CoinBNB8
BNDBruneian Dollar$2
BOBBolivian Boliviano$b2
BRLBrazilian realR$2
BSDBahamian dollarB$2
BSVBitcoin SVBSV8
BTCBitcoin₿8
BTNBhutanese NgultrumNu.2
BWPBotswana PulaP2
BYNBelarusian rubleр2
BZDBelize dollarBZ$2
CADCanadian Dollar$2
CDFCongolese FrancFC2
CHFSwiss FrancCHF2
CLPChilean Peso$0
CNYYuan or chinese renminbi¥2
COPColombian peso$2
CRCCosta Rican colón₡2
CROcrypto.comCRO8
CUCCuban convertible peso$2
CUPCuban peso₱2
CVECape Verdean Escudo$2
CZKCzech korunaKč2
DASHDashDASH8
DJFDjiboutian Francfdj0
DKKDanish kronekr2
DOPDominican peso$2
DZDAlgerian Dinarجد2
EGPEgyptian Pound£ 2
EOSEOSEOS8
ERNEritrean nakfaናቕፋ2
ETBEthiopian BirrBr2
ETCEthereum ClassicETC8
ETHEtherΞ9
EUREuros€2
FJDFijian dollar$2
FKPFalkland Island Pound£2
GBPBritish Pound£2
GELGeorgian lariლ2
GHSGhanaian CediGH¢2
GIPGibraltar pound£2
GMDGambian dalasi2
GNFGuinean Franc0
GTQGuatemalan QuetzalQ2
GYDGuyanese dollar$2
HEDGHedge TradeHEDG8
HKDHong Kong dollarHK$2
HNLHonduran lempiraL2
HRKCroatian kunakn2
HTHuobi TokenHT8
HTGHaitian gourdeG2
HUFHungarian forintFt2
IDRIndonesian RupiahRp2
ILSIsraeli Shekel₪2
INRIndian Rupee₹2
IQDIraqi Dinarع.د3
IRRIranian Rial2
ISKIcelandic Kronakr0
JMDJamaican dollarJ$2
JODJordanian Dinar3
JPYJapanese yen¥0
KESKenyan ShillingKSh2
KGSKyrgyzstani somлв2
KHRCambodian Riel៛2
KMFComoran Franc0
KPWNorth Korean won₩2
KRWSouth Korean won₩0
KWDKuwaiti Dinarك3
KYDCaymanian Dollar$2
KZTKazakhstani tenge₸2
LAKLao or Laotian Kip₭2
LBPLebanese Poundل.ل2
LEOUNUS SED LEOLEO8
LINKChainLinkLINK8
LKRSri Lankan RupeeRs2
LRDLiberian Dollar$2
LSLLesotho lotiL or M2
LTCLitecoinLTC8
LTLLithuanian litasLt2
LYDLibyan Dinar د.ل3
MADMoroccan Dirhamم.د.2
MDLMoldovan LeuL2
MGAMalagasy AriaryAr2
MIOTAIOTAMIOTA8
MKDMacedonian Denarден2
MKRMAKERMKR8
MMKBurmese KyatK2
MNTMongolian Tughrik₮2
MOPMacau PatacaMOP$2
MROMauritanian OuguiyaUM2
MRUMauritanian OuguiyaUM2
MURMauritian rupeeRs2
MVRMaldivian Rufiyaarf2
MWKMalawian KwachaMK2
MXNMexico Peso$2
MYRMalaysian RinggitRM2
MZNMozambican MeticalMT2
NADNamibian Dollar$2
NEONeoNEO8
NGNNigerian Naira₦2
NIONicaraguan córdobaC$2
NOKNorwegian kronekr2
NPRNepalese RupeeRs2
NZDNew Zealand Dollar$2
OKBOKBOKB8
OMROmani Rialع.ر.3
ONTOntologyONT8
PABBalboa panamérnB/2
PENPeruvian nuevo solS/2
PGKPapua New Guinean KinaK2
PHPPhilippine Peso₱2
PKRPakistani RupeeRs2
PLNPolish złotyzł2
PYGParaguayan guarani₲0
QARQatari Riyalق.ر 2
RONRomanian leulei2
RSDSerbian DinarРСД2
RUBRussian Rouble₽2
RWFRwandan francFRw, RF, R₣0
SARSaudi Arabian Riyalر.س2
SBDSolomon Islander DollarSI$2
SCRSeychellois RupeeRs2
SDGSudanese Pound2
SEKSwedish kronakr2
SGDSingapore Dollar$2
SHPSaint Helena Pound£2
SLESierra Leonean LeoneLe2
SLLSierra Leonean LeoneLe2
SOSSomali ShillingS2
SRDSurinamese dollar$2
SSPSouth Sudanese pound£2
STNSão Tomé and Príncipe DobraDb2
SVCSalvadoran Colón₡2
SYPSyrian Pound£2
SZLSwazi LilangeniL or E2
THBThai Baht฿2
TJSTajikistani somoni2
TMTTurkmenistan manatT2
TNDTunisian Dinar3
TOPTongan Pa'angaT$2
TRXTronTRX8
TRYTurkish Lira₺2
TTDTrinidadian dollarTT$2
TWDTaiwan New DollarNT$2
TZSTanzanian ShillingSh2
UAHUkrainian Hryvnia₴2
UGXUgandan ShillingUSh0
USDUS Dollar$2
USDCUSD CoinUSDC8
USDTTetherUSDT8
UYUUruguayan peso$U2
UZSUzbekistani somлв2
VEDVenezuelan Bolívar DigitalBs.D2
VEFVenezuelan bolivarBs2
VESVenezuelan Bolívar SoberanoBs.S2
VETVeChainVET8
VNDVietnamese Dong₫0
VUVNi-Vanuatu VatuVT0
WSTSamoan Tālā$2
XAFCentral African CFA FrancFCFA0
XCDEast Caribbean dollarEC$2
XCGCaribbean GuilderCg2
XEMNEMXEM8
XLMStellarXLM8
XMRMoneroXMR8
XOFCFA Franc0
XPFCFP Franc0
XRPRippleXRP8
XTZTezosXTZ8
YERYemeni Rial2
ZARSouth African RandR2
ZECZcashZEC8
ZMWZambian KwachaZMK2
ZWDZimbabwean DollarZ$2
ZWGZimbabwe GoldZiG2

Get inspired by one of our real-life examples: Ticket, Invoice or Bank statement