Currency module provides utility methods for working with currencies.
Methods
- 
    <static> convertAmount(amount, fromId, toId)
- 
    
    Converts from one currency to another. Parameters:Name Type Description amountnumber | string Base currency amount. fromIdstring Source currency id. toIdstring Target currency id. Returns:The converted amount. - Type
- string
 
- 
    <static> convertFromBase(amount, toId)
- 
    
    Converts from the base currency to another currency. Parameters:Name Type Description amountnumber | string The amount in the base currency. toIdstring Target currency id. Returns:The converted amount. - Type
- string
 
- 
    <static> convertToBase(amount, fromId)
- 
    
    Converts a currency to the base currency. Parameters:Name Type Description amountnumber | string The amount in the source currency. fromIdstring Source currency id. Returns:The converted amount. - Type
- string
 
- 
    <static> convertWithRate(amount, fromRate, toRate)
- 
    
    Converts a currency with given conversion rates. Parameters:Name Type Description amountnumber | string The amount in the origin currency. fromRatenumber The origin conversion rate relative to the base currency. toRatenumber The target conversion rate relative to the base currency. Returns:The converted amount. - Type
- string
 
- 
    <static> formatAmount(amount [, currencyId] [, decimalPrecision] [, numberGroupingSeparator] [, decimalSeparator] [, symbolSeparator])
- 
    
    Formats a currency amount. Parameters:Name Type Argument Default Description amountnumber The amount to be formatted. currencyIdstring <optional> 
 The currency id to be used. If not specified, the system default will be used. decimalPrecisionnumber <optional> 
 2 The number of digits for decimal precision. numberGroupingSeparatorstring <optional> 
 ',' The thousands separator. decimalSeparatorstring <optional> 
 '.' The decimal separator (string between number and decimal digits). symbolSeparatorstring <optional> 
 '' The string between the symbol and the amount. Returns:The formatted currency amount. - Type
- string
 
- 
    <static> formatAmountLocale(amount [, currencyId] [, decimalPrecision])
- 
    
    Formats a currency amount according to the current user's locale. Parameters:Name Type Argument Description amountnumber The amount to format. currencyIdstring <optional> 
 The currency id to use. If not specified, the system default will be used. decimalPrecisionstring <optional> 
 The number of decimal digits to use. If not specified, the user preference will be used. Returns:formatted currency amount. - Type
- string
 
- 
    <static> getBaseCurrency()
- 
    
    Gets the system's base currency. Returns:The base currency data. - Type
- Object
 
- 
    <static> getBaseCurrencyId()
- 
    
    Gets the base currency id. Returns:The base currency id. - Type
- string
 
- 
    <static> getCurrenciesSelector(template)
- 
    
    Returns a map of currency IDs to the result of applying the given Handlebars template to them. Example for the templateparam:getCurrenciesSelector(Handlebars.compile('{{symbol}} ({{iso}})'));Parameters:Name Type Description templatefunction How to format the values returned. Returns:Map from currency IDs to formatted currency data. - Type
- Object
 
- 
    <static> getCurrencySymbol(currencyId)
- 
    
    Gets the symbol for the given currency ID. Parameters:Name Type Description currencyIdstring Currency identifier. Returns:The currency display symbol (e.g. "$"). - Type
- string
 
- 
    <static> unformatAmount(amount, numberGroupingSeparator, decimalSeparator [, toFloat])
- 
    
    Unformats a currency amount. Parameters:Name Type Argument Default Description amountstring The amount to unformat. numberGroupingSeparatorstring Thousands separator. decimalSeparatorstring The string between number and decimals. toFloatboolean <optional> 
 false If true, convert string to float value.Returns:The unformatted currency amount. - Type
- string
 
- 
    <static> unformatAmountLocale(amount, toFloat)
- 
    
    Unformats the currency amount according to the current user's locale. Parameters:Name Type Description amountstring Amount to unformat. toFloatboolean If true, convert string to float value.Returns:The unformatted currency amount. - Type
- string