in my landed cost voucher i create another field to get over all grand total. how to compute this before saving ? see the image below.
over all grand total, meaning sum of all Grand Totals?
In that case, you can make a custom field to have the overall grand total. Then you can write a trigger on the child table that update the custom field with the total. The logic in the custom script here can help:
Trigger on the child table means that the custom field will be updated whenever there is a change in the rows on child table, even before saving.
hi @pratu16x7 thank you for response.
yes i want to sum all grand totals. can you help me with my custom script, the computation is working after saving but i want to compute all grand total before saving.
frappe.ui.form.on("Landed Cost Voucher", "refresh", function(frm, cdt, cdn) {
data_44 = 0;
$.each(frm.doc.purchase_receipts || [], function(i, d) {
data_44 += flt(d.grand_total);
});
frm.set_value("data_44", data_44);
});
use this
frappe.ui.form.on("Landed Cost Purchase Receipt", "grand_total", function(frm, cdt, cdn) {
data_44 = 0;
$.each(frm.doc.purchase_receipts || [], function(i, d) {
data_44 += flt(d.grand_total);
});
console.log(data_44);
frm.set_value("data_44", data_44);
});
2 Likes
mark as solution from your side…