How to input Outstanding Balance in Sales Order

Hello,

Can I ask for help? I want to display the Outstanding Balance (Invoices that are not paid) in Sales Order. But it only displays “0.00” and how can I get the Customer Credit Limit.

Below is the code for Outstanding Balance :

cur_frm.cscript.customer = function(doc) {
return frappe.call({
method: “erpnext.accounts.utils.get_balance_on”,
args: {
date: frappe.datetime.nowdate(),
party_type: ‘Customer’,
party: doc.customer

	},
	callback: function(r) {
	doc.outstanding_balance = format_currency(r.message, erpnext.get_currency(doc.company));
	refresh_field('outstanding_balance');
    msgprint(doc.outstanding_balance)
	}
});

}

52%20PM

Thank you!

cur_frm.cscript.customer = function(doc) {
return frappe.call({
method: “erpnext.accounts.utils.get_balance_on”,
args: {
date: frappe.datetime.nowdate(),
party_type: ‘Customer’,
party: doc.customer

	},
	callback: function(r) {
	doc.outstanding_balance = format_currency(r.message, erpnext.get_currency(doc.company));
	refresh_field('outstanding_balance');
    msgprint(doc.outstanding_balance)
	}
});

}

**The outstanding balance of the customer ***
Total Accounts Receivable minus (-) the Credit Limit of the Customer