Show invoice's item tables in Payment Entry format

Hi,

I’m quite new for erpnext. I’m try to config and stuck for printing format of payment entry.

I’d like to add item tables as show in invoice to Payment Entry.

Can you guide how I can add.

below is the list that I want to replace with items table

1 Like

Got two ways to achieve that:

  1. Print Format Builder

  2. Print Format (Scripting)

Hi,

Thank you for reply,

Yes I knew that we need to modify with that 2 ways. But what I need is how to call invoice items to show in documents.

Thank you

To show where? In the print format?

If so you can use the child table name like this:

 {%- for row in doc.items -%}
            <tr>
                <td style="width: 3%;">{{ row.idx }}</td>
                <td style="width: 20%;">
                    {{ row.item_name }}
                    {% if row.item_code != row.item_name -%}
                    <br>Item Code: {{ row.item_code}}
                    {%- endif %}
                </td>
                <td style="width: 37%;">
                    <div style="border: 0px;">{{ row.description }}</div></td>
                <td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
                <td style="width: 15%; text-align: right;">{{
                    row.get_formatted("rate", doc) }}</td>
                <td style="width: 15%; text-align: right;">{{
                    row.get_formatted("amount", doc) }}</td>
            </tr>
            {%- endfor -%}

The item table in Sales Invoice is named items, so this snippet should work!

2 Likes

Thanks @yefritavarez,

Exactly what I’m looking for, but it seems I might be pasting the script in wrongly, basically, I pasted it in a new Custom HTML element within the print format. But its not working.

@Thanakrit_Kitirachpo Did you succeed in resolving this in another way?

Dear @adam26d You don’t need the Print Format Builder for this.

Here is the correct way to use @yefritavarez’s answer

-Create a new Print Format
-Check the Custom Format Checkbox
-Choose ‘Server’ on the Print Format Type
-Paste the code on the HTML

  • Save it

This should work like that !

Regards

Thanks @Lewinta :slight_smile:

I’m getting a blank screen

Still trying other options.

My JS is super rusty, haven’t coded in years but I’m happy to be getting my hands dirty again. Loads of customisations coming my way…

Image below - The result

  • Receipt 2 (Custom Payment Entry)
  • A white screen after setting up the script as Lewinta advised. No items yet.
  • No js issues

Image below - Setup as described

  • Create new print format - done

  • Check the Custom Format Checkbox - done

  • Choose ‘Server’ on the Print Format Type - done

  • Pasted the code on the HTML - done

Possible issues:

  • Reference error for Items

Next

I’ll simplify the script and build it from the bottom up.

  • Whats the best way to test and troubleshoot these scripts when creating them?
  • And how can I combine it with my existing DocType?
  • Where can I find quick start examples/templates/source code to copy and modify?

@adam26d,

I can see you are using this Print Format on a Payment Entry, that Doctype doesn’t have a child table called “sales_invoice_item”, unless you have created the field, that might be the reason why you are getting a blank screen.

here is one example with one of the existing fields on that DocType, I will use the “references” table

This is the code on the Print Format

   {%- if doc.references| count > 0 -%}
<h3>References</h3>
<table class="table table-bordered">
		<tbody>
			<tr>	
				<th>Type</th>
				<th>Name</th>
				<th>Total Amount(DOP)</th>
				<th>Outstanding(DOP)</th>
				<th>Allocated(DOP)</th>
			</tr>
			
			{%- for item in doc.references-%}
				<tr>
				<td> {{item.reference_doctype}}</td>
				<td> {{item.reference_name}}</td>
				<td> {{item.total_amount}}</td>
				<td> {{item.outstanding_amount}}</td>
				<td> {{item.allocated_amount}}</td>
				</tr>
			{%- endfor -%}
			
			
		</tbody>
	</table> 
{%endif%}

Try that…

1 Like

This is the Print Format

And this is the Result, very basic just to Ilustrate…

Thank you @Lewinta. So that is exactly what I’m trying to achieve; pull the items table from the invoice. Not much relevant documentation on the topic yet.

Would you know how to achieve this?

This is all you need, check it out, you can print any child table if you understand the following code...

<table class="table table-bordered">
		<tbody>
			<tr>	
				<th>`HeadingField1`</th>
				<th>`HeadingField2`</th>
			</tr>
			{%- for item in doc.`child_table`-%}
				<tr>
				     <td> {{item.`field1`}}</td>
				     <td> {{item.`field2`}}</td>
				</tr>
			{%- endfor -%}
		</tbody>
</table>

I think I get you Lewinta; Child Table. So what I have to figure out is how to make the related invoice’s items a child table of the payment entry.

This helped me so much so thank you! What if we have about 20 invoices on one check? I’m looking for a way to have it continue the table to the right as I have only a few columns on my table. I have shrunk it down and can fit about 10 invoices on one table now but need to have it carry to the next area. Any help on that?

On payment entry doctype, I have address displaying. Now, I need it to display on print format for me. I got this:
{{ no such element: erpnext.accounts.doctype.payment_entry.payment_entry.PaymentEntry object[‘address_display’] }}

when using:


{{ doc.address_display }}

Any ideas for me?

@yefritavarez : Hi How to Remove the AED from columns, please help. Thanks in Advance

What is the AED ?