From 4706ed3b53fa4f1f50b4349cf5dbb48c88386dcc Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 22 Jun 2020 21:42:54 +1000 Subject: [PATCH] Revert "dev/core#1603 remove places where taxAmount is rounded" This reverts commit 777d61015ae35bb60a08f779d9aa8cb8dc9df708. --- CRM/Contribute/BAO/Contribution.php | 6 +++--- CRM/Price/BAO/PriceSet.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index f1b2d3446a..1050193219 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4204,7 +4204,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac ) { $taxRateParams = $taxRates[$params['financial_type_id']]; $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount(CRM_Utils_Array::value('total_amount', $params), $taxRateParams); - $params['tax_amount'] = $taxAmount['tax_amount']; + $params['tax_amount'] = round($taxAmount['tax_amount'], 2); // Get Line Item on update of contribution if (isset($params['id'])) { @@ -4227,7 +4227,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac if (isset($value['financial_type_id']) && array_key_exists($value['financial_type_id'], $taxRates)) { $taxRate = $taxRates[$value['financial_type_id']]; $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($value['line_total'], $taxRate); - $taxAmountArray[] = $taxAmount['tax_amount']; + $taxAmountArray[] = round($taxAmount['tax_amount'], 2); } } $params['tax_amount'] = array_sum($taxAmountArray); @@ -4238,7 +4238,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac if (isset($params['financial_type_id']) && array_key_exists($params['financial_type_id'], $taxRates) && $isLineItem) { $taxRate = $taxRates[$params['financial_type_id']]; $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['line_total'], $taxRate); - $params['tax_amount'] = $taxAmount['tax_amount']; + $params['tax_amount'] = round($taxAmount['tax_amount'], 2); } } return $params; diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index bc08909594..2ed80ff8eb 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -1485,10 +1485,10 @@ WHERE ps.id = %1 public static function setLineItem($field, $lineItem, $optionValueId, &$totalTax) { // Here we round - i.e. after multiplying by quantity if ($field['html_type'] == 'Text') { - $taxAmount = $field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty']; + $taxAmount = round($field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty'], 2); } else { - $taxAmount = $field['options'][$optionValueId]['tax_amount']; + $taxAmount = round($field['options'][$optionValueId]['tax_amount'], 2); } $taxRate = $field['options'][$optionValueId]['tax_rate']; $lineItem[$optionValueId]['tax_amount'] = $taxAmount; @@ -1705,7 +1705,7 @@ WHERE ct.id = cp.financial_type_id AND if (array_key_exists($params['financial_type_id'], $taxRates)) { $field['options'][key($field['options'])]['tax_rate'] = $taxRates[$params['financial_type_id']]; $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($field['options'][$optionValueId]['amount'], $field['options'][$optionValueId]['tax_rate']); - $field['options'][$optionValueId]['tax_amount'] = $taxAmount['tax_amount']; + $field['options'][$optionValueId]['tax_amount'] = round($taxAmount['tax_amount'], 2); } } if (!empty($field['options'][$optionValueId]['tax_rate'])) { -- 2.25.1