Ejemplo n.º 1
0
 /**
  * Get client status as string
  *
  * @return int
  * @throws \RuntimeException
  */
 public function getClientStatusAsString()
 {
     if (!$this->hasRole("ROLE_CLIENT")) {
         throw new \RuntimeException('User dose not have role: ROLE_CLIENT');
     }
     return $this->profile->getClientStatusAsString();
 }
Ejemplo n.º 2
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->factory = $builder->getFormFactory();
     $builder->add('firstName', 'text', array('attr' => array('class' => 'input-medium', 'placeholder' => 'First Name'), 'required' => false))->add('middleName', 'text', array('attr' => array('class' => 'input-small', 'placeholder' => 'Middle Name'), 'required' => false))->add('lastName', 'text', array('attr' => array('class' => 'input-medium', 'placeholder' => 'Last Name'), 'required' => false))->add('birthDate', 'date', array('attr' => array('class' => 'jq-ce-date input-small', 'placeholder' => 'MM-DD-YYYY'), 'format' => 'MM-dd-yyyy', 'label' => 'Birth Date', 'required' => false, 'widget' => 'single_text'))->add('citizenship', 'choice', array('choices' => array('1' => 'Yes', '0' => 'No'), 'data' => 1, 'expanded' => true, 'label' => 'U.S. citizen?', 'property_path' => false, 'constraints' => array(new True(array('message' => 'Spouse of your client should be U.S. citizen.')))));
     $builder->add('employmentType', 'choice', array('choices' => Profile::getEmploymentTypeChoices(), 'expanded' => true, 'label' => 'Employment Status', 'multiple' => false, 'required' => true))->add('employerName', 'text', array('attr' => array('class' => 'input-medium'), 'label' => 'Employer Name', 'required' => false))->add('industry', 'text', array('attr' => array('class' => 'input-medium'), 'required' => false))->add('occupation', 'text', array('attr' => array('class' => 'input-medium'), 'required' => false))->add('businessType', 'text', array('attr' => array('class' => 'input-medium'), 'label' => 'Type of Business', 'required' => false))->add('employerAddress', 'text', array('attr' => array('class' => 'input-large'), 'label' => 'Employer Address', 'required' => false))->add('employmentCity', 'text', array('attr' => array('class' => 'input-medium'), 'label' => 'Employment City', 'required' => false))->add('employmentState', 'entity', array('attr' => array('class' => 'input-medium'), 'class' => 'WealthbotAdminBundle:State', 'label' => 'State', 'empty_value' => 'Select a State', 'required' => false))->add('employmentZip', 'text', array('attr' => array('class' => 'input-mini'), 'label' => 'Zip Code', 'required' => false));
     $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData'));
     $builder->addEventListener(FormEvents::BIND, array($this, 'onBindData'));
 }
Ejemplo n.º 3
0
 public function stepOneAction(Request $request)
 {
     /** @var \Doctrine\ORM\EntityManager $em */
     $em = $this->get('doctrine.orm.entity_manager');
     /** @var User $user */
     $user = $this->getUser();
     $profile = $user->getProfile();
     if (!$profile) {
         $profile = new Profile();
         $profile->setUser($user);
     }
     $isPreSave = $request->isXmlHttpRequest() || $request->get('is_pre_save');
     $form = $this->createForm(new ClientProfileFormType($isPreSave), $profile);
     if ($request->isMethod("post")) {
         $form->bind($request);
         if ($form->isValid()) {
             $profile = $form->getData();
             $spouse = $user->getSpouse();
             if ($profile->getMaritalStatus() === Profile::CLIENT_MARITAL_STATUS_MARRIED) {
                 $spouse->setClient($user);
             } else {
                 $user->removeAdditionalContact($spouse);
                 $em->remove($spouse);
             }
             if (!$isPreSave) {
                 $profile->setRegistrationStep(1);
             }
             $em->persist($profile);
             $em->persist($user);
             $em->flush();
             if ($isPreSave && $request->isXmlHttpRequest()) {
                 return $this->getJsonResponse(array('status' => 'success'));
             }
             if ($profile->getClientSource() == Profile::CLIENT_SOURCE_IN_HOUSE) {
                 $redirectUrl = $this->generateUrl("rx_client_portfolio");
             } else {
                 $redirectUrl = $this->generateUrl("rx_client_profile_step_two");
             }
             return $this->redirect($redirectUrl);
         } elseif ($isPreSave && $request->isXmlHttpRequest()) {
             return $this->getJsonResponse(array('status' => 'error'));
         }
     }
     return $this->render('WealthbotClientBundle:Profile:step_one.html.twig', array('form' => $form->createView(), 'ria_company_information' => $user->getProfile()->getRia()->getRiaCompanyInformation()));
 }
Ejemplo n.º 4
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);
 }
 private function validateOwnerInformation(FormInterface $form, $data)
 {
     if ($form->has('first_name') && !$data->getFirstName()) {
         $form->get('first_name')->addError(new FormError('Required.'));
     }
     if ($form->has('middle_name') && !preg_match('/[A-Za-z]/', $data->getMiddleName())) {
         $form->get('middle_name')->addError(new FormError('Enter least 1 letter.'));
     }
     if ($form->has('last_name') && !$data->getLastName()) {
         $form->get('last_name')->addError(new FormError('Required.'));
     }
     if ($form->has('street') && !$data->getStreet()) {
         $form->get('street')->addError(new FormError('Required.'));
     }
     if ($form->has('city') && !$data->getCity()) {
         $form->get('city')->addError(new FormError('Required.'));
     }
     if ($form->has('state') && !$data->getState()) {
         $form->get('state')->addError(new FormError('Required.'));
     }
     if ($form->has('estimated_income_tax') && !$data->getEstimatedIncomeTax()) {
         $form->get('estimated_income_tax')->addError(new FormError('Required.'));
     }
     // Choices validation
     if ($form->has('marital_status') && !in_array($data->getMaritalStatus(), Profile::getMaritalStatusChoices())) {
         $form->get('marital_status')->addError(new FormError('Required.'));
     }
     if ($form->has('annual_income') && !in_array($data->getAnnualIncome(), Profile::getAnnualIncomeChoices())) {
         $form->get('annual_income')->addError(new FormError('Required.'));
     }
     if ($form->has('liquid_net_worth') && !in_array($data->getLiquidNetWorth(), array_keys(Profile::getLiquidNetWorthChoices()))) {
         $form->get('liquid_net_worth')->addError(new FormError('Required.'));
     }
     if ($form->has('employment_type') && !in_array($data->getEmploymentType(), array_keys(Profile::getEmploymentTypeChoices()))) {
         $form->get('employment_type')->addError(new FormError('Required.'));
     }
     if ($form->has('birth_date')) {
         $birthDateData = $form->get('birth_date')->getData();
         if ($birthDateData && $birthDateData instanceof \DateTime) {
             $year = (int) $birthDateData->format('Y');
             if ($year < 1900) {
                 $form->get('birth_date')->addError(new FormError('year must start with 19 or 20 e.g. 1980'));
             }
         } else {
             $form->get('birth_date')->addError(new FormError('date format must be MM-DD-YYYY'));
         }
     }
 }
Ejemplo n.º 6
0
 private function createUser(User $riaUser)
 {
     $clientUser = new User();
     $clientUser->setUsername('client');
     $clientUser->setEmail('*****@*****.**');
     $clientUser->setPlainPassword('client');
     $clientUser->setEnabled(true);
     $clientUser->setRoles(array('ROLE_CLIENT'));
     $clientUserProfile = new Profile();
     $clientUserProfile->setUser($clientUser);
     $clientUserProfile->setFirstName('ClientFirst');
     $clientUserProfile->setLastName('ClientLast');
     $clientUserProfile->setMiddleName('C');
     $clientUserProfile->setRegistrationStep(3);
     $clientUserProfile->setRia($riaUser);
     $clientUserProfile->setStatusProspect();
     $clientUser->setProfile($clientUserProfile);
     $clientSettings = new ClientSettings();
     $clientUser->setClientSettings($clientSettings);
     $clientSettings->setClient($clientUser);
     return $clientUser;
 }
Ejemplo n.º 7
0
 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;
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $client = $builder->getData();
     $this->factory = $builder->getFormFactory();
     /** @var \Wealthbot\UserBundle\Entity\User $ria */
     $ria = $client->getRia();
     $groups = array();
     foreach ($ria->getOwnGroups() as $group) {
         $groups[$group->getId()] = $group->getName();
     }
     $selectedGroupId = 0;
     $selectedGroup = $client->getGroups()->first();
     if ($selectedGroup) {
         $selectedGroupId = $selectedGroup->getId();
     }
     $builder->add('rebalancingLevel', 'choice', array('attr' => array('class' => 'input-medium'), 'choices' => Profile::$client_account_managed_choices, 'label' => 'Rebalancing Level: ', 'property_path' => 'profile.clientAccountManaged'));
     $builder->add('annualIncome', 'choice', array('attr' => array('class' => 'input-large'), 'choices' => Profile::getAnnualIncomeChoices(), 'empty_value' => 'Choose an Option', 'label' => 'Annual Income', 'property_path' => 'profile.annualIncome'))->add('estimatedIncomeTax', 'percent', array('attr' => array('class' => 'input-mini'), 'precision' => 0, 'required' => false, 'label' => 'Income tax bracket', 'property_path' => 'profile.estimatedIncomeTax'))->add('liquidNetWorth', 'choice', array('attr' => array('class' => 'input-large'), 'choices' => Profile::getLiquidNetWorthChoices(), 'empty_value' => 'Choose an Option', 'label' => 'Liquid Net Worth', 'property_path' => 'profile.liquidNetWorth'))->add('group', 'choice', array('attr' => array('class' => 'input-medium'), 'choices' => $groups, 'data' => $selectedGroupId, 'empty_value' => '', 'label' => 'Advisor Set: ', 'property_path' => false));
     $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPresetData'));
     $builder->addEventListener(FormEvents::BIND, array($this, 'onBindData'));
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $data = $builder->getData();
     $isExist = $data->getId();
     $builder->remove('citezen')->remove('ssn_tin_1')->remove('ssn_tin_2')->remove('ssn_tin_3')->remove('is_senior_political_figure')->remove('senior_spf_name')->remove('senior_political_title')->remove('senior_account_owner_relationship')->remove('senior_country_office')->remove('is_publicly_traded_company')->remove('publicle_company_name')->remove('publicle_address')->remove('publicle_city')->remove('publicleState')->remove('is_broker_security_exchange_person')->remove('broker_security_exchange_company_name')->remove('compliance_letter_file')->add('email', 'email')->add('first_name', 'text', array('required' => false, 'disabled' => true))->add('middle_name', 'text', array('required' => false, 'disabled' => true))->add('last_name', 'text', array('required' => false, 'disabled' => true))->add('birth_date', 'date', array('widget' => 'single_text', 'format' => 'MM-dd-yyyy', 'required' => true, 'disabled' => true, 'attr' => array('class' => 'jq-date input-small')))->add('citizenship', 'choice', array('choices' => array(1 => 'Yes', 0 => 'No'), 'expanded' => true, 'multiple' => false, 'required' => false, 'property_path' => false, 'data' => $isExist ? 1 : null, 'label' => $data && $data->getMaritalStatus() == 'Married' ? 'Are you and your spouse both U.S. citizens?' : 'Are you a U.S. citizen?', 'disabled' => true))->add('marital_status', 'choice', array('choices' => Profile::getMaritalStatusChoices(), 'empty_value' => 'Choose an Option', 'required' => false))->add('phone_number', 'text', array('required' => false))->add('spouse', new ClientSpouseFormType())->add('annual_income', 'choice', array('choices' => Profile::getAnnualIncomeChoices(), 'empty_value' => 'Choose an Option', 'required' => false))->add('estimated_income_tax', 'percent', array('precision' => 0, 'required' => false, 'label' => 'What is your estimated income tax bracket?'))->add('liquid_net_worth', 'choice', array('choices' => Profile::getLiquidNetWorthChoices(), 'empty_value' => 'Choose an Option', 'required' => false));
     $formFactory = $builder->getFormFactory();
     $builder->addEventListener(FormEvents::PRE_BIND, function (FormEvent $event) use($formFactory) {
         $form = $event->getForm();
         $data = $event->getData();
         if ($data === null) {
             return;
         }
         if (isset($data['marital_status'])) {
             $form->remove('citizenship');
             $form->add($formFactory->createNamed('citizenship', 'choice', null, array('choices' => array(1 => 'Yes', 0 => 'No'), 'expanded' => true, 'multiple' => false, 'required' => false, 'property_path' => false, 'data' => isset($data['id']) ? 1 : null, 'label' => $data['marital_status'] == 'Married' ? 'Are you and your spouse both U.S. citizens?' : 'Are you a U.S. citizen?', 'disabled' => true)));
         }
     });
     $builder->addEventListener(FormEvents::BIND, array($this, 'changeProfileValidate'));
 }
Ejemplo n.º 10
0
 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;
 }
Ejemplo n.º 11
0
 public function validate(FormEvent $event)
 {
     /** @var \Wealthbot\UserBundle\Entity\Profile $data */
     $data = $event->getData();
     $form = $event->getForm();
     if ($form->has('first_name') && !$data->getFirstName()) {
         $form->get('first_name')->addError(new FormError('Required.'));
     }
     if ($form->has('last_name') && !$data->getLastName()) {
         $form->get('last_name')->addError(new FormError('Required.'));
     }
     if ($form->has('street') && !$data->getStreet()) {
         $form->get('street')->addError(new FormError('Required.'));
     }
     if ($form->has('city') && !$data->getCity()) {
         $form->get('city')->addError(new FormError('Required.'));
     }
     if ($form->has('state') && !$data->getState()) {
         $form->get('state')->addError(new FormError('Required.'));
     }
     if ($form->has('estimated_income_tax') && !$data->getEstimatedIncomeTax()) {
         $form->get('estimated_income_tax')->addError(new FormError('Required.'));
     }
     // Choices validation
     if ($form->has('marital_status') && !in_array($data->getMaritalStatus(), Profile::getMaritalStatusChoices())) {
         $form->get('marital_status')->addError(new FormError('Required.'));
     }
     if ($form->has('annual_income') && !in_array($data->getAnnualIncome(), Profile::getAnnualIncomeChoices())) {
         $form->get('annual_income')->addError(new FormError('Required.'));
     }
     if ($form->has('liquid_net_worth') && !in_array($data->getLiquidNetWorth(), array_keys(Profile::getLiquidNetWorthChoices()))) {
         $form->get('liquid_net_worth')->addError(new FormError('Required.'));
     }
     if ($form->has('employment_type') && !in_array($data->getEmploymentType(), array_keys(Profile::getEmploymentTypeChoices()))) {
         $form->get('employment_type')->addError(new FormError('Required.'));
     }
     if ($form->has('birth_date')) {
         $birthDateData = $form->get('birth_date')->getData();
         if ($birthDateData && $birthDateData instanceof \DateTime) {
             $year = (int) $birthDateData->format('Y');
             if ($year < 1900) {
                 $form->get('birth_date')->addError(new FormError('year must start with 19 or 20 e.g. 1980'));
             }
         } else {
             $form->get('birth_date')->addError(new FormError('date format must be MM-DD-YYYY'));
         }
     }
     if ($form->has('spouse') && $data->getMaritalStatus() === Profile::CLIENT_MARITAL_STATUS_MARRIED) {
         /** @var ClientAdditionalContact $spouse */
         $spouse = $form->get('spouse')->getData();
         $phoneNum = str_replace(array(' ', '-', '(', ')'), '', $data->getPhoneNumber());
         $spouseValidator = new ClientSpouseFormValidator($form->get('spouse'), $data->getUser()->getSpouse());
         $spouseValidator->validate();
         $spouse->setSpouseFirstName($data->getFirstName());
         $spouse->setSpouseMiddleName($data->getMiddleName());
         $spouse->setSpouseLastName($data->getLastName());
         $spouse->setSpouseBirthDate($data->getBirthDate());
         $spouse->setState($data->getState());
         $spouse->setCity($data->getCity());
         $spouse->setStreet($data->getStreet());
         $spouse->setZip($data->getZip());
         $spouse->setPhoneNumber($phoneNum);
         $spouse->setType(ClientAdditionalContact::TYPE_SPOUSE);
         $spouse->setMaritalStatus(Profile::CLIENT_MARITAL_STATUS_MARRIED);
     }
 }
Ejemplo n.º 12
0
 public function getPaymentMethod()
 {
     return $this->profile->getPaymentMethod();
 }
Ejemplo n.º 13
0
 /**
  * @param $sheet
  * @param $ria
  * @param $clients
  * @param $year
  * @param $quarter
  * @return mixed
  */
 protected function billTable($sheet, $ria, $clients, $year, $quarter)
 {
     $index = 9;
     // Set table head background
     $sheet->getStyle("A{$index}:K{$index}")->getFill()->applyFromArray(array('type' => \PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => '8EB4E3')));
     $totals = "";
     $totalCell = "K{$index}";
     foreach ($clients as $client) {
         // Get client accounts
         $clientAccounts = $this->summaryInformationManager->getAccountsInformationByClient($client, $year, $quarter);
         foreach ($clientAccounts as $account) {
             $index++;
             $clientAccount = $this->em->getRepository('WealthbotClientBundle:ClientAccount')->find($account['id']);
             $billItem = $this->em->getRepository('WealthbotClientBundle:BillItem')->getByAccountAndPeriod($clientAccount, $year, $quarter);
             $sheet->setCellValue("A{$index}", $client->getLastName());
             $sheet->setCellValue("B{$index}", $client->getFirstName());
             $sheet->setCellValue("C{$index}", SystemAccount::getTypeName($account['type']));
             $sheet->setCellValue("D{$index}", $account['number']);
             $sheet->setCellValue("E{$index}", $client->getFeeShedule());
             $sheet->setCellValue("F{$index}", Profile::getPaymentMethodName($client->getPaymentMethod()));
             $sheet->setCellValue("G{$index}", $account['averageAccountValue']);
             $sheet->setCellValue("H{$index}", $account['daysInPortfolio']);
             $sheet->setCellValue("I{$index}", empty($billItem) ? 0 : $billItem->getAdminFee());
             $sheet->setCellValue("J{$index}", empty($billItem) ? 0 : $billItem->getRiaFee());
             $sheet->setCellValue("K{$index}", "=SUM(I{$index}:J{$index})");
             // Set currency USD format
             $sheet->getStyle("G{$index}")->applyFromArray(array('numberformat' => array('code' => \PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD)));
             $sheet->getStyle("I{$index}:K{$index}")->applyFromArray(array('numberformat' => array('code' => \PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD)));
             $font = $sheet->getStyle("A{$index}:K{$index}")->getFont();
             $font->setName('Arial')->setSize(10);
             // Save total cell
             $totals .= "K{$index},";
             // Set table body background
             $sheet->getStyle("A{$index}:K{$index}")->getFill()->applyFromArray(array('type' => \PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'DCE6F2')));
         }
     }
     // Calculate total
     $sheet->setCellValue($totalCell, "=SUM(" . substr($totals, 0, -1) . ")");
     $sheet->getStyle($totalCell)->getFont()->setBold(true);
     $sheet->getStyle($totalCell)->applyFromArray(array('numberformat' => array('code' => \PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD)));
     return $sheet;
 }
 protected function validateMaritalStatus(FormInterface $form)
 {
     if ($form->has('marital_status')) {
         $maritalStatus = $form->get('marital_status')->getData();
         if (!in_array($maritalStatus, Profile::getMaritalStatusChoices())) {
             $form->get('marital_status')->addError(new FormError('Required.'));
         }
         if ($maritalStatus == Profile::CLIENT_MARITAL_STATUS_MARRIED) {
             if ($form->has('spouse_first_name')) {
                 $firstName = $form->get('spouse_first_name')->getData();
                 if (is_null($firstName) || !is_string($firstName)) {
                     $form->get('spouse_first_name')->addError(new FormError('Enter first name.'));
                 }
             }
             if ($form->has('spouse_last_name')) {
                 $firstName = $form->get('spouse_last_name')->getData();
                 if (is_null($firstName) || !is_string($firstName)) {
                     $form->get('spouse_last_name')->addError(new FormError('Enter last name.'));
                 }
             }
             if ($form->has('spouse_last_name')) {
                 $minYears = 18;
                 $birthDate = $form->get('spouse_birth_date')->getData();
                 if (!$birthDate) {
                     $form->get('spouse_birth_date')->addError(new FormError('Enter spouse date of birth.'));
                 } else {
                     $nowDate = new \DateTime('now');
                     $interval = $nowDate->diff($birthDate);
                     if ((int) $interval->format('%y%') < $minYears) {
                         $form->get('spouse_birth_date')->addError(new FormError("Your spouse must be at least {$minYears} years old."));
                     }
                 }
             }
         }
     }
 }
 /**
  * Submit client suggested portfolio
  *
  * @param Profile $profile
  */
 private function submit(Profile $profile)
 {
     $proposedPortfolio = $this->form->get('client')->get('portfolio')->getData();
     $client = $profile->getUser();
     $riaCompanyInfo = $client->getRiaCompanyInformation();
     //$client->submitFinalPortfolio();
     $this->clientPortfolioManager->approveProposedPortfolio($client, $proposedPortfolio);
     $profile->setRegistrationStep(4);
     // If client account managed is null set ria account managed for client
     if (null === $profile->getClientAccountManaged() && $riaCompanyInfo) {
         $profile->setClientAccountManaged($riaCompanyInfo->getAccountManaged());
     }
     $this->em->persist($client);
     $this->em->flush();
     $mailer = $this->getOption('mailer');
     if ($mailer instanceof MailerInterface) {
         $mailer->sendClientPortfolioIsSubmittedEmail($client);
     }
 }