/** * Fetch Non-Qualified Monthly Funds Avail for Investment * @param int $id */ public function fetchNonQualifiedMonthlyFundsAvail($id) { $nonQualifiedMoney = '0'; $this->checkAcl('read'); //Get Non-Qualified Money Avail from Client Employment Ret Plan $clientEmploymentGateway = new Clients_Model_ClientEmploymentGateway(); //This function simply returns the matching plus amount with no other details //Saving this to determine if I want to use this functionality over the function //below // $nonQualRetPlanMoney = $clientEmploymentGateway->fetchClientAndSpouseRetMoneyPlus($id); $nonQualRetPlanMoney = $clientEmploymentGateway->fetchClientAndSpouseRetFundsAvailForTx($id, 'Non-Qualified'); if (is_object($nonQualRetPlanMoney)) { $nonQualRetPlanMoney = $nonQualRetPlanMoney->toArray(); } if ($nonQualRetPlanMoney) { foreach ($nonQualRetPlanMoney as $key => $value) { if ($nonQualRetPlanMoney[$key]['client_employment_yourcontribution'] > $nonQualRetPlanMoney[$key]['client_employment_matchingmax']) { $nonQualifiedMoney += $nonQualRetPlanMoney[$key]['client_employment_yourcontribution'] - $nonQualRetPlanMoney[$key]['client_employment_matchingmax']; } } } //Get Non-Qualified Monthly Funds 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->fetchClientMonthlyFundsAvail($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']){ // $nonQualifiedMoney += ($nonQualInvestments[$key]['client_investment_amount'] - $nonQualInvestments[$key]['client_investment_emfundamt'] ); // }else{ // $nonQualifiedMoney += $nonQualInvestments[$key]['client_investment_txamount']; // } // }else{ $nonQualifiedMoney += $nonQualInvestments[$key]['client_investment_monthlycontribute']; // } } } //Get Non-Qualified Monthly Funds Avail from Client Assets //Check if Money is labeled as Emer Fund Money. $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'] && $nonQualAssets[$key]['client_asset_emfundamt']) { $nonQualifiedMoney += $nonQualAssets[$key]['client_asset_pmtamount']; } else { $nonQualifiedMoney += $nonQualAssets[$key]['client_asset_pmtamount']; } } } //Get Monthly Premiums from any existing Term Life Policies $clientInsuranceGateway = new Clients_Model_ClientInsuranceGateway(); $termLifePremiums = $clientInsuranceGateway->fetchClientTermLifePremiumByClientId($id); if (is_object($termLifePremiums)) { $termLifePremiums = $termLifePremiums->toArray(); } if ($termLifePremiums) { foreach ($termLifePremiums as $key => $value) { $nonQualifiedMoney += $termLifePremiums[$key]['client_insurance_mthlypremium']; } } return $nonQualifiedMoney; }