public
|
#
__construct( )
Initialize Currencies
Overrides
|
public
mixed
|
#
getList( integer $company_id, integer $page = 1, string $order_by = array('code'=>"ASC") )
Fetches a list of all currencies for a given company
Fetches a list of all currencies for a given company
Parameters
- $company_id
integer $company_id The ID of the company to fetch currencies for
- $page
integer $page The page to return results for (optional, default 1)
- $order_by
string $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
mixed An array of stdClass objects representing currencies, false if no currencies
found
|
public
integer
|
#
getListCount( integer $company_id )
Returns the total number of currencies returned from Currencies::getList(),
useful in constructing pagination for the getList() method.
Returns the total number of currencies returned from Currencies::getList(),
useful in constructing pagination for the getList() method.
Parameters
- $company_id
integer $company_id The ID of the company to fetch currencies for
Returns
integer The total number of currencies
See
|
public
mixed
|
#
getAll( integer $company_id )
Fetches a full list of all currencies for a given company
Fetches a full list of all currencies for a given company
Parameters
- $company_id
integer $company_id The ID of the company to fetch currencies for
Returns
mixed An array of stdClass objects representing all currencies, or false if no
currencies found
|
private
Record
|
#
getCurrencies( integer $company_id )
Partially constructs the query required by Currencies::getList(),
Currencies::getListCount(), and Currencies::getAll()
Partially constructs the query required by Currencies::getList(),
Currencies::getListCount(), and Currencies::getAll()
Parameters
- $company_id
integer $company_id The company ID to fetch currencies for
Returns
Record
The partially constructed query Record object
|
public
mixed
|
#
get( string $currency_code, mixed $company_id )
Fetches a currency using the given currency code
Fetches a currency using the given currency code
Parameters
- $currency_code
string $currency_code The ISO 4217 currency code to fetch on
- $company_id
Returns
mixed stdClass object representing the currency if it exists, false otherwise
|
public
array
|
#
getFormats( )
Returns an array containing every supported currency format with an example
in key/value pairs
Returns an array containing every supported currency format with an example
in key/value pairs
Returns
array An array of currency formats in key/value pairs where the key is the format and
the value is an example
|
public
|
#
add( array $vars )
Adds a new currency
Parameters
- $vars
array $vars An array of currency info including: -code The ISO 4217 currency code
-company_id The Company ID -format The format code to use for this currency
-prefix The prefix to use for this currency -suffix The suffix to use for this
currency -exchange_rate The exchange rate in relation to the primary currency
-exchange_updated The datetime the exchange_rate was last updated
|
public
|
#
edit( string $currency_code, integer $company_id, array $vars )
Edits an existing currency
Edits an existing currency
Parameters
- $currency_code
string $currency_code The ISO 4217 currency code we are updating
- $company_id
integer $company_id The Company ID for this currency code
- $vars
array $vars An array of currency info including: -format The format code to use for
this currency -prefix The prefix to use for this currency -suffix The suffix to
use for this currency -exchange_rate The exchange rate in relation to the
primary currency -exchange_updated The datetime the exchange_rate was last
updated
|
public
|
#
delete( string $currency_code, integer $company_id )
Deletes an existing currency
Deletes an existing currency
Parameters
- $currency_code
string $currency_code The ISO 4217 currency code we are deleting
- $company_id
integer $company_id The Company ID for this currency code
|
public
float
|
#
convert( float $amount, string $from_currency, string $to_currency, integer $company_id )
Converts an amount from one currency to another using the exchange rate
Converts an amount from one currency to another using the exchange rate
Parameters
- $amount
float $amount The amount to convert
- $from_currency
string $from_currency The ISO 4217 currency code format representing $amount
- $to_currency
string $to_currency The ISO 4217 currency code to format to
- $company_id
integer $company_id The ID of the company
Returns
float The $amount converted between currencies
|
public
string
|
#
toDecimal( string $value, string $currency, integer $company_id = null, integer $decimals = 2 )
Converts a currency value into a decimal representation based on ISO 31-0
Converts a currency value into a decimal representation based on ISO 31-0
Parameters
- $value
string $value A currency value
- $currency
string $currency The ISO 4217 currency code format representing $value
- $company_id
integer $company_id The company ID to fetch the currency for
- $decimals
integer $decimals The number of decimals points (precision)
Returns
string The value in decimal format based on ISO 31-0
See
|
public
string
|
#
toCurrency( float $value, string $currency, integer $company_id = null, boolean $prefix = true, boolean $suffix = true, boolean $code = false, boolean $with_separator = true, integer $decimals = 2 )
Converts the given decimal value into a currency value.
Converts the given decimal value into a currency value.
Parameters
- $value
float $value The decimal value to convert
- $currency
string $currency The ISO 4217 currency code format to apply to $value
- $company_id
integer $company_id The company ID to fetch the currency for
- $prefix
boolean $prefix True to include the prefix symbol for this currency, false otherwise
- $suffix
boolean $suffix True to include the suffix symbol for this currency, false otherwise
- $code
boolean $code True to include the currency code for this currency, false otherwise
- $with_separator
boolean $with_separator True to include the separator for this currency, false otherwise
- $decimals
integer $decimals The number of decimal places (precision)
Returns
string The value formatted for the specified currency
See
|
public
string
|
#
toCurrencyValue( float $value, string $currency, boolean $with_separator = true, integer $company_id = null, integer $decimals = 2 )
Converts the given decimal value into a currency value exluding the prefix,
suffix, and currency code symbols
Converts the given decimal value into a currency value exluding the prefix,
suffix, and currency code symbols
Parameters
- $value
float $value The decimal value to convert
- $currency
string $currency The ISO 4217 currency code format to apply to $value
- $with_separator
boolean $with_separator True to include the separator for this currency, false otherwise
- $company_id
integer $company_id The company ID to fetch the currency for
- $decimals
integer $decimals The number of decimal places (precision)
Returns
string The value formatted for the specified currency
See
|
private
array
|
#
getRules( array $vars )
Returns the rule set for adding/editing currencies
Returns the rule set for adding/editing currencies
Parameters
- $vars
array $vars The input vars
Returns
array Currency rules
|
public
boolean
|
#
validateCurrencyInUse( string $currency_code, integer $company_id )
Checks if a currency code is currently in use
Checks if a currency code is currently in use
Parameters
- $currency_code
string $currency_code The ISO 4217 currency code to check
- $company_id
integer $company_id The company ID whose currency to check
Returns
boolean True if the currency code is in use, false otherwise
|
public
boolean
|
#
validateCurrencyIsDefault( string $currency_code, integer $company_id )
Checks if the given currency code is set as the default currency
Checks if the given currency code is set as the default currency
Parameters
- $currency_code
string $currency_code The ISO 4217 currency code to check
- $company_id
integer $company_id The company ID whose default currency to check
Returns
boolean True if the currency is the default currency for this company, false otherwise
|
public
boolean
|
#
validateCurrencyFormat( string $format )
Validates a currency's 'format' field
Validates a currency's 'format' field
Parameters
- $format
string $format The format to check, (e.g. "#.###")
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateCurrencyExists( string $code, integer $company_id )
Validates a currency exists
Validates a currency exists
Parameters
- $code
string $code The currency code
- $company_id
integer $company_id The company ID
Returns
boolean True if the currency exists, false otherwise
|
public
array
|
#
getExchangeRateProcessors( )
Retrieves a list of exchange rate processors
Retrieves a list of exchange rate processors
Returns
array A list of exchange rate processors
|
public
|
#
updateRates( )
Updates all currency exchange rates for the current company using the
configured processor.
Updates all currency exchange rates for the current company using the
configured processor.
|