From 6fec0f2e6b5b0e58a295f4a9130c825a83ebae8d Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 28 Apr 2020 10:20:25 +1200 Subject: [PATCH] Further removal of long-deprecated skipCleanMoney Per https://github.com/civicrm/civicrm-core/commit/243320eda23195985815ceb65ec7ee9079ae3014 NOT setting this true (ie having the function clean up the money has been giving deprecation notices for a year, it can go now --- CRM/Contribute/BAO/Contribution.php | 9 ++------- CRM/Contribute/BAO/Contribution/Utils.php | 18 +++--------------- CRM/Price/Page/Field.php | 2 +- CRM/Price/Page/Option.php | 2 +- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 3f2d17d920..dbc9482836 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4162,11 +4162,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac public static function checkTaxAmount($params, $isLineItem = FALSE) { $taxRates = CRM_Core_PseudoConstant::getTaxRates(); - // This function should be only called after standardisation (removal of - // thousand separator & using a decimal point for cents separator. - // However, we don't know if that is always true :-( - // There is a deprecation notice tho :-) - $unknownIfMoneyIsClean = empty($params['skipCleanMoney']) && !$isLineItem; // Update contribution. if (!empty($params['id'])) { // CRM-19126 and CRM-19152 If neither total or financial_type_id are set on an update @@ -4213,7 +4208,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac empty($params['skipLineItem']) && !$isLineItem ) { $taxRateParams = $taxRates[$params['financial_type_id']]; - $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount(CRM_Utils_Array::value('total_amount', $params), $taxRateParams, $unknownIfMoneyIsClean); + $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount(CRM_Utils_Array::value('total_amount', $params), $taxRateParams); $params['tax_amount'] = round($taxAmount['tax_amount'], 2); // Get Line Item on update of contribution @@ -4247,7 +4242,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac // update line item of contrbution 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, $unknownIfMoneyIsClean); + $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['line_total'], $taxRate); $params['tax_amount'] = round($taxAmount['tax_amount'], 2); } } diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index cbdd33d080..a9e84fac1e 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -473,26 +473,14 @@ LIMIT 1 * Amount of field. * @param float $taxRate * Tax rate of selected financial account for field. - * @param bool $ugWeDoNotKnowIfItNeedsCleaning_Help - * This should ALWAYS BE FALSE and then be removed. A 'clean' money string uses a standardised format - * such as '1000.99' for one thousand $/Euro/CUR and ninety nine cents/units. - * However, we are in the habit of not necessarily doing that so need to grandfather in - * the new expectation. * * @return array * array of tax amount * */ - public static function calculateTaxAmount($amount, $taxRate, $ugWeDoNotKnowIfItNeedsCleaning_Help = FALSE) { - $taxAmount = []; - if ($ugWeDoNotKnowIfItNeedsCleaning_Help) { - Civi::log()->warning('Deprecated function, make sure money is in usable format before calling this.', ['civi.tag' => 'deprecated']); - $amount = CRM_Utils_Rule::cleanMoney($amount); - } - // There can not be any rounding at this stage - as this is prior to quantity multiplication - $taxAmount['tax_amount'] = ($taxRate / 100) * $amount; - - return $taxAmount; + public static function calculateTaxAmount($amount, $taxRate) { + // There can not be any rounding at this stage - as it should be done at point of display. + return ['tax_amount' => ($taxRate / 100) * $amount]; } /** diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index 141670e4d1..3563bd3dcc 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -133,7 +133,7 @@ class CRM_Price_Page_Field extends CRM_Core_Page { $getTaxDetails = TRUE; } if (isset($priceField[$priceFieldBAO->id]['tax_rate'])) { - $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($priceField[$priceFieldBAO->id]['price'], $priceField[$priceFieldBAO->id]['tax_rate'], TRUE); + $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($priceField[$priceFieldBAO->id]['price'], $priceField[$priceFieldBAO->id]['tax_rate']); $priceField[$priceFieldBAO->id]['tax_amount'] = $taxAmount['tax_amount']; } } diff --git a/CRM/Price/Page/Option.php b/CRM/Price/Page/Option.php index df3b6a3fc9..d477b90b83 100644 --- a/CRM/Price/Page/Option.php +++ b/CRM/Price/Page/Option.php @@ -142,7 +142,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page { if ($invoicing && isset($customOption[$id]['tax_rate'])) { $getTaxDetails = TRUE; } - $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($customOption[$id]['amount'], $customOption[$id]['tax_rate'], TRUE); + $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($customOption[$id]['amount'], $customOption[$id]['tax_rate']); $customOption[$id]['tax_amount'] = $taxAmount['tax_amount']; } if (!empty($values['financial_type_id'])) { -- 2.25.1