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

contribution summary is wrong if contact belongs to many groups

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.1.5
    • Fix Version/s: 3.2.2
    • Component/s: CiviContribute
    • Labels:
      None

      Description

      As non-admin, when I go to the "Contributions" tab of a contact form, the generated SQL query is :

      =============================
      SELECT COUNT( civicrm_contribution.total_amount ) as total_count,
      SUM( civicrm_contribution.total_amount ) as total_amount,
      AVG( civicrm_contribution.total_amount ) as total_avg,
      currency as currency

      FROM civicrm_contact contact_a
      LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id
      INNER JOIN civicrm_contribution_type ON civicrm_contribution.contribution_type_id = civicrm_contribution_type.id

      LEFT JOIN civicrm_group_contact `civicrm_group_contact-10` ON contact_a.id = `civicrm_group_contact-10`.contact_id
      LEFT JOIN civicrm_group_contact `civicrm_group_contact-23` ON contact_a.id = `civicrm_group_contact-23`.contact_id
      LEFT JOIN civicrm_group_contact `civicrm_group_contact-24` ON contact_a.id = `civicrm_group_contact-24`.contact_id
      LEFT JOIN civicrm_group_contact `civicrm_group_contact-2` ON contact_a.id = `civicrm_group_contact-2`.contact_id
      LEFT JOIN civicrm_group_contact `civicrm_group_contact-3` ON contact_a.id = `civicrm_group_contact-3`.contact_id
      LEFT JOIN civicrm_group_contact `civicrm_group_contact-42` ON contact_a.id = `civicrm_group_contact-42`.contact_id
      LEFT JOIN civicrm_group_contact `civicrm_group_contact-8` ON contact_a.id = `civicrm_group_contact-8`.contact_id
      LEFT JOIN civicrm_group_contact `civicrm_group_contact-9` ON contact_a.id = `civicrm_group_contact-9`.contact_id

      LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_43` ON contact_a.id = `civicrm_group_contact_cache_43`.contact_id
      LEFT JOIN civicrm_option_group option_group_payment_instrument ON ( option_group_payment_instrument.name = 'payment_instrument')
      LEFT JOIN civicrm_option_value payment_instrument ON (civicrm_contribution.payment_instrument_id = payment_instrument.value
      AND option_group_payment_instrument.id = payment_instrument.option_group_id )
      LEFT JOIN civicrm_option_group option_group_contribution_status ON (option_group_contribution_status.name = 'contribution_status')
      LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.contribution_status_id = contribution_status.value
      AND option_group_contribution_status.id = contribution_status.option_group_id )

      WHERE ( contact_a.id = 111248 AND civicrm_contribution.is_test = 0 )
      AND civicrm_contribution.contribution_status_id = 1

      GROUP BY currency;
      ==============================

      The contact (id=111248) belongs to the groups 10, 23, 24, etc.

      The result is obviously wrong:

      -------------------------------------------+

      total_count total_amount total_avg currency

      -------------------------------------------+

      256 204800.00 800.000000 EUR

      -------------------------------------------+
      1 row in set (0.01 sec)

      The result is that the user sees those values on the "Contributions" tab of the contacts form.

        Attachments

          Activity

            People

            • Assignee:
              kurund Kurund Jalmi
              Reporter:
              cbenz Christophe Benz
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: