• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/cashbox/cashboxbitrix.php
  • Класс: BitrixSaleCashboxCashboxBitrix
  • Вызов: CashboxBitrix::buildCheckQuery
public function buildCheckQuery(Check $check)
{
	$result = array();

	$data = $check->getDataForCheck();

	foreach ($data['payments'] as $payment)
	{
		$result['payments'][] = array(
			'type' => $this->getValueFromSettings('PAYMENT_TYPE', $payment['type']),
			'value' => $payment['sum']
		);
	}

	$typeMap = $this->getCheckTypeMap();
	if (isset($typeMap[$data['type']]))
	{
		$result['type'] = $typeMap[$data['type']];
	}
	else
	{
		return array();
	}

	$result['uuid'] = static::buildUuid(static::UUID_TYPE_CHECK, $data['unique_id']);
	$result['zn'] = $this->getField('NUMBER_KKM');
	$result['items'] = array();
	foreach ($data['items'] as $item)
	{
		$vat = $this->getValueFromSettings('VAT', $item['vat']);
		if ($vat === null)
			$vat = $this->getValueFromSettings('VAT', 'NOT_VAT');

		$value = array(
			'name' => $item['name'],
			'price' => (float)$item['base_price'],
			'quantity' => $item['quantity'],
			'VAT' => (int)$vat
		);

		if (isset($item['discount']) && is_array($item['discount']))
		{
			$discountValue = PriceMaths::roundPrecision($item['base_price']*$item['quantity']) - $item['sum'];
			$value['discount'] = $discountValue;

			$discountType = $item['discount']['discount_type'] === 'P' ? 1 : 0;
			$value['discount_type'] = $discountType;
		}

		$result['items'][] = $value;
	}
	$result['client'] = $data['client_email'];

	/** @var MainTypeDateTime $dateTime */
	$dateTime = $data['date_create'];
	$result['timestamp'] = (string)$dateTime->getTimestamp();

	return $result;
}