Skip to content

Commit

Permalink
Merge pull request #19274 from eileenmcnaughton/tax
Browse files Browse the repository at this point in the history
[REF] Fix tax_amount to be consistent & load from the templateContribution
  • Loading branch information
mattwire authored Dec 24, 2020
2 parents 44e9ef9 + 0408b3c commit e4e20a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ protected static function repeatTransaction(&$contribution, $input, $contributio
else {
$contributionParams['financial_type_id'] = $templateContribution['financial_type_id'];
}
foreach (['contact_id', 'currency', 'source', 'amount_level', 'address_id', 'on_behalf', 'source_contact_id'] as $fieldName) {
foreach (['contact_id', 'currency', 'source', 'amount_level', 'address_id', 'on_behalf', 'source_contact_id', 'tax_amount'] as $fieldName) {
if (isset($templateContribution[$fieldName])) {
$contributionParams[$fieldName] = $templateContribution[$fieldName];
}
Expand All @@ -2465,9 +2465,6 @@ protected static function repeatTransaction(&$contribution, $input, $contributio
if (isset($contribution->contribution_page_id) && is_numeric($contribution->contribution_page_id)) {
$contributionParams['contribution_page_id'] = $contribution->contribution_page_id;
}
if (!empty($contribution->tax_amount)) {
$contributionParams['tax_amount'] = $contribution->tax_amount;
}

$createContribution = civicrm_api3('Contribution', 'create', $contributionParams);
$contribution->id = $createContribution['id'];
Expand Down
6 changes: 4 additions & 2 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4721,8 +4721,10 @@ public function testContributionGetUnique() {
/**
* Test Repeat Transaction Contribution with Tax amount.
* https://lab.civicrm.org/dev/core/issues/806
*
* @throws \CRM_Core_Exception
*/
public function testRepeatContributionWithTaxAmount() {
public function testRepeatContributionWithTaxAmount(): void {
$this->enableTaxAndInvoicing();
$financialType = $this->callAPISuccess('financial_type', 'create', [
'name' => 'Test taxable financial Type',
Expand All @@ -4740,7 +4742,7 @@ public function testRepeatContributionWithTaxAmount() {
$this->callAPISuccess('contribution', 'repeattransaction', [
'original_contribution_id' => $contribution['id'],
'contribution_status_id' => 'Completed',
'trxn_id' => uniqid(),
'trxn_id' => 'test',
]);
$payments = $this->callAPISuccess('Contribution', 'get', ['sequential' => 1])['values'];
//Assert if first payment and repeated payment has the same contribution amount.
Expand Down

0 comments on commit e4e20a1

Please sign in to comment.