{% for items in doc.references %}
{% set result = frappe.get_all("Purchase Invoice Item", filters={'parent': items.reference_name}, fields=['item_name', 'qty', 'rate', 'amount']) %}
{% for item in result %}
</tr>
{% endfor %}
{% endfor %}
Sr. No
Type
Name
Due Date
Item Name
Qty
Rate
Amount
Outstanding
Allocated
{{ loop.index }}
{{ items.reference_doctype }}
{{ items.reference_name }}
{{ items.due_date }}
{{ item.item_name }}
{{ item.qty }}
{{ item.rate }}
{{ item.amount }}
{{ items.outstanding_amount }}
{{ items.allocated_amount }}
My total wth:
{% set total_wth_amount = [0] %}
{% for items in doc.references %}
{% set result=frappe.db.get_value("Purchase Invoice Item",filters={'parent':items.reference_name},fieldname=['rate','qty','amount','item_name'],as_dict=true) %}
{% if result.item_name == "Rent" or result.item_name == "Science TextBook" or result.item_name == "WTH item" %}
{% set wth_rate = 5 %}
{% else %}
{% set wth_rate = 0 %}
{% endif %}
{% if wth_rate > 0 %}
{% set wth_amount = result.amount * (wth_rate / 100) %}
{% if total_wth_amount.append(total_wth_amount.pop() + wth_amount) %}{% endif %}
{% endif %}
{% endfor %}
Total withheld tax amount is:
{{ frappe.format_value(total_wth_amount.pop(), {‘fieldtype’:
‘Currency’, ‘options’: ‘TZS’}) }}
So i need the total amount in my table minus the total wth