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 Import (Moderator: Yashodha Chaku) »
  • 3.4.0 - imported contributions not marked as pledge payments
Pages: [1]

Author Topic: 3.4.0 - imported contributions not marked as pledge payments  (Read 1332 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
3.4.0 - imported contributions not marked as pledge payments
April 27, 2011, 10:57:39 pm
3.4.0 - reproducible on Drupal Demo

When I attempt to import the attached CSV file to the demo site, the contribution is added, but the contribution is not marked as a pledge payment, even though the amounts etc match the next payment. The import screen suggests that both the contribution and the payment were successfully added.

Ken
« Last Edit: April 27, 2011, 11:06:05 pm by ken »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: 3.4.0 - imported contributions not marked as pledge payments
April 28, 2011, 12:55:29 am
As far as I know the only way to import contributions as pledge payments is through the api/ a script. I do have code that I use for this (in conjunction with the migrate module)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: 3.4.0 - imported contributions not marked as pledge payments
April 28, 2011, 04:36:47 am
Eileen,

This functionality works in 3.3.5. It was added in 3.1, I think,

Ken

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: 3.4.0 - imported contributions not marked as pledge payments
April 28, 2011, 09:14:34 pm
The problem is due to a difference between API v2 and v3.

The following patch fixes the problem. I've taken the liberty of filing issue CRM-7994 for this.

Code: [Select]
--- /data/Download/CiviCRM/civicrm-3.4.0-drupal/CRM/Contribute/Import/Parser/Contribution.php   2011-03-15 08:49:22.000000000 +1100
+++ /var/www/xxx/sites/all/modules/civicrm/CRM/Contribute/Import/Parser/Contribution.php        2011-04-29 13:51:06.978431381 +1000
@@ -455,7 +455,8 @@
                     }
                     
                     $this->_newContributions[] = $newContribution['id'];
+                    $formatted['contribution_id'] = $newContribution['id'];
                                       
                     //return soft valid since we need to show how soft credits were added
                     if ( CRM_Utils_Array::value( 'soft_credit_to', $formatted ) ) {
                         return CRM_Contribute_Import_Parser::SOFT_CREDIT;
@@ -523,7 +524,8 @@
             }
             
             $this->_newContributions[] = $newContribution['id'];
+            $formatted['contribution_id'] = $newContribution['id'];
                     
             //return soft valid since we need to show how soft credits were added
             if ( CRM_Utils_Array::value( 'soft_credit_to', $formatted ) ) {
                 return CRM_Contribute_Import_Parser::SOFT_CREDIT;

The API call eventually invokes CRM_Contribute_BAO_Contribution::create(). On line 226 of that file the $params argument is modified ...

        $params['contribution_id'] = $contribution->id;

In v2, that change to the array filters back to the caller of the API, but this doesn't happen in v3.

This issue raises the wider questions ...
  • Does this fix need to be applied in other cases?
  • Should the API pass back changes in it's arguments to the caller?

Ken
« Last Edit: April 28, 2011, 09:23:29 pm by ken »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: 3.4.0 - imported contributions not marked as pledge payments
April 28, 2011, 09:35:44 pm
This has been the topic of some discussion - officially the params object shouldn't be changed by the api but there are still some cases where it happens....
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: 3.4.0 - imported contributions not marked as pledge payments
April 28, 2011, 09:45:01 pm
NB - if you call

api v3 create & create one item the id will be returned e.g

$result = ('Contribution','Create',$params);
echo $result['id'] ;

will give the id of the contribution just created -so perhaps you don't need the other now?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: 3.4.0 - imported contributions not marked as pledge payments
April 28, 2011, 10:47:35 pm
Eileen,

The $formatted variable is passed to the function which updates the pledge payment. So I added the element to that array.

Ken

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: 3.4.0 - imported contributions not marked as pledge payments
April 28, 2011, 11:08:34 pm
Quote from: Eileen on April 28, 2011, 09:35:44 pm
This has been the topic of some discussion - officially the params object shouldn't be changed by the api but there are still some cases where it happens....

Well, now $params is by value, so pretty much sure it is enforced ;)

The problem. as ken have identified (many thanks) is that the api v2 did modify the param, and the calling code was expecting it. That's the kind of bug/intended side effect that is difficult to spot while porting to api v3.

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • 3.4.0 - imported contributions not marked as pledge payments

This forum was archived on 2017-11-26.