skip to Main Content

xplan xmerge

Generic filters
Exact matches only
Filter by Custom Post Type

Try these: client detailstasks syntaxsuperannuation

Function: Currency

Many financial planning documents such as: Fact Finds, Advice Documents, Review Reports and Portfolio valuations make heavy use of displaying dollar values.  A custom currency function to greatly reduce repetitive code and keeps your coding cleaner and easier to read:

Defining the function

Recommend you define this function at the start of your template so that you can call it throughout the template as needed.

Setec Astronomy

<:let currency2=lambda x: currency(floatify(x), 2, has_symbol=True, blank_zero=False):>

Example usage

Notice how through the function you don’t need to hardcode the dollar sign into your documents either.  This will add it automatically

Setec Astronomy

output: $100,000.00


You may find that some documents have a mix of dollar values, i.e., some that show to two decimal places and others that show no decimal places.  This can be common with an SOA where insurance sums insured are typically without decimal places, but fees and investment costs may show them.

To achieve this, you just define two different currency functions.  In the example below, we have assigned them currency0 and currency2 respectively where the number on the end denotes the decimal places:

Setec Astronomy

<:let currency0=lambda x: currency(floatify(x), 0, has_symbol=True, blank_zero=False):>
<:let currency2=lambda x: currency(floatify(x), 2, has_symbol=True, blank_zero=False):>


You could also define a single function that accepts two arguments:

Setec Astronomy

<:let Currency=lambda x, y: currency(floatify(x), y, has_symbol=True, blank_zero=False):>

In use:

Setec Astronomy

<:=Currency($client.ordinary_wages, 0):>
output: $100,000

See also

Back To Top