From 9e12a48048ff951c9f29a926aac0c998f862856c Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Fri, 9 Jun 2023 08:15:46 -0600 Subject: [PATCH] Fix PHP warning on Participant --- CRM/Event/Form/Participant.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index bccecffa73..737094c4b1 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -2193,7 +2193,10 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_ $eventAmount = []; $totalTaxAmount = 0; - //add dataArray in the receipts in ADD and UPDATE condition + // add dataArray in the receipts in ADD and UPDATE condition + // dataArray contains the total tax amount for each tax rate, in the form [tax rate => total tax amount] + // include 0% tax rate if it exists because if $dataArray controls if tax is shown for each line item + // in the message templates and we want to show 0% tax if set, even if there is no total tax $dataArray = []; if ($this->_action & CRM_Core_Action::ADD) { $line = $lineItem ?? []; @@ -2203,13 +2206,13 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_ } if (Civi::settings()->get('invoicing')) { foreach ($line as $key => $value) { - if (isset($value['tax_amount'])) { + if (isset($value['tax_amount']) && isset($value['tax_rate'])) { $totalTaxAmount += $value['tax_amount']; if (isset($dataArray[(string) $value['tax_rate']])) { - $dataArray[(string) $value['tax_rate']] = $dataArray[(string) $value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value); + $dataArray[(string) $value['tax_rate']] += $value['tax_amount']; } else { - $dataArray[(string) $value['tax_rate']] = $value['tax_amount'] ?? NULL; + $dataArray[(string) $value['tax_rate']] = $value['tax_amount']; } } } -- 2.25.1