CAllCrmLead::RefreshAccountingData

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmLead
  4. RefreshAccountingData
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_lead.php
  • Класс: \CAllCrmLead
  • Вызов: CAllCrmLead::RefreshAccountingData
static function RefreshAccountingData(array $IDs)
{
	$dbResult = self::GetListEx(
		array(),
		array('@ID' => $IDs, 'CHECK_PERMISSIONS' => 'N'),
		false,
		false,
		array('ID', 'CURRENCY_ID', 'EXCH_RATE')
	);

	if(!is_object($dbResult))
	{
		return;
	}

	$entity = new CCrmLead(false);
	while($fields = $dbResult->Fetch())
	{
		$ID = (int)$fields['ID'];

		$currencyID = isset($fields['CURRENCY_ID']) ? $fields['CURRENCY_ID'] : '';
		$exchRate = isset($fields['EXCH_RATE']) ? (double)$fields['EXCH_RATE'] : -1;

		$currentCurrencyID = $currencyID !== '' ? $currencyID : CCrmCurrency::GetBaseCurrencyID();
		$currentExchRate = CCrmCurrency::GetExchangeRate($currencyID);
		if($currentCurrencyID === $currencyID && $currentExchRate === $exchRate)
		{
			continue;
		}

		$updateFields = array('CURRENCY_ID' => $currentCurrencyID, 'EXCH_RATE' => $currentExchRate);
		$entity->Update(
			$ID,
			$updateFields,
			false,
			false,
			array(
				'REGISTER_SONET_EVENT' => false,
				'ENABLE_SYSTEM_EVENTS' => false,
				'IS_SYSTEM_ACTION' => true
			)
		);
	}
}

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