DB error on search for account_type_code or account_code
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Thu, 30 Oct 2014 06:38:01 +0000 (12:08 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Thu, 30 Oct 2014 06:38:01 +0000 (12:08 +0530)
CRM/Contribute/BAO/Query.php

index 047c1fd152c9c2746cf45664612eb1d60a0d02d9..f3c533946b63d4a9ecb9a5d649df5d9c7105151d 100644 (file)
@@ -722,11 +722,19 @@ class CRM_Contribute_BAO_Query {
         }
         break;
 
+      case 'civicrm_financial_account':
+        if ($mode & CRM_Contact_BAO_Query::MODE_CONTACTS) {
+          $from = " $side JOIN civicrm_financial_account ON contact_a.id = civicrm_financial_account.contact_id ";
+        }
+        break;
+
       case 'civicrm_accounting_code':
-        $from = " $side JOIN civicrm_entity_financial_account ON civicrm_entity_financial_account.entity_id = civicrm_contribution.financial_type_id AND civicrm_entity_financial_account.entity_table = 'civicrm_financial_type' ";
-        $from .= " INNER JOIN civicrm_financial_account ON civicrm_financial_account.id = civicrm_entity_financial_account.financial_account_id ";
-        $from .= " INNER JOIN civicrm_option_value cov ON cov.value = civicrm_entity_financial_account.account_relationship AND cov.name = 'Income Account is' ";
-        $from .= " INNER JOIN civicrm_option_group cog ON cog.id = cov.option_group_id AND cog.name = 'account_relationship' ";
+        if ($mode & CRM_Contact_BAO_Query::MODE_CONTRIBUTE) {
+          $from = " $side JOIN civicrm_entity_financial_account ON civicrm_entity_financial_account.entity_id = civicrm_contribution.financial_type_id AND civicrm_entity_financial_account.entity_table = 'civicrm_financial_type' ";
+          $from .= " INNER JOIN civicrm_financial_account ON civicrm_financial_account.id = civicrm_entity_financial_account.financial_account_id ";
+          $from .= " INNER JOIN civicrm_option_value cov ON cov.value = civicrm_entity_financial_account.account_relationship AND cov.name = 'Income Account is' ";
+          $from .= " INNER JOIN civicrm_option_group cog ON cog.id = cov.option_group_id AND cog.name = 'account_relationship' ";
+        }
         break;
 
       case 'civicrm_contribution_page':