client side - recalculate amount and total amount on change of qty or valuation reate of the item

This commit is contained in:
Neil Trini Lasrado 2015-02-13 15:31:20 +05:30
parent 2e0e711eb2
commit 9aafe76f63

View File

@ -476,3 +476,19 @@ cur_frm.cscript.company = function(doc, cdt, cdn) {
cur_frm.cscript.posting_date = function(doc, cdt, cdn){
erpnext.get_fiscal_year(doc.company, doc.posting_date);
}
var calculate_total = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
amount = d.incoming_rate * d.qty
frappe.model.set_value(cdt, cdn, 'amount', amount);
return frappe.call({
doc: cur_frm.doc,
method: "set_total_amount",
callback: function(r) {
refresh_field('total_amount');
}
});
}
cur_frm.cscript.incoming_rate = calculate_total;
cur_frm.cscript.qty = calculate_total;