From b1b2796c6734407a6050de085105e8ab40369865 Mon Sep 17 00:00:00 2001 From: eileenmcnaughton Date: Mon, 30 Nov 2015 05:40:50 +0000 Subject: [PATCH] CRM-17636 fix for items not being recorded correctly (modified_date, invoice_id, is_email_receipt. Partial fix on contribution_status_id - covers setting to pending but not yet updating to In Progress --- CRM/Member/Form.php | 10 +++++----- CRM/Member/Form/MembershipRenewal.php | 2 ++ api/v3/ContributionRecur.php | 1 + .../phpunit/CRM/Member/Form/MembershipRenewalTest.php | 5 ++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index ca06acb5c5..cea4b87d49 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -330,13 +330,13 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { $contributionRecurParams = array( 'contact_id' => $paymentParams['contactID'], 'amount' => $paymentParams['total_amount'], + 'contribution_status_id' => 'Pending', 'payment_processor_id' => $paymentParams['payment_processor_id'], - 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams), + 'campaign_id' => $paymentParams['campaign_id'], 'financial_type_id' => $paymentParams['financial_type_id'], - 'is_email_receipt' => CRM_Utils_Array::value('is_email_receipt', $paymentParams), - // This is not great as it could also be direct debit - but is consistent with elsewhere & all need fixing. - 'payment_instrument_id' => 1, - 'invoice_id' => CRM_Utils_Array::value('invoiceID ', $paymentParams), + 'is_email_receipt' => $paymentParams['is_email_receipt'], + 'payment_instrument_id' => $paymentParams['payment_instrument_id'], + 'invoice_id' => $paymentParams['invoice_id'], ); $mapping = array( diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 80eab40f8d..45f27a228c 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -529,6 +529,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $this->_params['register_date'] = $now; $this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal"); $this->_params['amount'] = $this->_params['total_amount']; + $this->_params['payment_instrument_id'] = $this->_paymentProcessor['payment_instrument_id']; // at this point we've created a contact and stored its address etc // all the payment processors expect the name and address to be in the passed params @@ -537,6 +538,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { if (!empty($this->_params['send_receipt'])) { $paymentParams['email'] = $this->_contributorEmail; } + $paymentParams['is_email_receipt'] = !empty($this->_params['send_receipt']); $paymentParams['contactID'] = $this->_contributorContactID; diff --git a/api/v3/ContributionRecur.php b/api/v3/ContributionRecur.php index a7a0b293de..40dfb47c5b 100644 --- a/api/v3/ContributionRecur.php +++ b/api/v3/ContributionRecur.php @@ -57,6 +57,7 @@ function _civicrm_api3_contribution_recur_create_spec(&$params) { $params['create_date']['api.default'] = 'now'; $params['frequency_interval']['api.required'] = 1; $params['start_date']['api.default'] = 'now'; + $params['modified_date']['api.default'] = 'now'; } /** diff --git a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php index eab0f6ef64..baeda99bfd 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php @@ -330,13 +330,12 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { // @todo fix this part! /* $this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', - 'In Progress'), $contributionRecur['contribution_status_id']); + 'In Progress'), $contributionRecur['contribution_status_id']); $this->assertNotEmpty($contributionRecur['next_sched_contribution_date']); - */ + */ $this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Credit Card'), $contributionRecur['payment_instrument_id']); - $contribution = $this->callAPISuccess('Contribution', 'getsingle', array( 'contact_id' => $this->_individualId, 'is_test' => TRUE, -- 2.25.1