Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
cashboxatolfarmv5.php
1<?php
2
3namespace Bitrix\Sale\Cashbox;
4
7
8Localization\Loc::loadMessages(__FILE__);
9
16{
17 const SERVICE_URL = 'https://online.atol.ru/possystem/v5';
18 const SERVICE_TEST_URL = 'https://testonline.atol.ru/possystem/v5';
19
20 private const MARK_CODE_TYPE_GS1_M = 'gs1m';
21
25 public static function getName()
26 {
27 return Localization\Loc::getMessage('SALE_CASHBOX_ATOL_FARM_V5_TITLE');
28 }
29
33 protected function buildPosition(array $checkData, array $item): array
34 {
35 $result = [
36 'name' => $this->buildPositionName($item),
37 'price' => $this->buildPositionPrice($item),
38 'sum' => $this->buildPositionSum($item),
39 'quantity' => $this->buildPositionQuantity($item),
40 'measure' => $this->buildPositionMeasure($item),
41 'payment_method' => $this->buildPositionPaymentMethod($checkData),
42 'payment_object' => $this->buildPositionPaymentObject($item),
43 'vat' => [
44 'type' => $this->buildPositionVatType($checkData, $item)
45 ],
46 ];
47
48 if (isset($item['marking_code']))
49 {
50 $result['mark_processing_mode'] = '0';
51 $result['mark_code'] = $this->buildPositionGs1mMarkCode($item);
52 }
53
54 if (isset($item['supplier_info']))
55 {
56 $result['agent_info'] = $this->buildPositionAgentInfo();
57 $result['supplier_info'] = $this->buildPositionSupplierInfo($item['supplier_info']);
58 }
59
60 return $result;
61 }
62
66 protected static function hasMeasureSettings(): bool
67 {
68 return true;
69 }
70
75 private function buildPositionMeasure(array $item): ?int
76 {
77 $tag2108Value = $this->getValueFromSettings('MEASURE', $item['measure_code']);
78 if (is_null($tag2108Value) || $tag2108Value === '')
79 {
80 $tag2108Value = $this->getValueFromSettings('MEASURE', 'DEFAULT');
81 }
82
83 return (is_null($tag2108Value) || $tag2108Value === '') ? null : (int)$tag2108Value;
84 }
85
90 private function buildPositionGs1mMarkCode(array $item): array
91 {
92 return [
93 self::MARK_CODE_TYPE_GS1_M => base64_encode($item['marking_code']),
94 ];
95 }
96
97 private function buildPositionAgentInfo(): array
98 {
102 return [
103 'type' => 'another',
104 ];
105 }
106
107 private function buildPositionSupplierInfo(array $supplier): array
108 {
109 $supplierInfo = [];
110
111 if (!empty($supplier['phones']))
112 {
113 $phoneParser = PhoneNumber\Parser::getInstance();
114
115 foreach ($supplier['phones'] as $phone)
116 {
117 $phoneNumber = $phoneParser->parse($phone);
118 $formattedPhone = $phoneNumber->format(PhoneNumber\Format::E164);
119 if ($formattedPhone)
120 {
121 $supplierInfo['phones'][] = $formattedPhone;
122 }
123 }
124 }
125
126 if (!empty($supplier['name']))
127 {
128 $supplierInfo['name'] = mb_substr($supplier['name'], 0, 256);
129 }
130
131 if (empty($supplier['inn']))
132 {
133 $supplierInfo['inn'] = '000000000000';
134 }
135 else
136 {
137 $supplierInfo['inn'] = $supplier['inn'];
138 }
139
140 return $supplierInfo;
141 }
142
180
184 public static function getFfdVersion(): ?float
185 {
186 return 1.2;
187 }
188
192 public static function isCorrectionOn(): bool
193 {
194 return false;
195 }
196}
buildPositionVatType(array $checkData, array $item)
buildPosition(array $checkData, array $item)
getValueFromSettings($name, $code)
Definition cashbox.php:201
const PAYMENT_OBJECT_SOCIAL_INSURANCE
Definition check.php:47
const PAYMENT_OBJECT_LOTTERY_PRIZE
Definition check.php:32
const PAYMENT_OBJECT_MEDICAL_INSURANCE_IP
Definition check.php:45
const PAYMENT_OBJECT_COMMODITY_MARKING_EXCISE
Definition check.php:50
const PAYMENT_OBJECT_NON_OPERATING_GAIN
Definition check.php:38
const PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING_EXCISE
Definition check.php:49
const PAYMENT_OBJECT_RESORT_FEE
Definition check.php:40
const PAYMENT_OBJECT_PENSION_INSURANCE_IP
Definition check.php:43
const PAYMENT_OBJECT_PROPERTY_RIGHT
Definition check.php:37
const PAYMENT_OBJECT_GAMBLING_PRIZE
Definition check.php:30
const PAYMENT_OBJECT_COMMODITY_MARKING
Definition check.php:52
const PAYMENT_OBJECT_AGENT_COMMISSION
Definition check.php:34
const PAYMENT_OBJECT_MEDICAL_INSURANCE
Definition check.php:46
const PAYMENT_OBJECT_INTELLECTUAL_ACTIVITY
Definition check.php:33
const PAYMENT_OBJECT_GAMBLING_BET
Definition check.php:29
const PAYMENT_OBJECT_CASINO_PAYMENT
Definition check.php:48
const PAYMENT_OBJECT_PENSION_INSURANCE
Definition check.php:44
const PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING
Definition check.php:51