- Модуль: crmmobile
- Путь к файлу: ~/bitrix/modules/crmmobile/lib/ProductGrid/DocumentSummaryQuery.php
- Класс: BitrixCrmMobileProductGridDocumentSummaryQuery
- Вызов: DocumentSummaryQuery::execute
public function execute(): array
{
$payment = PaymentRepository::getInstance()->getById($this->documentId);
if (!$payment)
{
return [];
}
$items = $payment->getPayableItemCollection()->toArray();
$deliveryCost = 0;
foreach ($payment->getPayableItemCollection()->getShipments() as $delivery)
{
/**
* @var Shipment $entity
* @var PayableShipmentItem $delivery
*/
$entity = $delivery->getEntityObject();
if (!$entity)
{
continue;
}
$deliveryCost += $entity->getPrice();
}
$productCost = 0;
$totalTax = 0;
$totalDiscount = 0;
$totalBrutto = 0;
foreach ($payment->getPayableItemCollection()->getBasketItems() as $item)
{
/**
* @var BasketItem $entity
*/
$entity = $item->getEntityObject();
$quantity = $item->getQuantity();
$productCost += $entity->getPriceWithVat() * $quantity;
$totalTax += $entity->getVat() * $quantity;
$totalDiscount += ($entity->getBasePriceWithVat() - $entity->getPriceWithVat()) * $quantity;
$totalBrutto += $entity->getBasePriceWithVat() * $quantity;
}
return [
'items' => $items,
'totalRows' => count($items),
'totalProductCost' => $productCost,
'deliveryCost' => $deliveryCost,
'totalCost' => $productCost + $deliveryCost,
'totalTax' => $totalTax,
'totalDiscount' => $totalDiscount,
'totalWithoutDiscount' => $totalBrutto + $deliveryCost,
'currency' => Catalog::getBaseCurrency(),
];
}