Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/gl_control/gl_control.py b/accounts/doctype/gl_control/gl_control.py
index 9dec4d5..deb88f7 100644
--- a/accounts/doctype/gl_control/gl_control.py
+++ b/accounts/doctype/gl_control/gl_control.py
@@ -141,6 +141,9 @@
 	# ----------------
 	def save_entries(self, cancel, adv_adj, update_outstanding):
 		for le in self.entries:
+			# round off upto 2 decimal
+			le.debit, le.credit = round(le.debit, 2), round(le.credit, 2)
+			
 			#toggle debit, credit if negative entry
 			if flt(le.debit) < 0 or flt(le.credit) < 0:
 				tmp=le.debit
diff --git a/patches/november_2012/gle_floating_point_issue.py b/patches/november_2012/gle_floating_point_issue.py
new file mode 100644
index 0000000..c345152
--- /dev/null
+++ b/patches/november_2012/gle_floating_point_issue.py
@@ -0,0 +1,16 @@
+def execute():
+	import webnotes
+	
+	webnotes.conn.sql("""update `tabGL Entry` 
+		set debit = round(debit, 2), credit = round(credit, 2)""")
+
+	gle = webnotes.conn.sql("""select voucher_type, voucher_no, 
+		sum(ifnull(debit,0)) - sum(ifnull(credit, 0)) as diff 
+	    from `tabGL Entry`
+		group by voucher_type, voucher_no
+		having sum(ifnull(debit, 0)) != sum(ifnull(credit, 0))""", as_dict=1)
+
+	for d in gle:
+		webnotes.conn.sql("""update `tabGL Entry` set debit = debit - %s 
+			where voucher_type = %s and voucher_no = %s and debit > 0 limit 1""", 
+			(d['diff'], d['voucher_type'], d['voucher_no']))
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 93fc08d..1e54d5b 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -701,4 +701,8 @@
 		'patch_module': 'patches.november_2012',
 		'patch_file': 'production_order_patch',
 	},
+	{
+		'patch_module': 'patches.november_2012',
+		'patch_file': 'gle_floating_point_issue',
+	},
 ]
\ No newline at end of file