• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/shipment.php
  • Класс: BitrixSaleShipment
  • Вызов: Shipment::onShipmentItemCollectionModify
public function onShipmentItemCollectionModify($action, ShipmentItem $shipmentItem, $name = null, $oldValue = null, $value = null)
{
	if ($action != EventActions::UPDATE)
	{
		return new Result();
	}

	if ($this->isSystem()
		&& $name != 'RESERVED_QUANTITY'
	)
	{
		throw new MainNotSupportedException(Loc::getMessage('SALE_SHIPMENT_SYSTEM_SHIPMENT_CHANGE'));
	}

	if ($name === "QUANTITY")
	{
		$result = $this->transferItem2SystemShipment($shipmentItem, $oldValue - $value);

		if (!$this->isMarkedFieldCustom('WEIGHT'))
		{
			$this->setField(
				'WEIGHT',
				$this->getShipmentItemCollection()->getWeight()
			);
		}

		return $result;
	}
	elseif ($name === 'RESERVED_QUANTITY')
	{
		$order = $this->getParentOrder();
		if ($order &&
			!InternalsActionEntity::isTypeExists(
				$order->getInternalId(),
				InternalsActionEntity::ACTION_ENTITY_SHIPMENT_COLLECTION_RESERVED_QUANTITY
			)
		)
		{
			InternalsActionEntity::add(
				$order->getInternalId(),
				InternalsActionEntity::ACTION_ENTITY_SHIPMENT_COLLECTION_RESERVED_QUANTITY,
				[
					'METHOD' => 'BitrixSaleShipmentCollection::updateReservedFlag',
					'PARAMS' => [$this->getCollection()]
				]
			);
		}
	}

	return new Result();
}