/**
  * @return array
  */
 private function getBeneficiariesInformationTabs()
 {
     $tabs = array();
     $primary = 0;
     $alternative = 0;
     /** @var Beneficiary[] $accountBeneficiaries */
     $accountBeneficiaries = $this->beneficiary->getAccount()->getBeneficiaries();
     foreach ($accountBeneficiaries as $beneficiary) {
         if ($beneficiary->isPrimary()) {
             $primary++;
             $prefix = 'beneficiary_' . $primary . '_';
         } else {
             $alternative++;
             $prefix = 'alternative_beneficiary_' . $alternative . '_';
         }
         $nameTab = new TextTab();
         $nameTab->setTabLabel($prefix . 'name')->setValue($beneficiary->getFullName());
         $tabs[] = $nameTab;
         $relationshipTab = new TextTab();
         $relationshipTab->setTabLabel($prefix . 'relationship')->setValue($beneficiary->getRelationship());
         $tabs[] = $relationshipTab;
         $birthDateTab = new TextTab();
         $birthDateTab->setTabLabel($prefix . 'birth_date')->setValue($beneficiary->getBirthDate()->format('m-d-Y'));
         $tabs[] = $birthDateTab;
         $ssnTab = new TextTab();
         $ssnTab->setTabLabel($prefix . 'ssn')->setValue($beneficiary->getSsn());
         $tabs[] = $ssnTab;
         $shareTab = new TextTab();
         $shareTab->setTabLabel($prefix . 'share')->setValue($beneficiary->getShare());
         $tabs[] = $shareTab;
     }
     return $tabs;
 }
Exemplo n.º 2
0
 private function createClientBeneficiary(array $data, ClientAccount $account)
 {
     $beneficiary = new Beneficiary();
     $beneficiary->setAccount($account);
     $beneficiary->setType($data['type']);
     $beneficiary->setState($this->getReference('state-' . $data['state']));
     $beneficiary->setFirstName($data['first_name']);
     $beneficiary->setLastName($data['last_name']);
     $beneficiary->setMiddleName($data['middle_name']);
     $beneficiary->setSsn($data['ssn']);
     $beneficiary->setBirthDate(new \DateTime($data['birth_date']));
     $beneficiary->setStreet($data['street']);
     $beneficiary->setCity($data['city']);
     $beneficiary->setZip($data['zip']);
     $beneficiary->setRelationship($data['relationship']);
     $beneficiary->setShare($data['share']);
     return $beneficiary;
 }
Exemplo n.º 3
0
 private function buildBeneficiaryByClient(User $client)
 {
     $spouse = $client->getSpouse();
     $profile = $client->getProfile();
     $beneficiary = new Beneficiary();
     $beneficiary->setFirstName($spouse->getFirstName());
     $beneficiary->setMiddleName($spouse->getMiddleName());
     $beneficiary->setLastName($spouse->getLastName());
     $beneficiary->setBirthDate($spouse->getBirthDate());
     $beneficiary->setStreet($profile->getStreet());
     $beneficiary->setState($profile->getState());
     $beneficiary->setCity($profile->getCity());
     $beneficiary->setZip($profile->getZip());
     $beneficiary->setRelationship('Spouse');
     $beneficiary->setShare(100);
     return $beneficiary;
 }
Exemplo n.º 4
0
 public function validate(FormEvent $event)
 {
     /** @var $data Beneficiary */
     $form = $event->getForm();
     $data = $event->getData();
     $type = $data->getType();
     $firstName = $data->getFirstName();
     $middleName = $data->getMiddleName();
     $lastName = $data->getLastName();
     $birthDate = $data->getBirthDate();
     $city = $data->getCity();
     $street = $data->getStreet();
     $state = $data->getState();
     $relationship = $data->getRelationship();
     $share = $data->getShare();
     if (!array_key_exists($type, Beneficiary::getTypeChoices())) {
         $form->get('type')->addError(new FormError('Choose an option.'));
     }
     if (null === $firstName || !is_string($firstName)) {
         $form->get('first_name')->addError(new FormError('Required.'));
     }
     if (!preg_match('/[A-Za-z]/', $middleName)) {
         $form->get('middle_name')->addError(new FormError('Enter least 1 letter.'));
     }
     if (null === $lastName || !is_string($lastName)) {
         $form->get('last_name')->addError(new FormError('Required.'));
     }
     if (!$birthDate instanceof \DateTime) {
         $form->get('birth_date')->addError(new FormError('Enter correct date.'));
     }
     if (null === $city || !is_string($city)) {
         $form->get('city')->addError(new FormError('Required.'));
     }
     if (null === $street || !is_string($street)) {
         $form->get('street')->addError(new FormError('Required.'));
     }
     if (null === $state) {
         $form->get('state')->addError(new FormError('Required.'));
     }
     if (null === $relationship || !is_string($relationship)) {
         $form->get('relationship')->addError(new FormError('Required.'));
     }
     if (null == $share || !is_numeric($share)) {
         $form->get('relationship')->addError(new FormError('Enter correct value.'));
     }
     if (round($share) < 0.01 || round($share) > 100) {
         $form->get('relationship')->addError(new FormError('Value must be in range between 0.01 and 100'));
     }
     if ($form->has('zip')) {
         $zipDigits = 5;
         $zip = str_replace(array(' ', '-'), '', $data->getZip());
         if (!is_numeric($zip)) {
             $form->get('zip')->addError(new FormError("Enter correct zip code."));
         } elseif (strlen($zip) != $zipDigits) {
             $form->get('zip')->addError(new FormError("Zip code must be {$zipDigits} digits."));
         } else {
             $data->setZip($zip);
         }
     }
 }
Exemplo n.º 5
0
 public function addBeneficiaryAction(Request $request)
 {
     /** @var $em EntityManager */
     /** @var $repo SystemAccountRepository */
     /** @var $beneficiaryRepo BeneficiaryRepository */
     $em = $this->get('doctrine.orm.entity_manager');
     $repo = $em->getRepository('WealthbotClientBundle:SystemAccount');
     $beneficiaryRepo = $em->getRepository('WealthbotClientBundle:Beneficiary');
     $signatureManager = $this->get('wealthbot_docusign.document_signature.manager');
     $client = $this->getUser();
     /** @var $account SystemAccount */
     $account = $repo->find($request->get('account_id'));
     if (!$account || $account->getClientId() != $client->getId()) {
         return $this->getJsonResponse(array('status' => 'error', 'message' => sprintf('You have not account id: %s.', $account->getId())));
     }
     $clientAccount = $account->getClientAccount();
     $beneficiary = new Beneficiary();
     $beneficiary->setAccount($clientAccount);
     $form = $this->createForm(new BeneficiaryFormType(false, true), $beneficiary);
     if ($request->isMethod('post')) {
         $form->bind($request);
         if ($form->isValid()) {
             /** @var Beneficiary $beneficiary */
             $beneficiary = $form->getData();
             $shareSum = $beneficiaryRepo->getBeneficiariesShareForAccount($clientAccount, $beneficiary->getType());
             if (round($beneficiary->getShare()) + $shareSum > 100) {
                 $form->get('share')->addError(new FormError('Beneficiary share can not be more then 100%.'));
             } else {
                 $em->persist($beneficiary);
                 $em->flush();
                 $this->get('wealthbot_docusign.document_signature.manager')->createSignature($beneficiary);
                 $event = new WorkflowEvent($client, $beneficiary, Workflow::TYPE_PAPERWORK);
                 $this->get('event_dispatcher')->dispatch(ClientEvents::CLIENT_WORKFLOW, $event);
                 $this->dispatchHistoryEvent($client, 'Created beneficiary');
                 return $this->getJsonResponse(array('status' => 'success', 'form' => $this->renderView('WealthbotClientBundle:Dashboard:_beneficiaries_sign.html.twig', array('signatures' => $signatureManager->findChangeBeneficiaryByClientAccount($clientAccount), 'account' => $account)), 'content' => $this->renderView('WealthbotClientBundle:Dashboard:_beneficiary_row.html.twig', array('account' => $account, 'beneficiary' => $beneficiary))));
             }
         }
         return $this->getJsonResponse(array('status' => 'error', 'content' => $this->renderView('WealthbotClientBundle:Dashboard:_beneficiary_form.html.twig', array('form' => $form->createView(), 'account' => $account))));
     }
     return $this->getJsonResponse(array('status' => 'success', 'content' => $this->renderView('WealthbotClientBundle:Dashboard:_beneficiary_form.html.twig', array('form' => $form->createView(), 'account' => $account))));
 }