Global variables and custom functions

Is there a way to define variables in one template that can be used across different templates?

eg can the tax brackets personal taxes for calender year 2018 be defined in one place and used in other places? If yes, how can I achieve this?

Same thing with custom functions: is it possible to make one own’s functions (eg IsLeapYear) in one spot and then use that function by calling it in other templates?

Thanks!

Hi Bart,

For this you’ll have to set the template as a reconciliation.
Once this is done, you can use the following syntax to fetch variables created in the reconciliation template:

period.reconciliations..custom.some.thing

The handle is defined in the reconciliation template as well. This should allow you to use variables from one template in other templates.

Does this help you further?

OK Jelle, thank you for your reply. Could you give a concrete example?

Suppose I want to define the following variables in the reconciliation template:

  • tax_bracket_lower = 5000
  • tax_bracket_upper = 12000
  • tax_bracket_percentage = 0.125

So I put in (eg) in the reconciliation template:

custom.pb.tax_bracket_lower = 5000
custom.pb.tax_bracket_upper = 12000
custom.pb.tax_bracket_percentage = 0.125

and then I call them in the other template like this?

{% assign var = period.reconciliations.custom.pb.tax_bracket_upper - custom.pb.tax_bracket_lower %}

Hi @Bart_Verhaeghe,

In your code you forget your handle, given to the reconciliation template you are using to read those cusrtom variables.

If your reconciliation template has brackets as a handle, you can read any custom object of that template by this :

{{ period.reconciliations.brackets.custom.pb.tax_bracket_upper }}

You can make it more clear by doing this for example :

{% assign brackets = period.reconciliations.brackets %}

{{ brackets..custom.pb.tax_bracket_upper }} 

If you custom recon template doens’t have a handle, it can be added on firm level :

33