/** * Get All History for Ria Clients Query * * @param User $ria * @return \Doctrine\ORM\QueryBuilder */ public function findHistoryForRiaClientsQuery(User $ria, $filters = array()) { $qb = $this->createQueryBuilder('cpv')->leftJoin('cpv.clientPortfolio', 'cp')->leftJoin('cp.client', 'c')->leftJoin('c.profile', 'p')->leftJoin('c.groups', 'cg')->leftJoin('cp.portfolio', 'po')->leftJoin('p.ria', 'r')->leftJoin('r.riaCompanyInformation', 'rci')->where('p.ria_user_id = :riaId')->setParameter('riaId', $ria->getId()); if (!empty($filters)) { if (isset($filters['client_id']) && $filters['client_id']) { $qb->andWhere('c.id = :clientId')->setParameter('clientId', $filters['client_id']); } elseif (isset($filters['client']) && $filters['client']) { $name = explode(',', $filters['client']); $lname = trim($name[0]); $fname = isset($name[1]) && $name[1] ? trim($name[1]) : null; if ($fname) { $qb->andWhere('p.last_name = :lname AND p.first_name LIKE :fname')->setParameter('lname', $lname)->setParameter('fname', '%' . $fname . '%'); } else { $qb->andWhere('p.last_name LIKE :searchStr OR p.first_name LIKE :searchStr')->setParameter('searchStr', '%' . $lname . '%'); } } if (isset($filters['date_from']) && $filters['date_from']) { $date = \DateTime::createFromFormat('m-d-Y', $filters['date_from']); $qb->andWhere('cpv.date >= :dateFrom')->setParameter('dateFrom', $date->format('Y-m-d')); } if (isset($filters['date_to']) && $filters['date_to']) { $date = \DateTime::createFromFormat('m-d-Y', $filters['date_to']); $qb->andWhere('cpv.date <= :dateTo')->setParameter('dateTo', $date->format('Y-m-d')); } if (isset($filters['set_id']) && $filters['set_id']) { $qb->andWhere('cg.id = :group')->setParameter('group', $filters['set_id']); } } return $qb; }
public function hasDeleteAccess(User $user, ClientActivitySummary $activitySummary) { if ($user->hasRole('ROLE_RIA') && $activitySummary->getClient()->getRia()->getId() == $user->getId()) { return true; } return false; }
protected function success(User $user, User $questionsOwner) { $em = $this->em; $questions = $em->getRepository('WealthbotRiaBundle:RiskQuestion')->getOrderedQuestionsByOwnerId($questionsOwner->getId()); $withdrawAge = 0; $answers = array(); foreach ($questions as $question) { $key = 'answer_' . $question->getId(); $data = $this->form->get($key)->getData(); $answer = array('question' => $question); if ($question->getIsWithdrawAgeInput()) { $withdrawAge = (int) $answer; $age = $this->getClientAge($user); $ageDiff = $withdrawAge - (int) $age; $answer['data'] = $ageDiff; } else { $answer['data'] = $data; } $answers[] = $answer; } $riskToleranceManager = new RiskToleranceManager($user, $this->em, $answers); $riskToleranceManager->saveUserAnswers(); if (!$this->request->isXmlHttpRequest()) { $suggestedModel = $riskToleranceManager->getSuggestedPortfolio(); $this->processSuggestedPortfolio($user, $suggestedModel, $withdrawAge); } }
public function buildForm(FormBuilderInterface $builder, array $options) { foreach ($this->questions as $question) { if ($question->getIsWithdrawAgeInput()) { $builder->add('client_birth_date', 'date', array('widget' => 'text', 'pattern' => '{{ month }}-{{ day }}-{{ year }}', 'required' => true))->add('answer_' . $question->getId(), 'text', array('label' => $question->getTitle(), 'property_path' => false, 'required' => true, 'data' => $this->user->getProfile()->getWithdrawAge())); } else { $userAnswer = $this->em->getRepository('WealthbotClientBundle:ClientQuestionnaireAnswer')->createQueryBuilder('ua')->where('ua.client_id = :client_id AND ua.question_id = :question_id')->setParameters(array('client_id' => $this->user->getId(), 'question_id' => $question->getId()))->setMaxResults(1)->getQuery()->getOneOrNullResult(); $userAnswer = $userAnswer ? $userAnswer->getAnswer() : $userAnswer; $builder->add('answer_' . $question->getId(), 'entity', array('class' => 'WealthbotRiaBundle:RiskAnswer', 'query_builder' => function (EntityRepository $er) use($question) { return $er->createQueryBuilder('a')->where('a.risk_question_id = :question_id')->setParameter('question_id', $question->getId()); }, 'empty_value' => $userAnswer ? false : 'Choose an Option', 'property' => 'title', 'property_path' => false, 'required' => true, 'label' => $question->getTitle(), 'preferred_choices' => $userAnswer ? array($userAnswer) : array())); } } if (!$this->isPreSave) { $this->addOnBindValidator($builder); } }
/** * @param User $client * @param bool $isClientView * @return array */ public function getAccountsForClient(User $client, $isClientView = false) { if ($isClientView) { $accounts = $this->em->getRepository('WealthbotClientBundle:SystemAccount')->findByClientIdAndNotStatus($client->getId(), SystemAccount::STATUS_CLOSED); } else { $accounts = $client->getSystemAccounts()->toArray(); } return $accounts; }
protected function getExistsRatings($exclude) { $query = $this->em->getRepository('WealthbotAdminBundle:ModelRiskRating')->createQueryBuilder('mrr')->leftJoin('mrr.model', 'pm')->leftJoin('pm.parent', 'p')->where('mrr.owner_id = :owner_id')->andWhere('p.id = :parent_id')->setParameter('owner_id', $this->user->getId())->setParameter('parent_id', $this->thirdParty->getId())->getQuery(); $riaRiskRatings = $query->getResult(); $existsRatings = array(); foreach ($riaRiskRatings as $object) { if ($object->getRating() != $exclude) { $existsRatings[] = $object->getRating(); } } return $existsRatings; }
protected function sendEmailMessages(User $owner, $documentType, MailerInterface $mailer) { $userRepo = $this->em->getRepository('WealthbotUserBundle:User'); $clients = array(); if ($owner->hasRole('ROLE_RIA')) { $clients = $userRepo->findClientsByRiaId($owner->getId()); } foreach ($clients as $client) { foreach ($client->getSlaveClients() as $slaveClient) { $mailer->sendClientUpdatedDocumentsEmail($slaveClient, $documentType); } $mailer->sendClientUpdatedDocumentsEmail($client, $documentType); } }
/** * Submit form process * * @param User $client * @return bool * @throws NotValidException */ public function process(User $client) { if ($this->request->isMethod('post')) { $this->form->bind($this->request); $accountsIds = $this->form->get('accounts_ids')->getData(); if (!is_array($accountsIds) || empty($accountsIds)) { throw new NotValidException('Select accounts which you want to close.'); } elseif (!$this->repo->isClientAccounts($client->getId(), $accountsIds)) { throw new NotValidException('You can not close this accounts.'); } if ($this->form->isValid()) { $this->onSuccess($client); return true; } } return false; }
private function onSuccess(User $user, User $questionsOwner) { $questions = $this->em->getRepository('WealthbotRiaBundle:RiskQuestion')->getOrderedQuestionsByOwnerId($questionsOwner->getId()); $answers = array(); foreach ($questions as $question) { $key = 'answer_' . $question->getId(); $data = $this->form->get($key)->getData(); $answer = array('question' => $question); if ($question->getIsWithdrawAgeInput()) { $withdrawAge = (int) $answer; $age = $this->getClientAge($user); $ageDiff = $withdrawAge - (int) $age; $answer['data'] = $ageDiff; } else { $answer['data'] = $data; } $answers[] = $answer; $this->saveTempQuestionnaireItem($user->getId(), $question->getId(), $data->getId()); } $riskToleranceManager = new RiskToleranceManager($user, $this->em, $answers); $suggestedPortfolio = $riskToleranceManager->getSuggestedPortfolio(); $this->saveTempPortfolio($user->getId(), $suggestedPortfolio->getId()); $this->dm->flush(); }
public function findClientsByRia(User $ria) { $qb = $this->createQueryBuilder('c')->leftJoin('c.profile', 'p')->leftJoin('c.groups', 'ug')->where('p.ria_user_id = :ria_id')->andWhere('c.roles LIKE :role')->andWhere('p.client_status = :client_status')->groupBy('c.id')->setParameter('role', '%ROLE_CLIENT%')->setParameter('client_status', Profile::CLIENT_STATUS_CLIENT); if (($ria->hasRole('ROLE_RIA_ADMIN') || $ria->hasRole('RIA_USER')) && !$ria->hasGroup('All')) { $groupIds = array(); foreach ($ria->getGroups() as $group) { $groupIds[] = $group->getId(); } $qb->andWhere($qb->expr()->in('ug.id', $groupIds))->setParameter('ria_id', $ria->getRia()->getId()); } else { $qb->setParameter('ria_id', $ria->getId()); } return $qb->getQuery()->getResult(); }
private function createActivity(User $client, $message, $amount) { $activity = new Activity(); $activity->setClientUserId($client->getId()); $activity->setClientStatus($client->getProfile()->getClientStatus()); $activity->setFirstName($client->getFirstName()); $activity->setLastName($client->getLastName()); $activity->setRiaUserId($client->getRia()->getId()); $activity->setAmount($amount); $activity->setMessage($message); $activity->setCreatedAt(new \DateTime()); return $activity; }
public function prepareClientPortfolioValuesInformation(User $client) { $clientPortfolioValuesCollection = $this->repo->findOrderedByDateForClient($client->getId()); $clientPortfolioValuesInformation = new ClientPortfolioValuesInformation($clientPortfolioValuesCollection); return $clientPortfolioValuesInformation; }
protected function validateClientAssetClasses(EntityManager $em, User $client) { $ria = $client->getProfile()->getRia(); $q = "\n SELECT aof.account_id, aof.is_preferred, s.*\n FROM client_accounts ca\n LEFT JOIN account_outside_funds aof ON (ca.id = aof.account_id)\n LEFT JOIN outside_funds fund ON (fund.id = aof.outside_fund_id)\n LEFT JOIN outside_fund_associations ofa ON (ofa.outside_fund_id = fund.id)\n LEFT JOIN ria_subclasses rs ON (rs.id = ofa.ria_subclass_id)\n LEFT JOIN subclasses s ON (rs.subclass_id = s.id)\n WHERE ca.client_id = :client_id AND ofa.ria_user_id = :ria_id AND aof.is_preferred = :is_preferred\n GROUP BY s.asset_class_id\n "; $stmt = $em->getConnection()->prepare($q); $stmt->bindValue('ria_id', $ria->getId()); $stmt->bindValue('client_id', $client->getId()); $stmt->bindValue('is_preferred', 0); $stmt->execute(); $results = $stmt->fetchAll(); $unPreferred = array(); foreach ($results as $result) { $unPreferred[$result['account_id']][] = $result['asset_class_id']; } $stmt = $em->getConnection()->prepare($q); $stmt->bindValue('ria_id', $ria->getId()); $stmt->bindValue('client_id', $client->getId()); $stmt->bindValue('is_preferred', 1); $stmt->execute(); $results = $stmt->fetchAll(); $preferred = array(); foreach ($results as $result) { $preferred[$result['account_id']][] = $result['asset_class_id']; } $badAsset = array(); //echo "<pre>"; foreach ($unPreferred as $account => $assetClasses) { //var_dump($account, $assetClasses); if (isset($preferred[$account])) { //var_dump($assetClasses, $preferred[$account]); //echo "----"; // Search asset classes that's doesn't have preferred subclass $diff = array_diff($assetClasses, $preferred[$account]); // If exists than add to array with not valid asset classes if ($diff) { $badAsset[$account] = $diff; } //var_dump($badAsset); //echo "<br/>"; } else { // All asset classes doesn't have preferred subclass $badAsset[$account] = $assetClasses; } //var_dump($badAsset); //echo "<br/>------------------------------------------------------------<br/>"; } $data['error'] = false; if (count($badAsset) > 0) { $data['error'] = true; $data['bad_asset_classes'] = $badAsset; } //die; return $data; }
public function findHistoryForRiaClientsQuery(User $ria, $filters = array()) { $qb = $this->createQueryBuilder('cav')->leftJoin('cav.clientPortfolio', 'cp')->leftJoin('cp.client', 'c')->leftJoin('c.profile', 'p')->leftJoin('c.groups', 'cg')->leftJoin('cp.portfolio', 'po')->leftJoin('p.ria', 'r')->leftJoin('r.riaCompanyInformation', 'rci')->leftJoin('cav.systemClientAccount', 'sca')->leftJoin('sca.clientAccount', 'ca')->leftJoin('ca.groupType', 'gt')->leftJoin('gt.type', 't')->where('p.ria_user_id = :riaId')->setParameter('riaId', $ria->getId()); $this->addHistoryFilterQueryPart($qb, $filters); return $qb; }
public function findByRiaQuery(User $ria, $limit = null) { $qb = $this->repository->createQueryBuilder()->field('riaUserId')->equals($ria->getId())->field('isShowRia')->equals(true)->limit($limit)->sort('createdAt', 'desc'); return $qb->getQuery(); }
public function hasRetirementAccount(User $client) { $retirementAccounts = $this->getRetirementAccountsByClientId($client->getId()); return count($retirementAccounts) ? true : false; }
public function getClientInformation(User $client, $year, $quarter) { $period = $this->periodManager->getPeriod($year, $quarter); $data = array('id' => $client->getId(), 'createdAt' => $client->getCreated(), 'cash' => $this->cashManager->getCashOnDate($client, $period['endDate']), 'clientStatus' => $this->getClientStatus($client), 'billCreatedAt' => $this->getClientBillDate($client, $year, $quarter), 'billingSpecName' => $client->getFeeShedule(), 'name' => $client->getName(), 'paymentMethod' => $client->getPaymentMethod(), 'portfolioValue' => $this->getPortfolioValue($client, $period['endDate']), 'status' => $this->getClientBillStatusText($client, $year, $quarter), 'statusNumber' => $this->getClientBillStatus($client, $year, $quarter)); return $data; }
public function getAvailableSubclassesQuery($assetClassId, User $owner) { $qb = $this->createQueryBuilder('s')->where('s.asset_class_id = :assetClassId')->andWhere("s.name NOT IN ('Intermediate Muni', 'Short Muni')")->setParameters(array('assetClassId' => $assetClassId))->orderBy('s.id', 'ASC'); if ($owner->hasRole('ROLE_RIA') || $owner->hasRole('ROLE_CLIENT')) { $qb->leftJoin('s.securityAssignments', 'sec')->andWhere('sec.model_id IS NOT NULL')->andWhere('s.owner_id = :owner_id')->setParameter('owner_id', $owner->getId()); } else { $qb->andWhere('s.owner_id IS NULL AND s.source_id IS NULL'); } return $qb; }
/** * Get recipient client user id * * @return int */ public function getClientUserId() { return 'primary_' . $this->user->getId(); }
public function sendCustodianWorkflowDocuments(User $ria, Workflow $workflow) { $documents = array(); if ($workflow->canHaveDocuments()) { /** @var DocumentSignature $signature */ foreach ($workflow->getDocumentSignatures() as $signature) { $document = $signature->getDocument(); $documents[$document->getOriginalName()] = $this->router->generate('rx_download_document', array('filename' => $document->getFilename(), 'originalName' => $document->getOriginalName()), true); } } if (count($documents)) { $template = $this->parameters['template']['docusign_custodian_workflow_documents']; $fromEmail = $this->parameters['from_email']['docusign_custodian_workflow_documents']; $custodian = $ria->getCustodian(); $context = array('custodian' => $custodian, 'ria' => $ria, 'logo' => $this->getRiaLogo($ria->getId())); return $this->sendMessage($template, $fromEmail, $custodian->getEmail(), $context, $documents); } return 0; }