getVirtualAccount ( CesBankExchange  $exchange)
inherited

Get virtual account for this exchange, or create if needed.

Todo:
notify exchange admin in case of virtual user creation.
Returns
Account the virtual account for this exchange. It is created if it doesn't exist.

References CesBankExchange\$name.

1670  {
1671  $s = new IcesSerializer('CesBankLocalAccount');
1672  $name = $this->code . $exchange->code;
1673  $virt_account = $s->loadFromUniqueKey('name', $name);
1674  if ($virt_account === FALSE) {
1675  $record = array(
1676  'id' => NULL,
1677  'exchange' => $this->id,
1678  'name' => $name,
1679  'balance' => 0.0,
1680  'state' => CesBankLocalAccount::STATE_HIDDEN,
1681  'kind' => CesBankLocalAccount::TYPE_VIRTUAL,
1682  'limitchain' => $this->limitchain,
1683  'users' => array(
1684  array(
1685  'account' => NULL,
1686  'user' => 1,
1687  'role' => CesBankAccountUser::ROLE_ACCOUNT_ADMINISTRATOR,
1688  ),
1689  ),
1690  );
1691  // This dependence is a bit weird. Isn't it?
1692  $bank = new CesBank();
1693  $bank->createAccount($record);
1694  $virt_account = new CesBankLocalAccount($record);
1695  }
1696  return $virt_account;
1697  }
Loads and saves to db objects of class IcesDBObject.
Definition: common.db.logic.inc:17
$name
Name.
Definition: ces_bank.logic.inc:1475
CesBankLocalAccount is a banking account.
Definition: ces_bank.logic.inc:1785
CesBank.
Definition: ces_bank.logic.inc:20