Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-13567

CiviContribute Detail report fails if you add batch data as a filter

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.0
    • Fix Version/s: 4.4.1
    • Component/s: None
    • Labels:
      None

      Description

      Contribution Detail Report / Membership & Contribution Detail Report : Neither report is working properly for filter by Batch Name in 4.4. I see 2 problems:

      1. The criteria being used to see if batches should be exposed to the report is wrong
      $this->_closedBatches = CRM_Batch_BAO_Batch::getBatches();

      This is checking for type_id = 1, 2. I think that should be removed since Accounting Batches have NULL for type_id
      Also, don't see why we should only look for Closed batches. Probably should also remove the status_id filter on that functions and just check for 1 or more batches w/ item_count >=1.

      2. Even after I remove the filters and get the filter criteria, the report is not finding eligible contribution records - so the constructed query is incorrect.

      (I am not getting the fatal reported below by Eileen).

      == Original Post =========
      Just tried on demo - create a batch & then filter on it at http://drupal.demo.civicrm.org/civicrm/report/contribute/detail - I think the batch table may not be joined in although I have only given it a superficial look

      backTrace

      #0 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/Error.php(148): CRM_Core_Error::backtrace()
      #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
      #2 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
      #3 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/DB.php(969): PEAR_Error->PEAR_Error("DB Error: no such field", -19, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
      #4 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/PEAR.php(564): DB_Error->DB_Error(-19, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
      #5 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/DB/common.php(1905): PEAR->raiseError(NULL, -19, NULL, NULL, "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", "DB_Error", TRUE)
      #6 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/DB/mysql.php(898): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'batch_civireport.id' in 'where clause'")
      #7 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
      #8 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/DB/common.php(1216): DB_mysql->simpleQuery("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
      #9 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/DB/DataObject.php(2421): DB_common->query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
      #10 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/DB/DataObject.php(1613): DB_DataObject->_query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
      #11 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/DAO.php(155): DB_DataObject->query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
      #12 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/DAO.php(917): CRM_Core_DAO->query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", TRUE)
      #13 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Report/Form.php(2085): CRM_Core_DAO::executeQuery("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
      #14 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Report/Form.php(2456): CRM_Report_Form->buildRows("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", (Array:0))
      #15 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Report/Form/Contribute/Detail.php(523): CRM_Report_Form->postProcess()
      #16 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/Form.php(246): CRM_Report_Form_Contribute_Detail->postProcess()
      #17 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/QuickForm/Action/Submit.php(73): CRM_Core_Form->mainProcess()
      #18 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Submit->perform(Object(CRM_Report_Form_Contribute_Detail), "submit")
      #19 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Report_Form_Contribute_Detail), "submit")
      #20 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/Controller.php(316): HTML_QuickForm_Page->handle("submit")
      #21 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Utils/Wrapper.php(117): CRM_Core_Controller->run()
      #22 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Report/Page/Report.php(78): CRM_Utils_Wrapper->run("CRM_Report_Form_Contribute_Detail", NULL, NULL)
      #23 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/Invoke.php(292): CRM_Report_Page_Report->run((Array:4), NULL)
      #24 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/Invoke.php(70): CRM_Core_Invoke::runItem((Array:14))
      #25 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
      #26 /var/www/drupal7.civicrm.org/svn/civicrmdemo43/drupal/civicrm.module(436): CRM_Core_Invoke::invoke((Array:4))
      #27 [internal function](): civicrm_invoke("report", "contribute", "detail")
      #28 /var/www/drupal7.civicrm.org/public/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:3))
      #29 /var/www/drupal7.civicrm.org/public/index.php(21): menu_execute_active_handler()
      #30

      {main}

      Sorry but we are not able to provide this at the moment.
      DB Error: no such field
      Error Details
      Database Error Code: Unknown column 'batch_civireport.id' in 'where clause', 1054
      Additional Details:

      Array
      (
      [callback] => Array
      (
      [0] => CRM_Core_Error
      [1] => handle
      )

      [code] => -19
      [message] => DB Error: no such field
      [mode] => 16
      [debug_info] => SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, email_civireport.email as civicrm_email_email, phone_civireport.phone as civicrm_phone_phone, contacthonor.id as civicrm_contact_honor_id_honor, contribution_civireport.id as civicrm_contribution_contribution_id, contribution_civireport.financial_type_id as civicrm_contribution_financial_type_id, contribution_civireport.currency as civicrm_contribution_currency, contribution_civireport.receive_date as civicrm_contribution_receive_date, SUM(contribution_civireport.total_amount) as civicrm_contribution_total_amount_sum, address_civireport.country_id as civicrm_address_country_id
      FROM civicrm_contact contact_civireport
      INNER JOIN civicrm_contribution contribution_civireport
      ON contact_civireport.id = contribution_civireport.contact_id AND contribution_civireport.is_test = 0
      LEFT JOIN civicrm_phone phone_civireport
      ON (contact_civireport.id = phone_civireport.contact_id AND
      phone_civireport.is_primary = 1)
      LEFT JOIN civicrm_address address_civireport
      ON contact_civireport.id = address_civireport.contact_id AND
      address_civireport.is_primary = 1

      LEFT JOIN civicrm_email email_civireport
      ON contact_civireport.id = email_civireport.contact_id AND
      email_civireport.is_primary = 1

      LEFT JOIN civicrm_contact contacthonor
      ON contacthonor.id = contribution_civireport.honor_contact_id WHERE ( contribution_civireport.contribution_status_id IN (1) ) AND ( batch_civireport.id IN (1) ) AND contact_civireport.is_deleted = 0 GROUP BY contact_civireport.id, contribution_civireport.id ORDER BY contact_civireport.sort_name ASC LIMIT 0, 50 [nativecode=1054 ** Unknown column 'batch_civireport.id' in 'where clause']
      [type] => DB_Error
      [user_info] => SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, email_civireport.email as civicrm_email_email, phone_civireport.phone as civicrm_phone_phone, contacthonor.id as civicrm_contact_honor_id_honor, contribution_civireport.id as civicrm_contribution_contribution_id, contribution_civireport.financial_type_id as civicrm_contribution_financial_type_id, contribution_civireport.currency as civicrm_contribution_currency, contribution_civireport.receive_date as civicrm_contribution_receive_date, SUM(contribution_civireport.total_amount) as civicrm_contribution_total_amount_sum, address_civireport.country_id as civicrm_address_country_id
      FROM civicrm_contact contact_civireport
      INNER JOIN civicrm_contribution contribution_civireport
      ON contact_civireport.id = contribution_civireport.contact_id AND contribution_civireport.is_test = 0
      LEFT JOIN civicrm_phone phone_civireport
      ON (contact_civireport.id = phone_civireport.contact_id AND
      phone_civireport.is_primary = 1)
      LEFT JOIN civicrm_address address_civireport
      ON contact_civireport.id = address_civireport.contact_id AND
      address_civireport.is_primary = 1

      LEFT JOIN civicrm_email email_civireport
      ON contact_civireport.id = email_civireport.contact_id AND
      email_civireport.is_primary = 1

      LEFT JOIN civicrm_contact contacthonor
      ON contacthonor.id = contribution_civireport.honor_contact_id WHERE ( contribution_civireport.contribution_status_id IN (1) ) AND ( batch_civireport.id IN (1) ) AND contact_civireport.is_deleted = 0 GROUP BY contact_civireport.id, contribution_civireport.id ORDER BY contact_civireport.sort_name ASC LIMIT 0, 50 [nativecode=1054 ** Unknown column 'batch_civireport.id' in 'where clause']
      [to_string] => [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, email_civireport.email as civicrm_email_email, phone_civireport.phone as civicrm_phone_phone, contacthonor.id as civicrm_contact_honor_id_honor, contribution_civireport.id as civicrm_contribution_contribution_id, contribution_civireport.financial_type_id as civicrm_contribution_financial_type_id, contribution_civireport.currency as civicrm_contribution_currency, contribution_civireport.receive_date as civicrm_contribution_receive_date, SUM(contribution_civireport.total_amount) as civicrm_contribution_total_amount_sum, address_civireport.country_id as civicrm_address_country_id
      FROM civicrm_contact contact_civireport
      INNER JOIN civicrm_contribution contribution_civireport
      ON contact_civireport.id = contribution_civireport.contact_id AND contribution_civireport.is_test = 0
      LEFT JOIN civicrm_phone phone_civireport
      ON (contact_civireport.id = phone_civireport.contact_id AND
      phone_civireport.is_primary = 1)
      LEFT JOIN civicrm_address address_civireport
      ON contact_civireport.id = address_civireport.contact_id AND
      address_civireport.is_primary = 1

      LEFT JOIN civicrm_email email_civireport
      ON contact_civireport.id = email_civireport.contact_id AND
      email_civireport.is_primary = 1

      LEFT JOIN civicrm_contact contacthonor
      ON contacthonor.id = contribution_civireport.honor_contact_id WHERE ( contribution_civireport.contribution_status_id IN (1) ) AND ( batch_civireport.id IN (1) ) AND contact_civireport.is_deleted = 0 GROUP BY contact_civireport.id, contribution_civireport.id ORDER BY contact_civireport.sort_name ASC LIMIT 0, 50 [nativecode=1054 ** Unknown column 'batch_civireport.id' in 'where clause']"]
      )

        Attachments

          Activity

            People

            • Assignee:
              dgg David Greenberg
              Reporter:
              eileen Eileen McNaughton
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: