Sum of Table Columns in Print Format

Hello,

I am creating custom print format for Salary Slip, In which I am printing Loan Table as below.

Now I want to add a row with Totals.

May I know if any easy way is there.

@umarless

{% set total_loans=[0]%}
{% for l in doc.loans %}
{% if total_loans.append(total_loans.pop()+l.principal_amount) -%}{% endif %}
{% endfor %}

{{total_loans}}
1 Like