Siftsciex v0.3.1 Siftsciex.Currency View Source
The Currency module handles the translation of price values from the client unit to the “base in micros” units Sift Science expects. Most of the logic here is governed by configuration values. Siftsciex
performs all calculations relative to the base unit for the currency given. This means that the library needs to know if a value is a quantity of that base unit or some other multiple of that unit. The :currency_factors
configuration value allows you to tell Siftsciex
how to convert a value to the base unit for the currency being used.
Link to this section Summary
Functions
Converts the given amount for the given currency to the corresponding micros
value based on the configuration for that currency
Link to this section Functions
Converts the given amount for the given currency to the corresponding micros
value based on the configuration for that currency.
Parameters
amount
: The amount that should be converted as aninteger
type
: The currency type, if no configuration is found for that currency then thedefault
configuration factor will be used, if there no configuration is found for that currency and no:default
is set then the value will be converted directly to micros (amount * 10_000)
Examples
iex> Currency.as_micros(8, "USD")
8000000
iex> Currency.as_micros(8, :usd)
8000000
iex> Currency.as_micros(800, :unknown)
8000000