- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/cashbox/sellordercheck.php
- Класс: BitrixSaleCashboxSellOrderCheck
- Вызов: SellOrderCheck::getDataForCheck
public function getDataForCheck()
{
$result = array(
'type' => static::getType(),
'unique_id' => $this->getField('ID'),
'items' => array(),
'date_create' => new MainTypeDateTime()
);
$order = null;
$discountList = array();
$entities = $this->getEntities();
if ($entities)
{
foreach ($entities as $entity)
{
if ($order === null)
{
$order = CheckManager::getOrder($entity);
$discount = $order->getDiscount();
$discount->calculate();
$discountList = $discount->getApplyResult();
}
if ($entity instanceof Payment)
{
$paySystem = PaySystemManager::getById($entity->getPaymentSystemId());
$result['payments'][] = array(
'is_cash' => $paySystem['IS_CASH'],
'sum' => $entity->getSum()
);
}
elseif ($entity instanceof Shipment)
{
$item = array(
'name' => MainLocalizationLoc::getMessage('SALE_CASHBOX_PREPAYMENT_DELIVERY'),
'price' => (float)$entity->getField('BASE_PRICE_DELIVERY'),
'quantity' => 1,
'vat' => 0
);
if ($discountList['PRICES']['DELIVERY']['DISCOUNT'] > 0)
{
$item['discount'] = array(
'discount' => $discountList['PRICES']['DELIVERY']['DISCOUNT'],
'discount_type' => 'C',
);
}
$result['items'][] = $item;
}
}
if ($order !== null)
{
$properties = $order->getPropertyCollection();
$email = $properties->getUserEmail();
$result['client_email'] = $email->getValue();
$basketCollection = $order->getBasket();
if ($basketCollection)
{
/** @var BasketItem $basketItem */
foreach ($basketCollection as $basketItem)
{
$vatInfo = array();
if (MainLoader::includeModule('catalog'))
{
$dbRes = CCatalogProduct::GetVATInfo($basketItem->getProductId());
$vatInfo = $dbRes->Fetch();
}
$item = array(
'name' => $basketItem->getField('NAME'),
'price' => $basketItem->getBasePrice(),
'quantity' => (float)$basketItem->getQuantity(),
'vat' => $vatInfo ? $vatInfo['ID'] : 0
);
if ($discountList['PRICES']['BASKET'][$basketItem->getId()]['DISCOUNT'] > 0)
{
$item['discount'] = array(
'discount' => $discountList['PRICES']['BASKET'][$basketItem->getId()]['DISCOUNT'],
'discount_type' => 'C',
);
}
$result['items'][] = $item;
}
}
}
}
return $result;
}