• Модуль: crmmobile
  • Путь к файлу: ~/bitrix/modules/crmmobile/lib/Controller/Action/Terminal/CreatePaymentAction.php
  • Класс: BitrixCrmMobileControllerActionTerminalCreatePaymentAction
  • Вызов: CreatePaymentAction::setContactCompany
private function setContactCompany(CrmOrderOrder $order, $existingClient): SaleResult
{
	$result = new SaleResult();

	$clientCollection = $order->getContactCompanyCollection();

	$entityTypeId = (int)$existingClient['entityTypeId'];
	if ($entityTypeId === CCrmOwnerType::Company)
	{
		/** @var CrmOrderContactCompanyEntity $contactCompanyEntity */
		$contactCompanyEntity = $clientCollection->createCompany();
	}
	elseif ($entityTypeId === CCrmOwnerType::Contact)
	{
		/** @var CrmOrderContactCompanyEntity $contactCompanyEntity */
		$contactCompanyEntity = $clientCollection->createContact();
	}

	if (isset($contactCompanyEntity))
	{
		return $contactCompanyEntity->setFields([
			'ENTITY_ID' => $existingClient['id'],
			'IS_PRIMARY' => 'Y'
		]);
	}

	return $result;
}