From: eileenmcnaughton Date: Sat, 5 Mar 2016 02:58:33 +0000 (+0000) Subject: CRM-18166 Update receipt_date in IPN calls X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cc7b912fce1e4a81dfae5567ef01485b3bce3afd;p=civicrm-core.git CRM-18166 Update receipt_date in IPN calls --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 149a5b26cf..365ca8f1e2 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4401,10 +4401,6 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) $values['is_email_receipt'] = $recurContrib->is_email_receipt; } - if (!empty($values['is_email_receipt'])) { - $contributionParams['receipt_date'] = $changeDate; - } - if (!empty($memberships)) { foreach ($memberships as $membershipTypeIdKey => $membership) { if ($membership) { @@ -4621,6 +4617,10 @@ LIMIT 1;"; $values['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $input, $userName); } } + // Contribution ID should really always be set. But ? + if (!$returnMessageText && (!isset($input['receipt_update']) || $input['receipt_update'])) { + civicrm_api3('Contribution', 'create', array('receipt_date' => 'now', 'id' => $contribution->id)); + } return $contribution->composeMessageArray($input, $ids, $values, $recur, $returnMessageText); } diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index e06a79e877..a3b941811f 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -180,7 +180,7 @@ AND {$this->_componentClause}"; $input['net_amount'] = $contribution->net_amount; $input['trxn_id'] = $contribution->trxn_id; $input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : NULL; - $input['receipt_date'] = $contribution->receipt_date; + $input['receipt_update'] = $params['receipt_update']; // CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date); @@ -198,10 +198,6 @@ AND {$this->_componentClause}"; // reset template values before processing next transactions $template->clearTemplateVars(); - if (!empty($params['receipt_update'])) { - $objects['contribution']->receipt_date = date('Y-m-d H-i-s'); - $objects['contribution']->save(); - } } if ($elements['createPdf']) { diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index a374f8f8ee..d5d97da0c9 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -1578,8 +1578,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->callAPISuccess('contribution', 'completetransaction', array( 'id' => $contribution['id'], )); - $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'sequential' => 1)); - $this->assertEquals('Completed', $contribution['values'][0]['contribution_status']); + $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id'])); + $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.',