mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
fix outstanding and floating point issue in gl entry
This commit is contained in:
15
patches/february_2013/fix_outstanding.py
Normal file
15
patches/february_2013/fix_outstanding.py
Normal file
@@ -0,0 +1,15 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
for dt in ["Sales Invoice", "Purchase Invoice"]:
|
||||
records = webnotes.conn.sql("""select name, outstanding_amount from `tab%s`
|
||||
where docstatus = 1""" % dt)
|
||||
for r in records:
|
||||
outstanding = webnotes.conn.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry`
|
||||
where against_voucher = %s and against_voucher_type = %s
|
||||
and ifnull(is_cancelled, 'No') = 'No'""", (r[0], dt))
|
||||
if flt(r[1]) != abs(flt(outstanding[0][0])):
|
||||
# print r, outstanding
|
||||
webnotes.conn.sql("update `tab%s` set outstanding_amount = %s where name = %s" %
|
||||
(dt, '%s', '%s'), (abs(flt(outstanding[0][0])), si[0]))
|
||||
22
patches/february_2013/gle_floating_point_issue_revisited.py
Normal file
22
patches/february_2013/gle_floating_point_issue_revisited.py
Normal file
@@ -0,0 +1,22 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
|
||||
records = webnotes.conn.sql("""select name, grand_total, debit_to from `tabSales Invoice`
|
||||
where docstatus = 1""", as_dict=1)
|
||||
|
||||
for r in records:
|
||||
gle = webnotes.conn.sql("""select name, debit from `tabGL Entry`
|
||||
where account = %s and voucher_type = 'Sales Invoice' and voucher_no = %s
|
||||
and ifnull(is_cancelled, 'No') = 'No' limit 1""", (r.debit_to, r.name), as_dict=1)
|
||||
if gle:
|
||||
diff = round((flt(r.grand_total) - flt(gle[0]['debit'])), 2)
|
||||
|
||||
if abs(diff) == 0.01:
|
||||
# print r.name, r.grand_total, gle[0]['debit']
|
||||
webnotes.conn.sql("""update `tabGL Entry` set debit = debit + %s
|
||||
where name = %s""", (diff, gle[0]['name']))
|
||||
|
||||
webnotes.conn.sql("""update `tabGL Entry` set credit = credit - %s
|
||||
where voucher_type = 'Sales Invoice' and voucher_no = %s
|
||||
and credit > 0 limit 1""", (diff, r.name))
|
||||
@@ -167,5 +167,5 @@ patch_list = [
|
||||
"patches.february_2013.account_negative_balance",
|
||||
"patches.february_2013.remove_account_utils_folder",
|
||||
"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)')",
|
||||
]
|
||||
Reference in New Issue
Block a user