Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
cashboxbitrixv3.php
1<?php
2
3namespace Bitrix\Sale\Cashbox;
4
7
8Localization\Loc::loadMessages(__FILE__);
9
15{
16 public function buildCheckQuery(Check $check)
17 {
18 $result = parent::buildCheckQuery($check);
19
20 if ($this->isContainMarkingCode($result))
21 {
22 $result['validateMarkingCodes'] = true;
23 }
24
25 return $result;
26 }
27
28 protected function isContainMarkingCode(array $check) : bool
29 {
30 if (isset($check['items']))
31 {
32 foreach ($check['items'] as $item)
33 {
34 if (
35 isset($item['imcParams'])
36 && !empty($item['imcParams']['imc'])
37 )
38 {
39 return true;
40 }
41 }
42 }
43
44 return false;
45 }
46
47 protected function buildPosition(array $checkData, array $item)
48 {
49 $position = parent::buildPosition($checkData, $item);
50
51 $position['measurementUnit'] = (int)$this->getValueFromSettings('MEASURE', $item['measure_code']);
52
53 if (isset($position['nomenclatureCode']))
54 {
55 unset($position['nomenclatureCode']);
56 }
57
58 if (isset($item['marking_code']))
59 {
60 $position['imcParams'] = [
61 'imcType' => 'auto',
62 'imc' => base64_encode($item['marking_code']),
63 'itemEstimatedStatus' => $this->buildEstimatedStatus($checkData),
64 'imcModeProcessing' => 0,
65 ];
66 }
67
68 return $position;
69 }
70
71 protected function buildEstimatedStatus(array $checkData) : string
72 {
73 if (mb_strpos($checkData['type'], 'sellreturn') === 0)
74 {
75 return 'itemPieceReturn';
76 }
77
78 return 'itemPieceSold';
79 }
80
84 protected function getPaymentObjectMap()
85 {
86 $result = parent::getPaymentObjectMap();
87
88 $result[Check::PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING_EXCISE] = 'exciseWithoutMarking ';
89 $result[Check::PAYMENT_OBJECT_COMMODITY_MARKING_EXCISE] = 'exciseWithMarking ';
90 $result[Check::PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING] = 'commodityWithoutMarking ';
91 $result[Check::PAYMENT_OBJECT_COMMODITY_MARKING] = 'commodityWithMarking';
92
93 return $result;
94 }
95
99 public static function getName()
100 {
101 return Localization\Loc::getMessage('SALE_CASHBOX_BITRIX_V3_TITLE');
102 }
103
108 public static function getSettings($modelId = 0)
109 {
110 $settings = parent::getSettings($modelId);
111
112 $kkmList = static::getSupportedKkmModels();
113 if (isset($kkmList[$modelId]))
114 {
115 $settings['MEASURE'] = static::getMeasureSettings();
116 }
117
118 return $settings;
119 }
120
121 protected static function getMeasureSettings(): array
122 {
123 $measureItems = [];
124 if (Main\Loader::includeModule('catalog'))
125 {
126 $measuresList = \CCatalogMeasure::getList();
127 while ($measure = $measuresList->fetch())
128 {
129 $measureItems[$measure['CODE']] = [
130 'TYPE' => 'STRING',
131 'LABEL' => $measure['MEASURE_TITLE'],
132 'REQUIRED' => 'Y',
133 'VALUE' => MeasureCodeToTag2108Mapper::getTag2108Value($measure['CODE']),
134 ];
135 }
136 }
137
138 return [
139 'LABEL' => Localization\Loc::getMessage('SALE_CASHBOX_MEASURE_SUPPORT_SETTINGS'),
140 'ITEMS' => $measureItems,
141 ];
142 }
146 public static function getFfdVersion(): ?float
147 {
148 return 1.2;
149 }
150}
buildPosition(array $checkData, array $item)
getValueFromSettings($name, $code)
Definition cashbox.php:201
const PAYMENT_OBJECT_COMMODITY_MARKING_EXCISE
Definition check.php:50
const PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING_EXCISE
Definition check.php:49
const PAYMENT_OBJECT_COMMODITY_MARKING
Definition check.php:52
const PAYMENT_OBJECT_COMMODITY_MARKING_NO_MARKING
Definition check.php:51