# Collections & complex rules

We can combine the rules we have shown above and the following is an example actually used in a council.&#x20;

\{{#each V2Account.CtaxDetails.YearsWithPositiveBalanceOutstanding\}}

**For  \{{Year\}}**

**Your Balance is: \{{formatToString BalanceOutstanding 'C' \}}**

&#x20;\{{#each RecYrSummary\}}&#x20;

&#x20;\{{#if @last\}}&#x20;

&#x20;\{{#if\_eq Stage.StageCode 'FINAL'\}}

&#x20;       **The recovery stage for this year is: \{{Stage.Value\}}**

&#x20;**The date this came into effect was: \{{Stage.StageDate\}}**

&#x20;**Being at final notice is bad :(**

&#x20;                              \{{/if\_eq\}}&#x20;

&#x20;\{{#if\_eq Stage.StageCode ‘BAIL'\}}

&#x20;       **The recovery stage for this year is: \{{Stage.Value\}}**

&#x20;**The date this came into effect was: \{{Stage.StageDate\}}**

&#x20;**Your account is with the Bailiffs. Contact them.**

&#x20;       \{{/if\_eq\}}&#x20;

&#x20;\{{/if\}}&#x20;

&#x20;\{{/each\}}

\{{/each\}}

Note only the content in **bold** is actually going to be shown to the customer.

What this does is:

1. Checks for all years where there is a balance outstanding&#x20;
2. Shows the year and balance for these&#x20;
3. Checks the collection of recovery periods inside each year&#x20;
4. Retrieves the most recent status using the @last rule&#x20;
5. Uses if statements to show different content to the customer based upon the current stage of their account

An example response where the account was at a Bailiff for 2019/20 would be:

**For 2019/20**

**Your Balance is: £1203.00**

**The recovery stage for this year is Bailiff**

**The date this came into effect was 20/03/2020**

**Your account is with the Bailiffs. Contact them.**
