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);
frm.refresh_field(âtotal_quantityâ);
}
})
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) {
frappe.call({
"method": "frappe.client.get",
args: {
doctype: "Customer",
name: frm.doc.customer
},
callback: function (data) {
frappe.model.set_value(frm.doctype,
frm.docname, "credit_limit",
data.message.credit_limits[0].credit_limit
);
}
});
});
Have you Find any solution? How to implement it
Here is script to get customer balance on invoice using html
{% if doc.customer %}
{% set ledger_entries = frappe.get_all("GL Entry", filters={"party_type": "Customer", "party": doc.customer}, fields=["SUM(debit) - SUM(credit) as balance"]) %}
{% if ledger_entries %}
{% set balance = ledger_entries[0].balance %}
<p><b>Customer Balance: {{ frappe.format_value(balance, { "fieldtype": "Currency" }) }}</b></p>
{% endif %}
{% endif %}