#Loop getting the values from amount column in loan disbursement charges table
{% set loan_disbursement_charges = doc.loan_disbursement_charges %}
{%- for row in loan_disbursement_charges -%}
#Getting the total of the values of amount rows
{%- sum += row.get_formatted("amount", doc) -%}<br>
{%- endfor -%}
#Getting the difference , placing it to total variable
{%- total = sum - doc.disbursed_amount -%}
#Printing total
{%- print(total) -%}
{% set sum = 0 %}
{% set loan_disbursement_charges = doc.loan_disbursement_charges %}
{% for row in loan_disbursement_charges %}
{% set sum = sum + row.amount %}
{% endfor %}
{% set total = sum - doc.disbursed_amount %}
{{ total }}
i revised the code like this … no more error , but the arithmetic is not reflecting to the output