Patch for fixing floating point issue in gl entry
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