How to list all overdue invoices when create a new one

When i am creating a new invoice,

I would like to create a kind of field thats is like the customer statement to receive,
so when i make the invoice i can list all the others invoice outstanding.

Do you want to mail this along with new invoice?

no i want to print the statement with the invoice incide of the invoice

You can use this.

  	{%- set outstanding_invoice = frappe.get_list("Sales Invoice", 
  		fields=["name","posting_date","customer","rounded_total","outstanding_amount"],
  		filters={ "docstatus":1, "customer":doc.customer, "outstanding_amount":(">",0)})
  	-%}
  	{%- for row in outstanding_invoice -%}
  	
  	<tr>
  		<td width="18%" valign="top">
  			<p align="center">
  				{{ row.name }}
  			</p>
  		</td>
  		<td width="12%" valign="top">
  			<p align="center">
  				{{ row.posting_date.strftime("%d-%m-%Y") }}
  			</p>
  		</td>
  		<td width="37%" valign="top">
  			<p align="center">
  				{{ row.customer }}
  			</p>
  		</td>
  		<td width="13%" valign="top">
  			<p align="right">
  				Rs. {{ row.rounded_total }}
  			</p>
  		</td>
  		<td width="18%" valign="top">
  			<p align="right">
  				 Rs. {{ row.outstanding_amount}}</strong>
  			</p>
  		</td>
  	</tr>
  	{% endfor %}
  	<tr>
  		<td width="68%" colspan="3" valign="top">
  			<p align="center">
  				<strong>Total Outstanding</strong>
  			</p>
  		</td>
  		<td width="13%" valign="top">
  			<p align="right">
  				<strong></strong>
  			</p>
  		</td>
  		<td width="18%" valign="top">
  			<p align="right">
  				<strong>Rs. {{ outstanding_invoice|sum(attribute='outstanding_amount') }}</strong>
  			</p>
  		</td>
  	</tr>			
  </tbody>

Invoice

Date

Customer

Invoice Amt

Outstanding Amt

5 Likes

will try and let you know thank you

Thank you very much it worked

Hello again, how could i take days/age of those invoices, as in accounts receivable?

Yes, its possible. You need to get it calculated for each outstanding invoice.

daer i have also pasted it in custom script but get this error when refresh:

SyntaxError: Unexpected token <
at Class.setup (http://www.fmtrd.com/assets/js/form.min.js:2507:17)
at _f.Frm.setup (http://www.fmtrd.com/assets/js/form.min.js:174:22)
at _f.Frm.refresh (http://www.fmtrd.com/assets/js/form.min.js:454:30)
at Class.load (http://www.fmtrd.com/assets/js/form.min.js:87:33)
at http://www.fmtrd.com/assets/js/form.min.js:82:7
at Object.callback (http://www.fmtrd.com/assets/js/desk.min.js:6096:6)
at Object.callback [as success_callback] (http://www.fmtrd.com/assets/js/desk.min.js:1151:16)
at _ (http://www.fmtrd.com/assets/js/desk.min.js:1175:34)
at Object. (http://www.fmtrd.com/assets/js/desk.min.js:1271:4)
at i (http://www.fmtrd.com/assets/frappe/js/lib/jquery/jquery.min.js:2:27151)

i dont know if it helps but i had to change this line to this one

filters={ ā€œdocstatusā€:1, ā€œcustomerā€:doc.customer, ā€œoutstanding_amountā€:(">",0)})

can you support how to do it in html, i know to make on excel but not good with codeā€¦ if its possible

Yes looks like syntax error, corrected in the above code

dear i ma not a programmer and this is first custom script i am using so guide me if i am doing ok. i have just copied the code given above and copied it in custom script under doctype sale invoice and thats it.

How can we print total outstanding in sales invoice. I need the total outstanding only.

Thant was Perfect . Thank you