/**
  * Create account owner with type = 'other'
  * and returns array
  *
  * @param ClientAdditionalContact $otherContact
  * @return array
  */
 private function createOtherAccountOwner(ClientAdditionalContact $otherContact)
 {
     /** @var ClientAdditionalContactRepository $repo */
     $repo = $this->em->getRepository('WealthbotClientBundle:ClientAdditionalContact');
     $exist = $repo->findOneBy(array('client_id' => $this->client->getId(), 'first_name' => $otherContact->getFirstName(), 'middle_name' => $otherContact->getMiddleName(), 'last_name' => $otherContact->getLastName(), 'relationship' => $otherContact->getRelationship(), 'type' => ClientAdditionalContact::TYPE_OTHER));
     if ($exist) {
         $otherContact = $exist;
     }
     $otherContact->setType(ClientAccountOwner::OWNER_TYPE_OTHER);
     $otherContact->setClient($this->client);
     $this->em->persist($otherContact);
     $this->em->flush();
     $owner = array('owner_type' => ClientAccountOwner::OWNER_TYPE_OTHER, 'owner_contact_id' => $otherContact->getId());
     return $owner;
 }
 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();
 }
 private function createClientAdditionalContact(array $data, User $clientUser)
 {
     $additionalContact = new ClientAdditionalContact();
     $additionalContact->setClient($clientUser);
     if ($data['state']) {
         $additionalContact->setState($this->getReference('state-' . $data['state']));
     }
     $additionalContact->setFirstName($data['first_name']);
     $additionalContact->setLastName($data['last_name']);
     $additionalContact->setMiddleName($data['middle_name']);
     $additionalContact->setStreet($data['street']);
     $additionalContact->setCity($data['city']);
     $additionalContact->setZip($data['zip']);
     $additionalContact->setIsDifferentAddress($data['is_different_address']);
     $additionalContact->setBirthDate(new \DateTime($data['birth_date']));
     $additionalContact->setPhoneNumber($data['phone_number']);
     $additionalContact->setSsnTin($data['ssn_tin']);
     $additionalContact->setIncomeSource($data['income_source']);
     $additionalContact->setIsSeniorPoliticalFigure($data['is_senior_political_figure']);
     $additionalContact->setIsPubliclyTradedCompany($data['is_publicly_traded_company']);
     $additionalContact->setIsBrokerSecurityExchangePerson($data['is_broker_security_exchange_person']);
     $additionalContact->setEmail($data['email']);
     $additionalContact->setType($data['type']);
     $additionalContact->setEmploymentType($data['employment_type']);
     return $additionalContact;
 }
Exemple #4
0
 /**
  * Create new spouse object for user
  *
  * @return ClientAdditionalContact
  */
 public function createSpouseObject()
 {
     $spouse = new ClientAdditionalContact();
     $spouse->setSpouseFirstName($this->getFirstName());
     $spouse->setSpouseMiddleName($this->getMiddleName());
     $spouse->setSpouseLastName($this->getLastName());
     $spouse->setSpouseBirthDate($this->getBirthDate());
     $spouse->setCity($this->getCity());
     $spouse->setStreet($this->getStreet());
     $spouse->setState($this->getState());
     $spouse->setZip($this->getZip());
     $spouse->setPhoneNumber($this->getPhoneNumber());
     $spouse->setMaritalStatus(Profile::CLIENT_MARITAL_STATUS_MARRIED);
     $spouse->setType(ClientAdditionalContact::TYPE_SPOUSE);
     return $spouse;
 }
 public function setSpouse(\Wealthbot\ClientBundle\Entity\ClientAdditionalContact $spouse)
 {
     $spouse->setClient($this->user);
     $this->user->setSpouse($spouse);
 }
 /**
  * Create and save new client account owner
  *
  * @param ClientAccount $account
  * @param $ownerType
  * @return ClientAccountOwner
  */
 private function createAccountOwnerByType(ClientAccount $account, $ownerType)
 {
     $owner = new ClientAccountOwner();
     $owner->setOwnerType($ownerType);
     $owner->setAccount($account);
     switch ($ownerType) {
         case ClientAccountOwner::OWNER_TYPE_SELF:
             $owner->setClient($account->getClient());
             break;
         case ClientAccountOwner::OWNER_TYPE_SPOUSE:
             $owner->setContact($account->getClient()->getSpouse());
             break;
         case ClientAccountOwner::OWNER_TYPE_OTHER:
             $contactData = $this->getOtherContact();
             $existContact = $this->em->getRepository('WealthbotClientBundle:ClientAdditionalContact')->findOneBy(array('client_id' => $account->getClientId(), 'first_name' => $contactData->getFirstName(), 'middle_name' => $contactData->getMiddleName(), 'last_name' => $contactData->getLastName(), 'relationship' => $contactData->getRelationship(), 'type' => ClientAccountOwner::OWNER_TYPE_OTHER));
             if ($contactData->getId() && !$existContact) {
                 $contact = new ClientAdditionalContact();
                 $contact->setFirstName($contactData->getFirstName());
                 $contact->setMiddleName($contactData->getMiddleName());
                 $contact->setLastName($contactData->getLastName());
                 $contact->setRelationship($contactData->getRelationship());
                 $contact->setType(ClientAccountOwner::OWNER_TYPE_OTHER);
             } elseif (!$contactData->getId() && $existContact) {
                 $contact = $existContact;
             } else {
                 $contact = $contactData;
             }
             $contact->setClient($account->getClient());
             $owner->setContact($contact);
             $this->em->persist($contact);
             $this->em->persist($owner);
             break;
     }
     $account->addAccountOwner($owner);
     $this->em->persist($owner);
     $this->em->flush();
     return $owner;
 }