Transfer money between the technical
wallet and the operator|seller wallet.

@param OperationInterface $operation
@return type
@throws Exception
@throws WalletNotFoundException
961612
public function transfer(OperationInterface $operation)
    {
        try {
            $vendor = $this->getVendor($operation);

            if (!$vendor || $this->hipay->isAvailable($vendor->getEmail())) {
                throw new WalletNotFoundException($vendor);
            }

            if (!$this->checkOperationVendorEnabled($vendor, $operation)) {
                throw new VendorDisabledException($vendor->getMiraklId(), 'transfer');
            }
            if ($operation->getAmount() <= 0) {
                throw new InvalidAmountException($operation);
            }

            $this->hasSufficientFunds($operation->getAmount(), $this->technicalAccount, true);

            $operation->setHiPayId($vendor->getHiPayId());

            $transfer = new TransferModel(
                round($operation->getAmount(), self::SCALE),
                $vendor,
                $this->operationManager->generatePrivateLabel($operation),
                $this->operationManager->generatePublicLabel($operation)
            );

            //Transfer
            $transferId = $this->hipay->transfer($transfer, $vendor);

            $operation->setStatus(new Status(Status::TRANSFER_SUCCESS));
            $operation->setTransferId($transferId);
            $operation->setUpdatedAt(new DateTime());
            $this->operationManager->save($operation);

            $this->logOperation(
                $operation->getMiraklId(),
                $operation->getPaymentVoucher(),
                Status::TRANSFER_SUCCESS,
                ""
            );

            return $transferId;
        } catch (VendorDisabledException $e) {
            $operation->setStatus(new Status(Status::TRANSFER_VENDOR_DISABLED));
            $operation->setUpdatedAt(new DateTime());
            $this->operationManager->save($operation);

            $this->logOperation(
                $operation->getMiraklId(),
                $operation->getPaymentVoucher(),
                Status::TRANSFER_VENDOR_DISABLED,
                $e->getMessage()
            );

            throw $e;
        } catch (WrongWalletBalance $e) {
            $operation->setStatus(new Status(Status::TRANSFER_NEGATIVE));
            $operation->setUpdatedAt(new DateTime());
            $this->operationManager->save($operation);

            $this->logOperation(
                $operation->getMiraklId(),
                $operation->getPaymentVoucher(),
                Status::TRANSFER_NEGATIVE,
                $e->getMessage()
            );

            throw $e;
        } catch (InvalidAmountException $e) {
            $operation->setStatus(new Status(Status::INVALID_AMOUNT));
            $operation->setUpdatedAt(new DateTime());
            $this->operationManager->save($operation);

            $this->logOperation(
                $operation->getMiraklId(),
                $operation->getPaymentVoucher(),
                Status::INVALID_AMOUNT,
                $e->getMessage()
            );

            throw $e;
        } catch (Exception $e) {
            $operation->setStatus(new Status(Status::TRANSFER_FAILED));
            $operation->setUpdatedAt(new DateTime());
            $this->operationManager->save($operation);

            $this->logOperation(
                $operation->getMiraklId(),
                $operation->getPaymentVoucher(),
                Status::TRANSFER_FAILED,
                $e->getMessage()
            );

            throw $e;
        }
    }
889327
public function transact($amount, $orderId, $invoiceNumber = null)
    {
        $this->transaction = [
            'amount' => $amount,
            'orderId' => $orderId,
            'invoiceNumber' => $invoiceNumber ?: $orderId,
        ];

        return $this->initiateTransaction();
    }
129745
private function getOperationHandler(OperationInterface $operation)
    {
        foreach ($this->operationHandlers as $operationHandler) {
            if ($operationHandler->supports($operation)) {
                return $operationHandler;
            }
        }

        return null;
    }
296038
public function removeOperation(OperationInterface $operation)
    {
        if ($this->operations->contains($operation)) {
            $this->operations->removeElement($operation);
        }

        return $this;
    }
863692
protected function returnAccessRelatedObject(EntityInterface $entity, $operation, $account) {
    $related_object = $entity->get('field_activity_entity')->getValue();
    if (!empty($related_object)) {
      $ref_entity_type = $related_object['0']['target_type'];
      $ref_entity_id = $related_object['0']['target_id'];
      $ref_entity = entity_load($ref_entity_type, $ref_entity_id);

      return AccessResult::allowedIf($ref_entity->access($operation, $account));
    }
  }
741599
protected function getOperationHandler(LdapOperationInterface $operation)
    {
        foreach ($this->handler as $handler) {
            if ($handler->supports($operation)) {
                $handler->setConnection($this->connection);
                $handler->setEventDispatcher($this->dispatcher);

                return $handler;
            }
        }

        throw new LdapConnectionException(sprintf(
            'Operation "%s" with a class name "%s" does not have a supported operation handler.',
            $operation->getName(),
            get_class($operation)
        ));
    }
578645
public function process($src, OperationInterface $operation)
    {
        $field = $operation->getField();
        $order = $operation->getOrder();
        $src->order .= "ORDER BY $field $order";
        return $src;
    }
510408
private function setTransaction(TransactionInterface $transaction) {
        $transactions = $this->getTransactions();
        $transactions[$this->getDbService()] = $transaction;
        $this->setTransactions($transactions);
    }
115207
protected function idleReconnectIfNeeded(LdapOperationInterface $operation)
    {
        // An auth operation will force a reconnect anyways, so avoid extra work
        if (!$this->connection->getConfig()->getIdleReconnect() || $operation instanceof AuthenticationOperation) {
            return;
        }

        if ($this->connection->getIdleTime() >= $this->connection->getConfig()->getIdleReconnect()) {
            $this->connection->close()->connect();
        }
    }
1068498
public function setOperation(\CampaignChain\CoreBundle\Entity\Operation $operation)
    {
        $this->operation = $operation;

        return $this;
    }
337159
public function process($src, OperationInterface $operation)
    {
        $callable = $operation->getCallback();
        $arguments = array_merge([$src], $operation->getArguments());
        $res = call_user_func_array($callable, $arguments);
        return $res ?: $src;
    }
1098576
private function getReason(OperationInterface $operation)
    {
        if (!$this->pool) {
            return null;
        }

        $reason = $operation->getReason();
        if ($reason instanceof Rule) {
            switch ($reason->getReason()) {
                case Rule::RULE_JOB_INSTALL:
                    return 'Required by the root package: ' . $reason->getPrettyString($this->pool);
                case Rule::RULE_PACKAGE_REQUIRES:
                    return $reason->getPrettyString($this->pool);
                default:
            }
        }

        return null;
    }
54927
public function addOperation(OperationInterface $operation)
    {
        $this->operations[$operation->getName()] = $operation->setServiceDescription($this);

        return $this;
    }
578294
public function queue(Operations $operations)
    {
        foreach ($operations->getOperations() as $operation) {
            if ($operation instanceof AddDocumentOperation) {
                $identity = $operation->getDocument()->getIdentity();
                $job = new Job('indexer:add', array((string) $identity));
            } elseif ($operation instanceof AddIdentityOperation) {
                $identity = $operation->getIdentity();
                $job = new Job('indexer:add', array((string) $identity));
            } elseif ($operation instanceof UpdateDocumentOperation) {
                $identity = $operation->getDocument()->getIdentity();
                $job = new Job('indexer:add', array('--update', (string) $identity));
            } elseif ($operation instanceof UpdateIdentityOperation) {
                $identity = $operation->getIdentity();
                $job = new Job('indexer:add', array('--update', (string) $identity));
            } elseif ($operation instanceof DeleteDocumentOperation) {
                $identity = $operation->getDocument()->getIdentity();
                $job = new Job('indexer:delete', array('--identifier', (string) $identity));
            } elseif ($operation instanceof DeleteIdentityOperation) {
                $identity = $operation->getIdentity();
                $job = new Job('indexer:delete', array('--identifier', (string) $identity));
            } elseif ($operation instanceof DeleteTypeOperation) {
                $job = new Job('indexer:delete', array('--type', $operation->getType()));
            } elseif ($operation instanceof DeleteAllOperation) {
                $job = new Job('indexer:delete', array('--all'));
            } elseif ($operation instanceof FlushOperation) {
                $job = new Job('indexer:index', array('--flush'));
            } elseif ($operation instanceof OptimizeOperation) {
                $job = new Job('indexer:index', array('--optimize'));
            } elseif ($operation instanceof CommitOperation) {
                $job = new Job('indexer:index', array('--commit'));
            } elseif ($operation instanceof RollbackOperation) {
                $job = new Job('indexer:index', array('--rollback'));
            } else {
                continue;
            }

            $this->jobManager->addJob($job);
        }

        return true;
    }
101602
private function createOperation($accIdDebit, $accIdCredit, $amount, $note)
    {
        /* prepare transaction */
        $tran = new ETrans();
        $tran->setDebitAccId($accIdDebit);
        $tran->setCreditAccId($accIdCredit);
        $tran->setValue($amount);
        $tran->setNote($note);
        /* perform operation */
        $req = new \Praxigento\Accounting\Api\Service\Operation\Create\Request();
        $req->setOperationTypeCode(Cfg::CODE_TYPE_OPER_WALLET_REFUND);
        $req->setTransactions([$tran]);
        $req->setOperationNote($note);
        $resp = $this->servOper->exec($req);
        $result = $resp->getOperationId();
        return $result;
    }
232680
public function getUpdateOperation($input, $fields) {
		$operation = new UpdateTransactionOperation(static::getClass(), $input, $fields, $this);
		$operation->setSQLAdapter(static::getSQLAdapter());
		return $operation;
	}
865528
private function transaction($command, $amount, $currency = 981, $description = '', $language = 'GE', $type = 'SMS', array $additional = [])
    {
        return $this->process(
            $command,
            array_merge([
                'amount'         => $amount,
                'currency'       => $currency,
                'client_ip_addr' => $this->clientIp,
                'description'    => $description,
                'language'       => $language,
                'msg_type'       => $type,
            ], $additional)
        );
    }