Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
cashboxorangedataffd12.php
1<?php
2
3namespace Bitrix\Sale\Cashbox;
4
6
7Localization\Loc::loadMessages(__FILE__);
8
15{
16 private const FFD_12_VERSION = 4;
17
21 private const PLANNED_STATUS_SALE = 1;
22 private const PLANNED_STATUS_SALE_RETURN = 3;
23
27 public static function getName()
28 {
29 return Localization\Loc::getMessage('SALE_CASHBOX_ORANGE_DATA_TITLE_FFD_12');
30 }
31
35 protected function buildPosition(array $checkData, array $item, bool $isSellReturn): array
36 {
37 $result = [
38 'text' => $this->buildPositionText($item),
39 'quantity' => $this->buildPositionQuantity($item),
40 'price' => $this->buildPositionPrice($item),
41 'tax' => $this->buildPositionTax($checkData, $item),
42 'paymentMethodType' => $this->buildPositionPaymentMethodType($checkData),
43 'paymentSubjectType' => $this->buildPositionPaymentSubjectType($item),
44 'plannedStatus' => $isSellReturn ? self::PLANNED_STATUS_SALE_RETURN : self::PLANNED_STATUS_SALE,
45 ];
46
47 if (isset($item['marking_code']))
48 {
49 $result['itemCode'] = $this->buildPositionMarkingCode($item);
50 }
51
52 $result['quantityMeasurementUnit'] = $this->buildPositionQuantityMeasurementUnit($item);
53
54 if (isset($item['supplier_info']))
55 {
56 $result += $this->buildPositionAgentInfo();
57 $result += $this->buildPositionSupplier($item['supplier_info']);
58 }
59
60 return $result;
61 }
62
66 public function buildCheckQuery(Check $check)
67 {
68 $result = parent::buildCheckQuery($check);
69 $result['content']['ffdVersion'] = self::FFD_12_VERSION;
70
71 return $result;
72 }
73
78 {
79 $data = $this->getCheckData($check);
80 $correctionInfo = $data['correction_info'];
81
82 $result = $this->buildCheckQueryByCheckData($data, ($check->getType() === 'sellreturn'));
83 $result['content']['ffdVersion'] = self::FFD_12_VERSION;
84 $result['content']['correctionType'] = $this->getCorrectionTypeMap($correctionInfo['type']);
85 $result['content']['causeDocumentDate'] = $this->getCorrectionCauseDocumentDate($correctionInfo);
86 $result['content']['causeDocumentNumber'] = $this->getCorrectionCauseDocumentNumber($correctionInfo);
87 $result['content']['totalSum'] = $this->getCorrectionTotalSum($correctionInfo);
88
89 $vats = $this->getVatsByCheckData($data);
90 if (is_array($vats))
91 {
92 foreach ($vats as $vat)
93 {
94 $result['content'][$vat['code']] = $vat['value'];
95 }
96 }
97
98 return $result;
99 }
100
104 protected function getVatKeyPrefix(): string
105 {
106 return 'vat';
107 }
108
112 protected function getCorrectionUrlPath(): string
113 {
114 return '/correction12/';
115 }
116
154
159 private function buildPositionMarkingCode(array $item)
160 {
161 return $item['marking_code'];
162 }
163
167 protected static function hasMeasureSettings(): bool
168 {
169 return true;
170 }
171
176 private function buildPositionQuantityMeasurementUnit(array $item): ?int
177 {
178 $tag2108Value = $this->getValueFromSettings('MEASURE', $item['measure_code']);
179 if (is_null($tag2108Value) || $tag2108Value === '')
180 {
181 $tag2108Value = $this->getValueFromSettings('MEASURE', 'DEFAULT');
182 }
183
184 return (is_null($tag2108Value) || $tag2108Value === '') ? null : (int)$tag2108Value;
185 }
186
190 public static function getFfdVersion(): ?float
191 {
192 return 1.2;
193 }
194
198 public static function isCorrectionOn(): bool
199 {
200 return false;
201 }
202}
getValueFromSettings($name, $code)
Definition cashbox.php:201
buildPosition(array $checkData, array $item, bool $isSellReturn)
buildCheckQueryByCheckData(array $checkData, bool $isSellReturn)
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