• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/shipment.php
  • Класс: BitrixSaleShipment
  • Вызов: Shipment::add
private function add()
{
	$result = new Result();

	$registry = Registry::getInstance(static::getRegistryType());

	$this->setFieldNoDemand('ORDER_ID', $this->getParentOrderId());

	$r = static::addInternal($this->getFields()->getValues());
	if (!$r->isSuccess())
	{
		/** @var OrderHistory $orderHistory */
		$orderHistory = $registry->getOrderHistoryClassName();

		$orderHistory::addAction(
			'SHIPMENT',
			$this->getParentOrderId(),
			'SHIPMENT_ADD_ERROR',
			null,
			$this,
			["ERROR" => $r->getErrorMessages()]
		);

		$result->addErrors($r->getErrors());
		return $result;
	}

	$id = $r->getId();
	$this->setFieldNoDemand('ID', $id);
	$result->setId($id);

	$this->setAccountNumber($id);

	if (!$this->isSystem())
	{
		/** @var OrderHistory $orderHistory */
		$orderHistory = $registry->getOrderHistoryClassName();

		$orderHistory::addAction(
			'SHIPMENT',
			$this->getParentOrderId(),
			'SHIPMENT_ADDED',
			$id,
			$this
		);
	}

	return $result;
}