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) »
  • Improvements / additions to Contribution summary report
Pages: [1]

Author Topic: Improvements / additions to Contribution summary report  (Read 1790 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Improvements / additions to Contribution summary report
January 21, 2010, 06:54:44 am
Hello folks,

We are using the donation report for a political party that wants to analyse its membership contributions.  It has a system where a proportion of the membership fee is allocated to a regional party (this is called the Regional Capitation).  We have implemented a hook that is fired when a membership contribution is made.  The hook looks at the regional party of the contact that made the donation and adds two peices of custom data to the donation: 1) the regional party, and 2) the amount that should be allocated to the regional party.

We can then use the donation report to group by regional party and give us the sum for each regional party.  This works REALLY well so far, and I have attached an 'alpha' screenshot with the results.  Walking you through the screenshot, we have

* The total value of contributions made
* The number of conributions made
* The average (not so necessary, but fine)
* The region (these regions are stored in the DB as contacts - we'll need to change this so it shows the name, not the ID, but no big deal)
* The Regional Capitation (i.e. the amount allocated to the regional party)

So all is good apart from the last column.  The last column should display the "Amount Statistics" for that field, rather than the first amount it encounters.

So I want to improve the Contribution report so it allows Amount Statistics for any custom field that you can perform Amount statistics on.

So I am asking people for pointers in modifying the report.  

CRM/Report/Form/Contribute/Summary.php is I presume the place to start because this report is based on Donor Report (Summary).

I am wondering how far into the guts of CiviReport I need to go, and where the best place to modify this information is, and if you think this something that is worth incorperating generally as an option in CiviReport for any data that it makes sense to do that for.  I am guessing Money, Duration, Any custom data that is of the type number or money, etc.

Michael
« Last Edit: January 21, 2010, 10:35:40 am by michaelmcandrew »
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Improvements / additions to Contribution summary report
January 21, 2010, 11:28:20 am
I am assuming you know that defining CIVICRM_REPORT_CONTRIBUTION_CUSTOM_DATA in settings file allows contribution summary & detail reports expose custom data.

So most of the code is already there with select, joins and group-bys. Now to show statistics (contribution summary), all you have to do is make sure that Aggregate functions are applied to the columns you want statistics for.

For example, current query is sth like:
Select SUM(total_amount) as total_amount_sum, custom_field_1 as custom_field_1, ...
FROM ..
LEFT JOIN ..
WHERE ..
GROUP BY (receive_date),..

All you have to do is convert "custom_field_1 as custom_field_1" to "SUM(custom_field_1) as custom_field_1".

CRM/Report/Form/Contribute/Summary.php::select() method which constructs the select clause, is where you can apply aggregate function based on custom data type (Money, Duration, Integer..).
« Last Edit: January 21, 2010, 11:33:32 am by Deepak Srivastava »
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Improvements / additions to Contribution summary report
November 08, 2010, 07:18:31 am
A working report definition here:

https://github.com/michaelmcandrew/gp/blob/master/php/CRM/Report/Form/Contribute/RegionalCapitationSummary.php
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Improvements / additions to Contribution summary report

This forum was archived on 2017-11-26.