9Localization\Loc::loadMessages(__FILE__);
35 $dateTime = $data[
'date_create'];
40 $serviceEmail = static::getDefaultServiceEmail();
44 'timestamp' => $dateTime->format(
'd.m.Y H:i:s'),
45 'external_id' => static::buildUuid(static::UUID_TYPE_CHECK, $data[
'unique_id']),
52 'email' => $serviceEmail,
59 'total' => (float)$data[
'total_sum']
63 $email = $data[
'client_email'] ??
'';
65 $phone = \NormalizePhone($data[
'client_phone']);
66 if (is_string($phone))
68 if ($phone[0] !==
'7')
81 if ($clientInfo ===
'PHONE')
83 $result[
'receipt'][
'client'] = [
'phone' => $phone];
85 elseif ($clientInfo ===
'EMAIL')
87 $result[
'receipt'][
'client'] = [
'email' => $email];
91 $result[
'receipt'][
'client'] = [];
95 $result[
'receipt'][
'client'][
'email'] = $email;
100 $result[
'receipt'][
'client'][
'phone'] = $phone;
104 if (isset($data[
'payments']))
106 $paymentTypeMap = $this->getPaymentTypeMap();
107 foreach ($data[
'payments'] as $payment)
109 $result[
'receipt'][
'payments'][] = [
110 'type' => $paymentTypeMap[$payment[
'type']],
111 'sum' => (float)$payment[
'sum']
116 foreach ($data[
'items'] as $item)
118 $result[
'receipt'][
'items'][] = $this->
buildPosition($data, $item);
143 if (isset($item[
'nomenclature_code']))
157 return mb_substr($item[
'name'], 0, static::MAX_NAME_LENGTH);
166 return (
float)$item[
'price'];
175 return (
float)$item[
'sum'];
184 return $item[
'quantity'];
195 return $checkTypeMap[$checkData[
'type']];
206 return $paymentObjectMap[$item[
'payment_object']];
222 return $this->mapVatValue($checkData[
'type'], $vat);
231 $hexCode = bin2hex($code);
232 $hexCodeArray = str_split($hexCode, 2);
233 $hexCodeArray = array_map(
'ToUpper', $hexCodeArray);
235 return join(
' ', $hexCodeArray);
247 $operation =
'sell_correction';
250 $operation =
'sell_refund';
265 $dateTime = $data[
'date_create'];
267 $documentDate = $data[
'correction_info'][
'document_date'];
268 if (!$documentDate instanceof Main\
Type\
Date)
274 'timestamp' => $dateTime->format(
'd.m.Y H:i:s'),
275 'external_id' => static::buildUuid(static::UUID_TYPE_CHECK, $data[
'unique_id']),
285 'correction_info' => [
286 'type' => $data[
'correction_info'][
'type'],
287 'base_date' => $documentDate->format(
'd.m.Y H:i:s'),
288 'base_number' => $data[
'correction_info'][
'document_number'],
289 'base_name' => mb_substr(
290 $data[
'correction_info'][
'description'],
300 if (isset($data[
'payments']))
302 $paymentTypeMap = $this->getPaymentTypeMap();
303 foreach ($data[
'payments'] as $payment)
305 $result[
'correction'][
'payments'][] = [
306 'type' => $paymentTypeMap[$payment[
'type']],
307 'sum' => (float)$payment[
'sum']
312 if (isset($data[
'vats']))
314 foreach ($data[
'vats'] as $item)
317 if (is_null($vat) || $vat ===
'')
322 $result[
'correction'][
'vats'][] = [
324 'sum' => (float)$item[
'sum']
344 private function mapVatValue($checkType, $vat)
347 self::CODE_VAT_10 => [
355 self::CODE_VAT_20 => [
365 return $map[$vat][$checkType] ?? $vat;
409 private function getPaymentTypeMap()
422 private static function getDefaultServiceEmail()
424 return Main\Config\Option::get(
'main',
'email_from');
432 return Localization\Loc::getMessage(
'SALE_CASHBOX_ATOL_FARM_V4_TITLE');
468 protected function getRequestUrl($operation, $token, array $queryData = array())
470 $serviceUrl = static::SERVICE_URL;
474 $serviceUrl = static::SERVICE_TEST_URL;
477 $groupCode = $this->
getField(
'NUMBER_KKM');
479 if ($operation === static::OPERATION_CHECK_REGISTRY)
481 return $serviceUrl.
'/'.$groupCode.
'/'.$queryData[
'CHECK_TYPE'].
'?token='.$token;
483 elseif ($operation === static::OPERATION_CHECK_CHECK)
485 return $serviceUrl.
'/'.$groupCode.
'/report/'.$queryData[
'EXTERNAL_UUID'].
'?token='.$token;
487 elseif ($operation === static::OPERATION_GET_TOKEN)
489 return $serviceUrl.
'/getToken';
501 $settings = parent::getSettings($modelId);
502 unset($settings[
'PAYMENT_TYPE']);
504 $settings[
'SERVICE'][
'ITEMS'][
'EMAIL'] = [
506 'LABEL' => Localization\Loc::getMessage(
'SALE_CASHBOX_ATOL_FARM_SETTINGS_SERVICE_EMAIL_LABEL'),
507 'VALUE' => static::getDefaultServiceEmail()
510 $settings[
'INTERACTION'] = [
511 'LABEL' => Localization\Loc::getMessage(
'SALE_CASHBOX_ATOL_FARM_SETTINGS_INTERACTION'),
515 'LABEL' => Localization\Loc::getMessage(
'SALE_CASHBOX_ATOL_FARM_SETTINGS_MODE_HANDLER_LABEL'),
517 static::HANDLER_MODE_ACTIVE => Localization\Loc::getMessage(
'SALE_CASHBOX_ATOL_FARM_MODE_ACTIVE'),
518 static::HANDLER_MODE_TEST => Localization\Loc::getMessage(
'SALE_CASHBOX_ATOL_FARM_MODE_TEST'),
535 if (empty($checkData[
'receipt'][
'client'][
'email']) && empty($checkData[
'receipt'][
'client'][
'phone']))
537 $result->addError(
new Main\
Error(Localization\
Loc::getMessage(
'SALE_CASHBOX_ATOL_ERR_EMPTY_PHONE_EMAIL')));
540 foreach ($checkData[
'receipt'][
'items'] as $item)
542 if ($item[
'vat'] ===
null)
544 $result->addError(
new Main\
Error(Localization\
Loc::getMessage(
'SALE_CASHBOX_ATOL_ERR_EMPTY_TAX')));
static getMessage($code, $replace=null, $language=null)
const PAYMENT_TYPE_ADVANCE
const PAYMENT_TYPE_CREDIT
const CALCULATED_SIGN_CONSUMPTION
const PAYMENT_TYPE_CASHLESS
registerCheck($operation, array $check)
buildPositionQuantity(array $item)
buildPositionPrice(array $item)
static getSettings($modelId=0)
printCorrectionImmediately(CorrectionCheck $check)
buildPositionPaymentObject(array $item)
buildPositionSum(array $item)
buildPositionVatType(array $checkData, array $item)
buildPosition(array $checkData, array $item)
const HANDLER_MODE_ACTIVE
buildPositionName(array $item)
buildPositionPaymentMethod(array $checkData)
buildPositionNomenclatureCode($code)
checkCorrection(CorrectionCheck $check)
validateCheckQuery(array $checkData)
getRequestUrl($operation, $token, array $queryData=array())
buildCheckQuery(Check $check)
getValueFromSettings($name, $code)
const PAYMENT_OBJECT_EXCISE
const PAYMENT_OBJECT_LOTTERY
const PAYMENT_OBJECT_SOCIAL_INSURANCE
const PAYMENT_OBJECT_COMPOSITE
const PAYMENT_OBJECT_LOTTERY_PRIZE
const PAYMENT_OBJECT_MEDICAL_INSURANCE_IP
const PAYMENT_OBJECT_COMMODITY_MARKING_EXCISE
const PAYMENT_OBJECT_NON_OPERATING_GAIN
const PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING_EXCISE
const PAYMENT_OBJECT_RESORT_FEE
const PAYMENT_OBJECT_PENSION_INSURANCE_IP
const PAYMENT_OBJECT_PROPERTY_RIGHT
const PAYMENT_OBJECT_GAMBLING_PRIZE
const PAYMENT_OBJECT_COMMODITY_MARKING
const PAYMENT_OBJECT_COMMODITY
const PAYMENT_OBJECT_AGENT_COMMISSION
const PAYMENT_OBJECT_ANOTHER
const PAYMENT_OBJECT_DEPOSIT
const PAYMENT_OBJECT_MEDICAL_INSURANCE
const PAYMENT_OBJECT_SERVICE
const PAYMENT_OBJECT_INTELLECTUAL_ACTIVITY
const PAYMENT_OBJECT_PAYMENT
const PAYMENT_OBJECT_EXPENSE
const PAYMENT_OBJECT_GAMBLING_BET
const PAYMENT_OBJECT_CASINO_PAYMENT
const PAYMENT_OBJECT_PENSION_INSURANCE
const PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING
const PAYMENT_OBJECT_SALES_TAX
buildCorrectionCheckQuery(CorrectionCheck $check)