• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/shipmentcollection.php
  • Класс: BitrixSaleShipmentCollection
  • Вызов: ShipmentCollection::tryUnreserve
public function tryUnreserve()
{
	$result = new Result();

	if (!$order = $this->getOrder())
	{
		throw new MainObjectNotFoundException('Entity "Order" not found');
	}
	/** @var Shipment $shipment */
	foreach ($this->collection as $shipment)
	{
		if ($shipment->isShipped())
		{
			if ($order &&
				!InternalsActionEntity::isTypeExists(
					$order->getInternalId(),
					InternalsActionEntity::ACTION_ENTITY_SHIPMENT_RESERVED_QUANTITY
				)
			)
			{
				InternalsActionEntity::add(
					$order->getInternalId(),
					InternalsActionEntity::ACTION_ENTITY_SHIPMENT_RESERVED_QUANTITY,
					array(
						'METHOD' => 'BitrixSaleShipment::updateReservedFlag',
						'PARAMS' => array($shipment)
					)
				);
			}

			continue;
		}

		$r = $shipment->tryUnreserve();
		if (!$r->isSuccess())
		{
			if (!$shipment->isSystem())
			{
				$registry = Registry::getInstance(static::getRegistryType());

				/** @var EntityMarker $entityMarker */
				$entityMarker = $registry->getEntityMarkerClassName();
				$entityMarker::addMarker($order, $shipment, $r);

				$shipment->setField('MARKED', 'Y');
			}
			$result->addErrors($r->getErrors());
		}
		elseif ($r->hasWarnings())
		{
			$result->addWarnings($r->getWarnings());
		}
	}

	return $result;
}