From 05e7741a49e049b27c95816618491ccc7e2b744e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 21 May 2022 08:43:42 +1200 Subject: [PATCH] Fix empty money handling --- CRM/Core/EntityTokens.php | 3 +++ tests/phpunit/CRM/Event/Form/Task/BadgeTest.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CRM/Core/EntityTokens.php b/CRM/Core/EntityTokens.php index 1e5fc68277..8f7866971b 100644 --- a/CRM/Core/EntityTokens.php +++ b/CRM/Core/EntityTokens.php @@ -120,6 +120,9 @@ class CRM_Core_EntityTokens extends AbstractTokenSubscriber { } if ($this->isMoneyField($field)) { $currency = $this->getCurrency($row); + if (empty($fieldValue) && !is_numeric($fieldValue)) { + $fieldValue = 0; + } if (!$currency) { // too hard basket for now - just do what we always did. return $row->format('text/plain')->tokens($entity, $field, diff --git a/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php b/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php index 5f265796c2..5ea633b850 100644 --- a/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php +++ b/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php @@ -94,7 +94,7 @@ class CRM_Event_Form_Task_BadgeTest extends CiviUnitTestCase { '{participant.register_date}' => 'February 19th, 2007', '{participant.source}' => 'Wimbeldon', '{participant.fee_level}' => 'low', - '{participant.fee_amount}' => NULL, + '{participant.fee_amount}' => '$ 0.00', '{participant.registered_by_id}' => NULL, '{participant.transferred_to_contact_id}' => NULL, '{participant.role_id:label}' => 'Attendee', -- 2.25.1