Try ERPNext Buy Support Partners Foundation Foundation Members

Amount calculation

hi all
i create custom script in sales order item for override amount calculation by fowllowing script

frappe.ui.form.on(“Sales Order Item”, “qty2”, function(frm, doctype, name) {
var row = locals[doctype][name];
var calc_qty
calc_qty = row.qty2 * row.sub_unit;
calc_qty += row.xqty;
row.amount = calc_qty * row.sub_rate;
refresh_field(“items”);

var total_new = 0;
$.each(frm.doc.items || [], function(i, d) {
total_new += flt(d.amount);
});
frm.set_value(“total”, total_new);
//doc_obj.calculate_taxes_and_totals();
//cur_frm.cscript.calculate_taxes_and_totals();
});

and i edit file taxes_and_totals.js and taxes_and_totals.py in line 94 from

item.amount = flt(item.qty * item.rate)

to

item.amount = flt(((item.qty2 * item.sub_unit)+item.xqty) * item.sub_rate;

item row amount and sales order total is correct it’s work.

but when add new row and seleted new item amount in all row and form total is recalculate back to
item.qty * item.rate

can you advice please.