+ /**
+ * Validate account relationship with financial account type
+ *
+ * @param obj $financialTypeAccount of CRM_Financial_DAO_EntityFinancialAccount
+ *
+ */
+ public static function validateRelationship($financialTypeAccount) {
+ $financialAccountLinks = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations();
+ $financialAccountType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialTypeAccount->financial_account_id, 'financial_account_type_id');
+ if (CRM_Utils_Array::value($financialTypeAccount->account_relationship, $financialAccountLinks) != $financialAccountType) {
+ $accountRelationships = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
+ $params = array(
+ 1 => $accountRelationships[$financialTypeAccount->account_relationship],
+ );
+ throw new Exception(ts("This financial account cannot have '%1' relationship.", $params));
+ }
+ }
+