CCrmCurrency::GetExchangeRate

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmCurrency
  4. GetExchangeRate
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_currency.php
  • Класс: \CCrmCurrency
  • Вызов: CCrmCurrency::GetExchangeRate
static function GetExchangeRate($currencyID)
{
	if (!Loader::includeModule('currency'))
	{
		return 1;
	}

	$currencyID = (string) $currencyID;

	$rates = new self::$currencyRatesClassName();
	if(!($rs = $rates->_get_last_rates(date('Y-m-d'), $currencyID)))
	{
		return 1.0;
	}

	$exchRate = (double)$rs['RATE'];
	$cnt = (int)$rs['RATE_CNT'];

	if ($exchRate <= 0)
	{
		$exchRate = (double)$rs["AMOUNT"];
		$cnt = (int)$rs['AMOUNT_CNT'];
	}

	return ($cnt !== 1 ? ($exchRate / $cnt) : $exchRate);
}

Добавить комментарий