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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • contribution_status_id values
Pages: [1]

Author Topic: contribution_status_id values  (Read 1290 times)

dougall

  • Guest
contribution_status_id values
August 27, 2008, 11:52:12 am
Hi,

Can anyone tell me what the contribution_status_id values relate to (or let me know where to look) for:
Quote
civicrm_contribution.contribution_status_id
civicrm_contribution_recur.contribution_status_id
...and if they have same meaning for both tables?

Thanks,
  Dougall

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_status_id values
August 27, 2008, 12:28:03 pm


Basically relates to the status of a contribution (or recurring contribution). Can be any of

Completed, Pending, Cancelled, Overdue, Failed, In progress

A recurring contribution is made up of multiple contributions, so it will be in a pending state until all its child contributions have either completed or any of them have failed

I think we use the same status for pledges

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

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: contribution_status_id values
March 03, 2010, 07:23:35 pm
Just a (late) followup for anyone looking for this in future:

The values are stored in the civicrm_option_values table and stored as a pseudoConstant in CiviCRM. You can see them via this SQL query:

Code: [Select]
select value, v.label from civicrm_option_value v join civicrm_option_group g on v.option_group_id = g.id and g.name = 'contribution_status';

Code: [Select]
+-------+-------------+
| value | label       |
+-------+-------------+
| 1     | Completed   |
| 2     | Pending     |
| 3     | Cancelled   |
| 4     | Failed      |
| 5     | In Progress |
| 6     | Overdue     |
+-------+-------------+

It is possible to alter those values via the CiviCRM GUI (or, it's been possible to do this in the past) so there is no guarantee that the statuses match on all sites. That said, there are a few instances of code in CiviCRM where status_id 1 is hardcoded as representing "Completed".

eg, One customer of ours removed and then re-created the "Completed" status via the GUI, but it was stored with another value (not 1). This caused things to start acting funky with regard to contribution processing.

This may have been resolved in CiviCRM since then, but from a look at the code this arvo, I see a few instances where it doesn't appear to be the case. Lobo, happy to open a related issue so that this can be looked into - right now I can't find the place in the CiviCRM UI where it's possible to change/add contribution statuses, so maybe the issue is fixed in the UI already.

Code: [Select]
grep -ri status_id CRM/Contribute/ | grep 1 ( | grep -v svn ) shows a bunch of instances where contribution_status_id=1 is hardcoded as meaning "Completed"
@xurizaemon ● www.fuzion.co.nz

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: contribution_status_id values
March 03, 2010, 09:30:39 pm
We already changed the mechanism how values are get stored and updated from 'civicrm_option_value' table.

We do allow to update 'label' which is viewable to user from UI but 'name' remains contacts from the time of creation.

So there are two scenario's :
1. Show status values to user on UI -
We are showing labels and retrieve mechanism is : CRM_Contribute_PseudoConstant::contributionStatus(  );

2. Use status values in programming logic -
We should pull names w/ CRM_Contribute_PseudoConstant::contributionStatus( null, 'name' );

But here we do require name should same like our sample db ( eg 'Completed' ) you can give/update label w/ any thing.

So removing hard coded status Id and compare w/ name is safe.

kiran
You Are Designed To Choose... Defined By Choice.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • contribution_status_id values

This forum was archived on 2017-11-26.