Creating a Custom Jinja report¶
You can quickly create a custom report using a Jinja2 template.
A Jinja template is a text file which can be used to generate any text-based output file (txt, html, csv, xml). Example templates can be found below which can be downloaded and tailored as required.
Employee Extract report example¶
The following template:
{#- Copyright © 2021 Innovatie Ltd. All rights reserved. -#}
{#- . -#}
works_id,email,name,mobile,date_of_birth,line1,line2,line3,line4,postcode,account_name,sort_code,account_number
{{ "" }}
{%- macro date2human(value) -%} {{- value.split('-')|reverse|join('/') -}} {%- endmacro -%}
{%- set titles = dict() -%}
{%- for s, title in snapshot['title'].items() -%}
{%- set x = titles.__setitem__(title['id'], title['title']) -%}
{%- endfor -%}
{%- for stree, employee in snapshot.employee.items() -%}
{{- employee.works_id -}},
{{- employee.email -}},
{{- titles[employee.title] }}{{ employee.name.split(',')[1] }} {{ employee.name.split(',')[0] -}},
{{- employee.mobile -}},
{{- date2human(employee.taxdetail.date_of_birth) -}},
{{- employee.postaldetail.line1.replace(',', ' ') -}},
{{- employee.postaldetail.line2 -}},
{{- employee.postaldetail.line3 -}},
{{- employee.postaldetail.line4 -}},
{{- employee.postaldetail.postcode -}},
{{- employee.bankdetail.account_name -}},
{{- employee.bankdetail.sort_code -}},
{{- employee.bankdetail.account_number }},
{{ "" }}
{%- endfor -%}
Will generate this CSV:
works_id |
name |
mobile |
date_of_birth |
line1 |
line2 |
line3 |
line4 |
postcode |
account_name |
sort_code |
account_number |
||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
223 |
Mr Sherlock Holmes |
+447000123456 |
11/09/1972 |
221B |
Baker Street |
NW1 6XE |
SHERLOCK HOLMES |
123456 |
12345678 |
||||
Miss H Havisham |
+447000123456 |
02/01/1989 |
103 |
Park Lane |
NW1 6XN |
H HAVISHAM |
123456 |
12345678 |
|||||
Mr William Tell |
+447000123456 |
01/02/1954 |
113 |
Waterloo Road |
NW1 6XU |
WILLIAM TELL |
123456 |
12345678 |
|||||
Miss Ali Baba |
+447000123456 |
15/09/1992 |
118 |
Old Kent Road |
NW1 6XX |
ALI BABA |
123456 |
12345678 |
|||||
Mr James Bond |
+447000123456 |
06/01/1920 |
123 |
Picadilly |
NW1 6XB |
JAMES BOND |
123456 |
12345678 |
|||||
Mr Huckleberry Finn |
+447000123456 |
07/01/1979 |
128 |
Strand |
NW1 6XX |
HUCKLEBERRY FINN |
123456 |
12345678 |
|||||
Robinson Crusoe |
+447000123456 |
01/08/1980 |
133 |
Mayfair |
NW1 6XY |
ROBINSON CRUSOE |
000000 |
00000000 |
|||||
Mr Hercule Poirot |
+447000123457 |
10/01/1986 |
143 |
Church Lane |
W2 2DA |
HERCULE POIROT |
123456 |
12345678 |
|||||
Employee extract CSV template can be
downloaded here
GB Payslip Report Example¶
This example template which for a GB payslip HTML template can be downloaded here
Will generate an HTML document one per employee:
Steps to create a new custom report¶
Add a new Report Definition based on the Jinja2 (employee pay run) template with a different name/description e.g. Employee Extract
Copy and paste the template text into the Template field.
Change the filename to whatever you want e.g. employee_extract.csv
Click Update to save the report
Redo the payrun and the report will be available in My documents .
This template will generate one page or one row per employee.
Tip
If you add extra spaces or new lines in the template - these will appear in the custom report