/** * Fetch Non-Qualified Funds Avail for Tx/Investment * @param int $id */ public function fetchNonQualifiedAccountFundsAvail($id) { $nonQualifiedAccounts = '0'; $this->checkAcl('read'); //Get Non-Qualified Money Avail from Client Employment Ret Plan $clientEmploymentGateway = new Clients_Model_ClientEmploymentGateway(); $nonQualRetPlanMoney = $clientEmploymentGateway->fetchClientAndSpouseRetFundsAvailForTx($id, 'Non-Qualified'); if ($nonQualRetPlanMoney) { foreach ($nonQualRetPlanMoney as $key => $value) { $nonQualifiedAccounts += $nonQualRetPlanMoney[$key]['client_employment_txamount']; } } //Get Non-Qualified Money Avail from Client Investments //Check if Money is labeled as Emer Fund Money. If so enure that Tx Amount //does not exceed Total minus Emer Fund Amount. $clientInvestmentGateway = new Clients_Model_ClientInvestmentGateway(); $nonQualInvestments = $clientInvestmentGateway->fetchClientInvestmentsAvailForTx($id, 'Non-Qualified'); if (is_object($nonQualInvestments)) { $nonQualInvestments = $nonQualInvestments->toArray(); } if ($nonQualInvestments) { foreach ($nonQualInvestments as $key => $value) { if ($nonQualInvestments[$key]['client_investment_emfund']) { $availFunds = $nonQualInvestments[$key]['client_investment_txamount'] + $nonQualInvestments[$key]['client_investment_emfundamt']; if ($availFunds < $nonQualInvestments[$key]['client_investment_amount']) { $nonQualifiedAccounts += $nonQualInvestments[$key]['client_investment_amount'] - $nonQualInvestments[$key]['client_investment_emfundamt']; } else { $nonQualifiedAccounts += $nonQualInvestments[$key]['client_investment_txamount']; } } else { $nonQualifiedAccounts += $nonQualInvestments[$key]['client_investment_txamount']; } } } //Get Non-Qualified Money Avail from Client Investments //Check if Money is labeled as Emer Fund Money. If so enure that Tx Amount //does not exceed Total minus Emer Fund Amount. $clientAssetGateway = new Clients_Model_ClientAssetGateway(); $nonQualAssets = $clientAssetGateway->fetchClientSavingsAssetByClientId($id); if (is_object($nonQualAssets)) { $nonQualAssets = $nonQualAssets->toArray(); } if ($nonQualAssets) { foreach ($nonQualAssets as $key => $value) { if ($nonQualAssets[$key]['client_asset_emfund']) { $nonQualifiedAccounts += $nonQualAssets[$key]['client_asset_value'] - $nonQualAssets[$key]['client_asset_emfundamt']; } else { $nonQualifiedAccounts += $nonQualAssets[$key]['client_asset_value']; } } } return $nonQualifiedAccounts; }