Total Unpaid amount fetching in sales invoice printformat

hi guys,
I want to fetch Total unpaid like its shows in customer dashboard in picture

and I’m using
get_balance_on(party_type=customer, party=doc.customer) but throwing error “get_balance_on is undefined”.
Please help me on this or suggest me any other method to fetch it.

@Ulter52 ,

Please create a custom field in the Sales Invoice and keep the Data Type as Data.

frappe.ui.form.on('Sales Invoice', {
	refresh(frm) {
	cur_frm.cscript.customer = function(doc) {
		method: "erpnext.accounts.utils.get_balance_on",
		args: {date: frappe.datetime.nowdate(), party_type: 'Customer', party: doc.customer},
		callback: function(r) {
			doc.cust_os = format_currency(r.message, erpnext.get_currency(;
			refresh_field('cust_os', 'accounts');  //cust_os is a custom field


1 Like

Sorry for not stating printformat.
Actually I want customer total outstanding in sales invoice print only. And I did not find where to use the above code after custom field creation.

@Ulter52 ,

it will not show on Standard Print Format, You will get a custom field once you make a copy of Standard and then refresh it.