• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/InventoryManagement/Helpers/Doctor.php
  • Класс: BitrixCatalogInventoryManagementHelpersDoctor
  • Вызов: Doctor::printProblems
public function printProblems(): void
{
	$sql = $this->getSql() . ' AND (
		cp.QUANTITY != csp.QUANTITY_AVAILABLE OR csp.QUANTITY_AVAILABLE IS NULL
		OR cp.QUANTITY_RESERVED != csp.QUANTITY_RESERVED OR csp.QUANTITY_RESERVED IS NULL
		OR sbr.QUANTITY_RESERVED > cp.QUANTITY_RESERVED
		OR cp.QUANTITY_RESERVED < 0
		OR csp.QUANTITY_RESERVED < 0
	)';

	$result = [];

	$rows = Application::getConnection()->query($sql);
	foreach ($rows as $row)
	{
		$problems = [];

		$storeReserveQuantity = (float)$row['STORE_QUANTITY_RESERVED'];
		$productReserveQuantity = (float)$row['PRODUCT_QUANTITY_RESERVED'];

		if ((float)$row['PRODUCT_QUANTITY_AVAILABLE'] !== (float)$row['STORE_QUANTITY_AVAILABLE'])
		{
			$problems[] = 'Available quantity not match';
		}

		if ($productReserveQuantity !== $storeReserveQuantity)
		{
			$problems[] = 'Reserve quantity not match';
		}

		if ($productReserveQuantity < 0.0)
		{
			$problems[] = 'Product reserve quantity less than 0';
		}

		if ($storeReserveQuantity < 0.0)
		{
			$problems[] = 'Store reserve quantity less than 0';
		}

		if ((float)$row['SALE_QUANTITY_RESERVED'] > $productReserveQuantity)
		{
			$problems[] = 'More is reserved in `sale` than in `catalog`';
		}

		if (empty($problems))
		{
			$problems[] = 'Unknown, check SQL';
		}

		$result[] = ['PROBLEMS' => join('; ', $problems)] + $row;
	}

	$this->printTable($result);
}