• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/cashbox/abstractcheck.php
  • Класс: BitrixSaleCashboxAbstractCheck
  • Вызов: AbstractCheck::setEntities
public function setEntities(array $entities)
{
	$this->entities = $entities;

	$orderId = null;
	$entityRegistryType = null;

	foreach ($this->entities as $entity)
	{
		if ($entity instanceof Payment)
		{
			$this->fields['PAYMENT_ID'] = $entity->getId();
			$this->fields['SUM'] = $entity->getSum();
			$this->fields['CURRENCY'] = $entity->getField('CURRENCY');
		}

		// compatibility
		if ($entity instanceof Shipment)
		{
			$this->fields['SHIPMENT_ID'] = $entity->getId();
		}

		if ($entityRegistryType === null)
		{
			$entityRegistryType = $entity::getRegistryType();
		}
		elseif ($entityRegistryType !== $entity::getRegistryType())
		{
			throw new MainArgumentTypeException('entities');
		}

		/** @var PaymentCollection|ShipmentCollection $collection */
		$collection = $entity->getCollection();

		if ($orderId === null)
		{
			$orderId = $collection->getOrder()->getId();
		}
		elseif ($orderId != $collection->getOrder()->getId())
		{
			throw new MainArgumentTypeException('entities');
		}
	}

	$this->fields['ORDER_ID'] = $orderId;
	$this->fields['ENTITY_REGISTRY_TYPE'] = $entityRegistryType;
}