How to add expiry date in sales invoice

Hello everyone, I got stuck from last 2 days, can anyone please help me.

Problem – How to add expiry date in sales invoice.

You can create a custom field in the Item table to track the expiry date.

Are you using batched inventory? For a batch you’re able to capture the Expiry date which you’ll be able to fetch in the item table.

Once the field is added, you can customize the print format.

@Prav94, Hope this will help as well as other. I have done little excersie.

  1. Make enable Item >> Has Batch No and Has Expiry Date.

Customnize Sales Invoic Item., add custom field (Expiry Date) below batch no.

then Editing Row and set field as below

Save. Reload.

Add below code in Custom Print Format - Type Jinja

<table class="table table-bordered">
		<th>Item Name</th>
		<th class="text-right">Qty</th>
		<th class="text-right">Rate</th>
		<th class="text-right">Amount</th>
	{%- for row in doc.items -%}
		<td style="width: 3%;">{{ row.idx }}</td>
		<td style="width: 20%;">
			{{ row.item_name }}
			{% if row.item_code != row.item_name -%}
			<br>Code: {{ row.item_code}}
			{%- endif %}
		<td style="width: 37%;">
			<div style="border: 0px;">{{ row.item_name }} <br> BATCH : {{ row.batch_no }} | EXPIRY : {{ row.expiry_date }} </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>
	{%- endfor -%}




@Suresh_Thakor Thanks for help.

Hi, I replicated the same steps, but I’m having troubles to get the expiry date, any ideas?

Erpnext v13

Thanks in advance

1 Like

For some reason the expiry date isn’t set. Make sure the same is set correctly and then check the print format.

You can also fetch the value in jinja using the get_value API.


1 Like

Clear add fetch from batch no then Go to Expiry Date field and set Add Fetch

1 Like