• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Reservation/Helpers/Doctor.php
  • Класс: Bitrix\Crm\Reservation\Helpers\Doctor
  • Вызов: Doctor::printProblems
public function printProblems(): void
{
	$result = [];

	$rows = $this->getRows();
	foreach ($rows as $row)
	{
		$problems = [];

		if (empty($row['OWNER_ID']))
		{
			$problems[] = 'Product row is deleted';
		}
		else
		{
			$isAllDeducted = $row['SALE_DEDUCTED_QUANTITY'] === $row['CRM_RESERVE_QUANTITY'];
			if ($isAllDeducted)
			{
				continue;
			}

			if ($row['CRM_RESERVE_STORE_ID'] !== $row['SALE_RESERVE_STORE_ID'])
			{
				$problems[] = 'Store are not equal';
			}

			if ($row['CRM_RESERVE_DATE_END'] !== $row['SALE_RESERVE_DATE_END'])
			{
				$problems[] = 'Date end are not equal';
			}

			// because crm not clean reserves after deduct shipment.
			$saleQuanity = $row['SALE_RESERVE_QUANTITY'] + $row['SALE_DEDUCTED_QUANTITY'];
			$crmQuantity = $row['CRM_RESERVE_QUANTITY'];
			if ($crmQuantity !== $saleQuanity)
			{
				$isWithReserves =
					$row['CRM_RESERVE_QUANTITY'] !== 0.0
					|| $row['SALE_RESERVE_QUANTITY'] !== 0.0
				;
				if ($isWithReserves)
				{
					$problems[] = 'Quantities not equal';
				}
			}
		}

		if (empty($problems))
		{
			continue;
		}

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

	$this->printTable($result);
}