Creating a Custom Jinja2 report¶
You can quickly create a custom report using a Jinja2 template. A Jinja2 template can be used to generate any text-based output file (including txt, html, csv, xml). paiyroll® automatically runs any custom reports based on its category:
- Employee pay run:
Runs after pay run completion. Used for example to generate payslips. Supports:
Quick start reports for:
- Company pre-approval:
Runs before and during pay run approval. Used for example to generate finance reports. Supports:
Quick start reports for:
Full-custom Jinja2 reports¶
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. -#}
{%- block everything -%}
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 -%}
{%- for stree, employee in snapshot.employee.items() -%}
{{- employee.works_id -}},
{{- employee.email -}},
{{- 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 -%}
{%- endblock -%}
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 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
Full-page payslips¶
Complete customisation is available for payslips. However, the majority of clients will only require a custom logo and a couple of branding colour changes.
Colours use web hex (hexadecimal) colours, which are capable of specifying over 16 million colours. Marketing or web-site departments should be familiar with the hex colours used for your branding, otherwise use a colour picker available on many web-sites to determine the hex colour. For example black is #000000 and white is #FFFFFF.
Simple custom payslip¶
The following example show how this is done. In Payslip2. In Settings > Template add the following customisation text:
either add or Update{% block heading_style %}color: #000000;{% endblock %}
{% block table_heading_style %}background-color: #00FF00;{% endblock %}
You customisations always are between the Curly brackets block sections. In the example above, the heading colour is changed to hex 000000 (black) and the table heading styles are also change to hex 00FF00 (green).
Here is another example where multiple customisations are separated by semicolons:
{% block client_logo_style %}max-width: 15%; background-color: #000000;{% endblock %}
A large logo is reduced in size to 15% of it’s width, and black is used as a background colour (the logo used is from Company branding). Note how each customisations ends with a semi-colons.
Reference: Full CSS used¶
Below for reference, is the full CSS (Cascading Style Sheets) used to customise the payslips:
body {
color: #08243c;
font-family: sans-serif;
padding-left: 2%;
padding-right: 2%;
{% block body_style %}{% endblock %}
}
h1 {
color: #3a799a;
background-color: #ffffff;
text-align: center;
padding: 5px;
{% block heading_style %}{% endblock %}
}
th {
color: #ffffff;
background-color: #73abca;
border-bottom: 1px solid #73abca;
border-top: 1px solid #73abca;
height: 1.25rem;
{% block table_heading_style %}{% endblock %}
}
table {
border-collapse: collapse;
width: 100%;
margin-top: 1rem;
{% block table_style %}{% endblock %}
}
.client_logo {
max-width: 35%;
margin-right: 5%;
float: right;
{% block client_logo_style %}{% endblock %}
}
{% block client_logo %}https://login.paiyroll.com/static/images/paiyroll.001.png{% endblock %}
Each section has its own block e.g. {% block body_style %} or {% block heading_style %} which you will need to use to refer and customise that section.
Compact payslips¶
Like Full-page payslips but based on a compact layout.
Cross-charging Shift-like pay to Departments¶
TBD
Advanced options¶
There are also advanced options which allow for a level of customisation between the full custom and the other types using the following Jinja blocks:
- header:
Report header section.
- body:
Report body section.
- p_identity:
Payslip-specific, Employee identity section.
- p_summary:
Payslip-specific, summary section.
- p_details:
Payslip-specific, details section.
- p_powered_by:
Payslip-specific, powered by paiyroll® section.
Contact paiyroll® support if this is of interest.