Entity/Profile.php
public function getAccountByCode($type_code)
    {
        switch ($type_code)
        {
            case Account::TYPE_ACCOUNTS_RECEIVABLE:
            case Account::TYPE_ACCOUNTS_PAYABLE:
            case Account::TYPE_SALES:
            case Account::TYPE_BANK:

                foreach ($this->getAccounts() as $account)
                {
                    if ($account->getTypeCode() == $type_code)
                    {
                        return $account;
                    }
                }

                // We couldn't find an account, so let's create one
                $account = new Account();
                $account->setBalance(0);
                $account->setProfile($this);
                $account->setTypeCode($type_code);
                $account->setName($this->getName().Account::getAccountNameSuffix($type_code));

                return $account;


            default:

                throw new \Exception('Invalid account code: '.$account_code);
        }
    }
public function getAccountByCode($type_code)
    {
        switch ($type_code)
        {
            case Account::TYPE_ACCOUNTS_RECEIVABLE:
            case Account::TYPE_ACCOUNTS_PAYABLE:
            case Account::TYPE_SALES:
            case Account::TYPE_BANK:

                foreach ($this->getAccounts() as $account)
                {
                    if ($account->getTypeCode() == $type_code)
                    {
                        return $account;
                    }
                }

                // We couldn't find an account, so let's create one
                $account = new Account();
                $account->setBalance(0);
                $account->setProfile($this);
                $account->setTypeCode($type_code);
                $account->setName($this->getName().Account::getAccountNameSuffix($type_code));

                return $account;


            default:

                throw new \Exception('Invalid account code: '.$account_code);
        }
    }
public function getAccountByCode ( $ type_code ) { switch ( $ type_code ) { case Account :: TYPE_ACCOUNTS_RECEIVABLE : case Account :: TYPE_ACCOUNTS_PAYABLE : case Account :: TYPE_SALES : case Account :: TYPE_BANK : foreach ( $ this -> getAccounts ( ) as $ account ) { if ( $ account -> getTypeCode ( ) == $ type_code ) { return $ account ; } } // We couldn't find an account, so let's create one $ account = new Account ( ) ; $ account -> setBalance ( 0 ) ; $ account -> setProfile ( $ this ) ; $ account -> setTypeCode ( $ type_code ) ; $ account -> setName ( $ this -> getName ( ) . Account :: getAccountNameSuffix ( $ type_code ) ) ; return $ account ; default : throw new \ Exception ( 'Invalid account code: ' . $ account_code ) ; } }
Get Profile's account by code

e.g. AP => Accounts Payable

@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since  2012-05-21

@param  string  $type_code

@return \HarvestCloud\CoreBundle\Entity\Account
Get Profile s account by code