Answers.Body: <p>This seems like a bug and I can reproduce it on <a href="https://dmaster.demo.civicrm.org" rel="nofollow noreferrer">https://dmaster.demo.civicrm.org</a>. Can you file a bug report at <a href="https://lab.civicrm.org/groups/dev/-/issues" rel="nofollow noreferrer">https://lab.civicrm.org/groups/dev/-/issues</a>?</p>
  <p>It looks like the problem is here, where it can't find the type: <a href="https://github.com/civicrm/civicrm-core/blob/639e58b05319f32a29b09eace7d00e9609cb86e4/CRM/Member/Tokens.php#L64" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/639e58b05319f32a29b09eace7d00e9609cb86e4/CRM/Member/Tokens.php#L64</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-22T11:32:58.997Z
Answers.Text: There is a bug report now at https://lab.civicrm.org/dev/core/-/issues/3805. A fix is available, but not yet upstream.
Answers.UserDisplayName: Martin Peth
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-10T15:29:17.533Z
Answers.LastActivityDate: 2022-08-10T15:42:35.803Z
Answers.LastEditDate: 2022-08-10T15:42:35.803Z
Answers.UserDisplayName: Demerit
Body: <p>I did a short test on the demo sandbox.</p>
  <p>Selected &quot;Find Membership&quot; and selected one record.
  I then choose Print/Merge Document and added 2 tokens, {membership.id} and {membership.fee}
  Then clicked &quot;Preview&quot; to see the pdf outcome.</p>
  <p>If I use only the token {membership.id} I do not get any error message and the preview is created.</p>
  <p>Adding {membership.fee} I get the following error message below.</p>
  <p>Is this effectively a bug or am I doing something wrong? Thanks for your feedback.</p>
  <p>The website encountered an unexpected error. Please try again later.
  TypeError: Return value of CRM_Utils_Money::formatUSLocaleNumericRounded() must be of the type string, null returned in CRM_Utils_Money::formatUSLocaleNumericRounded() (line 207 of /srv/buildkit/build/d9-master/vendor/civicrm/civicrm-core/CRM/Utils/Money.php).</p>
  <p>CRM_Utils_Money::formatUSLocaleNumericRounded() (Line: 249)
  CRM_Utils_Money::formatLocaleNumericRoundedByPrecision() (Line: 234)
  CRM_Utils_Money::formatLocaleNumericRoundedByCurrency() (Line: 281)
  CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency() (Line: 65)
  CRM_Member_Tokens-&gt;evaluateToken() (Line: 146)
  Civi\Token\AbstractTokenSubscriber-&gt;evaluateTokens() (Line: 264)
  Symfony\Component\EventDispatcher\EventDispatcher-&gt;doDispatch() (Line: 239)
  Symfony\Component\EventDispatcher\EventDispatcher-&gt;callListeners() (Line: 73)
  Symfony\Component\EventDispatcher\EventDispatcher-&gt;dispatch() (Line: 209)
  Civi\Core\CiviEventDispatcher-&gt;dispatch() (Line: 354)
  Civi\Token\TokenProcessor-&gt;evaluate() (Line: 64)
  CRM_Core_TokenSmarty::render() (Line: 349)
  CRM_Core_BAO_MessageTemplate::renderTemplateRaw() (Line: 271)
  CRM_Core_BAO_MessageTemplate::renderTemplate() (Line: 131)
  CRM_Member_Form_Task_PDFLetter-&gt;generateHTML() (Line: 98)
  CRM_Member_Form_Task_PDFLetter-&gt;postProcessMembers() (Line: 75)
  CRM_Member_Form_Task_PDFLetter-&gt;postProcess() (Line: 573)
  CRM_Core_Form-&gt;mainProcess() (Line: 56)
  CRM_Core_QuickForm_Action_Submit-&gt;perform() (Line: 203)
  HTML_QuickForm_Controller-&gt;handle() (Line: 103)
  HTML_QuickForm_Page-&gt;handle() (Line: 355)
  CRM_Core_Controller-&gt;run() (Line: 319)
  CRM_Core_Invoke::runItem() (Line: 69)
  CRM_Core_Invoke::_invoke() (Line: 36)
  CRM_Core_Invoke::invoke() (Line: 88)
  Drupal\civicrm\Civicrm-&gt;invoke() (Line: 80)
  Drupal\civicrm\Controller\CivicrmController-&gt;main()
  call_user_func_array() (Line: 123)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber{closure}() (Line: 564)
  Drupal\Core\Render\Renderer-&gt;executeInRenderContext() (Line: 124)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext() (Line: 97)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber{closure}() (Line: 158)
  Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw() (Line: 80)
  Symfony\Component\HttpKernel\HttpKernel-&gt;handle() (Line: 58)
  Drupal\Core\StackMiddleware\Session-&gt;handle() (Line: 48)
  Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle() (Line: 106)
  Drupal\page_cache\StackMiddleware\PageCache-&gt;pass() (Line: 85)
  Drupal\page_cache\StackMiddleware\PageCache-&gt;handle() (Line: 48)
  Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle() (Line: 51)
  Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle() (Line: 23)
  Stack\StackedHttpKernel-&gt;handle() (Line: 709)
  Drupal\Core\DrupalKernel-&gt;handle() (Line: 19)</p>
  
Tags: <core>
Title: Error on membership fee token when using Print/Merge Document
ThreadText: # Error on membership fee token when using Print/Merge Document
  
  (Asked by: username_0 on 2022-08-10)
  
  I did a short test on the demo sandbox.
  
  Selected "Find Membership" and selected one record.
  I then choose Print/Merge Document and added 2 tokens, {membership.id} and {membership.fee}
  Then clicked "Preview" to see the pdf outcome.
  
  If I use only the token {membership.id} I do not get any error message and the preview is created.
  
  Adding {membership.fee} I get the following error message below.
  
  Is this effectively a bug or am I doing something wrong? Thanks for your feedback.
  
  The website encountered an unexpected error. Please try again later.
  TypeError: Return value of CRM\_Utils\_Money::formatUSLocaleNumericRounded() must be of the type string, null returned in CRM\_Utils\_Money::formatUSLocaleNumericRounded() (line 207 of /srv/buildkit/build/d9-master/vendor/civicrm/civicrm-core/CRM/Utils/Money.php).
  
  CRM\_Utils\_Money::formatUSLocaleNumericRounded() (Line: 249)
  CRM\_Utils\_Money::formatLocaleNumericRoundedByPrecision() (Line: 234)
  CRM\_Utils\_Money::formatLocaleNumericRoundedByCurrency() (Line: 281)
  CRM\_Utils\_Money::formatLocaleNumericRoundedForDefaultCurrency() (Line: 65)
  CRM\_Member\_Tokens->evaluateToken() (Line: 146)
  Civi\Token\AbstractTokenSubscriber->evaluateTokens() (Line: 264)
  Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() (Line: 239)
  Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 73)
  Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 209)
  Civi\Core\CiviEventDispatcher->dispatch() (Line: 354)
  Civi\Token\TokenProcessor->evaluate() (Line: 64)
  CRM\_Core\_TokenSmarty::render() (Line: 349)
  CRM\_Core\_BAO\_MessageTemplate::renderTemplateRaw() (Line: 271)
  CRM\_Core\_BAO\_MessageTemplate::renderTemplate() (Line: 131)
  CRM\_Member\_Form\_Task\_PDFLetter->generateHTML() (Line: 98)
  CRM\_Member\_Form\_Task\_PDFLetter->postProcessMembers() (Line: 75)
  CRM\_Member\_Form\_Task\_PDFLetter->postProcess() (Line: 573)
  CRM\_Core\_Form->mainProcess() (Line: 56)
  CRM\_Core\_QuickForm\_Action\_Submit->perform() (Line: 203)
  HTML\_QuickForm\_Controller->handle() (Line: 103)
  HTML\_QuickForm\_Page->handle() (Line: 355)
  CRM\_Core\_Controller->run() (Line: 319)
  CRM\_Core\_Invoke::runItem() (Line: 69)
  CRM\_Core\_Invoke::\_invoke() (Line: 36)
  CRM\_Core\_Invoke::invoke() (Line: 88)
  Drupal\civicrm\Civicrm->invoke() (Line: 80)
  Drupal\civicrm\Controller\CivicrmController->main()
  call\_user\_func\_array() (Line: 123)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 564)
  Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 158)
  Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
  Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
  Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
  Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
  Drupal\page\_cache\StackMiddleware\PageCache->pass() (Line: 85)
  Drupal\page\_cache\StackMiddleware\PageCache->handle() (Line: 48)
  Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
  Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
  Stack\StackedHttpKernel->handle() (Line: 709)
  Drupal\Core\DrupalKernel->handle() (Line: 19)
  
  **Tags:** core
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-08-10. Score: 0
  
  This seems like a bug and I can reproduce it on <https://dmaster.demo.civicrm.org>. Can you file a bug report at <https://lab.civicrm.org/groups/dev/-/issues>?
  
  It looks like the problem is here, where it can't find the type: <https://github.com/civicrm/civicrm-core/blob/639e58b05319f32a29b09eace7d00e9609cb86e4/CRM/Member/Tokens.php#L64>
  
  > **Comments:**
  > **username_2**: There is a bug report now at https://lab.civicrm.org/dev/core/-/issues/3805. A fix is available, but not yet upstream.  
  
  ---
  
  