Hi,
How to set “Amount”,when “Qty” and “Rate” are enterd - This all happen in child table.
I am fresher in erpNext and js.
// blur event
frappe.ui.form.on(“Child doc name”, “field name”, function(frm, cdt, cdn) {
}
// For Set value
var d = locals[cdt][cdn];
d.amt= d.qty * d.rate;
cur_frm.refresh();
Hi,
I have wrote the code like,
frappe.ui.form.on(“Rental Item”,“rate”,function(frm,cdt,cdn)){
var d = locals[cdt][cdn];
d.amount = d.quantity*d.rate;
cur_frm.refresh();
});
and i got the result
THank you so much… !
Now i have a problem that, I need to add the child table amounts and set to total amount filed in parent…
Please help me…
op = frm.doc.child_table_name
sum = 0
for(var i=0; i < op.length; i++) {
sum += op[i].amt
}
// For set value
cur_frm.set_value(“sum”,sum)
hi,
Working…
I have wrote like this
frappe.ui.form.on(“Rental Item”,“amount”,function(frm,cdt,cdn){
var op = frm.doc.rental_item;
var total_amount = 0;
for(var i=0; i < op.length; i++) {
total_amount += op[i].amount
}
// For set value
cur_frm.set_value("total_amount",total_amount);
});
actually you had tried wrong event for make addition.
you have to use proper event for this.
i think might be this will helpfull to you
frappe.ui.form.on(“Rental Item”,“rate”,function(frm,cdt,cdn)){
var d = locals[cdt][cdn];
d.amount = d.quantity*d.rate;
total_amount = frm.doc.total_amount
total_amount += d.amount
cur_frm.set_value(“total_amount”,total_amount);
cur_frm.refresh();
});
or use button and use button click event and put previously given code,
Thank you …
Were I will get the documentation about methods and events of frappe or erpnext…