fixed renaming patch
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index c1fbe64..30b5ed5 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -340,7 +340,7 @@
    "read_only": 1
   }, 
   {
-   "fieldname": "base_taxes_and_charges", 
+   "fieldname": "base_total_taxes_and_charges", 
    "fieldtype": "Currency", 
    "label": "Total Taxes and Charges (Company Currency)", 
    "no_copy": 1, 
@@ -783,7 +783,7 @@
  "icon": "icon-file-text", 
  "idx": 1, 
  "is_submittable": 1, 
- "modified": "2015-02-11 16:13:52.294735", 
+ "modified": "2015-02-18 15:05:33.635613", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Purchase Order", 
@@ -854,7 +854,7 @@
   }
  ], 
  "read_only_onload": 1, 
- "search_fields": "status, transaction_date, supplier,base_grand_total", 
+ "search_fields": "status, transaction_date, supplier,grand_total", 
  "sort_field": "modified", 
  "sort_order": "DESC", 
  "title_field": "supplier_name"
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 341b3ca..fc0a574 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -295,6 +295,7 @@
 		self.doc.base_grand_total = flt(self.doc.get("taxes")[-1].total
 			if self.doc.get("taxes") else self.doc.base_net_total)
 
+		print self.doc
 		self.doc.base_total_taxes_and_charges = flt(self.doc.base_grand_total - self.doc.base_net_total,
 			self.doc.precision("base_total_taxes_and_charges"))
 
diff --git a/erpnext/patches/v5_0/rename_total_fields.py b/erpnext/patches/v5_0/rename_total_fields.py
index d9465fa..4e980ce 100644
--- a/erpnext/patches/v5_0/rename_total_fields.py
+++ b/erpnext/patches/v5_0/rename_total_fields.py
@@ -29,7 +29,6 @@
 	("grand_total", "base_grand_total"),
 	("grand_total_import", "grand_total"),
 	("rounded_total", "base_rounded_total"),
-	("rounded_total_import", "rounded_total"),
 	("in_words", "base_in_words"),
 	("in_words_import", "in_words"),
 	("other_charges_added", "base_taxes_and_charges_added"),
@@ -40,12 +39,18 @@
 )
 
 def execute():
-	for dt in selling_doctypes:
-		frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
+	for doctypes, fields in [[selling_doctypes, selling_renamed_fields], [buying_doctypes, buying_renamed_fields]]:
+		for dt in doctypes:
+			base_net_total = frappe.db.sql("select sum(ifnull({0}, 0)) from `tab{1}`".format(fields[0][1], dt))[0][0]
+			if not base_net_total:
+				meta = frappe.get_meta(dt)
+				frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
 
-		for f in selling_renamed_fields:
-			rename_field(dt, f[0], f[1])
+				for f in fields:
+					if meta.get_field(f[0]):
+						rename_field(dt, f[0], f[1])
 
-		# Added new field "total_taxes_and_charges" in buying cycle, updating value
-		frappe.db.sql("""update `tab{0}`
-			set total_taxes_and_charges = round(base_total_taxes_and_charges/conversion_rate, 2)""".format(dt))
+				# Added new field "total_taxes_and_charges" in buying cycle, updating value
+				if dt in ("Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"):
+					frappe.db.sql("""update `tab{0}` set total_taxes_and_charges =
+						round(base_total_taxes_and_charges/conversion_rate, 2)""".format(dt))