/** * Get client type * * @return string * @throws \Exception */ public function getClientType() { if (!$this->hasRole("ROLE_CLIENT")) { throw new \Exception('User has not role: ROLE_CLIENT.'); } return $this->clientSettings ? $this->clientSettings->getClientType() : ''; }
private function createClientUser(array $data, User $riaUser) { $clientUser = new User(); $clientUser->setUsername($data['username']); $clientUser->setEmail($data['username']); $clientUser->setPlainPassword($data['password']); $clientUser->setEnabled(true); $clientUser->setRoles(array('ROLE_CLIENT')); $clientUserProfile = new Profile(); $clientUserProfile->setUser($clientUser); $clientUserProfile->setRia($riaUser); $clientUserProfile->setFirstName($data['first_name']); $clientUserProfile->setLastName($data['last_name']); $clientUserProfile->setState($this->getReference('state-' . $data['state'])); $clientUserProfile->setStreet($data['street']); $clientUserProfile->setCity($data['city']); $clientUserProfile->setZip($data['zip']); $clientUserProfile->setBirthDate(new \DateTime($data['birth_date'])); $clientUserProfile->setPhoneNumber($data['phone_number']); $clientUserProfile->setMaritalStatus($data['marital_status']); $clientUserProfile->setAnnualIncome($data['annual_income']); $clientUserProfile->setEstimatedIncomeTax($data['estimated_income_tax']); $clientUserProfile->setLiquidNetWorth($data['liquid_net_worth']); $clientUserProfile->setEmploymentType($data['employment_type']); $clientUserProfile->setClientAccountManaged($data['client_account_managed']); $clientUserProfile->setRegistrationStep($data['registration_step']); $clientSettings = new ClientSettings(); $clientSettings->setStopTlhValue($data['stop_tlh_value']); $clientUser->setClientSettings($clientSettings); $clientSettings->setClient($clientUser); //$clientUserProfile->setSuggestedPortfolio($this->getReference('cec-ria-model-' . $data['suggested_portfolio_index'])); if (isset($data['client_status'])) { $clientUserProfile->setClientStatus($data['client_status']); } $clientUser->setProfile($clientUserProfile); if (isset($data['created'])) { $createdAt = new \DateTime($data['created']); $clientUser->setCreated($createdAt); } if (isset($data['paymentMethod'])) { $clientUser->getProfile()->setPaymentMethod($data['paymentMethod']); } return $clientUser; }
public function gainslossesAction(Request $request) { $params = array(); $totalNetProceeds = 0; $totalCost = 0; $longTermGainLoss = 0; $shortTermGainLoss = 0; $totalGainLoss = 0; $sort = $request->query->get('sort', 'securities.name'); $direction = $request->query->get('direction', 'ASC'); $client = $this->getUser(); /** @var EntityManager $em */ $em = $this->get('doctrine.orm.entity_manager'); $em->getConfiguration()->addCustomDatetimeFunction('YEAR', 'Wealthbot\\MailerBundle\\DQL\\DatetimeFunction\\Year'); $systemAccountManager = $this->get('wealthbot_client.system_account_manager'); /** @var \Wealthbot\ClientBundle\Repository\ClientSettings $repository */ $repository = $em->getRepository('WealthbotClientBundle:ClientSettings'); /** @var \Wealthbot\ClientBundle\Repository\PositionRepository $positionsRepo */ $positionsRepo = $em->getRepository('WealthbotClientBundle:Position'); /** @var \Wealthbot\ClientBundle\Repository\LotRepository $lotsRepo */ $lotsRepo = $em->getRepository('WealthbotClientBundle:Lot'); $isClientView = $this->isRiaClientView(); if ($isClientView) { $client = $this->getUser(); $clientSettings = $repository->findOneBy(array('client' => $client)); if (!$clientSettings) { $clientSettings = new ClientSettings(); $clientSettings->setClient($client); } $stopTLHValueForm = $this->createForm(new ClientStopTLHValueFormType(), $clientSettings); $params = array('stop_tlh_form' => $stopTLHValueForm->createView()); if ($request->isMethod("post")) { $stopTLHValueForm->bind($request); if ($stopTLHValueForm->isValid()) { $em->persist($clientSettings); $em->flush(); return $this->getJsonResponse(array("status" => "success")); } else { $content = $this->renderView("WealthbotClientBundle:Dashboard:gainlosses_stop_tlh_form.html.twig", array("form" => $stopTLHValueForm->createView())); return $this->getJsonResponse(array("status" => "error", "content" => $content)); } } } if ($request->isMethod("get")) { $isClientView = !$this->isRiaClientView(); $activeClientAccounts = $systemAccountManager->getAccountsForClient($client, $isClientView); $accounts = $activeClientAccounts; if ($accountId = $request->get('account_id')) { if ($account = $em->getRepository('WealthbotClientBundle:ClientAccount')->findBy(array('id' => $accountId, 'client' => $client))) { /** @var ClientAccount $account */ if ($systemAccount = $account->getSystemAccount()) { $accounts = array($systemAccount); } } } $gainLossYears = $positionsRepo->getGainLossYears($accounts); $year = $request->get('year'); if (empty($year)) { if (isset($gainLossYears[0])) { $year = $gainLossYears[0]['year']; } } $lots = $lotsRepo->getRealizedLots($year, $accounts, $sort, $direction); $paginator = $this->get('knp_paginator'); $pagination = $paginator->paginate($lots, $request->get('page', 1), 10); foreach ($pagination as $gainLoss) { $totalNetProceeds += $gainLoss->getAmount(); $totalCost += $gainLoss->getInitial()->getAmount(); $longTermGainLoss += $gainLoss->getLongTermGain(); $shortTermGainLoss += $gainLoss->getShortTermGain(); $totalGainLoss += $gainLoss->getRealizedGain(); } $params = array_merge($params, array('pagination' => $pagination, 'gainLossYears' => $gainLossYears, 'lots' => $lots, 'totalNetProceeds' => $totalNetProceeds, 'totalCost' => $totalCost, 'longTermGainLoss' => $longTermGainLoss, 'shortTermGainLoss' => $shortTermGainLoss, 'totalGainLoss' => $totalGainLoss)); } return $this->prepareResponse($request, 'gainslosses', 'Gains/Losses', $params); }