Try ERPNext Buy Support Partners Foundation Foundation Members

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

Hi,

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

			{{ item.allocated_amount  }}<br>

	{%- endfor -%}
	</span>

Can anyone help to bring values from another doctype?

Best Regards,
Kartive.

@Kartive_lfc, Try this

<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Sr. No</th>
<th>Type</th>
<th>Name</th>
<th>Due Date</th>
<th>Item Name</th>
<th>Qty</th>
<th>Rate</th>
<th>Amount</th>
<th>Outstanding</th>
<th>Allocated</th>
</tr>
</thead>
{% for items in doc.references %}
	<tr>
		<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>
	</tr>
{% endfor %}
</table> 

I hope this solves your problem.

Thanks @ROHAN_JAIN1, it helped a lot :smiley:

1 Like