- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/cashbox/cashboxatolfarm.php
- Класс: BitrixSaleCashboxCashboxAtolFarm
- Вызов: CashboxAtolFarm::buildCheckQuery
public function buildCheckQuery(Check $check)
{
$data = $check->getDataForCheck();
/** @var MainTypeDateTime $dateTime */
$dateTime = $data['date_create'];
$result = array(
'timestamp' => $dateTime->format('d.m.Y H:i:s'),
'external_id' => static::buildUuid(static::UUID_TYPE_CHECK, $data['unique_id']),
'service' => array(
'inn' => $this->getValueFromSettings('SERVICE', 'INN'),
'callback_url' => $this->getCallbackUrl(),
'payment_address' => $this->getValueFromSettings('SERVICE', 'P_ADDRESS'),
),
'receipt' => array(
'attributes' => array(
'sno' => $this->getValueFromSettings('TAX', 'SNO')
),
'payments' => array(),
'items' => array(),
'total' => (float)$data['total_sum']
)
);
$phone = NormalizePhone($data['client_phone']);
if (is_string($phone))
{
if ($phone[0] === '7')
$phone = mb_substr($phone, 1);
}
else
{
$phone = '';
}
$email = $data['client_email'] ?: '';
$clientInfo = $this->getValueFromSettings('CLIENT', 'INFO');
if ($clientInfo === 'PHONE')
{
$result['receipt']['attributes'] = ['phone' => $phone];
}
elseif ($clientInfo === 'EMAIL')
{
$result['receipt']['attributes'] = ['email' => $email];
}
else
{
$result['receipt']['attributes'] = [
'email' => $email,
'phone' => $phone,
];
}
foreach ($data['payments'] as $payment)
{
$result['receipt']['payments'][] = array(
'type' => (int)$this->getValueFromSettings('PAYMENT_TYPE', $payment['type']),
'sum' => (float)$payment['sum']
);
}
foreach ($data['items'] as $i => $item)
{
$vat = $this->getValueFromSettings('VAT', $item['vat']);
$result['receipt']['items'][] = array(
'name' => mb_substr($item['name'], 0, self::MAX_NAME_LENGTH),
'price' => (float)$item['price'],
'sum' => (float)$item['sum'],
'quantity' => $item['quantity'],
'tax' => ($vat !== null) ? $vat : $this->getValueFromSettings('VAT', 'NOT_VAT')
);
}
return $result;
}