From 9f907d9ffc95d47b60dafc604e173575e6798f83 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 19 Jun 2021 17:02:13 +1200 Subject: [PATCH] Deprecate passing in 'null' for tax This is the source of the php8 test fails -and it's wrong - it should be 0 not null --- CRM/Contribute/BAO/Contribution.php | 3 +++ CRM/Contribute/Form/Contribution.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 8ede963283..131a9fa400 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -186,6 +186,9 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { $lineTotal += (float) ($lineItem['line_total'] ?? 0); } } + if (($params['tax_amount'] ?? '') === 'null') { + CRM_Core_Error::deprecatedWarning('tax_amount should be not passed in (preferable) or a float'); + } if (!isset($params['tax_amount']) && $setPrevContribution && (isset($params['total_amount']) || isset($params['financial_type_id']))) { $params['tax_amount'] = $taxAmount; diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 5796571d34..7ac2c15973 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1446,7 +1446,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } else { $lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = ""; - $submittedValues['tax_amount'] = 'null'; + $submittedValues['tax_amount'] = 0; } if ($lineItems[$itemId]['tax_rate']) { $lineItems[$itemId]['tax_amount'] = ($lineItems[$itemId]['tax_rate'] / 100) * $lineItems[$itemId]['line_total']; -- 2.25.1