Ejemplo n.º 1
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.º 2
0
 private function createSystemAccount(array $data, ClientAccount $account)
 {
     $systemAccount = new SystemAccount();
     $systemAccount->setClientAccount($account);
     $systemAccount->setClient($account->getClient());
     $systemAccount->setAccountNumber($data['account_number']);
     $systemAccount->setAccountDescription($data['account_description']);
     $systemAccount->setType($data['type']);
     $systemAccount->setStatus($data['status']);
     if ($data['status'] === SystemAccount::STATUS_ACTIVE) {
         $systemAccount->setActivatedOn(new \DateTime());
     } elseif ($data['status'] === SystemAccount::STATUS_CLOSED) {
         $systemAccount->setClosed(new \DateTime());
     }
     $systemAccount->setSource(SystemAccount::SOURCE_SAMPLE);
     return $systemAccount;
 }