CCrmRestVat::update

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmRestVat
  4. update
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice_invoice.php
  • Класс: \CCrmRestVat
  • Вызов: CCrmRestVat::update
static function update($params)
{
	if (!CModule::IncludeModule('catalog'))
		throw new RestException('The Commercial Catalog module is not installed.');

	global $DB, $USER;

	$CrmPerms = new CCrmPerms($USER->GetID());
	if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE'))
		throw new RestException('Access denied.');

	$ID = intval(CCrmInvoiceRestUtil::getParamScalar($params, 'id', 0));
	if($ID <= 0)
		throw new RestException('Invalid identifier.');

	$fields = CCrmInvoiceRestUtil::getParamArray($params, 'fields');

	$fields = self::filterFields($fields, 'update');

	if (!is_array($fields) || count($fields) === 0)
		throw new RestException('Invalid parameters.');

	$DB->StartTransaction();
	$updatedID = false;
	if (count($fields) > 0)
	{
		$catalogVat = new CCatalogVat();
		$updatedID = $catalogVat->Update($ID, $fields);
	}
	if($updatedID)
	{
		$DB->Commit();
	}
	else
	{
		$DB->Rollback();
		throw new RestException('Error on updating VAT rate.');
	}

	return $updatedID;
}

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