Custom script to get customer balance on Sales Invoice

This link might help as well:

thank you , i was searching for this calculation ,

frappe.ui.form.on(‘Task’, {
validate: function(frm, cdt, cdn) {
// make calculation on the fields
var b = flt(frm.doc.rate_per_fedden);
var c = flt(frm.doc.treated_area);
var a = b * c;
frm.set_value(‘total_quantity’, a);

Do we have script in client side?

The script is client side script, in the Custom Script Doc Type.

how to use this method for email notifications to get closing balance of customer on submission of payment entry.

I tried using this in Message section of new notification:

{{ erpnext.accounts.utils.get_balance_on(date= frappe.datetime.nowdate(), party_type= doc.customer, party= doc.customer) }}

But its not working. Kindly guide me.

is it possible to use it in jinja?


I couldn’t make it work. I tried to find a custom script to fetch customer’s credit_limit into a custom field called customer_credit_limit in Sales Invoice doctype.

Tried to scroll through various forum post to fetch child table’s value into a single custom field on another doctype, apparently, there aren’t any similar post.

Found the solution from here Cur_frm.add_fetch - #5 by PAMPERO

This will fetch the first’s row’s value. We can use this for any types of child table value fetching into a single field of another doctype.

frappe.ui.form.on("Sales Invoice", "customer",
function(frm) {{
        "method": "frappe.client.get",
        args: {
            doctype: "Customer",
            name: frm.doc.customer
        callback: function (data) {
                frm.docname, "credit_limit",
1 Like