• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/document/action/store/decreasestorequantityaction.php
  • Класс: BitrixCatalogDocumentActionStoreDecreaseStoreQuantityAction
  • Вызов: DecreaseStoreQuantityAction::canExecute
public function canExecute(): Result
{
	$result = new Result();

	$amount = $this->getProductAmountNew();
	if ($amount < 0)
	{
		$can = false;

		$product = ProductTable::getRowById($this->productId);
		if (!$product || CheckRightsOnDecreaseStoreAmount::isDisabled())
		{
			$can = false;
		}
		elseif (CheckRightsOnDecreaseStoreAmount::isEnabled())
		{
			$can = AccessController::getCurrent()->check(
				ActionDictionary::ACTION_STORE_DOCUMENT_ALLOW_NEGATION_PRODUCT_QUANTITY,
				StoreDocument::createFromArray([
					'DOC_TYPE' => $this->docType,
				])
			);
		}
		elseif (CheckRightsOnDecreaseStoreAmount::isNotUsed())
		{
			$can = $product['NEGATIVE_AMOUNT_TRACE'] === 'Y';
		}

		if (!$can)
		{
			$message = Loc::getMessage("CATALOG_STORE_DOCS_ERR_INSUFFICIENTLY_AMOUNT_EXT", [
				"#STORE#" => $this->getStoreName(),
				"#PRODUCT#" => $this->getProductName(),
			]);
			$result->addError(new Error($message));
		}
	}

	return $result;
}