From 7104593e6094992e127801cc90b4f152ab1e0d07 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 9 Sep 2015 16:20:44 +0530 Subject: [PATCH] Test to check CRM-17146 - include trxn_date in completetransaction API --- CRM/Contribute/Form/Task/Status.php | 2 +- api/v3/Contribution.php | 8 ++++++++ tests/phpunit/api/v3/ContributionTest.php | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Task/Status.php b/CRM/Contribute/Form/Task/Status.php index 2a645f3840..16e6a8426f 100644 --- a/CRM/Contribute/Form/Task/Status.php +++ b/CRM/Contribute/Form/Task/Status.php @@ -140,7 +140,7 @@ AND co.id IN ( $contribIDs )"; $this->addRule("fee_amount_{$row['contribution_id']}", ts('Please enter a valid amount.'), 'money'); $defaults["fee_amount_{$row['contribution_id']}"] = 0.0; - $row['trxn_date'] = &$this->addDate("trxn_date_{$row['contribution_id']}", FALSE, + $row['trxn_date'] = $this->addDate("trxn_date_{$row['contribution_id']}", FALSE, ts('Receipt Date'), array('formatType' => 'activityDate') ); $defaults["trxn_date_{$row['contribution_id']}"] = $now; diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index ee3d251e2b..ab7abb5558 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -473,6 +473,11 @@ function _civicrm_api3_contribution_completetransaction_spec(&$params) { 'description' => 'If a fee has been charged then the amount', 'type' => CRM_Utils_Type::T_FLOAT, ); + $params['trxn_date'] = array( + 'title' => 'Transaction Date', + 'description' => 'Date this transaction occurred', + 'type' => CRM_Utils_Type::T_DATE, + ); } /** @@ -548,6 +553,9 @@ function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstC if (isset($params['is_email_receipt'])) { $input['is_email_receipt'] = $params['is_email_receipt']; } + if (!empty($params['trxn_date'])) { + $input['trxn_date'] = $params['trxn_date']; + } if (empty($contribution->contribution_page_id)) { static $domainFromName; static $domainFromEmail; diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 1c63c2e08b..eb9ad2987e 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -1542,9 +1542,10 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->createLoggedInUser(); $params = array_merge($this->_params, array('contribution_status_id' => 2, 'receipt_date' => 'now')); $contribution = $this->callAPISuccess('contribution', 'create', $params); - $this->callAPISuccess('contribution', 'completetransaction', array('id' => $contribution['id'])); + $this->callAPISuccess('contribution', 'completetransaction', array('id' => $contribution['id'], 'trxn_date' => date('Y-m-d'))); $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'sequential' => 1)); $this->assertEquals('Completed', $contribution['values'][0]['contribution_status']); + $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($contribution['values'][0]['receive_date']))); $mut->checkMailLog(array( 'Receipt - Contribution', 'Please print this confirmation for your records.', -- 2.25.1