I want to change fuctionality of taxes_and_totals.js as i have a custom ad_discount field in items child table to consider in calculations. how to do without altering original file? please guide…
Assuming the field is a currency and not percentage
Try this custom script:
frappe.ui.form.on("Quotation Item", "ad_discount", function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_disc = 0;
total = frm.doc.base_net_total;
$.each(frm.doc.items || [], function(i, d) {
total_disc += flt(d.ad_discount);
});
total -= total_disc
frm.set_value("base_net_total", total);
});
1 Like
Thanx Tanuj for answer,
but this discount affects all totals and tax calculations.
once ad_discout entered and above calculation processed will be ok. but after that, if rate or qty change taxes_and_totals called and in it custom field ad_discount will be not considered,
Try validate instead of ad_discount . The script will pass after all other calculations
Thanx Tanuj.
Wiil try and get back…