コード例 #1
0
 public function hasDeleteAccess(User $user, ClientActivitySummary $activitySummary)
 {
     if ($user->hasRole('ROLE_RIA') && $activitySummary->getClient()->getRia()->getId() == $user->getId()) {
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 private function getExistDocuments(User $user)
 {
     $documents = array();
     foreach ($user->getUserDocuments() as $document) {
         $documents[$document->getType()] = $document;
     }
     return $documents;
 }
コード例 #4
0
ファイル: TwigSwiftMailer.php プロジェクト: junjinZ/wealthbot
 public function sendConfirmationEmailMessage(User $user)
 {
     $template = $this->parameters['template']['confirmation'];
     $url = 'some url';
     //$this->router->generate('fos_user_registration_confirm', array('token' => $user->getConfirmationToken()), true);
     $context = array('user' => $user, 'confirmationUrl' => $url);
     $this->sendMessage($template, $context, $this->parameters['from_email']['confirmation'], $user->getEmail());
 }
コード例 #5
0
 private function getOriginalFees(User $ria)
 {
     $originalFees = array();
     foreach ($ria->getFees() as $fee) {
         $originalFees[] = $fee;
     }
     return $originalFees;
 }
コード例 #6
0
 public function __construct(User $client, $group = AccountGroup::GROUP_EMPLOYER_RETIREMENT, $validateAdditionalFields = true)
 {
     $this->client = $client;
     $this->group = $group;
     $this->isAllowRetirementPlan = $client->getProfile()->getRia()->getRiaCompanyInformation()->getIsAllowRetirementPlan();
     $this->validateAdditionalFields = $validateAdditionalFields;
     $this->contributionTypes = array('contributions' => 'Contributions', 'distributions' => 'Distributions', 'neither' => 'Neither');
 }
コード例 #7
0
 public function __construct(User $client, EntityManager $em, $validateAdditionalFields = true)
 {
     $this->client = $client;
     $this->em = $em;
     $this->validateAdditionalFields = $validateAdditionalFields;
     $riaCompanyInformation = $client->getProfile()->getRia()->getRiaCompanyInformation();
     $this->isAllowRetirementPlan = $riaCompanyInformation->getIsAllowRetirementPlan();
 }
コード例 #8
0
 /**
  * Create default Admin Spec for RIA
  *
  * @param User $ria
  * @return BillingSpec
  */
 public function initDefaultAdminSpec(User $ria)
 {
     $billingSpec = new BillingSpec();
     $billingSpec->setType(BillingSpec::TYPE_TIER);
     $billingSpec->setName('Admin spec for ' . $ria->getRiaCompanyInformation()->getName());
     $billingSpec->addAppointedUser($ria);
     $billingSpec->setMinimalFee(0.0);
     return $billingSpec;
 }
コード例 #9
0
 /**
  * @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;
 }
コード例 #10
0
ファイル: TwigSwiftMailer.php プロジェクト: junjinZ/wealthbot
 public function sendAdvCopyEmailMessage(User $client)
 {
     $ria = $client->getProfile()->getRia();
     $companyInformation = $ria->getRiaCompanyInformation();
     $template = $this->parameters['template']['adv_copy'];
     $context = array('client' => $client->getUsername(), 'company' => $companyInformation->getName());
     $extension = pathinfo($companyInformation->getAdvCopy(), PATHINFO_EXTENSION);
     $attachments = array('ADV Copy.' . $extension => $companyInformation->getWebAdvCopy());
     $this->sendMessage($template, $context, $this->parameters['from_email']['adv_copy'], $client->getEmail(), $attachments);
 }
コード例 #11
0
 public function __construct(User $client, array $systemAccounts = null)
 {
     if (null === $systemAccounts) {
         $systemAccounts = $client->getSystemAccounts();
     }
     /** @var SystemAccount $systemAccount */
     foreach ($systemAccounts as $systemAccount) {
         $clientAccount = $systemAccount->getClientAccount();
         $this->clientAccounts[$clientAccount->getId()] = $clientAccount->getSasCash();
     }
 }
コード例 #12
0
 public function getCashOnDate(User $user, \DateTime $date)
 {
     /** @var ClientAccount[] $accounts */
     $accounts = $user->getClientAccounts();
     $sum = 0;
     foreach ($accounts as $account) {
         $systemAccount = $account->getSystemAccount();
         if ($systemAccount) {
             $sum += $this->em->getRepository('WealthbotClientBundle:ClientAccountValue')->getFreeCashBeforeDate($systemAccount, $date);
         }
     }
     return $sum;
 }
コード例 #13
0
 /**
  * Returns ria if he has risk questions and admin otherwise
  *
  * @param User $user
  * @return User
  */
 public function getQuestionsOwner(User $user)
 {
     if ($user->hasRole('ROLE_CLIENT')) {
         $ria = $user->getRia();
     } else {
         $ria = $user;
     }
     $existQuestion = $this->findOneBy(array('owner_id' => $ria->getId()));
     if ($existQuestion) {
         return $ria;
     }
     return $this->_em->getRepository('WealthbotUserBundle:User')->getAdmin();
 }
コード例 #14
0
 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);
     }
 }
コード例 #15
0
 private function setClientDocument(User $client, Document $document, $isClientNotified)
 {
     if (!$client->getUserDocuments()->contains($document)) {
         $client->addUserDocument($document);
         if ($isClientNotified) {
             $this->mailer->sendClientRiaUploadedDocument($client);
         }
         $clientActivitySummary = new ClientActivitySummary();
         $clientActivitySummary->setClient($client);
         $clientActivitySummary->setDescription('Document Uploaded');
         $clientActivitySummary->setDocument($document);
         $client->addClientActivitySummary($clientActivitySummary);
         $this->em->persist($client);
     }
 }
コード例 #16
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->factory = $builder->getFormFactory();
     if ($billingSpec = $this->user->getAppointedBillingSpec()) {
         $fees = $billingSpec->getFees();
     } else {
         $fees = new ArrayCollection();
     }
     if (!$fees->count()) {
         $fee = new Fee();
         $fees[] = $fee;
     }
     $builder->add('fees', 'collection', array('type' => new FeeFormType($this->user), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_name' => '__name__', 'by_reference' => false, 'property_path' => false, 'data' => $fees))->add('minimum_billing_fee', 'number', array('precision' => 2, 'grouping' => true, 'required' => false));
     $builder->addEventListener(FormEvents::BIND, array($this, 'onBind'));
 }
コード例 #17
0
 public function saveDefaultConfiguration(User $user)
 {
     $configuration = null;
     if ($user->hasRole('ROLE_RIA')) {
         $configuration = $this->createRiaDefaultConfiguration($user);
     } elseif ($user->hasRole('ROLE_CLIENT')) {
         //TODO: next step
         $configuration = null;
     }
     if ($configuration) {
         $this->objectManager->persist($configuration);
         $this->objectManager->flush();
     }
     return $configuration;
 }
コード例 #18
0
ファイル: LoadClientData.php プロジェクト: junjinZ/wealthbot
 private function createQuestionnaireAnswers(ObjectManager $manager, User $clientUser)
 {
     $clientProfile = $clientUser->getProfile();
     $answers = array();
     for ($i = 1; $i <= 4; $i++) {
         $answers[] = array('question' => $this->getReference('ria-risk-question-' . $i), 'data' => $this->getReference('ria-risk-answer-' . $i . '-1'));
     }
     $riskToleranceManager = new RiskToleranceManager($clientUser, $manager, $answers);
     $riskToleranceManager->saveUserAnswers();
     $suggestedPortfolio = $riskToleranceManager->getSuggestedPortfolio();
     //$clientProfile->setSuggestedPortfolio($suggestedPortfolio);
     $clientPortfolioManager = $this->container->get('wealthbot_client.client_portfolio.manager');
     $clientPortfolioManager->proposePortfolio($clientUser, $suggestedPortfolio);
     $manager->persist($clientProfile);
 }
コード例 #19
0
ファイル: RiskTolerance.php プロジェクト: junjinZ/wealthbot
 /**
  * Get ria
  *
  * @return User
  */
 public function getRia()
 {
     if ($this->user->hasRole('ROLE_CLIENT')) {
         return $this->user->getRia();
     }
     return $this->user;
 }
コード例 #20
0
 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);
     }
 }
コード例 #21
0
 /**
  * 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;
 }
コード例 #22
0
 protected function updateTaxLossHarvesting(FormInterface $form, $subclassId, $withoutIds = array())
 {
     if ($this->user->hasRole('ROLE_RIA') && $this->user->getRiaCompanyInformation()->getIsTaxLossHarvesting() && (!$this->user->getRiaCompanyInformation()->getIsUseQualifiedModels() || $this->user->getRiaCompanyInformation()->getIsUseQualifiedModels() && !$this->isQualifiedModel)) {
         /** @var $securityAssignmentRepo SecurityAssignmentRepository */
         $securityAssignmentRepo = $this->em->getRepository('WealthbotAdminBundle:SecurityAssignment');
         $securityQueryBuilder = $securityAssignmentRepo->getSecuritiesQBBySubclassIdAndWithoutSecuritiesIds($subclassId, $withoutIds);
         $form->add($this->factory->createNamed('tax_loss_harvesting', 'entity', null, array('class' => 'WealthbotAdminBundle:SecurityAssignment', 'property' => 'security.name', 'empty_value' => 'Choose TLH Substitution', 'query_builder' => $securityQueryBuilder, 'attr' => empty($withoutIds) ? array('disabled' => 'disabled') : array(), 'required' => false)));
     }
 }
コード例 #23
0
 public function getPortfolioInformation(User $user, CeModelInterface $model, $isQualified = false)
 {
     if ($user->hasRole('ROLE_CLIENT')) {
         $ria = $user->getRia();
     } else {
         $ria = $user;
     }
     $portfolioInformation = new PortfolioInformation();
     $portfolioInformation->setUser($user);
     $portfolioInformation->setModel($model);
     $portfolioInformation->setIsQualifiedModel($isQualified);
     $portfolioInformation->setFees($this->feeManager->getClientFees($ria));
     if ($model->getOwner()->hasRole('ROLE_RIA')) {
         $transactionCommissionFees = $this->em->getRepository('WealthbotAdminBundle:SecurityAssignment')->findMinAndMaxTransactionFeeForModel($model->getParentId());
         $portfolioInformation->setTransactionCommissionFees(array_values($transactionCommissionFees));
     }
     return $portfolioInformation;
 }
コード例 #24
0
 public function setUp()
 {
     $questions = array();
     for ($i = 0; $i < 4; $i++) {
         $question = new RiskQuestion();
         $question->setTitle('Question ' . ($i + 1));
         for ($j = 0; $j < 4; $j++) {
             $answer = new RiskAnswer();
             $answer->setTitle('Answer ' . ($i + 1) . ' - ' . ($j + 1));
             $answer->setQuestion($question);
             $answer->setPoint($j);
             $question->addAnswer($answer);
         }
         $questions[] = $question;
     }
     $userAnswers = array();
     foreach ($questions as $key => $question) {
         $userAnswer = new ClientQuestionnaireAnswer();
         $userAnswer->setQuestion($question);
         $questionAnswers = $question->getAnswers();
         $userAnswer->setAnswer($questionAnswers[$key]);
         $userAnswers[] = $userAnswer;
     }
     $portfolio = new CeModel();
     for ($i = 0; $i < 4; $i++) {
         $modelMock = $this->getMock('Wealthbot\\AdminBundle\\Entity\\CeModel', array('getId'));
         $modelMock->expects($this->any())->method('getId')->will($this->returnValue($i + 1));
         $modelMock->setName('Model ' . ($i + 1));
         $modelMock->setRiskRating($i + 1);
         $portfolio->addChildren($modelMock);
     }
     $riaCompanyInformation = new RiaCompanyInformation();
     $riaCompanyInformation->setPortfolioModel($portfolio);
     $ria = new User();
     $ria->setRoles(array('ROLE_RIA'));
     $ria->setRiaCompanyInformation($riaCompanyInformation);
     $userProfile = new Profile();
     $userProfile->setRia($ria);
     $user = new User();
     $user->setRoles(array('ROLE_CLIENT'));
     $user->setProfile($userProfile);
     $this->riskTolerance = new RiskTolerance($user, $userAnswers);
 }
コード例 #25
0
ファイル: LoadAdminData.php プロジェクト: junjinZ/wealthbot
 private function createUser()
 {
     $adminUser = new User();
     $adminUser->setUsername('webo');
     $adminUser->setEmail('*****@*****.**');
     $adminUser->setPlainPassword('weboDemo32');
     $adminUser->setEnabled(true);
     $adminUser->setRoles(array('ROLE_SUPER_ADMIN'));
     return $adminUser;
 }
コード例 #26
0
 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;
 }
コード例 #27
0
ファイル: ClientAccount.php プロジェクト: junjinZ/wealthbot
 /**
  * Get primary applicant of account
  *
  * @return AccountOwnerInterface|null
  */
 public function getPrimaryApplicant()
 {
     $owners = $this->getOwners();
     if (!$this->client->isMarried() && array_key_exists(ClientAccountOwner::OWNER_TYPE_SELF, $owners)) {
         return $owners[ClientAccountOwner::OWNER_TYPE_SELF];
     }
     $primaryApplicant = null;
     if (array_key_exists(ClientAccountOwner::OWNER_TYPE_SELF, $owners)) {
         $primaryApplicant = $owners[ClientAccountOwner::OWNER_TYPE_SELF];
     } elseif (array_key_exists(ClientAccountOwner::OWNER_TYPE_SPOUSE, $owners)) {
         $primaryApplicant = $owners[ClientAccountOwner::OWNER_TYPE_SPOUSE];
     }
     return $primaryApplicant;
 }
コード例 #28
0
ファイル: LoadBillData.php プロジェクト: junjinZ/wealthbot
 public function createBill(User $user, $dateStr, ObjectManager $manager)
 {
     $date = new \DateTime($dateStr);
     $period = $this->periodManager->getPreviousQuarter($date);
     $accounts = $user->getClientAccounts();
     $bill = new Bill();
     $bill->setCreatedAt(new \DateTime($dateStr));
     $bill->setClient($user);
     $bill->setYear($period['year']);
     $bill->setQuarter($period['quarter']);
     $manager->persist($bill);
     foreach ($accounts as $account) {
         $systemAccount = $account->getSystemAccount();
         if ($systemAccount) {
             $billItem = new BillItem();
             $billItem->setSystemAccount($systemAccount);
             $billItem->setBill($bill);
             $billItem->setFeeBilled($this->feeManager->getRiaFee($account, $period['year'], $period['quarter']));
             $billItem->setCreatedAt(new \DateTime($dateStr));
             $manager->persist($billItem);
         }
     }
     $manager->flush();
 }
コード例 #29
0
 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();
 }
コード例 #30
0
ファイル: LoadRiaData.php プロジェクト: junjinZ/wealthbot
 private function createUser()
 {
     $riaUser = new User();
     $riaUser->setUsername('ria');
     $riaUser->setEmail('*****@*****.**');
     $riaUser->setPlainPassword('ria');
     $riaUser->setEnabled(true);
     $riaUser->setRoles(array('ROLE_RIA'));
     $riaUserProfile = new Profile();
     $riaUserProfile->setUser($riaUser);
     $riaUserProfile->setCompany('Wealthbot');
     $riaUserProfile->setFirstName('RiaFirst');
     $riaUserProfile->setLastName('RiaLast');
     $riaUserProfile->setRegistrationStep(5);
     $riaUser->setProfile($riaUserProfile);
     return $riaUser;
 }