Xplan Quick Xplain
Additional currency arguments
Let’s take a quick look at some additional currency function arguments.
Some versions back now, IRESS added in additional arguments to the currency function to enhance its capabilities. The additions were detailed via the release notes for the time (see release notes can be exciting from a coding perspective ;). Up until recently I hadn’t had a practical use for them but while putting together the table_it() article, one of those arguments was more useful than the concatenate alternative.
So, they may not be practical in every case, but like a lot of things, they are good to keep in mind for when you may use them.
These don’t need to be included and it would be quicker to not specify them if you aren’t interested in them:
1. has_symbol=True: This allows the merge output to automatically include the currency symbol. So instead of manually adding it before your code it can be automatically included as part of currency function:
<:=currency($client.total_assets.value, 0, has_symbol=1):>
# As you would expect, since 1 and True are the same you can just sub in 0 for False or 1 for True if you prefer.
At first glance writing this is lengthier than just adding a $ symbol so for one off cases you may be tempted to keep doing it the old way. However some instances where this will be useful:
1.1 When you are using currency outputs in complex data – As used in the tablet_it() article, to add the currency symbol requires you to convert the currency to a string and add it with the symbol. here it can be encapsulated all in one.
1.2 Multi-regional templates – This probably only applies to IRESS, but as Xplan continues it’s world wide domination into other regions you never know. This approach allows you to run the same template in different regions and each region should merge with their respective currency symbol.
1.3 Variables Functions and Variables for options – Client’s often have a lot of different preferences. Some don’t want to see currency symbols on each line item of tables etc. Using this approach plus a variable system would allow you to readily build in a mechanism to cater for that.
1.4 Functions – If you wrap this up into a function you will only need to write it once so making use of these extra arguments is even more worthwhile.
2. blank_zero=True: This option lets you specify whether zero values should appear in the output.
<:=currency($client.total_assets.value, blank_zero=True, has_symbol=True):>
Depending on what you are creating and the intended outputs this can be of use. The blank value also overwrites the has_symbol argument, so if there is no value nothing will merge including the symbol, so you won’t have a symbol and no value next to them.
Just two additional arguments that you can use and may be beneficial, pending what you are looking to achieve.
The only other point to consider is why IRESS devs don’t like consistency. Wouldn’t keeping consistency between these two arguments have been slightly more beneficial i.e: