Commonified sales/purchase taxes and charges master.js code
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index 3a01ca0..13796c6 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -154,20 +154,6 @@
 		}
 	},
 
-	rate: function(doc, cdt, cdn) {
-		var item = frappe.get_doc(cdt, cdn);
-		frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
-
-		if(item.price_list_rate) {
-			item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
-				precision("discount_percentage", item));
-		} else {
-			item.discount_percentage = 0.0;
-		}
-
-		this.calculate_taxes_and_totals();
-	},
-
 	discount_amount: function() {
 		this.calculate_taxes_and_totals();
 	},
@@ -432,3 +418,7 @@
 		})
 	}
 })
+
+frappe.ui.form.on("Sales Taxes and Charges", "rate", function(frm, cdt, cdn) {
+	cur_frm.cscript.calculate_taxes_and_totals();
+})