From 9062791c51f57177c6a6422d133016dda8dea1a0 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sun, 20 Feb 2022 14:03:19 +0000 Subject: [PATCH] Remove use of overrideDefaultCurrency method from eventInfo template. --- CRM/Event/Page/EventInfo.php | 7 +++++-- CRM/Price/BAO/PriceField.php | 13 +++++++------ templates/CRM/Event/Page/EventInfo.tpl | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index cffa121265..20eb2126b7 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -58,6 +58,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { //retrieve event information $params = ['id' => $this->_id]; + $values = ['event' => NULL]; CRM_Event_BAO_Event::retrieve($params, $values['event']); if (!$values['event']['is_active']) { @@ -84,9 +85,11 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { $values['event']['event_tz'] = CRM_Core_SelectValues::timezone()[$values['event']['event_tz']]; + $eventCurrency = CRM_Utils_Array::value('currency', $values['event'], $config->defaultCurrency); + $this->assign('eventCurrency', $eventCurrency); + // show event fees. if ($this->_id && !empty($values['event']['is_monetary'])) { - CRM_Contribute_BAO_Contribution_Utils::overrideDefaultCurrency($values['event']); //CRM-10434 $discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event'); @@ -145,7 +148,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { $values['feeBlock']['isDisplayAmount'][$fieldCnt] = $fieldValues['is_display_amounts'] ?? NULL; if (Civi::settings()->get('invoicing') && isset($optionVal['tax_amount'])) { - $values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm); + $values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm, $eventCurrency); $values['feeBlock']['tax_amount'][$fieldCnt] = $optionVal['tax_amount']; } else { diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 6726f0b744..387d8d7ef5 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -830,21 +830,22 @@ WHERE id IN (" . implode(',', array_keys($priceFields)) . ')'; * Tax display setting option. * * @param string $taxTerm + * @param string|null $currency * * @return string * Tax label for custom field. */ - public static function getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm) { + public static function getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm, $currency = NULL) { if ($displayOpt == 'Do_not_show') { - $label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']); + $label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount'], $currency); } elseif ($displayOpt == 'Inclusive') { - $label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']); - $label .= ' ' . ts('(includes %1 of %2)', [1 => $taxTerm, 2 => CRM_Utils_Money::format($opt['tax_amount'])]) . ''; + $label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount'], $currency); + $label .= ' ' . ts('(includes %1 of %2)', [1 => $taxTerm, 2 => CRM_Utils_Money::format($opt['tax_amount'], $currency)]) . ''; } else { - $label = CRM_Utils_Money::format($opt[$valueFieldName]); - $label .= ' + ' . CRM_Utils_Money::format($opt['tax_amount']) . ' ' . $taxTerm . ''; + $label = CRM_Utils_Money::format($opt[$valueFieldName], $currency); + $label .= ' + ' . CRM_Utils_Money::format($opt['tax_amount'], $currency) . ' ' . $taxTerm . ''; } return $label; diff --git a/templates/CRM/Event/Page/EventInfo.tpl b/templates/CRM/Event/Page/EventInfo.tpl index 5d33dca43d..79c85015fa 100644 --- a/templates/CRM/Event/Page/EventInfo.tpl +++ b/templates/CRM/Event/Page/EventInfo.tpl @@ -190,16 +190,16 @@ {* Skip price field label for quick_config price sets since it duplicates $event.fee_label *} {else} - {$feeBlock.label.$idx} - {if $isPriceSet & $feeBlock.isDisplayAmount.$idx} - - {if $feeBlock.tax_amount && $feeBlock.tax_amount.$idx} - {$feeBlock.value.$idx} - {else} - {$feeBlock.value.$idx|crmMoney} - {/if} - - {/if} + {$feeBlock.label.$idx} + {if $isPriceSet & $feeBlock.isDisplayAmount.$idx} + + {if $feeBlock.tax_amount && $feeBlock.tax_amount.$idx} + {$feeBlock.value.$idx} + {else} + {$feeBlock.value.$idx|crmMoney:$eventCurrency} + {/if} + + {/if} {/if} {/foreach} -- 2.25.1