31 return static::CALCULATED_SIGN_INCOME;
39 return Main\Localization\Loc::getMessage(
'SALE_CASHBOX_PREPAYMENT_NAME');
47 return static::SUPPORTED_ENTITY_TYPE_PAYMENT;
55 return static::SUPPORTED_ENTITY_TYPE_SHIPMENT;
71 $result = parent::extractDataInternal();
73 $result = $this->correlatePrices($result);
75 foreach ($result[
'PRODUCTS'] as $i => $item)
77 $result[
'PRODUCTS'][$i][
'PAYMENT_OBJECT'] = static::PAYMENT_OBJECT_PAYMENT;
80 if (!empty($result[
'DELIVERY']) && \is_array($result[
'DELIVERY']))
82 foreach ($result[
'DELIVERY'] as $i => $item)
84 $result[
'DELIVERY'][$i][
'PAYMENT_OBJECT'] = static::PAYMENT_OBJECT_PAYMENT;
101 private function correlatePrices($result)
104 foreach ($result[
'PAYMENTS'] as $payment)
106 $paymentSum += $payment[
'SUM'];
110 $order = $result[
'ORDER'];
112 $rate = $paymentSum / $order->getPrice();
114 $countProductPositions = \count($result[
'PRODUCTS']);
115 $countDeliveryPositions = $result[
'DELIVERY'] ? \count($result[
'DELIVERY']) : 0;
117 if ($countDeliveryPositions === 0)
120 for ($i = 0; $i < $countProductPositions - 1; $i++)
124 $result[
'PRODUCTS'][$i][
'SUM'] = $sum;
127 $result[
'PRODUCTS'][$i][
'BASE_PRICE'] = $result[
'PRODUCTS'][$i][
'PRICE'] = $price;
130 if (isset($result[
'PRODUCTS'][$i][
'DISCOUNT']))
132 unset($result[
'PRODUCTS'][$i][
'DISCOUNT']);
136 if (isset($result[
'PRODUCTS']))
138 $lastElement = $countProductPositions - 1;
140 $price =
PriceMaths::roundPrecision($result[
'PRODUCTS'][$lastElement][
'SUM'] / $result[
'PRODUCTS'][$lastElement][
'QUANTITY']);
141 $result[
'PRODUCTS'][$lastElement][
'BASE_PRICE'] = $result[
'PRODUCTS'][$lastElement][
'PRICE'] = $price;
143 if (isset($result[
'PRODUCTS'][$lastElement][
'DISCOUNT']))
145 unset($result[
'PRODUCTS'][$lastElement][
'DISCOUNT']);
152 for ($i = 0; $i < $countProductPositions; $i++)
156 $result[
'PRODUCTS'][$i][
'SUM'] = $sum;
159 $result[
'PRODUCTS'][$i][
'BASE_PRICE'] = $result[
'PRODUCTS'][$i][
'PRICE'] = $price;
161 if (isset($result[
'PRODUCTS'][$i][
'DISCOUNT']))
163 unset($result[
'PRODUCTS'][$i][
'DISCOUNT']);
167 if ($countDeliveryPositions === 1)
171 $result[
'DELIVERY'][0][
'BASE_PRICE'] = $result[
'DELIVERY'][0][
'PRICE'] = $price;
173 if (isset($result[
'DELIVERY'][0][
'DISCOUNT']))
175 unset($result[
'DELIVERY'][0][
'DISCOUNT']);
180 for ($i = 0; $i < $countDeliveryPositions - 1; $i++)
184 $result[
'DELIVERY'][$i][
'SUM'] = $sum;
187 $result[
'DELIVERY'][$i][
'BASE_PRICE'] = $result[
'DELIVERY'][$i][
'PRICE'] = $price;
189 if (isset($result[
'DELIVERY'][$i][
'DISCOUNT']))
191 unset($result[
'DELIVERY'][$i][
'DISCOUNT']);
195 if (isset($result[
'DELIVERY']))
197 $lastElement = $countDeliveryPositions - 1;
199 $price =
PriceMaths::roundPrecision($result[
'DELIVERY'][$lastElement][
'SUM'] / $result[
'DELIVERY'][$lastElement][
'QUANTITY']);
200 $result[
'DELIVERY'][$lastElement][
'BASE_PRICE'] = $result[
'DELIVERY'][$lastElement][
'PRICE'] = $price;
202 if (isset($result[
'DELIVERY'][$lastElement][
'DISCOUNT']))
204 unset($result[
'DELIVERY'][$lastElement][
'DISCOUNT']);