Test to check CRM-17146 - include trxn_date in completetransaction API
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 9 Sep 2015 10:50:44 +0000 (16:20 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 9 Sep 2015 10:50:44 +0000 (16:20 +0530)
CRM/Contribute/Form/Task/Status.php
api/v3/Contribution.php
tests/phpunit/api/v3/ContributionTest.php

index 2a645f3840427afcefe533b874f9cc38ab13dcc0..16e6a8426f2a357e867addbb7a12dbbd7a7259e1 100644 (file)
@@ -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;
index ee3d251e2b1d9896550212b7c36aa14ad6a6d59f..ab7abb5558c4424b682fae60e0c91443d426bae9 100644 (file)
@@ -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;
index 1c63c2e08b60df9f124d0e9eb3fc77893dea9598..eb9ad2987ea090995ec8f5d5ec83af1741490ed0 100644 (file)
@@ -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.',