public function buildForm(FormBuilderInterface $builder, array $options) { $client = $builder->getData(); if (!$client instanceof User || $client instanceof User && !$client->hasRole('ROLE_CLIENT')) { throw new Exception('Client is required'); } /** @var User $ria */ $ria = $client->getRia(); $builder->add('portfolio', 'entity', array('class' => 'WealthbotAdminBundle:CeModel', 'property' => 'name', 'query_builder' => function (EntityRepository $er) use($ria) { return $er->createQueryBuilder('p')->where('p.parent IS NOT NULL')->andWhere('p.ownerId = :owner_id')->setParameters(array('owner_id' => $ria->getId())); }, 'property_path' => false, 'data' => $this->proposedPortfolio ? $this->proposedPortfolio->getPortfolio() : null)); }
protected function buildModelForm(FormBuilderInterface $builder, User $ria) { $builder->add('client', new ChooseClientPortfolioFormType($this->clientPortfolio), array('mapped' => false, 'data' => $this->clientPortfolio->getClient())); if ($ria->getRiaCompanyInformation()->isCollaborativeProcessing()) { $builder->add('groups', 'entity', array('multiple' => false, 'property' => 'name', 'property_path' => 'user.groups', 'label' => 'Groups:', 'class' => 'Wealthbot\\UserBundle\\Entity\\Group', 'query_builder' => function (EntityRepository $er) use($ria) { return $er->createQueryBuilder('g')->andWhere('g.owner = :owner')->orWhere('g.owner is null')->setParameter('owner', $ria); })); } }
public function getLatestValuesForPortfolio(ClientPortfolio $clientPortfolio) { return $this->repo->getLastValueByClient($clientPortfolio->getClient()); }
/** * Update client status by client portfolio object * * @param Workflow $workflow * @param ClientPortfolio $clientPortfolio */ public function updateClientStatusByClientPortfolio(Workflow $workflow, ClientPortfolio $clientPortfolio) { if ($clientPortfolio->isProposed()) { $workflow->setClientStatus(Workflow::CLIENT_STATUS_PORTFOLIO_PROPOSED); } elseif ($clientPortfolio->isClientAccepted()) { $workflow->setClientStatus(Workflow::CLIENT_STATUS_PORTFOLIO_CLIENT_ACCEPTED); $workflow->setIsArchived(true); } }
/** * Approve proposed portfolio * * @param User $client * @param CeModelInterface $proposedModel * @return ClientPortfolio * @throws \RuntimeException */ public function approveProposedPortfolio(User $client, CeModelInterface $proposedModel = null) { $approvedPortfolio = $this->getApprovedClientPortfolio($client); if ($approvedPortfolio) { if (null !== $proposedModel) { $approvedPortfolio->setPortfolio($proposedModel); } } elseif (!$approvedPortfolio) { $approvedPortfolio = $this->getProposedClientPortfolio($client); if (!$approvedPortfolio && null !== $proposedModel) { $approvedPortfolio = new ClientPortfolio(); $approvedPortfolio->setClient($client); $approvedPortfolio->setPortfolio($proposedModel); } if (!$approvedPortfolio) { throw new \RuntimeException(sprintf('Client with id: %s does not have proposed portfolio', $client->getId())); } } $approvedPortfolio->setStatusAdvisorApproved(); $this->om->persist($approvedPortfolio); $this->om->flush(); return $approvedPortfolio; }