Good day everyone.
I have created a custom script for child table grid calculation to multiply Quantity x Rate and gives me the amount in the child table. my child table has the following columns; quantity, rate and amount. e.g quantity x rate = amount. and also want to sum the amount and get total on parent table. my custom script works well on desktop view but not mobile view. below is my script;
frappe.ui.form.on(‘Memo Table’, {
“qty”: function(frm, cdt, cdn) {
let gridRow = frm.open_grid_row();
if (!gridRow) {
gridRow = frm.get_field(‘details’).grid.get_row(cdn);
}
callAmount(gridRow);
},
"rate": function(frm, cdt, cdn) {
let gridRow = frm.open_grid_row();
if (!gridRow) {
gridRow = frm.get_field('details').grid.get_row(cdn);
}
callAmount(gridRow);
},
amount: function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var total = 0;
frm.doc.details.forEach(function (d) { total += d.amount; });
frm.set_value("total", total);
refresh_field("total");
},
details_remove: function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var total = 0;
frm.doc.details.forEach(function (d) { total += d.amount; });
frm.set_value("total", total);
refresh_field("total");
},
})
function callAmount(gridRow) {
let qty = gridRow.on_grid_fields_dict.qty.value;
let rate = gridRow.on_grid_fields_dict.rate.value;
let amount = qty * rate;
frappe.model.set_value(
gridRow.doc.doctype,
gridRow.doc.name,
‘amount’,
amount
);
}
my child table name = Memo Table
child table name on parent table = details
Total field name on parent table = total.
I really need your help to make it work on mobile view