Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] remove first attempt to set currency in repeattransaction flow #18055

Merged
merged 1 commit into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2620,8 +2620,11 @@ protected static function repeatTransaction(&$contribution, &$input, $contributi
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.
Expand Down Expand Up @@ -4462,11 +4465,6 @@ public static function completeOrder($input, &$ids, $objects, $isPostPaymentCrea
], 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.
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function testGetTemplateContributionNewTemplate() {
'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',
Expand All @@ -254,6 +254,7 @@ public function testGetTemplateContributionNewTemplate() {
'contribution_recur_id' => $contributionRecur['id'],
]);
$this->assertEquals('Template Contribution', $repeatContribution['values'][$repeatContribution['id']]['source']);
$this->assertEquals('AUD', $repeatContribution['values'][$repeatContribution['id']]['currency']);
}

/**
Expand Down