enfr

Repeatable sections

Updated: 2016-12-12

TaxCycle's template editor allows you to write one piece of template code and then tell TaxCycle to repeatedly run through it to apply it to more than one taxpayer. For example, this treatment is used in the built-in T1 JLetter to repeat the section for the principal taxpayer and then the spouse. This means, you only ever need to maintain one set of code. 

To work with repeatable sections, you need to first understand how to open the Template Editor and test your code. Learn about these in the Template Editor topic. Repeatable sections always contain field codes and conditions, so please read the help topics on Field codes and constants and Conditions before continuing. 

Examples of repeatable sections

You can find repeatable sections in a few built-in templates:

Template Use
JLetter To repeat the section which describes the tax credits applied to the principal taxpayer and spouse.
Invoice To repeat disbursements and line items.
JInvoice To repeat the invoice for the principal taxpayer and spouse. And, nested within this repeatable section, others to repeat disbursements and line items.
JPreSeason To repeat the checklist for the principal taxpayer and spouse.
JISlips To create a list of incomplete slips for the principal taxpayer and spouse.
FISlips To create a list of incomplete slips for all taxpayers in the file. This means for the principal taxpayer, the spouse and any dependants that have full returns.

Example A: Repeatable section in FISlips

{{! Repeat Section template }} {{< repeat }} 

{{ Info.ID.FirstName }}

{{# IncompleteSlips }} 

· {{ . }}

{{# Items }} 

o {{ . }}

{{/ Items }} 

{{/ IncompleteSlips }} {{/ repeat }} {{# File.Clients }} {{> repeat }} {{/ File.Clients }}

Adding a comment to explain

All of the repeatable section in the built-in templates begin with a comment. Link field codes and conditions, comments are enclosed in enclosed in double braces {{ }} (curly brackets). Within those braces, they begin with an exclamation mark {{! }}. Comments do not need closing. 

In Example A, above, the comment for the start of the repeatable section is {{! Repeat Section template }}.

Defining a repeatable section of template code

Each repeatable section must be surrounded by an opening and closing tag. In Example A, above, the opening tag is {{< repeat }} and the closing tag is {{/ repeat }}.

It actually doesn't matter that you use the word "repeat" in these tags, only that you use the same word in both the opening and closing tag. For example, JLetter uses "details," and JInvoice has two sections, "outerRepeat" and "LineItems."

Telling TaxCycle for what or whom to repeat it

After you define a repeatable section of code, you need to tell TaxCycle for what or whom to repeat it. This usually goes right after the closing tag, either on the same line or the next line. 

In Example A, above, the code repeats for all clients in the file: {{# File.Clients }} {{> repeat }} {{/ File.Clients }}

{{# File.Clients }} Opens the statement that tells TaxCycle to repeat for all clients in the file. This means the principal taxpayer, spouse and any dependants who have full tax returns.
{{> repeat }} Tells TaxCycle what to repeat. The word "repeat" in this code must match the word used to define the repeatable section.
{{/ File.Clients }} Closes the statement. This matches the opening statement, except it has the / (forward) slash to close the statement.

To repeat this statement for just the principal taxpayer and spouse, use the following piece of code:

{{# CurrentClient }} {{> repeat }} {{/ CurrentClient }} {{# CurrentSpouse }} {{> repeat }} {{/ CurrentSpouse }} 

Specifying the person

The CurrentClient portion of the field code this tells the Template Editor to look at the visible or active client. There are similar field codes to help you access specify the person whose form and field you wish to access.

Code Description

CurrentClient

Look at visible or active client. This code is relative of what return in the file you are looking at. If you are on the spouse/partner's return, it will look at the spouse's information. Likewise for dependants. This is what makes it possible for the CLetter to work for anyone in the file. 

CurrentSpouse

Look at the spouse of the CurrentClient. This code is relative of where you are in the return. If you are on the spouse/partner's return, it will look at the principal taxpayer's information. Likewise for dependants. This is what makes it possible for the JLetter to work for anyone in the file.

File.Principal

Access the principal taxpayer, even if you are on a dependant's or spouse's return. Unlike CurrentClient, it is not relative to what return in the file you are looking at. You can also use this to trigger repeatable sections. See Repeatable sections help topic.

Useful for relevant and used template properties to check whether the CurrentClient is also the principal taxpayer in the file. For example:

CurrentClient = File.Principal

File.Partner Access the spouse/partner taxpayer, even if you are on a dependant's or principal taxpayer's return. Unlike CurrentSpouse, it is not relative to what return in the file you are looking at. You can also use this to trigger repeatable sections. See Repeatable sections help topic.

File.Dependants

Access information for all dependants in the file.

A basic way to use this is to check whether there are dependants in the file:
{{#File.Dependants}}
This text will show if there are dependants in the file.
{{/File.Dependants}}

Another way to use this is to return a list of the value in a field for all dependants in the file. For example, if there are three dependants in the file, this will give a list of their first names: {{#File.Dependants}}{{Info.ID.FirstName}} {{/File.Dependants}} will create a list a list of those results: Joe Jane Jimmy

File.Clients

Used in repeatable sections, to repeat code for all the clients in the file. This includes principal taxpayer, spouse/partner and all dependants. See Repeatable sections help topic.

{{ aggregate(File.Clients, "1") }}

Count the number of clients in a file. This uses the aggregate function. See the Field codes help topic to learn more.

{{ count(File.Dependants) }}

Count the number dependants in the file.

Useful for relevant and used template properties to check whether there are any dependants in the file at all. For example:

count(File.Dependants) > 0

{{# File.Clients }}
{{# . = File.Principal}}
This is Principal
{{/ . = File.Principal}}
{{# . != File.Principal}}

This is not the principal
{{/ . != File.Principal}}
{{/ File.Clients}}
To treat one of the taxpayers differently, the . (period) will return the value of the CurrentClient, so you can check to see if it matches the Principal.