CCrmAccountingHelper::PrepareAccountingData

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmAccountingHelper
  4. PrepareAccountingData
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_accounting_helper.php
  • Класс: \CCrmAccountingHelper
  • Вызов: CCrmAccountingHelper::PrepareAccountingData
static function PrepareAccountingData($arFields)
{
	$accountCurrencyID = CCrmCurrency::GetAccountCurrencyID();
	if (!isset($accountCurrencyID[0]))
	{
		return false;
	}

	$currencyID = isset($arFields['CURRENCY_ID']) ? strval($arFields['CURRENCY_ID']) : '';
	if (!CCrmCurrency::GetByID($currencyID))
	{
		// Currency is invalid or not assigned
		return false;
	}

	if ($currencyID === $accountCurrencyID)
	{
		// Avoid conversion to float since possible data lost
		return [
			'ACCOUNT_CURRENCY_ID' => $accountCurrencyID,
			'ACCOUNT_SUM' => isset($arFields['SUM']) ? $arFields['SUM'] : 0.0,
		];
	}

	$account = CCrmCurrency::ConvertMoney(
		isset($arFields['SUM']) ? doubleval($arFields['SUM']) : 0.0,
		$currencyID,
		$accountCurrencyID,
		isset($arFields['EXCH_RATE']) ? doubleval($arFields['EXCH_RATE']) : -1
	);

	return [
		'ACCOUNT_CURRENCY_ID' => $accountCurrencyID,
		'ACCOUNT_SUM' => $account,
	];
}

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