Answers.Body: <p>This was a regression and was fixed. <a href="https://lab.civicrm.org/dev/core/-/issues/2344" rel="nofollow noreferrer">https://lab.civicrm.org/dev/core/-/issues/2344</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-02T15:31:55.093Z
Answers.LastActivityDate: 2021-02-02T15:31:55.093Z
Answers.UserDisplayName: netzih
Body: <p>I'm creating a custom thank you following the instructions here</p>
  <p><a href="https://docs.civicrm.org/user/en/latest/contributions/manual-receipts-and-thank-yous/" rel="nofollow noreferrer">https://docs.civicrm.org/user/en/latest/contributions/manual-receipts-and-thank-yous/</a></p>
  <p>However the {contribution.total_amount} token is causing an error saying</p>
  <blockquote>
  <p>Invalid currency &quot;USD****~~~~USD****~~~~USD****~~~~USD****~~~~USD&quot;</p>
  </blockquote>
  <p>All of my contributions are in dollars and that's what I've also set in localization.</p>
  <p>What could be causing this?</p>
  <p>This only happens when using the grouping option.
  I'm wondering if it relates to
  <a href="https://github.com/civicrm/civicrm-core/blob/3bfdcfb534a0b27a4f7f4c65bb07f2670ac31d14/CRM/Contribute/Form/Task/PDFLetterCommon.php#L74" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/3bfdcfb534a0b27a4f7f4c65bb07f2670ac31d14/CRM/Contribute/Form/Task/PDFLetterCommon.php#L74</a></p>
  <p>CiviCRM 5.32.2<br />
  Joomla 3.9.23</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-04T15:27:19.370Z
Comments.Text: That's a very strange currency. To find where it's coming from you could try adding some debugging in [here](https://github.com/civicrm/civicrm-core/blob/f0dcef9d944cfbfd16a286140afdcfc66e3d8202/CRM/Utils/Money.php#L54) to print a stack trace and what the input params are.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-04T22:48:45.390Z
Comments.Text: I'll tell you what's interesting, if I don't group the contributions it doesn't happen.
Comments.UserDisplayName: Elin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-05T21:41:51.040Z
Comments.Text: So if I change that "placeholder separator" to ""  I get  USDUSDUSDUSD ... so somehow it is not doing the replacements I guess.
Comments.UserDisplayName: Elin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-05T21:56:40.153Z
Comments.Text: This code comment might be old, but maybe the feature was never fully completed: https://github.com/civicrm/civicrm-core/blob/208ecdd87bc5251c4f075f006741fd8b747a0810/CRM/Contribute/Form/Task/PDFLetter.php#L104
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-08T04:31:39.843Z
Comments.Text: Interesting!  I think that maybe those options shouldn't be in the dropdown then!  The documentation shows it as implemented though.
Comments.UserDisplayName: Elin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-15T22:16:48.657Z
Comments.Text: @Elin did you ever work this out?
  I am struggling with the same thing on 2 sites (although something I found interesting is that it is only happening on WP, When trying the same thing on Drupal it is running fine)
Comments.UserDisplayName: netzih
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-16T00:31:46.610Z
Comments.Text: And I just noticed you are using Joomla, So maybe it is not WP specific.
Comments.UserDisplayName: netzih
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-16T19:00:24.313Z
Comments.Text: Correct, I think it is a problem i the implementation of the grouping.  Interestingly, the ID and date of contributions  tokens works perfectly but the amount does not.  Then the placeholder is being used and pasted together.
Comments.UserDisplayName: Elin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-16T20:59:50.033Z
Comments.Text: So the problem is that when doing the grouping, the $separator is put in between each  contribution detail, so with two contributions you end up with "USD****~~~~USD"  as the value for $currency instead of "USD"   which then throws an exception when fed into the Money format function.   So basically probably the currency needs to be handled differently because of that validity test.
Comments.UserDisplayName: Elin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-17T00:52:54.793Z
Comments.Text: Turns out someone else reported a very similar issue today https://lab.civicrm.org/dev/report/-/issues/56
Comments.UserDisplayName: Elin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-18T18:12:43.123Z
Comments.Text: Yes, however still interesting why it's working fine on Drupal but not on WP or Joomla (the only thing I can think of is that the Drupal civi instalation is an older version of civi, haven't updated it yet)
Comments.UserDisplayName: netzih
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-18T19:31:00.810Z
Comments.Text: Yes I tried to look at history to see if something had changed, but there was nothing obvious to me.  it's all internal to Civi so the CMS should not matter.
Comments.UserDisplayName: Elin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-21T23:08:17.140Z
Comments.Text: Was able to reproduce this error in both Drupal and wpmasters demo sites. This seems to be something quite recent as I was able to create this letter on Drupal and WP on early versions (tried on 5.31.0 and earlier and it worked fine) however on 5.32.2 (and possibly even earlier) it has been showing this error..
Comments.UserDisplayName: netzih
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-31T21:08:34.470Z
Comments.Text: @Elin I just created an issue at https://lab.civicrm.org/dev/core/-/issues/2344
  I could not see if you created one, If you did I should cancel/merge mine with yours.
Comments.UserDisplayName: netzih
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-01T06:00:32.807Z
Comments.Text: @netzih Thanks, I had added it to another issue that was also about multiple contributions, but I don't know if they are really due to the same thing so better to have a separate issue.
Comments.UserDisplayName: Elin
Tags: <message-templates><currency>
Title: Invalid Currency error when using custom template
ThreadText: # Invalid Currency error when using custom template
  
  (Asked by: username_0 on 2021-01-03)
  
  I'm creating a custom thank you following the instructions here
  
  <https://docs.civicrm.org/user/en/latest/contributions/manual-receipts-and-thank-yous/>
  
  However the {contribution.total\_amount} token is causing an error saying
  
  > Invalid currency "USD\*\*\*\*~~~~USD\*\*\*\*~~~~USD\*\*\*\*~~~~USD\*\*\*\*~~~~USD"
  
  All of my contributions are in dollars and that's what I've also set in localization.
  
  What could be causing this?
  
  This only happens when using the grouping option.
  I'm wondering if it relates to
  <https://github.com/civicrm/civicrm-core/blob/3bfdcfb534a0b27a4f7f4c65bb07f2670ac31d14/CRM/Contribute/Form/Task/PDFLetterCommon.php#L74>
  
  CiviCRM 5.32.2  
  Joomla 3.9.23
  
  **Tags:** message-templates, currency
  
  > **Comments:**
  > **username_1**: That's a very strange currency. To find where it's coming from you could try adding some debugging in [here](https://github.com/civicrm/civicrm-core/blob/f0dcef9d944cfbfd16a286140afdcfc66e3d8202/CRM/Utils/Money.php#L54) to print a stack trace and what the input params are.  
  > **username_0**: I'll tell you what's interesting, if I don't group the contributions it doesn't happen.  
  > **username_0**: So if I change that "placeholder separator" to ""  I get  USDUSDUSDUSD ... so somehow it is not doing the replacements I guess.  
  > **username_1**: This code comment might be old, but maybe the feature was never fully completed: https://github.com/civicrm/civicrm-core/blob/208ecdd87bc5251c4f075f006741fd8b747a0810/CRM/Contribute/Form/Task/PDFLetter.php#L104  
  > **username_0**: Interesting!  I think that maybe those options shouldn't be in the dropdown then!  The documentation shows it as implemented though.  
  > **username_2**: @username_0 did you ever work this out? I am struggling with the same thing on 2 sites (although something I found interesting is that it is only happening on WP, When trying the same thing on Drupal it is running fine)  
  > **username_2**: And I just noticed you are using Joomla, So maybe it is not WP specific.  
  > **username_0**: Correct, I think it is a problem i the implementation of the grouping.  Interestingly, the ID and date of contributions  tokens works perfectly but the amount does not.  Then the placeholder is being used and pasted together.  
  > **username_0**: So the problem is that when doing the grouping, the $separator is put in between each  contribution detail, so with two contributions you end up with "USD****~~~~USD"  as the value for $currency instead of "USD"   which then throws an exception when fed into the Money format function.   So basically probably the currency needs to be handled differently because of that validity test.  
  > **username_0**: Turns out someone else reported a very similar issue today https://lab.civicrm.org/dev/report/-/issues/56  
  > **username_2**: Yes, however still interesting why it's working fine on Drupal but not on WP or Joomla (the only thing I can think of is that the Drupal civi instalation is an older version of civi, haven't updated it yet)  
  > **username_0**: Yes I tried to look at history to see if something had changed, but there was nothing obvious to me.  it's all internal to Civi so the CMS should not matter.  
  > **username_2**: Was able to reproduce this error in both Drupal and wpmasters demo sites. This seems to be something quite recent as I was able to create this letter on Drupal and WP on early versions (tried on 5.31.0 and earlier and it worked fine) however on 5.32.2 (and possibly even earlier) it has been showing this error..  
  > **username_2**: @username_0 I just created an issue at https://lab.civicrm.org/dev/core/-/issues/2344 I could not see if you created one, If you did I should cancel/merge mine with yours.  
  > **username_0**: @username_2 Thanks, I had added it to another issue that was also about multiple contributions, but I don't know if they are really due to the same thing so better to have a separate issue.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-02-02. Score: 2 | Accepted answer
  
  This was a regression and was fixed. <https://lab.civicrm.org/dev/core/-/issues/2344>
  
  
  ---
  
  