Overview

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • auth
        • ldap
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
      • exchange
        • rates
          • currency
            • layer
          • fixer
          • open
            • exchange
              • rates
          • x
            • rates
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • perforated
            • invoice
          • quickbooks
            • invoice
          • templates
            • default
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • reports
        • aging
          • invoices
        • client
          • data
            • portability
        • custom
          • report
        • invoice
          • creation
        • package
          • revenue
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • core
      • Automation
        • Tasks
          • Common
          • Task
        • Type
          • Common
          • Cron
      • Pricing
        • ItemComparator
        • MetaItem
        • Modifier
          • Type
            • Description
              • Type
                • Discount
                • Option
                • Service
                • Tax
            • Discount
            • Price
            • Proration
        • Presenter
          • Build
            • Invoice
            • InvoiceData
            • Options
            • Service
            • ServiceChange
            • ServiceData
          • Collection
          • Format
            • Fields
            • Type
              • Discount
              • Item
              • Option
              • Options
              • Package
              • Pricing
              • Service
              • Tax
          • Items
            • Invoice
            • Service
          • Type
      • ServiceProviders
      • Util
        • Captcha
          • Captchas
          • Common
        • Common
          • Traits
        • Events
          • Common
          • Handlers
          • Observers
        • Filters
          • Common
        • GeoIp
        • Input
          • Fields
            • Common
        • Tax
        • Widgets
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • helpers
      • color
      • data
        • structure
  • None
  • PHP

Classes

  • Accounts
  • Actions
  • ApiKeys
  • Backup
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CouponTerms
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • EmailVerifications
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • MessageGroups
  • Messages
  • MessengerManager
  • ModuleClientMeta
  • ModuleManager
  • ModuleTypes
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • ServiceInvoices
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • SystemEvents
  • Taxes
  • Themes
  • Transactions
  • Users
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class Currencies

Currency Management

Model
Extended by AppModel uses Blesta\Core\Util\Common\Traits\Container
Extended by Currencies
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/currencies.php
Methods summary
public
# __construct( )

Initialize Currencies

Initialize Currencies

Overrides

AppModel::__construct()
public mixed
# getList( integer $company_id, integer $page = 1, string $order_by = ['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
The ID of the company to fetch currencies for
$page
The page to return results for (optional, default 1)
$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
The ID of the company to fetch currencies for

Returns

integer
The total number of currencies

See

Currencies::getList()
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
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
public mixed
# get( string $currency_code, integer $company_id )

Fetches a currency using the given currency code

Fetches a currency using the given currency code

Parameters

$currency_code
The ISO 4217 currency code to fetch on
$company_id
The ID of the company whose currency to fetch

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

Adds a new currency

Parameters

$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
  • precision The decimal precision 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
The ISO 4217 currency code we are updating
$company_id
The Company ID for this currency code
$vars

An array of currency info including:

  • format The format code to use for this currency
  • precision The decimal precision 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
The ISO 4217 currency code we are deleting
$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
The amount to convert
$from_currency
The ISO 4217 currency code format representing $amount
$to_currency
The ISO 4217 currency code to format to
$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 = null )

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
A currency value
$currency
The ISO 4217 currency code format representing $value
$company_id
The company ID to fetch the currency for
$decimals

The number of decimal places (precision) (optional, default null to use the currency's defined precision)

Returns

string
The value in decimal format based on ISO 31-0

See

Currencies::toCurrency()
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 = null )

Converts the given decimal value into a currency value.

Converts the given decimal value into a currency value.

Parameters

$value
The decimal value to convert
$currency
The ISO 4217 currency code format to apply to $value
$company_id
The company ID to fetch the currency for
$prefix
True to include the prefix symbol for this currency, false otherwise
$suffix
True to include the suffix symbol for this currency, false otherwise
$code
True to include the currency code for this currency, false otherwise
$with_separator
True to include the separator for this currency, false otherwise
$decimals

The number of decimal places (precision) (optional, default null to use the currency's defined precision)

Returns

string
The value formatted for the specified currency

See

Currencies::toDecimal()
Currencies::toCurrencyValue()
public string
# toCurrencyValue( float $value, string $currency, boolean $with_separator = true, integer $company_id = null, integer $decimals = null )

Converts the given decimal value into a currency value excluding the prefix, suffix, and currency code symbols

Converts the given decimal value into a currency value excluding the prefix, suffix, and currency code symbols

Parameters

$value
The decimal value to convert
$currency
The ISO 4217 currency code format to apply to $value
$with_separator
True to include the separator for this currency, false otherwise
$company_id
The company ID to fetch the currency for
$decimals

The number of decimal places (precision) (optional, default null to use the currency's defined precision)

Returns

string
The value formatted for the specified currency

See

Currencies::toCurrency()
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
The ISO 4217 currency code to check
$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
The ISO 4217 currency code to check
$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
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
The currency code
$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 boolean|ExchangeRate
# getExchangeRateProcessor( string $processor )

Retrieves an instance of the exchange rate processor. Sets Input errors if the processor cannot not be found.

Retrieves an instance of the exchange rate processor. Sets Input errors if the processor cannot not be found.

Parameters

$processor
The name of the exchange rate processor (e.g. google_finance)

Returns

boolean|ExchangeRate
An instance of the ExchangeRate processor if found, otherwise boolean false
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.

Methods inherited from AppModel
_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()
Methods used from Blesta\Core\Util\Common\Traits\Container
getFromContainer()
Properties inherited from AppModel
$logger, $replacement_keys
Blesta API documentation generated by ApiGen