Ejemplo n.º 1
0
 /**
  * Check account outside fund and create new if does not exist
  *
  * @param ClientAccount $account
  * @param SecurityAssignment $securityAssignment
  * @param bool $isPreferred
  * @return mixed|void
  * @throws \Wealthbot\AdminBundle\Exception\DataAlreadyExistsException
  */
 protected function checkAccountAssociation(ClientAccount $account, SecurityAssignment $securityAssignment, $isPreferred)
 {
     if ($this->existAccountAssociation($account->getId(), $securityAssignment->getId())) {
         throw new DataAlreadyExistsException(sprintf("SecurityAssignment with id: %s already exist for client account with id: %s", $securityAssignment->getId(), $account->getId()));
     }
     $this->createAccountAssociation($account, $securityAssignment, $isPreferred);
 }
 public function __construct(EntityManager $em, ClientAccount $account, $isPreSaved = false)
 {
     $this->em = $em;
     $this->account = $account;
     $this->hasFunding = $account->hasFunding();
     $this->hasDistributing = $account->hasDistributing();
     $this->isPreSaved = $isPreSaved;
 }
 /**
  * Check if account outside fund exist and create new if it does not exist
  *
  * @param ClientAccount $account
  * @param SecurityAssignment $securityAssignment
  * @param $isPreferred
  * @return mixed|null|AccountOutsideFund
  */
 protected function checkAccountAssociation(ClientAccount $account, SecurityAssignment $securityAssignment, $isPreferred)
 {
     $association = $this->existAccountAssociation($account->getId(), $securityAssignment->getId());
     if (!$association) {
         $association = $this->createAccountAssociation($account, $securityAssignment, $isPreferred);
     } else {
         $this->updateAccountAssociation($association, $isPreferred);
     }
     return $association;
 }
Ejemplo n.º 4
0
 public function getAccountValueOnDate(ClientAccount $account, \DateTime $date)
 {
     $systemAccount = $account->getSystemAccount();
     $v = 0;
     if ($systemAccount) {
         $v = $this->em->getRepository('WealthbotClientBundle:ClientAccountValue')->getSumBeforeDate($systemAccount, $date);
     }
     if ($v == 0) {
         $v = $account->getValue();
     }
     return $v;
 }
Ejemplo n.º 5
0
 /**
  * @param ClientAccount $account
  * @param $year
  * @param int $quarter
  * @return null|BillItem
  */
 public function getByAccountAndPeriod(ClientAccount $account, $year, $quarter = 0)
 {
     $systemAccount = $account->getSystemAccount();
     if (!$systemAccount) {
         return null;
     }
     $qb = $this->createQueryBuilder('i')->where('i.systemAccount = :systemAccount')->leftJoin('i.bill', 'b')->andWhere('b.year = :year')->setParameter('systemAccount', $systemAccount)->setParameter('year', $year)->setMaxResults(1);
     if ($quarter == 0) {
         $qb->orderBy('b.quarter', 'DESC');
     } else {
         $qb->andWhere('b.quarter = :quarter')->setParameter('quarter', $quarter);
     }
     return $qb->getQuery()->getOneOrNullResult();
 }
Ejemplo n.º 6
0
 /**
  * @return float
  */
 public function getProjectedValue()
 {
     $value = 0;
     if ($this->clientAccount) {
         $value = $this->clientAccount->getValueSum();
     }
     return $value;
 }
Ejemplo n.º 7
0
 /**
  * @param TokenInterface $token
  * @param ClientAccount $object
  * @param array $attributes
  * @return int
  */
 public function vote(TokenInterface $token, $object, array $attributes)
 {
     if (!$object instanceof ClientAccount) {
         return VoterInterface::ACCESS_ABSTAIN;
     }
     $user = $token->getUser();
     if (!$user instanceof User) {
         return VoterInterface::ACCESS_ABSTAIN;
     }
     if ($user->isAdmin()) {
         return VoterInterface::ACCESS_GRANTED;
     }
     if (in_array($attributes[0], array(static::PERMISSION_CHANGE_CONSOLIDATOR, static::PERMISSION_APPROVE_BILL, static::PERMISSION_EDIT))) {
         if ($user == $object->getClient()->getRia()) {
             return VoterInterface::ACCESS_GRANTED;
         }
     }
     return VoterInterface::ACCESS_ABSTAIN;
 }
 /**
  * Set account_id for owners in $this->owners array
  *
  * @param ClientAccount $account
  */
 protected function saveAccountOwners(ClientAccount $account)
 {
     $ownerTypes = $this->getOwnerTypes();
     if (empty($ownerTypes) && $account->getAccountOwners()->isEmpty()) {
         $owner = new ClientAccountOwner();
         $owner->setOwnerType(ClientAccountOwner::OWNER_TYPE_SELF);
         $owner->setClient($account->getClient());
         $owner->setAccount($account);
         $this->em->persist($owner);
         $this->em->flush();
     } else {
         foreach ($account->getAccountOwners() as $accountOwner) {
             $this->em->remove($accountOwner);
         }
         foreach ($ownerTypes as $type) {
             $this->createAccountOwnerByType($account, $type);
         }
         $this->em->persist($account);
         $this->em->flush();
     }
 }
 protected function onSuccess(ClientAccount $account, $withMaritalStatus)
 {
     /** @var AccountOwnerInterface $data */
     $data = $this->form->getData();
     $isPrimaryApplicant = $data instanceof UserAccountOwnerAdapter;
     if (true === $withMaritalStatus && $isPrimaryApplicant) {
         /** @var $profile Profile */
         $profile = $account->getClient()->getProfile();
         $spouse = $account->getClient()->getSpouse();
         $maritalStatus = $this->form->get('marital_status')->getData();
         if ($maritalStatus == Profile::CLIENT_MARITAL_STATUS_MARRIED) {
             if (!$spouse) {
                 $spouse = new ClientAdditionalContact();
                 $spouse->setClient($account->getClient());
                 $spouse->setType(ClientAdditionalContact::TYPE_SPOUSE);
             }
             if ($this->form->has('spouse_first_name')) {
                 $spouse->setFirstName($this->form->get('spouse_first_name')->getData());
             }
             if ($this->form->has('spouse_middle_name')) {
                 $spouse->setMiddleName($this->form->get('spouse_middle_name')->getData());
             }
             if ($this->form->has('spouse_last_name')) {
                 $spouse->setLastName($this->form->get('spouse_last_name')->getData());
             }
             if ($this->form->has('spouse_birth_date')) {
                 $spouse->setBirthDate($this->form->get('spouse_birth_date')->getData());
             }
         }
         $profile->setMaritalStatus($maritalStatus);
         $this->em->persist($profile);
     }
     $account->setStepAction($isPrimaryApplicant ? ClientAccount::STEP_ACTION_PERSONAL : ClientAccount::STEP_ACTION_ADDITIONAL_PERSONAL);
     $account->setIsPreSaved($this->request->isXmlHttpRequest());
     $this->em->persist($data->getObjectToSave());
     $this->em->persist($account);
     $this->em->flush();
 }
Ejemplo n.º 10
0
 private function onSuccess(ClientAccount $account, $isPreSaved = false)
 {
     /** @var AccountOwnerInterface $data */
     $data = $this->form->getData();
     $isPrimaryApplicant = $data instanceof UserAccountOwnerAdapter;
     if ($isPrimaryApplicant) {
         $account->setProcessStep(ClientAccount::PROCESS_STEP_STARTED_TRANSFER);
         $account->setStepAction(ClientAccount::STEP_ACTION_BASIC);
     } else {
         $account->setStepAction(ClientAccount::STEP_ACTION_ADDITIONAL_BASIC);
     }
     $account->setIsPreSaved($isPreSaved);
     $this->em->persist($data->getObjectToSave());
     $this->em->persist($account);
     $this->em->flush();
 }
Ejemplo n.º 11
0
 /**
  * Save transfer information of account
  *
  * @param ClientAccount $account
  * @return \Wealthbot\ClientBundle\Entity\TransferInformation
  */
 protected function saveTransferInformation(ClientAccount $account)
 {
     $transferInformation = $account->getTransferInformation();
     $transferCustodianId = $this->form->get('transferInformation')->get('transfer_custodian_id')->getData();
     $isFirmNotAppear = $this->form->get('transferInformation')->get('is_firm_not_appear')->getData();
     $transferInformation->setClientAccount($account);
     if (!$isFirmNotAppear && $transferCustodianId) {
         $transferCustodian = $this->em->getRepository('WealthbotClientBundle:TransferCustodian')->find($transferCustodianId);
         $transferInformation->setTransferCustodian($transferCustodian);
         $questionnaire = $transferInformation->getQuestionnaireAnswers();
         foreach ($questionnaire as $answer) {
             $answer->setTransferInformation($transferInformation);
         }
     }
     return $transferInformation;
 }
Ejemplo n.º 12
0
 public function createAccountAction(Request $request)
 {
     if (!$request->isMethod("post") || !$request->isXmlHttpRequest()) {
         throw $this->createNotFoundException('Page not found.');
     }
     $client = $this->getUser();
     if (!$client || !$client->hasRole('ROLE_CLIENT')) {
         return $this->getJsonResponse(array('status' => 'error', 'message' => 'Client does not exist.'));
     }
     /** @var \Doctrine\ORM\EntityManager $em */
     $em = $this->get('doctrine.orm.entity_manager');
     $adm = $this->get('wealthbot_docusign.account_docusign.manager');
     $group = $request->get('group');
     $allowedGroups = AccountGroup::getGroupChoices();
     if (!in_array($group, $allowedGroups)) {
         throw new HttpException(400, 'Invalid group type');
     }
     $groupTypeId = null;
     $groupType = null;
     $clientAccount = new ClientAccount();
     if ($group === AccountGroup::GROUP_DEPOSIT_MONEY || $group === AccountGroup::GROUP_FINANCIAL_INSTITUTION) {
         $groupType = $this->getAccountGroupType();
         $clientAccount->setGroupType($groupType);
     }
     $form = $this->createForm(new TypedClientAccountFormType($em, $client, $groupType, $group), $clientAccount);
     $formHandler = new ClientAccountFormHandler($form, $request, $adm, $this->getAccountOwners(), $this->getIsConsolidateAccount());
     $process = $formHandler->process();
     if ($process) {
         $this->removeAccountGroup();
         $this->removeAccountType();
         $this->removeAccountGroupType();
         $this->removeAccountOwners();
         /** @var ClientAccount $clientAccount */
         $clientAccount = $form->getData();
         if ($group == 'employer_retirement') {
             $responseData = $this->processEmployerRetirementAccountForm($clientAccount);
         } else {
             $responseData = $this->processAccountForm();
             $isType = $clientAccount->getGroupName() === AccountGroup::GROUP_DEPOSIT_MONEY;
             $systemAccounts = $em->getRepository('WealthbotClientBundle:SystemAccount')->findByClientIdAndType($client->getId(), $clientAccount->getSystemType());
             $responseData['in_right_box'] = $isType || count($systemAccounts) < 1 ? false : true;
             $responseData['transfer_url'] = $this->generateUrl('rx_client_dashboard_select_system_account', array('account_id' => $clientAccount->getId()));
         }
         $this->removeIsConsolidateAccount();
         $this->removeAccountStep();
         return $this->getJsonResponse($responseData);
     }
     $message = $this->getTitleMessageForAccountForm($group, $groupType);
     return $this->getJsonResponse(array('status' => 'error', 'form' => $this->renderView('WealthbotClientBundle:Profile:_client_accounts_form.html.twig', array('form' => $form->createView(), 'group' => $group, 'hide_submit_button' => true, 'title_message' => $message))));
 }
Ejemplo n.º 13
0
 /**
  *
  * @SecureParam(name="account", permissions="CHANGE_CONSOLIDATOR")
  * @ParamConverter("account", class="WealthbotClientBundle:ClientAccount")
  *
  * @param ClientAccount $account
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function updateAccountsPaysForAction(ClientAccount $account, Request $request)
 {
     $number = $request->get('paysFor');
     $em = $this->getDoctrine()->getManager();
     if ($number == '') {
         $account->setConsolidator(null);
     } else {
         $consolidateAccount = $em->getRepository('WealthbotClientBundle:ClientAccount')->getByAccountNumber($number);
         $ria = $this->getUser();
         if ($consolidateAccount->getClient()->getRia() !== $ria) {
             throw new AccessDeniedException('Consolidate account do not belongs to Your RIA');
         }
         if ($consolidateAccount->getClient() !== $account->getClient()) {
             throw new AccessDeniedException('Consolidate account do not belongs to client');
         }
         $account->setConsolidator($consolidateAccount);
     }
     $em->flush();
     return new JsonResponse(array());
 }
 /**
  * Build data for contribution form with one_time action
  *
  * @param ClientAccount $clientAccount
  * @param AccountContribution $existContribution
  * @return OneTimeContribution
  */
 private function buildOneTimeContributionData(ClientAccount $clientAccount, AccountContribution $existContribution = null)
 {
     $data = new OneTimeContribution();
     $data->setSystemAccount($clientAccount->getSystemAccount());
     if ($existContribution) {
         $data->setBankInformation($existContribution->getBankInformation());
         if ($existContribution->isOneTimeContribution()) {
             $data->setContributionYear($existContribution->getContributionYear());
             $data->setStartTransferDate($existContribution->getStartTransferDate());
             $data->setAmount($existContribution->getAmount());
         }
     }
     return $data;
 }
 /**
  * Returns array with:
  *  avg_value, count_values
  *
  * @param ClientAccount $account
  * @param \DateTime $dateFrom
  * @param \DateTime $dateTo
  * @return array
  */
 public function getAverageAccountValues(ClientAccount $account, \DateTime $dateFrom, \DateTime $dateTo)
 {
     $systemAccount = $account->getSystemAccount();
     if (!$systemAccount) {
         return array('avg_value' => 0, 'count_values' => 0);
     }
     $r = $this->createQueryBuilder('v')->select('AVG(v.total_value) as AV, COUNT(v.total_value) as CV')->where('v.systemClientAccount = :sysAccount')->andWhere('v.date >= :dateFrom')->andWhere('v.date < :dateTo')->orderBy('v.date', 'ASC')->setParameter('sysAccount', $systemAccount)->setParameter('dateFrom', $dateFrom)->setParameter('dateTo', $dateTo)->getQuery()->getArrayResult();
     if (count($r)) {
         return array('avg_value' => $r[0]['AV'], 'count_values' => $r[0]['CV']);
     } else {
         return array('avg_value' => 0, 'count_values' => 0);
     }
 }
Ejemplo n.º 16
0
 /**
  * @param ClientAccount $account
  * @param $year
  * @param $quarter
  * @param bool $flush
  * @throws \Exception
  */
 public function approveAccount(ClientAccount $account, $year, $quarter, $flush = false)
 {
     $client = $account->getClient();
     /** @var Bill $bill */
     if (!($bill = $this->em->getRepository('WealthbotClientBundle:Bill')->findByClientAndPeriod($client, $year, $quarter))) {
         throw new \Exception('Bill was not generated');
         //todo: make custom exception
     }
     $bill->setApprovedAt(new \DateTime());
     if ($billItem = $this->em->getRepository('WealthbotClientBundle:BillItem')->getByAccountAndPeriod($account, $year, $quarter)) {
         $billItem->getStatus() == BillItem::STATUS_BILL_GENERATED && $billItem->setStatus(BillItem::STATUS_BILL_APPROVED);
     } else {
         return false;
     }
     $flush && $this->em->flush();
     return true;
 }
Ejemplo n.º 17
0
 protected function denyAccessForCurrentRetirementAccount(ClientAccount $account)
 {
     /** @var $em EntityManager */
     /** @var $repo ClientAccountRepository */
     $em = $this->get('doctrine.orm.entity_manager');
     $repo = $em->getRepository('WealthbotClientBundle:ClientAccount');
     $isCurrentRetirement = $repo->findRetirementAccountById($account->getId()) ? true : false;
     if ($isCurrentRetirement) {
         throw new AccessDeniedException('Current retirement accounts has not this step.');
     }
 }
Ejemplo n.º 18
0
 /**
  * Get systemAccount
  *
  * @return \Wealthbot\ClientBundle\Entity\SystemAccount
  */
 public function getSystemAccount()
 {
     if (null === $this->systemAccount && $this->consolidator) {
         return $this->consolidator->getSystemAccount();
     }
     return $this->systemAccount;
 }
Ejemplo n.º 19
0
 /**
  * @SecureParam(name="account", permissions="EDIT")
  * @ParamConverter("account", class="WealthbotClientBundle:ClientAccount", options={"id" = "account_id"})
  */
 public function accountSettingsAction(ClientAccount $account, Request $request)
 {
     /** @var EntityManager $em */
     $em = $this->get('doctrine.orm.entity_manager');
     $systemAccount = $account->getSystemAccount();
     $form = $this->createForm(new AccountSettingsFormType($em), $account);
     $oneTimeDistribution = new Distribution();
     $oneTimeDistribution->setType(Distribution::TYPE_ONE_TIME);
     $oneTimeDistribution->setSystemClientAccount($systemAccount);
     $oneTimeDistributionForm = $this->createForm(new OneTimeDistributionFormType(), $oneTimeDistribution);
     $scheduledDistribution = $em->getRepository('WealthbotClientBundle:Distribution')->findOneBy(array('systemClientAccount' => $systemAccount, 'type' => Distribution::TYPE_SCHEDULED));
     if (null === $scheduledDistribution) {
         $scheduledDistribution = new Distribution();
         $scheduledDistribution->setType(Distribution::TYPE_SCHEDULED);
         $scheduledDistribution->setSystemClientAccount($systemAccount);
     }
     $scheduledDistributionForm = $this->createForm(new ScheduledDistributionFormType(), $scheduledDistribution);
     if ($request->isMethod('POST')) {
         $scheduledDistributionForm->bind($request);
         if ($scheduledDistributionForm->isValid()) {
             $scheduledDistributionFormData = $scheduledDistributionForm->getData();
             if ($scheduledDistributionFormData->getAmount() > 0) {
                 $em->persist($scheduledDistributionFormData);
                 $em->flush();
             }
         }
         $oneTimeDistributionForm->bind($request);
         if ($oneTimeDistributionForm->isValid()) {
             $oneTimeDistributionFormData = $oneTimeDistributionForm->getData();
             if ($oneTimeDistributionFormData->getAmount() > 0) {
                 $em->persist($oneTimeDistributionFormData);
                 $em->flush();
             }
         }
         $form->bind($request);
         if ($form->isValid()) {
             $formData = $form->getData();
             $em->persist($formData);
             $em->flush();
         }
     }
     return $this->render('WealthbotRiaBundle:Dashboard:account_settings.html.twig', array('scheduledDistributionForm' => $scheduledDistributionForm->createView(), 'oneTimeDistributionForm' => $oneTimeDistributionForm->createView(), 'form' => $form->createView()));
 }
Ejemplo n.º 20
0
 /**
  * Return new system account with client, client account, account number and account description
  *
  * @param ClientAccount $clientAccount
  * @return SystemAccount
  */
 private function createAccount(ClientAccount $clientAccount)
 {
     // If system account is exist then update it
     $systemAccount = $clientAccount->getSystemAccount();
     if (!$systemAccount) {
         $systemAccount = new SystemAccount();
     }
     $systemAccount->setClient($clientAccount->getClient());
     $systemAccount->setClientAccount($clientAccount);
     $systemAccount->setType($clientAccount->getSystemType());
     $systemAccount->setAccountNumber('CE-000-' . rand(100000000, 999999999));
     $systemAccount->setAccountDescription($clientAccount->getOwnersAsString() . ' ' . $clientAccount->getTypeName());
     return $systemAccount;
 }
 /**
  * Validate form data
  *
  * @param FormInterface $form
  * @param ClientAccount $data
  */
 private function validate(FormInterface $form, ClientAccount $data)
 {
     $group = $form->get('group')->getData();
     if ($data) {
         $data->setClient($this->client);
         if ($group == AccountGroup::GROUP_EMPLOYER_RETIREMENT) {
             $data->setMonthlyDistributions(null);
             $data->setSasCash(null);
             if (floatval($data->getValue()) < 50000) {
                 $form->get('value')->addError(new FormError('Minimum value must be $50,000 for retirement plans.'));
             }
             if ($form->get('plan_provider')->getData()) {
                 $financialInstitution = $data->getFinancialInstitution();
                 $data->setFinancialInstitution($form->get('plan_provider')->getData() . " (" . $financialInstitution . ")");
             }
         }
         if ($this->validateAdditionalFields && $form->has('owners')) {
             if ($data->getTypeName() == 'Joint Account') {
                 $ownerTypes = $form->get('owners')->get('owner_types')->getData();
                 if (!is_array($ownerTypes) || count($ownerTypes) !== 2) {
                     $form->get('owners')->get('owner_types')->addError(new FormError('You should select two owners of the account.'));
                 }
                 if ($form->get('owners')->has('other_contact')) {
                     /** @var ClientAdditionalContact $otherContact */
                     $otherContact = $form->get('owners')->get('other_contact')->getData();
                     if (!$otherContact->getFirstName() || trim($otherContact->getFirstName() == '')) {
                         $form->get('owners')->get('other_contact')->get('first_name')->addError(new FormError('Required.'));
                     }
                     if (!$otherContact->getMiddleName() || trim($otherContact->getMiddleName() == '')) {
                         $form->get('owners')->get('other_contact')->get('middle_name')->addError(new FormError('Required.'));
                     }
                     if (!$otherContact->getLastName() || trim($otherContact->getLastName() == '')) {
                         $form->get('owners')->get('other_contact')->get('last_name')->addError(new FormError('Required.'));
                     }
                     if (!$otherContact->getRelationship() || trim($otherContact->getRelationship() == '')) {
                         $form->get('owners')->get('other_contact')->get('relationship')->addError(new FormError('Required.'));
                     }
                 }
             } elseif ($this->client->isMarried()) {
                 $ownerType = $form->get('owners')->get('owner_types')->getData();
                 $choices = ClientAccountOwner::getOwnerTypeChoices();
                 unset($choices[ClientAccountOwner::OWNER_TYPE_OTHER]);
                 if (!$ownerType || !in_array($ownerType, $choices)) {
                     $form->get('owners')->get('owner_types')->addError(new FormError('Select owner of the account.'));
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
 public function getBillItemStatus(ClientAccount $account, $year, $quarter)
 {
     $period = $this->periodManager->getPeriod($year, $quarter);
     $systemAccount = $account->getSystemAccount();
     if (!$systemAccount) {
         return BillItem::STATUS_BILL_IS_NOT_APPLICABLE;
     }
     $activityCheck = $this->em->getRepository('WealthbotClientBundle:ClientAccountValue')->getFirstActivityDate($account);
     if (!$activityCheck || $activityCheck->getDate()->getTimestamp() >= $period['endDate']->getTimestamp()) {
         return BillItem::STATUS_BILL_IS_NOT_APPLICABLE;
     }
     /** @var BillItem $billItem */
     $billItem = $this->em->getRepository('WealthbotClientBundle:BillItem')->getByAccountAndPeriod($account, $year, $quarter);
     if ($billItem) {
         return $billItem->getStatus();
     }
     return BillItem::STATUS_BILL_NOT_GENERATED;
 }
Ejemplo n.º 23
0
 /**
  * @param ObjectManager $manager
  * @param array $data
  * @param User $clientUser
  * @return ClientAccount
  */
 private function createClientAccount(ObjectManager $manager, array $data, User $clientUser)
 {
     $securityRepository = $manager->getRepository('WealthbotAdminBundle:Security');
     $account = new ClientAccount();
     $account->setClient($clientUser);
     $account->setGroupType($this->getReference('client-account-group-type-' . $data['group_type_key']));
     $account->setFinancialInstitution($data['financial_institution']);
     $account->setValue($data['value']);
     $account->setMonthlyContributions($data['monthly_contributions']);
     $account->setMonthlyDistributions($data['monthly_distributions']);
     $account->setSasCash($data['sas_cash']);
     $account->setProcessStep($data['process_step']);
     $account->setStepAction($data['step_action']);
     $account->setIsPreSaved($data['is_pre_saved']);
     $account->setUnconsolidated($data['unconsolidated']);
     if ($data['consolidator_index']) {
         $consolidator = $clientUser->getClientAccounts()->get($data['consolidator_index'] - 1);
         $account->setConsolidator($consolidator);
     }
     foreach ($data['owners'] as $ownerType) {
         $accountOwner = new ClientAccountOwner();
         if ($ownerType === ClientAccountOwner::OWNER_TYPE_SELF) {
             $accountOwner->setClient($clientUser);
         } else {
             $accountOwner->setContact($clientUser->getAdditionalContacts()->first());
         }
         $accountOwner->setOwnerType($ownerType);
         $accountOwner->setAccount($account);
         $account->addAccountOwner($accountOwner);
     }
     $manager->persist($account);
     $manager->flush();
     $manager->refresh($account);
     if (isset($data['account_contribution'])) {
         $accountContribution = new AccountContribution();
         $accountContribution->setAccount($account);
         $accountContribution->setType($data['account_contribution']['type']);
         $accountContribution->setTransactionFrequency($data['account_contribution']['transaction_frequency']);
         $account->setAccountContribution($accountContribution);
         $manager->persist($accountContribution);
     }
     if (isset($data['securities'])) {
         foreach ($data['securities'] as $securityItem) {
             //ToDo: CE-402. Check that code is not needed more.
             //                $security = $securityRepository->findOneBySymbol($securityItem['symbol']);
             //                if (!$security) {
             //                    /** @var SecurityType $securityType */
             //                    $securityType = $this->getReference('security-type-' . $securityItem['type']);
             //
             //                    $security = new Security();
             //                    $security->setName($securityItem['name']);
             //                    $security->setSymbol($securityItem['symbol']);
             //                    $security->setSecurityType($securityType);
             //                    $security->setExpenseRatio($securityItem['exp_ratio']);
             //                }
             //                $securityAssignment = new SecurityAssignment();
             //                $securityAssignment->setSecurity($security);
             //                $securityAssignment->setRia($clientUser->getRia()); Deprecated
             //                $accountOutsideFund = new AccountOutsideFund();
             //                $accountOutsideFund->setAccount($account);
             //                $accountOutsideFund->setSecurityAssignment($securityAssignment);
             //                $accountOutsideFund->setIsPreferred(false);
             //
             //                $manager->persist($accountOutsideFund);
         }
     }
     $manager->persist($account);
     $manager->flush();
     $this->addReference('client-account-' . $account->getId(), $account);
     return $account;
 }
Ejemplo n.º 24
0
 /**
  * Find new consolidator for accounts by old consolidator account object
  *
  * @param ClientAccount $oldConsolidator
  * @return null|ClientAccount
  */
 public function findNewConsolidatorForAccounts(ClientAccount $oldConsolidator)
 {
     $clientId = $oldConsolidator->getClientId() ? $oldConsolidator->getClientId() : $oldConsolidator->getClient()->getId();
     return $this->findNewConsolidatorByClientIdAndSystemTypeAndOwner($clientId, $oldConsolidator->getSystemType(), $oldConsolidator->getOwner(), $oldConsolidator->getId());
 }
Ejemplo n.º 25
0
 /**
  * TODO: deprecated
  * @param ClientAccount $clientAccount
  * @param $year
  * @param $quarter
  * @return float|int
  */
 public function getBillAmount(ClientAccount $clientAccount, $year, $quarter)
 {
     $repo = $this->em->getRepository('WealthbotClientBundle:ClientAccountValue');
     $period = $this->periodManager->getPeriod($year, $quarter);
     $systemAccount = $clientAccount->getSystemAccount();
     $accountValues = $repo->getAverageAccountValues($systemAccount, $period['startDate'], $period['endDate']);
     if ($accountValues['count_values']) {
         $lastDay = $repo->getLastDayByPeriod($systemAccount, $period['startDate'], $period['endDate']);
         $dayInPeriod = $period['endDate']->diff($period['startDate'])->format('%a');
         //TODO: ???
         $fee = $this->getRiaFee($clientAccount, $year, $quarter);
         //TODO: Formula (BillingSpec fee value) * (account value in last day of quarter) * (number of days when account was open) / (number of days in quarter)
         return $fee * $lastDay->getTotalValue() * $accountValues['count_values'] / $dayInPeriod;
     }
     return 0;
 }
Ejemplo n.º 26
0
 private function createClientAccounts(ObjectManager $manager, User $clientUser)
 {
     $lastAccount = null;
     foreach ($this->accounts as $index => $item) {
         /** @var AccountGroupType $groupType */
         $groupType = $this->getReference('client-account-group-type-' . $item['group_key'] . '-' . $item['type_key']);
         $account = new ClientAccount();
         $account->setGroupType($groupType);
         $account->setClient($clientUser);
         $account->setFinancialInstitution($item['financial_institution']);
         $account->setValue($item['value']);
         $account->setMonthlyContributions($item['monthly_contributions']);
         $account->setMonthlyDistributions($item['monthly_distributions']);
         $account->setSasCash($item['sas_cash']);
         $accountOwner = new ClientAccountOwner();
         $accountOwner->setAccount($account);
         $accountOwner->setClient($clientUser);
         $accountOwner->setOwnerType(ClientAccountOwner::OWNER_TYPE_SELF);
         if (isset($item['consolidator_key']) && null !== $item['consolidator_key']) {
             /** @var ClientAccount $consolidator */
             $consolidator = $this->getReference('user-client-account-' . $item['consolidator_key']);
             $account->setConsolidator($consolidator);
         }
         if (isset($item['funds']) && $item['group_key'] === AccountGroup::GROUP_EMPLOYER_RETIREMENT) {
             foreach ($item['funds'] as $fundItem) {
                 //                    ToDo: CE-402: check that code is not needed more
                 //                    $outsideFund = $manager->getRepository('WealthbotAdminBundle:Security')->findOneBySymbol($fundItem['symbol']);
                 //                    if (!$outsideFund) {
                 //                        /** @var SecurityType $securityType */
                 //                        $securityType = $this->getReference('security-type-' . $fundItem['type']);
                 //
                 //                        $outsideFund = new Security();
                 //                        $outsideFund->setName($fundItem['name']);
                 //                        $outsideFund->setSymbol($fundItem['symbol']);
                 //                        $outsideFund->setSecurityType($securityType);
                 //                        $outsideFund->setExpenseRatio($fundItem['exp_ratio']);
                 //                    }
                 //                    $securityAssignment = new SecurityAssignment();
                 //                    $securityAssignment->setSecurity($outsideFund);
                 //                    $securityAssignment->setRia($clientUser->getRia());  Deprecated
                 //                    $securityAssignment->setIsPreferred(false);
                 //                    $accountOutsideFund = new AccountOutsideFund();
                 //                    $accountOutsideFund->setAccount($account);
                 //                    $accountOutsideFund->setSecurityAssignment($securityAssignment);
                 //                    $accountOutsideFund->setIsPreferred(false);
                 //                    $account->addAccountOutsideFund($accountOutsideFund);
                 //
                 //                    $manager->persist($accountOutsideFund);
             }
         }
         $manager->persist($account);
         $manager->persist($accountOwner);
         $this->addReference('user-client-account-' . ($index + 1), $account);
         if (!$account->isRetirementType()) {
             $lastAccount = $account;
         }
     }
     if ($lastAccount) {
         $systemAccount = new SystemAccount();
         $systemAccount->setClient($clientUser);
         $systemAccount->setClientAccount($lastAccount);
         $systemAccount->setAccountNumber('916985328');
         $systemAccount->setAccountDescription($lastAccount->getOwnersAsString() . ' ' . $lastAccount->getTypeName());
         $systemAccount->setType($lastAccount->getSystemType());
         $systemAccount->setSource(SystemAccount::SOURCE_SAMPLE);
         $clientUser->addSystemAccount($systemAccount);
         $this->addReference('system-account', $systemAccount);
         $manager->persist($systemAccount);
     }
 }
Ejemplo n.º 27
0
 public function sendClientRolloverInstruction401Email(ClientAccount $account, $rolloverMessage)
 {
     $template = $this->parameters['template']['client_rollover_instruction_401'];
     $client = $account->getClient();
     $ria = $client->getRia();
     $context = array('account' => $account, 'ria' => $ria, 'rollover_message' => $rolloverMessage, 'logo' => $this->getRiaLogo($ria->getId()));
     $this->sendMessage($template, $this->parameters['from_email']['client_rollover_instruction_401'], $client->getEmail(), $context);
 }