Example #1
0
 /**
  * @param RebalancerAction $rebalancerAction
  * @return Client
  */
 public function getClientByRebalancerAction(RebalancerAction $rebalancerAction)
 {
     $sql = "SELECT c.*, up.client_account_managed as accountManaged, up.estimated_income_tax as taxBracket FROM " . $this->table . " c\n                  LEFT JOIN " . self::TABLE_CLIENT_PORTFOLIO . " cp ON cp.client_id = c.id\n                  LEFT JOIN " . self::TABLE_CLIENT_PORTFOLIO_VALUE . " cpv ON cpv.client_portfolio_id = cp.id\n                  LEFT JOIN " . self::TABLE_REBALANCER_ACTION . " ra ON ra.client_portfolio_value_id = cpv.id\n                  LEFT JOIN " . self::TABLE_USER_PROFILE . " up ON c.id = up.user_id\n                WHERE ra.id = :rebalancerActionId AND cp.is_active = 1 AND c.roles LIKE :roles;\n        ";
     $parameters = array('rebalancerActionId' => $rebalancerAction->getId(), 'roles' => '%ROLE_CLIENT%');
     $result = $this->db->queryOne($sql, $parameters);
     $client = $this->bindObject($result);
     $rebalancerAction->setClient($client);
     return $client;
 }
 public function testGetAccountByRebalancerActionAccount()
 {
     /** @var AccountRepository $repository */
     $repository = $this->getMockBuilder('Model\\WealthbotRebalancer\\Repository\\AccountRepository')->disableOriginalConstructor()->setMethods(array('findClientAccounts', 'findAccountById'))->getMock();
     $client = new Client();
     $client->setId(45);
     $client->setAccountManaged(Client::ACCOUNT_MANAGED_ACCOUNT);
     $rebalancerAction = new RebalancerAction();
     $rebalancerAction->setClient($client);
     $mockAccount = $this->getMock('Model\\WealthbotRebalancer\\Account');
     $repository->expects($this->once())->method('findAccountById')->will($this->returnValue($mockAccount));
     $repository->getAccountsByRebalancerAction($rebalancerAction);
 }
Example #3
0
 public function getAccountsByRebalancerAction(RebalancerAction $rebalancerAction)
 {
     $client = $rebalancerAction->getClient();
     if ($client->isHouseholdLevelRebalancer()) {
         $collection = $this->findClientAccounts($client);
     } else {
         $account = $this->findAccountById($rebalancerAction->getAccountId());
         $account->setClient($client);
         $collection = new AccountCollection();
         $collection->add($account);
     }
     return $collection;
 }
 public function saveStatus(RebalancerAction $rebalancerAction)
 {
     $sql = "UPDATE " . self::TABLE_REBALANCER_ACTION . " SET status = :status\n                    WHERE id = :id";
     $parameters = array('id' => $rebalancerAction->getId(), 'status' => $rebalancerAction->getStatus());
     $this->db->query($sql, $parameters);
 }
 public function testSetStatus()
 {
     $this->rebalancerAction->setStatus(Job::REBALANCE_TYPE_NO_ACTIONS);
     $this->assertEquals(Job::REBALANCE_TYPE_NO_ACTIONS, $this->rebalancerAction->getStatus());
 }