objects::calculateDocumentTotals

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. objects
  4. calculateDocumentTotals
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/entity/paymentdocumentsrepository.php
  • Класс: Bitrix\Crm\Entity\objects
  • Вызов: objects::calculateDocumentTotals
private function calculateDocumentTotals(array $documentList): array
{
	$documentTotals = [];

	$shipmentIds = array_column($documentList, 'ID');
	$shipmentBasketResult = Sale\ShipmentItem::getList([
		'select' => ['PRICE' => 'BASKET.PRICE', 'ORDER_DELIVERY_ID', 'QUANTITY'],
		'filter' => ['=ORDER_DELIVERY_ID' => $shipmentIds]
	]);
	while ($shipmentItem = $shipmentBasketResult->fetch())
	{
		if (!isset($documentTotals[$shipmentItem['ORDER_DELIVERY_ID']]))
		{
			$documentTotals[$shipmentItem['ORDER_DELIVERY_ID']] = 0;
		}

		$documentTotals[$shipmentItem['ORDER_DELIVERY_ID']] += (float)$shipmentItem['PRICE'] * $shipmentItem['QUANTITY'];
	}

	return $documentTotals;
}

Добавить комментарий