CRM-18368 pass through contribution status id
authoreileenmcnaugton <eileen@fuzion.co.nz>
Wed, 6 Apr 2016 09:11:37 +0000 (21:11 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Wed, 6 Apr 2016 09:11:37 +0000 (21:11 +1200)
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Form/Task/PDF.php
api/v3/Contribution.php
tests/phpunit/api/v3/ContributionTest.php

index 1d3ba32cff9394a945c33ac5b9cbe49ebf60135f..3459480dd82db366b3ef1d4a0c4f2727b64fccc2 100644 (file)
@@ -4344,6 +4344,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
       'campaign_id',
       'receive_date',
       'receipt_date',
+      'contribution_status_id',
     );
     if (self::isSingleLineItem($primaryContributionID)) {
       $inputContributionWhiteList[] = 'financial_type_id';
@@ -4526,7 +4527,7 @@ LIMIT 1;";
     elseif (!empty($contribution->_relatedObjects['membership'])) {
       $input['skipLineItem'] = TRUE;
       $input['contribution_mode'] = 'membership';
-      $contribution->contribution_status_id = $completedContributionStatusID;
+      $contribution->contribution_status_id = $contributionParams['contribution_status_id'];
       $contribution->trxn_id = CRM_Utils_Array::value('trxn_id', $input);
       $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
     }
index 9daaacd4dfc759079ed3843858d1674c49b72d88..0cd93f140c0b45f7f738029127260394852d1512 100644 (file)
@@ -181,6 +181,7 @@ AND    {$this->_componentClause}";
       $input['trxn_id'] = $contribution->trxn_id;
       $input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : NULL;
       $input['receipt_update'] = $params['receipt_update'];
+      $input['contribution_status_id'] = $contribution->contribution_status_id;
 
       // CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date
       $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);
index 19643950c955d21f1aa72adf3b7e6ca75392f373..a95bf6a0e4cd65352fcba1ea4ab988c4cb1c9646 100644 (file)
@@ -559,10 +559,16 @@ function civicrm_api3_contribution_repeattransaction(&$params) {
     }
 
     unset($contribution->id, $contribution->receive_date, $contribution->invoice_id);
-    $contribution->contribution_status_id = $params['contribution_status_id'];
     $contribution->receive_date = $params['receive_date'];
 
-    $passThroughParams = array('trxn_id', 'total_amount', 'campaign_id', 'fee_amount', 'financial_type_id');
+    $passThroughParams = array(
+      'trxn_id',
+      'total_amount',
+      'campaign_id',
+      'fee_amount',
+      'financial_type_id',
+      'contribution_status_id',
+    );
     $input = array_intersect_key($params, array_fill_keys($passThroughParams, NULL));
 
     $params = _ipn_process_transaction($params, $contribution, $input, $ids, $original_contribution);
index 1b56f901c427fcd78baef69d6215bf402dd932c0..d536229bd8dbc36e1582b108a064b056722160cd 100644 (file)
@@ -1579,11 +1579,13 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
       'id' => $contribution['id'],
     ));
     $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id']));
+    $this->assertEquals('SSF', $contribution['contribution_source']);
     $this->assertEquals('Completed', $contribution['contribution_status']);
     $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($contribution['receipt_date'])));
     $mut->checkMailLog(array(
       'Receipt - Contribution',
       'Please print this confirmation for your records.',
+      'May 11th, 2012',
     ));
     $mut->stop();
   }
@@ -1664,6 +1666,20 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $this->callAPISuccessGetCount('Contribution', array('contribution_test' => 1), 2);
   }
 
+  /**
+   * Test repeat contribution passed in status.
+   */
+  public function testRepeatTransactionPassedInStatus() {
+    $originalContribution = $this->setUpRepeatTransaction();
+
+    $this->callAPISuccess('contribution', 'repeattransaction', array(
+      'original_contribution_id' => $originalContribution['id'],
+      'contribution_status_id' => 'Pending',
+      'trxn_id' => uniqid(),
+    ));
+    $this->callAPISuccessGetCount('Contribution', array('contribution_status_id' => 2), 1);
+  }
+
   /**
    * Test repeat contribution accepts recur_id instead of original_contribution_id.
    */