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

LYBUNT report returns incorrect values under certain common circumstances

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.2.7
    • Fix Version/s: 3.0
    • Component/s: CiviReport
    • Labels:
      None

      Description

      v2.2.7

      The LYBUNT (CRM/Report/Form/Contribute/Lybunt.php) report returns inflated values under certain circumstances. This affects the list view as well as the detail view. Running this report we were getting contribution summaries that were in some cases 10 or 14 times the correct values. I identified two problems, both of them relating to the SQL. The generated SQL for this report includes an email address, and in some cases is supposed to filter on group ids.

      Problem 1:
      The SQL joins the civicrm_email table on contact_id and is_primary=1. The problem is appears that there can multiple records with the is_primary bit set. When a certain contact has multiple primary email addresses, the report will return a contribution row for each primary email address thereby inflating the sum for a given year by the number of primary email address.

      Problem 2:
      The SQL joins the civicrm_group[_contact] tables. If the contact is a member of one or more groups AND there was no criteria given for group membership, then a contribution row for each group the contact is a member of is returned. This inflates the contribution numbers by the number of active groups the contact was a member of.

      Solution:
      For joining with the civicrm_email table adding an extra condition to the ON clause of "AND email.location_type_id = 5" will limit the list to only the billing email address. For joining with the civicrm_group[_contact] tables, a conditional should be put around those joins such that they are not invoked unless the user actually specified some group criteria.

      The attached patch seems to fix the issue for me.

        Attachments

          Activity

            People

            • Assignee:
              sunil Sunil Pawar
              Reporter:
              nkinkade Nathan Kinkade
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: