fixes in gle_floating_point_issue patch

This commit is contained in:
Nabin Hait 2013-02-19 15:13:23 +05:30
parent fe787259b6
commit 66ea0861ff
3 changed files with 24 additions and 14 deletions

View File

@ -1,15 +1,24 @@
def execute(): def execute():
import webnotes import webnotes
from webnotes.utils import flt from webnotes.utils import flt
for dt in ["Sales Invoice", "Purchase Invoice"]: records = webnotes.conn.sql("""
records = webnotes.conn.sql("""select name, outstanding_amount from `tab%s` select against_voucher_type, against_voucher,
where docstatus = 1""" % dt) sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) as outstanding from `tabGL Entry`
for r in records: where ifnull(is_cancelled, 'No') = 'No'
outstanding = webnotes.conn.sql(""" and against_voucher_type in ("Sales Invoice", "Purchase Invoice")
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` and ifnull(against_voucher, '') != ''
where against_voucher = %s and against_voucher_type = %s group by against_voucher_type, against_voucher""", as_dict=1)
and ifnull(is_cancelled, 'No') = 'No'""", (r[0], dt)) for r in records:
if flt(r[1]) != abs(flt(outstanding[0][0])): outstanding = webnotes.conn.sql("""select name, outstanding_amount from `tab%s`
# print r, outstanding where name = %s and docstatus = 1""" %
webnotes.conn.sql("update `tab%s` set outstanding_amount = %s where name = %s" % (r["against_voucher_type"], '%s'), (r["against_voucher"]))
(dt, '%s', '%s'), (abs(flt(outstanding[0][0])), r[0]))
if outstanding and abs(flt(r["outstanding"])) != flt(outstanding[0][1]):
if ((r["against_voucher_type"]=='Sales Invoice' and flt(r["outstanding"]) >= 0) \
or (r["against_voucher_type"]=="Purchase Invoice" and flt(["outstanding"]) <= 0)):
webnotes.conn.set_value(r["against_voucher_type"], r["against_voucher"],
"outstanding_amount", abs(flt(r["outstanding"])))
else:
print r["against_voucher_type"], r["against_voucher"], \
outstanding[0][1], abs(flt(r["outstanding"]))

View File

@ -13,7 +13,7 @@ def execute():
diff = round((flt(r.grand_total) - flt(gle[0]['debit'])), 2) diff = round((flt(r.grand_total) - flt(gle[0]['debit'])), 2)
if abs(diff) == 0.01: if abs(diff) == 0.01:
# print r.name, r.grand_total, gle[0]['debit'] # print r.name, r.grand_total, gle[0]['debit'], diff
webnotes.conn.sql("""update `tabGL Entry` set debit = debit + %s webnotes.conn.sql("""update `tabGL Entry` set debit = debit + %s
where name = %s""", (diff, gle[0]['name'])) where name = %s""", (diff, gle[0]['name']))

View File

@ -169,9 +169,10 @@ patch_list = [
"patches.february_2013.update_company_in_leave_application", "patches.february_2013.update_company_in_leave_application",
"execute:webnotes.conn.sql_ddl('alter table tabSeries change `name` `name` varchar(100)')", "execute:webnotes.conn.sql_ddl('alter table tabSeries change `name` `name` varchar(100)')",
"execute:webnotes.conn.sql('update tabUserRole set parentfield=\"user_roles\" where parentfield=\"userroles\"')", "execute:webnotes.conn.sql('update tabUserRole set parentfield=\"user_roles\" where parentfield=\"userroles\"')",
"patches.february_2013.fix_outstanding",
"patches.february_2013.p01_event", "patches.february_2013.p01_event",
"execute:webnotes.delete_doc('Page', 'Calendar')", "execute:webnotes.delete_doc('Page', 'Calendar')",
"patches.february_2013.p02_email_digest", "patches.february_2013.p02_email_digest",
"patches.february_2013.p05_leave_application", "patches.february_2013.p05_leave_application",
"patches.february_2013.gle_floating_point_issue_revisited",
"patches.february_2013.fix_outstanding",
] ]