Ejemplo n.º 1
0
 /**
  * @param User $client
  * @return array
  */
 public function getClientAccountsValues(User $client)
 {
     $accounts = $this->getAccountsForClient($client);
     $accountValues = array('total' => array('value' => 0, 'projected_value' => 0, 'contributions' => 0, 'distributions' => 0, 'sas_cash' => 0));
     /** @var SystemAccount $account */
     foreach ($accounts as $account) {
         $clientAccount = $account->getClientAccount();
         $value = $this->accountValuesManager->getTotalValue($account);
         $projectedValue = $account->getProjectedValue();
         $contributions = $clientAccount->getContributionsSum();
         $distributions = $clientAccount->getDistributionsSum();
         $accountValues[$account->getId()] = array('account' => $account, 'value' => $value, 'projected_value' => $projectedValue, 'contributions' => $contributions, 'distributions' => $distributions);
         $accountValues['total']['value'] += $value;
         $accountValues['total']['projected_value'] += $projectedValue;
         $accountValues['total']['contributions'] += $contributions;
         $accountValues['total']['distributions'] += $distributions;
         $accountValues['total']['sas_cash'] += $clientAccount->getSasCashSum();
     }
     $fundedPercent = 0;
     if ($accountValues['total']['projected_value'] > 0) {
         $fundedPercent = round($accountValues['total']['value'] / $accountValues['total']['projected_value'] * 100, 2);
     }
     $accountValues['total']['funded_percent'] = $fundedPercent;
     return $accountValues;
 }
Ejemplo n.º 2
0
 /**
  * Update client status by system client account
  *
  * @param Workflow $workflow
  * @param SystemAccount $account
  */
 public function updateClientStatusBySystemAccount(Workflow $workflow, SystemAccount $account)
 {
     $value = $this->accountValuesManager->getTotalValue($account);
     if ($account->isActive()) {
         $workflow->setClientStatus(Workflow::CLIENT_STATUS_ACCOUNT_OPENED);
     } elseif ($workflow->isClientStatusAccountOpened() && $value > 1) {
         $workflow->setClientStatus(Workflow::CLIENT_STATUS_ACCOUNT_FUNDED);
     }
 }