CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Contribution History by Relationship
Pages: [1] 2

Author Topic: Contribution History by Relationship  (Read 10683 times)

Guy Iaccarino

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 5
    • Greenleaf Advancement
  • CiviCRM version: 4.4.10, 4.5.4
  • CMS version: WordPress 4, Drupal 7, Drupal 6, Joomla 3
  • MySQL version: 5.5
  • PHP version: 5.3
Contribution History by Relationship
May 01, 2013, 12:27:56 pm
The Contribution History by Relationship Report is fabulous, especially because it not only allows you to do things like look at all the donations from all members of a household and the household itself, but also because it totals them, which the Contribution by Household report doesn't do.

However, this report seems to only grab one gift in a given year per entity instead of all the gifts. For instance, if there is a Household, Member 1, and Member 2, and all or some of them have made multiple gifts for a given year, the report will only show one gift from each entity for that given year.

Has anyone else seen this? Any ideas? is it a bug?

Thanks,

Guy
Guy Iaccarino
www.greenleafadvancement.com

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Contribution History by Relationship
May 01, 2013, 04:59:47 pm
Yes, seems like a bug. Would help if you can take a look at the report and see if you can figure out whats happening and why.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Guy Iaccarino

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 5
    • Greenleaf Advancement
  • CiviCRM version: 4.4.10, 4.5.4
  • CMS version: WordPress 4, Drupal 7, Drupal 6, Joomla 3
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Contribution History by Relationship
May 14, 2013, 06:10:50 pm
lobo - I think I mentioned that I got a quote for 10 hours to fix this report. Where would be the best place to see if anyone wanted to contribute towards getting it fixed? I'd be inclined to move on this right away if I could get someone to split it.
Guy Iaccarino
www.greenleafadvancement.com

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Contribution History by Relationship
May 15, 2013, 12:56:55 pm
I noticed the sql produced by this report had two fields with the same name "civicrm_contribution_total_amount":

Code: [Select]
SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name,
                           contact_civireport.id as civicrm_contact_id,
                           SUM(contribution_civireport.total_amount) as civicrm_contribution_total_amount,
                           contribution_civireport.total_amount as civicrm_contribution_total_amount,
                           YEAR(contribution_civireport.receive_date) as civicrm_contribution_receive_date 
                      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
                     WHERE contact_civireport.id IN (1,2,3)
                       AND contribution_civireport.is_test = 0
                       AND ( contribution_civireport.contribution_status_id IN (1) )
                  GROUP BY contribution_civireport.contact_id, YEAR(contribution_civireport.receive_date)

When I ran the sql, I think that the report is using the second instance (which would only capture a single contribution per row), but think it should be using the SUM value in the first instance (which would sum all contributions by contact by year).

I made the following test edit to the report to the function select() for the total_amount field (moving it to within the if/else statement below), which resulted in only the SUM value (first instance) being included in the query result set, and this sum value being used by the report.:
Code: [Select]
/*
            if ($fieldName == 'total_amount') {
              $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}";
             
            }
*/

            if (CRM_Utils_Array::value('is_statistics', $field)) {
              $this->_columnHeaders[$fieldName]['type'] = $field['type'];
              $this->_columnHeaders[$fieldName]['title'] = $field['title'];
              continue;
            }
            elseif ($fieldName == 'receive_date') {
              $select[] = "YEAR({$field['dbAlias']}) as {$tableName}_{$fieldName}";
            }
            elseif ($fieldName == 'total_amount') {
              $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}";
            }
            else {
              $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
              $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
              $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
            }

If you think this addresses the issue, I can look to post a patch file.

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Contribution History by Relationship
May 15, 2013, 02:07:25 pm
Attached is patch for v4.2.8

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Contribution History by Relationship
May 15, 2013, 03:32:12 pm

can you please file an issue and attach the patch there

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Contribution History by Relationship
May 15, 2013, 03:43:11 pm
Sure, will do.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Contribution History by Relationship
May 15, 2013, 03:58:49 pm
Helen - Wondering if there's a better name for this report? "Contribution Aggregate by Relationship" or ??? Also, we dropped the word '... Report' from report titles in 4.3.

Separately I think we should include an instance of this report for new installs in 4.3 +. If you're up for including a patch to the report meta-data to do this, that would be great. Check the report instance inserts in xml/templates/civicrm_navigation.tpl starting at line 650 (in 4.3) for examples of this happens.
Protect your investment in CiviCRM by  becoming a Member!

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Contribution History by Relationship
May 15, 2013, 04:00:59 pm
Issue created: http://issues.civicrm.org/jira/browse/CRM-12637

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Contribution History by Relationship
May 15, 2013, 04:30:39 pm
Hi Dave, I found the report instance entries you described and am happy look at creating a patch.  I'll create a separate issue for this.

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Contribution History by Relationship
May 16, 2013, 06:37:49 am
Opened issue for adding instance of report to new installs: http://issues.civicrm.org/jira/browse/CRM-12643

Guy Iaccarino

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 5
    • Greenleaf Advancement
  • CiviCRM version: 4.4.10, 4.5.4
  • CMS version: WordPress 4, Drupal 7, Drupal 6, Joomla 3
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Contribution History by Relationship
May 16, 2013, 07:13:54 am
Helen, thank you so much for taking this project on!


Helen or Dave, since I have a bit of programming experience but am new to the open source community (at least at the programming level), could you please tell me how I read the top of the patch file? More specifically, how do I read the patch file to know exactly where to put the code? I think I've got it but would like to make sure.


Thank you again!!!!!!!!!!
Guy Iaccarino
www.greenleafadvancement.com

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Contribution History by Relationship
May 16, 2013, 08:03:53 am
Hi Guy,

this is the file that I patched:
/CRM/Report/Form/Contribute/History.php

I'd make a copy of this in your custom dir, and apply the patch to the custom copy.

To apply a patch to a single file, change to the directory where the file is located and call patch:
patch < {/path/to/patch/file}

The file name at the top tells the patch command which file to patch, the numbers in the patch file tell the patch command which lines to apply the changes to.
i.e. @@ -292,10 +292,6 @@

This link may help relating to patches in general: http://book.civicrm.org/developer/current/introduction/fixing-bugs/


Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Contribution History by Relationship
May 16, 2013, 09:07:22 am
Quote from: Guy Iaccarino on May 16, 2013, 07:13:54 am
Helen, thank you so much for taking this project on!

Helen or Dave, since I have a bit of programming experience but am new to the open source community (at least at the programming level), could you please tell me how I read the top of the patch file? More specifically, how do I read the patch file to know exactly where to put the code? I think I've got it but would like to make sure.

Thank you again!!!!!!!!!!

Guy - please pay it back by helping some other folks when u can on the forums, and consider pitching in for one of the 4.4 'make it happen' campaigns.

>>http://civicrm.org/make-it-happen
Protect your investment in CiviCRM by  becoming a Member!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Contribution History by Relationship
May 16, 2013, 09:10:22 am
Quote from: hbergin on May 16, 2013, 06:37:49 am
Opened issue for adding instance of report to new installs: http://issues.civicrm.org/jira/browse/CRM-12643

Excellent! I've added you the the crm-contributors group in Jira and assigned the issue to you :-)
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Contribution History by Relationship

This forum was archived on 2017-11-26.