CAllCrmDeal::OnAccountCurrencyChange

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

	$rs = self::GetList(
		array('ID' => 'ASC'),
		//array('!ACCOUNT_CURRENCY_ID' => $accountCurrencyID),
		array(),
		array('ID', 'CURRENCY_ID', 'OPPORTUNITY', 'TAX_VALUE', 'EXCH_RATE')
	);

	$entity = new CCrmDeal(false);
	while($arParams = $rs->Fetch())
	{
		$ID = intval($arParams['ID']);
		$entity->Update($ID, $arParams, false, false);
		$arRows = CCrmProductRow::LoadRows('D', $ID);

		$context = array();
		if(isset($arParams['CURRENCY_ID']))
		{
			$context['CURRENCY_ID'] = $arParams['CURRENCY_ID'];
		}

		if(isset($arParams['EXCH_RATE']))
		{
			$context['EXCH_RATE'] = $arParams['EXCH_RATE'];
		}

		if(count($arRows) > 0)
		{
			CCrmProductRow::SaveRows('D', $ID, $arRows, $context);
		}
	}
}

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