Try ERPNext Buy Support Partners Foundation Foundation Members

Print Format Issues Fetching Purchase Invoice Item table into another Doctype such as Payment Entry


I am new to ERPNext and currently trying to create a custom Print format where the requirement is to bring the Purchase Invoice Item Information in a custom Print Format for Payment Entry.

In short, in Payment Entry we have the Item table consisting of Purchase Invoice Reference Name, now i need those invoices corresponding information such as Item, Accepted Qty, Rate, Amount.

For the current doctype I am the below snippet.

	<span style="top:9.1cm;left: 1.7cm;
		position: absolute;">
		{%- for item in doc.references -%}

			{{ item.reference_name }}<br>

	{%- endfor -%}
			<span style="top:9.1cm;left: 16.0cm;
		position: absolute;">
		{%- for item in doc.references -%}

			{{ item.allocated_amount  }}<br>

	{%- endfor -%}

Can anyone help to bring values from another doctype?

Best Regards,

@Kartive_lfc, Try this

<table class="table table-bordered table-condensed">
<th>Sr. No</th>
<th>Due Date</th>
<th>Item Name</th>
{% for items in doc.references %}
		<td>{{ items.idx }} </td>
		<td>{{ items.reference_doctype }} </td>
		<td>{{ items.reference_name }} </td>
		<td>{{ items.due_date }} </td>
{%	set result=frappe.db.get_value("Purchase Invoice Item",filters={'parent':items.reference_name},fieldname=['rate','qty','amount','item_name'],as_dict=true) %}
		<td>{{ result.item_name }} </td>
		<td>{{ result.qty }} </td>
		<td>{{ result.rate }} </td>
		<td>{{ result.amount }} </td>
		<td>{{ items.outstanding_amount }} </td>
		<td>{{ items.allocated_amount }} </td>
{% endfor %}

I hope this solves your problem.

Thanks @ROHAN_JAIN1, it helped a lot :smiley:

1 Like