-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Use new money formatting util for smarty formatting #22309
Conversation
(Standard links)
|
@eileenmcnaughton looks good to differentiate the currencies in the rows. We should extend the same to statistics as well. |
@yashodha yes - this change would affect anything that goes through crmMoney smarty modifier |
56b5ad1
to
57818f9
Compare
Where are these currency symbols coming from? I am used to ISO 4217 where currencies get a two letter prefix of the ISO two letter country code followed by a letter for the currency name, usually its first letter D for Dollar or Y for Yen, etc. E.g. CA$100.00 US$100.00 AU$100.00, or CAD$100.00 USD$100.00 AUD$100.00. I have never seen a standard that makes $ mean US dollar, CA$ mean Canadian dollar, and A$ mean Australian dollar. |
It's from Brick Money, but what comes out depends on your locale and the separator settings in the locale admin page. The above screenshots look like en_US, but e.g.
Leaving out the identifier makes sense in a single-currency install, but maybe not in a multi-currency install? I'm mixed opinion on the rest. |
Yeah - it changes according to your locale - my general feeling on that is that other people have put thought into what makes sense for the various locales and it is unlikely that we would come up with something that makes more sense Note that the separator settings are ignored in favour of locale-sensible-separators if you use the define |
ae29360
to
ad587cb
Compare
@eileenmcnaughton Failure in
So... Brick and Civi::format are trying to offer a compromise system that works across many different languages/currencies/user-roles/marketing-strategies/org-structures/etc. That is tricky... I see Joe's point.... in some contexts, abbreviated @demeritcowboy's suggestion sounds like an improvement. It still has some essential features of the current compromise -- it uses Brick's opinions for most language/currency issues (left/right placement, symbols, delimiters, etc), and it doesn't require you to fine-tune every caller. The improvement comes from using extra information about the org -- information that (AFAIK) isn't currently available to Brick. @eileenmcnaughton hesitance to dig is also relatable -- this space is quite fiddly. I'm not sure I'd want this PR to depend on that issue. Rephrase as a question: Should this subthread block the current PR? - or could it be forked off (eg to a separate (My gut says to fork it off as a separate concern... Brick is already used in other parts of Civi. The current compromise in Brick gives better out-of-the-box behavior for more situations than the status-quo. But it could be better...) |
This switches us from the old function to the new function
ad587cb
to
d6d93aa
Compare
The test is fixed now anyway! |
@eileenmcnaughton CiviGrant is broken in 5.46 and I bisected my way to this commit. To reproduce:
|
@eileenmcnaughton this fixes it: #22427 |
Overview
Use new money formatting util for smarty formatting.
Note this does not affect formatting in most cases.
However, one important improvement is that when viewing a value in a dollar currency that differs from the site locale the currency is made explicit - making it possible to distinguish between (for example) USD and CAD at a glance in a way that is locale based.
Before
Smarty crmMoney function uses legacy formatting
CRM_Utils_Money::format($amount, $currency)
Currency = USD
Currency = CAD
Currency = EUR
After
Switch to our new
Civi::format()->money($amount, $currency)
functionCurrency = USD
Currency = CAD
Currency = EUR
Technical Details
Comments