I attempted two different ways to calculate total discount amount [after item wise different discount amount in item row] but got error.
method 1:
{% set dis_amount =0 %}
{% set total_discount =0%}
{% for row in doc.items %}
{% set dis_amount = (row.discount_amount) %}
{% set total_discount = total_discount + dis_amount %}
{{ items | sum(attribute= discount_amount ) }} //##optional i found i tried, not worked same output
{% endfor%}
{{ total_discount }}
output : 0 --no sum at all
method 2:
{% set total_discount = [0] -%}
{% for item in doc.items -%}
{% if total_discount.append(total_discount.pop()+ item["discount_amount"]) -%}{% endif %}
{% endfor %}
{{ total_discount }}
output is like: [1908.89] —calculate total but “in bracket”, unable to remove
any help or change on this will be deeply appreciated.