• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/cashbox/cashboxatolfarmv4.php
  • Класс: BitrixSaleCashboxCashboxAtolFarmV4
  • Вызов: CashboxAtolFarmV4::buildCheckQuery
public function buildCheckQuery(Check $check)
{
	$data = $check->getDataForCheck();

	/** @var MainTypeDateTime $dateTime */
	$dateTime = $data['date_create'];

	$serviceEmail = $this->getValueFromSettings('SERVICE', 'EMAIL');
	if (!$serviceEmail)
	{
		$serviceEmail = static::getDefaultServiceEmail();
	}

	$result = [
		'timestamp' => $dateTime->format('d.m.Y H:i:s'),
		'external_id' => static::buildUuid(static::UUID_TYPE_CHECK, $data['unique_id']),
		'service' => [
			'callback_url' => $this->getCallbackUrl(),
		],
		'receipt' => [
			'client' => [],
			'company' => [
				'email' => $serviceEmail,
				'sno' => $this->getValueFromSettings('TAX', 'SNO'),
				'inn' => $this->getValueFromSettings('SERVICE', 'INN'),
				'payment_address' => $this->getValueFromSettings('SERVICE', 'P_ADDRESS'),
			],
			'payments' => [],
			'items' => [],
			'total' => (float)$data['total_sum']
		]
	];

	$email = $data['client_email'] ?? '';

	$phone = NormalizePhone($data['client_phone']);
	if (is_string($phone))
	{
		if ($phone[0] !== '7')
		{
			$phone = '7'.$phone;
		}

		$phone = '+'.$phone;
	}
	else
	{
		$phone = '';
	}

	$clientInfo = $this->getValueFromSettings('CLIENT', 'INFO');
	if ($clientInfo === 'PHONE')
	{
		$result['receipt']['client'] = ['phone' => $phone];
	}
	elseif ($clientInfo === 'EMAIL')
	{
		$result['receipt']['client'] = ['email' => $email];
	}
	else
	{
		$result['receipt']['client'] = [];

		if ($email)
		{
			$result['receipt']['client']['email'] = $email;
		}

		if ($phone)
		{
			$result['receipt']['client']['phone'] = $phone;
		}
	}

	if (isset($data['payments']))
	{
		$paymentTypeMap = $this->getPaymentTypeMap();
		foreach ($data['payments'] as $payment)
		{
			$result['receipt']['payments'][] = [
				'type' => $paymentTypeMap[$payment['type']],
				'sum' => (float)$payment['sum']
			];
		}
	}

	foreach ($data['items'] as $item)
	{
		$result['receipt']['items'][] = $this->buildPosition($data, $item);
	}

	return $result;
}