Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.7
-
Fix Version/s: 1.7
-
Component/s: CiviContribute
-
Labels:None
Description
A contribution is added to the system using the crm_create_contribution function where receive_date is set using date('Ymd'). This field is defined as datetime in the database. Here is a sample params string for the create_contribution function:
$params = array(
'domain_id' => 1,
'contact_id' => $contact->contact_id,
'receive_date' => date('Ymd'),
'total_amount' => $strMemberCost,
'contribution_type_id' => CONTRIBUTE_MEMBERSHIP
);
I then want to find the most recent contribution of a particular type, so I prepare params for crm_get_contribution like this where $startDate is in YYYY-MM-DD format:
$params = array('contact_id' => $contactID,
'receive_date' => $startDate,
'contribution_type_id' => CONTRIBUTE_NEWSLETTER);
Running crm_get_contribution like this returns a "match not found" error even though the dates match.
I try appending the time to the above date since the dB also has the time string:
$params = array('contact_id' => $contactID,
'receive_date' => $startDate . ' 00:00:00',
'contribution_type_id' => CONTRIBUTE_NEWSLETTER);
Now when I call crm_get_contribution it returns an error object with the message: [message] => Did not find contribution object for 506, where 506 is the id of the matching contribution record.
So this seems to find the right record, but fails when trying to return it.
I've attached a modified version of the GetContribution unit test that attepmts to replicate this.
Running CiviCRM 1.7.beta.9184 with Drupal 4.7.6 on FreeBSD 6