-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#9820 -Update EmailTemplate.php #10277
base: hotfix
Are you sure you want to change the base?
Conversation
It should it be titled |
Allows currency fields to be parsed in email templates as currency on the final email.
019d8e2
to
c9d5a96
Compare
Hello @pstevens71, thanks for your contribution! Regards, |
Hey @pstevens71 ! Thank you for your contributions! I've given this PR a test locally For example, if I create the following Email template for Opportunities: I create a 2nd Currency for GBP, and set it on an Opportunity: The Email comes through with the correct Currency selected, but the "Amount" field is rendered in USD: Do you know if this is intended/expected for this PR? Thanks! |
Hmm, it seems like the problem (in addition to this one) is with the _convertToType() either not parsing the right currency or, not getting passed what it needs to do so. I'll have a look. |
Ok having a deeper dive into the _convertToType() function it will always convert it to the default currency specified in the locale (not the amount, but they formatting of the output). It needs a condition to check the current record to see if a different currency is set in order to work for an alternate currency from the default locale. I'll see if I can come up with something for that too. |
Grr, why does everything have to be a can of worms! Ok so the amount in $opportunity_amount_usdollar is not actually the amount in USD, it's an unfortunate field name, it is actually the amount in the default currency specified in the locale settings (in my case CDN). $opportunity_amount is the $opportunity_usdollar_amount converted to the currency selected in the opportuntiy. So in my case, $CDN = 1, and $25,000 outputs as both $25,000 for both fields. If I change the opp to USD then the output is: Amount in USD = $25,000 (which is actuall $25, 000 CDN) and the $opportunity_amount is now $18,250 (USD). So the rule would have to be something like if the record contains amount_usdollar, then use the locale currency, if the current record contains a currency ID other than the locale, then use that instead for the field. So the amount_usdollar should always output as the default locale and any other amounts (if they exist) should output in the currency of current record. Ok let's see if I can do that!!! |
Allows currency fields to be parsed in email templates as currency on the final email.
The current $value just outputs raw value. Needs to be formatted as currency. There is already a function in the file to do that, just need to get the field type to use the function.
Description
First lirst line just gets the field "type" from the array. The second field just runs the value through the already defined function _convertToType() which formats for currency if it is a currency field.
This is issue #9820
Motivation and Context
It solves the problem of email templates with currency being formatted properly.
How To Test This
I tested this with a currency field and also a text field and both work after the change and produce the desired result in the email template final formatting.
To test you can create an email template with a currency field and see it is not formatted as currency, apply the patch and then re-output the email and you'll see its formatted as currency.
Types of changes
Final checklist