From: eileenmcnaugton Date: Wed, 6 Apr 2016 09:11:37 +0000 (+1200) Subject: CRM-18368 pass through contribution status id X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d5580ed47592b53ba1f54c8f18097025eada6fb4;p=civicrm-core.git CRM-18368 pass through contribution status id --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 1d3ba32cff..3459480dd8 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -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); } diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index 9daaacd4df..0cd93f140c 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -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); diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 19643950c9..a95bf6a0e4 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -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); diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 1b56f901c4..d536229bd8 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -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. */