[REF] remove first attempt to set currency in repeattransaction flow
authoreileen <emcnaughton@wikimedia.org>
Tue, 4 Aug 2020 00:25:23 +0000 (12:25 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 4 Aug 2020 05:09:55 +0000 (17:09 +1200)
The currency is retrieved from the template transaction, these lines are no longer needed, as demonstrated
in the test

CRM/Contribute/BAO/Contribution.php
tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php

index 00300c63a808e7be229646b56a4f5158828cb385..5c5775157156201118c4380a72bd16a83b7c4864 100644 (file)
@@ -2620,8 +2620,11 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
       else {
         $contributionParams['financial_type_id'] = $templateContribution['financial_type_id'];
       }
-      $contributionParams['contact_id'] = $templateContribution['contact_id'];
-      $contributionParams['source'] = empty($templateContribution['source']) ? ts('Recurring contribution') : $templateContribution['source'];
+      foreach (['contact_id', 'currency', 'source'] as $fieldName) {
+        $contributionParams[$fieldName] = $templateContribution[$fieldName];
+      }
+
+      $contributionParams['source'] = $contributionParams['source'] ?: ts('Recurring contribution');
 
       //CRM-18805 -- Contribution page not recorded on recurring transactions, Recurring contribution payments
       //do not create CC or BCC emails or profile notifications.
@@ -4462,11 +4465,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
     ], array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)
     ));
 
-    // CRM-20678 Ensure that the currency is correct in subseqent transcations.
-    if (empty($contributionParams['currency']) && isset($objects['first_contribution']->currency)) {
-      $contributionParams['currency'] = $objects['first_contribution']->currency;
-    }
-
     $contributionParams['payment_processor'] = $input['payment_processor'] = $paymentProcessorId;
 
     // If paymentProcessor is not set then the payment_instrument_id would not be correct.
index 42dfd2b4f231c0cae25a627536e49b4ef05061a8..d34f23c2ee228cc90f415a892415016c84f8d13f 100644 (file)
@@ -227,7 +227,7 @@ class CRM_Contribute_BAO_ContributionRecurTest extends CiviUnitTestCase {
       'financial_type_id' => 1,
       'source' => 'Template Contribution',
       'payment_instrument_id' => 1,
-      'currency' => 'USD',
+      'currency' => 'AUD',
       'contact_id' => $this->individualCreate(),
       'contribution_status_id' => 1,
       'receive_date' => 'yesterday',
@@ -254,6 +254,7 @@ class CRM_Contribute_BAO_ContributionRecurTest extends CiviUnitTestCase {
       'contribution_recur_id' => $contributionRecur['id'],
     ]);
     $this->assertEquals('Template Contribution', $repeatContribution['values'][$repeatContribution['id']]['source']);
+    $this->assertEquals('AUD', $repeatContribution['values'][$repeatContribution['id']]['currency']);
   }
 
   /**