How to create custom Salary Slip print format in erpnext?

Hi Folks,

I have created a custom template for printing salary slips. I want to know the jinja variable names through which all fields can be rendered in template.
I want to access all the variables which are rendering in default Standard Salary Slip template in my own custom designed template.

Thanks.

@progShubham, please, take a look a this: Print Format

Also, search for Print Format List in your system and check those too for more info!

Ps: Variables in the form are passed to the template in the doc object ex. {{ doc.name }} will print out the id of the document.

Hey Shubham,

Creating a custom Salary Slip print format in ERPNext (version 8) involves utilizing Jinja templating to access and display various fields. Here’s a concise guide to help you get started:

Accessing Fields in Jinja Templates

Basic Fields: Use the doc object to access standard fields. For example:
{{ doc.name }}: Salary Slip ID
{{ doc.employee }}: Employee ID
{{ doc.employee_name }}: Employee Name
{{ doc.month }}: Salary Month
{{ doc.payment_days }}: Number of Payment Days
{{ doc.net_pay }}: Net Pay Amount
Child Tables: For fields like Earnings and Deductions, which are stored in child tables, iterate over them using loops:

jinja

CopyEdit

<table>
  <tr>
    <th>Earnings</th>
    <th>Amount</th>
  </tr>
  {% for row in doc.earnings %}
  <tr>
    <td>{{ row.salary_component }}</td>
    <td>{{ row.amount }}</td>
  </tr>
  {% endfor %}
</table>

<table>
  <tr>
    <th>Deductions</th>
    <th>Amount</th>
  </tr>
  {% for row in doc.deductions %}
  <tr>
    <td>{{ row.salary_component }}</td>
    <td>{{ row.amount }}</td>
  </tr>
  {% endfor %}
</table>

:hammer_and_wrench: Steps to Create a Custom Print Format

  1. Navigate to Print Format: Go to Setup > Printing > Print Format in ERPNext.
  2. Create New Format:
    Click on New.
    Enter a name for your print format.
    Select “Salary Slip” as the DocType.
    Choose “Custom” as the format type.
  3. Design Your Template:
    In the HTML section, use Jinja templating to structure your salary slip.
    Incorporate Bootstrap classes for styling, as ERPNext supports Bootstrap in print formats.
  4. Preview and Test:
    Save your print format.
    Go to a Salary Slip record.
    Click on Print and select your custom format to preview.

:books: Additional Resources

ERPNext Print Format Customization Guide: Offers insights into structuring and styling print formats. Read More
Jinja Templating in ERPNext: Understand how Jinja integrates with ERPNext’s print formats. Learn More
ERPNext Documentation on Print Formats: Official documentation for creating and managing print formats. Explore


If you’re looking for a tool to generate professional salary slips effortlessly, consider using [payslipgenerator.net] ( https://payslipgenerator.net ). It’s a user-friendly platform that can help streamline the process.

Let me know if you need further assistance or have specific requirements!