Trying to calculate line Total tax by subtracting net_amount from amount on sales invoice item. Below is my client script, please assist.
frappe.ui.form.on(‘Sales Invoice’, {
refresh(frm) {
// your code here
frappe.ui.form.on(“Sales Invoice Item”, “amount”, function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, “custom_vat_amount”, d.amount-d.net_amount);
refresh_field(“custom_vat_amount”);
});
frappe.ui.form.on("Sales Invoice Item", "net_amount", function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, "custom_vat_amount", d.amount-d.net_amount);
refresh_field("custom_vat_amount");
});
}
frappe.ui.form.on("Sales Invoice Item", {
net_amount: function(frm,cdt,cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, 'custom_vat_amount', d.amount-d.net_amount);
}
});
But why you want to calculate this… if this is for printing purpose you can make this in custom print format… This will avoid adding a extra field in child doctype…