Skip to content

Commit

Permalink
Fix PHP warning on Participant
Browse files Browse the repository at this point in the history
  • Loading branch information
larssandergreen committed Jun 9, 2023
1 parent 6602c89 commit 9e12a48
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,10 @@ protected function sendReceipts($params, $total_amount, array $customFields, arr
$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 ?? [];
Expand All @@ -2203,13 +2206,13 @@ protected function sendReceipts($params, $total_amount, array $customFields, arr
}
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'];
}
}
}
Expand Down

0 comments on commit 9e12a48

Please sign in to comment.