Class: AmountDcc

timapi.AmountDcc

Amount represents an amount of a specific currency.

Extends

Overview

Members-Overview

Methods-Overview

Member-List

currency :timapi.constants.Currency

Currency to use for transaction.
Overrides:

exponent :Number

Exponent.
Overrides:

markup :Number

Markup applied to the DCC rate by the DCC provider as minor units integer value.

markupExponent :Number

Exponent of the markup.

rate :Number

Exchange Rate in minor units as integer value.

rateExponent :Number

Exchange Rate Exponent.

value :Number

Amount in minor units as integer value.
Overrides:

Methods

getDecimalValue() → {Number}

Get amount-value in major units as floating point value.
Overrides:
Returns:
Amount-value in major units as floating point value

Type: Number

getMarkupDecimal() → {Number}

Markup applied to the DCC rate by the DCC provider as major units floating point value.
Returns:
Markup in major units as floating point value

Type: Number

getRateDecimal() → {Number}

Exchange rate in major units as floating point value.
Returns:
Exchange rate in major units as floating point value.

Type: Number

setCurrency(currency)

Set currency to use for transaction. Also sets the exponent. Assign to currency property directly if you want to keep the exponent unchanged.
Parameters:
Name Type Description
currency timapi.constants.Currency Currency
Overrides:

setDecimalValue(value)

Set amount-value in major units as floating point value
Parameters:
Name Type Description
value Number Amount-value in major units as floating point value (e.g. 10.5)
Overrides:
Throws:
  • Will throw error if amount in minor units is not representable as a 52bit value
  • Will throw error if amount is 0

setValue(value)

Set value of amount.
Parameters:
Name Type Description
value Number Value of amount as an integer value
Overrides:
Throws:
  • Will throw error if it's a floating point number. To make sure it's an integer you can either use Math.floor (8.6 -> 8) or Math.round (8.6 -> 9)
  • Will throw error if amount is not representable as a 52bit value. Use Number.isSafeInteger(value) to check wether value is safe or not
  • Will throw error if amount is 0

toString() → {String}

String representation for debugging purpose.
Overrides:
Returns:
String representation for debugging purpose

Type: String