fixes in total_in_words
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 82261ed..f144ce9 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -366,15 +366,6 @@
 		 	self.doc.posting_date,'Posting Date')
 		
 		self.validate_write_off_account()
-		
-		#get Purchase Common Obj
-		pc_obj = get_obj(dt='Purchase Common')
-		
-		 # get total in words
-		dcc = get_company_currency(self.doc.company)
-		self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
-		self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency,
-		 	self.doc.grand_total_import)
 
 	def check_prev_docstatus(self):
 		for d in getlist(self.doclist,'entries'):
diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py
index 79e4fe0..42b558c 100644
--- a/buying/doctype/purchase_common/purchase_common.py
+++ b/buying/doctype/purchase_common/purchase_common.py
@@ -456,14 +456,6 @@
 		}
 		#msgprint(ret)
 		return ret
-
-
-				
-	# Get total in words
-	# ==================================================================	
-	def get_total_in_words(self, currency, amount):
-		from webnotes.utils import money_in_words
-		return money_in_words(amount, currency)	
 	
 	# get against document date	
 	#-----------------------------
diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py
index f08a319..6cef02a 100644
--- a/buying/doctype/purchase_order/purchase_order.py
+++ b/buying/doctype/purchase_order/purchase_order.py
@@ -67,10 +67,6 @@
 		# Check for stopped status
 		self.check_for_stopped_status(pc_obj)
 		
-		 # get total in words
-		dcc = get_company_currency(self.doc.company)
-		self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
-		self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
 
 	def get_default_schedule_date(self):
 		get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.py b/buying/doctype/supplier_quotation/supplier_quotation.py
index 4f28ecf..c8f5282 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -37,7 +37,6 @@
 		
 		self.validate_fiscal_year()
 		self.validate_common()
-		self.set_in_words()
 
 	def on_submit(self):
 		purchase_controller = webnotes.get_obj("Purchase Common")
@@ -79,10 +78,4 @@
 		pc.validate_mandatory(self)
 		pc.validate_for_items(self)
 		pc.get_prevdoc_date(self)
-		pc.validate_reference_value(self)
-		
-	def set_in_words(self):
-		pc = get_obj('Purchase Common')
-		company_currency = get_company_currency(self.doc.company)
-		self.doc.in_words = pc.get_total_in_words(company_currency, self.doc.grand_total)
-		self.doc.in_words_import = pc.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
+		pc.validate_reference_value(self)
\ No newline at end of file
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index d7a2964..1127d82 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -20,7 +20,7 @@
 from webnotes.utils import flt
 
 from buying.utils import get_item_details
-from setup.utils import get_company_currency
+from setup.utils import get_company_currency, get_total_in_words
 
 from utilities.transaction_base import TransactionBase
 class BuyingController(TransactionBase):
@@ -31,6 +31,10 @@
 			
 			if self.doc.price_list_name and self.doc.price_list_currency:
 				self.validate_conversion_rate("price_list_currency", "plc_conversion_rate")
+				
+			# set total in words
+			if self.meta.get_field("in_words") and self.meta.get_field("in_words_import"):
+				self.set_total_in_words()
 		
 	def update_item_details(self):
 		for item in self.doclist.get({"parentfield": self.fname}):
@@ -68,3 +72,9 @@
 			msgprint(_('Please enter valid ') + conversion_rate_label + (': ') 
 				+ ("1 %s = [?] %s" % (currency, self.company_currency)),
 				raise_exception=True)
+
+	def set_total_in_words(self):
+		company_currency = get_company_currency(self.doc.company)
+		self.doc.in_words = get_total_in_words(self.doc.grand_total, company_currency)
+		self.doc.in_words_import = get_total_in_words(self.doc.grand_total_import,
+		 	self.doc.currency)
\ No newline at end of file
diff --git a/setup/utils.py b/setup/utils.py
index 396dc16..7005235 100644
--- a/setup/utils.py
+++ b/setup/utils.py
@@ -47,3 +47,9 @@
 		return {"price_list_currency": result[0][0]}
 	else:
 		return {}
+
+@webnotes.whitelist()
+def get_total_in_words(amount, currency):
+	from webnotes.utils import money_in_words
+	fraction = webnotes.conn.get_value("Currency", currency, "fraction")
+	return money_in_words(amount, currency, fraction)
\ No newline at end of file
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
index 5c4aebd..46484e0 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -17,12 +17,11 @@
 from __future__ import unicode_literals
 import webnotes
 
-from webnotes.utils import cstr, flt, get_defaults, getdate
+from webnotes.utils import cstr, flt, get_defaults
 from webnotes.model.doc import addchild
 from webnotes.model.wrapper import getlist
 from webnotes.model.code import get_obj
 from webnotes import msgprint
-from setup.utils import get_company_currency
 
 sql = webnotes.conn.sql
 
@@ -136,10 +135,6 @@
 		pc_obj.validate_reference_value(self)
 		self.check_for_stopped_status(pc_obj)
 
-		# get total in words
-		dcc = get_company_currency(self.doc.company)
-		self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
-		self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
 		# update valuation rate
 		self.update_valuation_rate()