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) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • CiviEvent Suggestions (Moderator: Michał Mach) »
  • Event Payment Status reporting
Pages: [1]

Author Topic: Event Payment Status reporting  (Read 591 times)

spalmstr

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 2
  • CiviCRM version: 4.5.4
  • CMS version: Joomla! 3.3.6 Stable [ Ember ] 01-October-2014 02:00 GMT
  • MySQL version: 5.6.21
  • PHP version: 5.6.0
Event Payment Status reporting
November 07, 2014, 02:34:52 am
The new event handling is looking great - you can at last record multiple payments for an event.  A challenge for the administrator, though, is to keep track of such payments and work out who owes what.  I am fairly ignorant about the underlying data, but have investigated some of the data tables and generated this query that might be used.  However, some of you experts may be able to tell me how it really should be done.  Ideally, it would be in the form of a report.  What are the best tables to use?  I notice that the event fees seem to appear in lots of different places, and I wonder if that is a good idea for the future design of CiviCRM.  The SQL looks like this:

select    e.id,
      e.title_en_GB,
        contact.last_name,
        contact.first_name,
        line_item.line_total as 'Total Cost',
        sum(ifnull(entity_trxn.amount, 0)) as 'Amount paid',
      line_item.line_total - sum(ifnull(entity_trxn.amount, 0)) as 'Amount owed',
        note.note as 'Note'
      from civicrm_event as e
        left join civicrm_participant as participant on e.id = participant.event_id
        left join civicrm_contact as contact on contact.id = participant.contact_id
        left join civicrm_participant_payment as payment on participant.id = payment.participant_id
        left join civicrm_contribution as contribution on contribution.id = payment.contribution_id
        left join civicrm_line_item as line_item on line_item.entity_id = participant.id and line_item.entity_table = 'civicrm_participant'
        left join civicrm_entity_financial_trxn as entity_trxn on entity_trxn.entity_id = contribution.id
      left join civicrm_financial_trxn as trxn on trxn.id = entity_trxn.financial_trxn_id
           Left Join civicrm_note as note On participant.id = note.entity_id and  note.entity_table = 'civicrm_participant'
where e.id = 2 and (trxn.to_financial_account_id = 6 or trxn.to_financial_account_id is null)
group by participant.id;

I just chose one event to test the query - a production version would need to allow one to choose the event in question.  Here is an example of the output.

idtitle_en_GBlast_namefirst_name"Total Cost""Amount paid""Amount owed"Note
2"MA Annual Conference 2015"LastName1FirstName1130.0050.0080.00NULL
2"MA Annual Conference 2015"LastName2FirstName2130.0020.00110.00NULL
2"MA Annual Conference 2015"LastName3FirstName3160.000.00160.00NULL
« Last Edit: November 08, 2014, 02:22:53 am by spalmstr »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • CiviEvent Suggestions (Moderator: Michał Mach) »
  • Event Payment Status reporting

This forum was archived on 2017-11-26.