From 1cf73915620a73196b5481139dc04be8f18a365f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 15 Mar 2013 13:42:31 +0530 Subject: [PATCH] patch to fix incorrect gl entries due to payment reconciliation between 2013-03-11 and 2013-03-15 --- controllers/accounts_controller.py | 5 +++- .../march_2013/p05_payment_reconciliation.py | 30 +++++++++++++++++++ patches/patch_list.py | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 patches/march_2013/p05_payment_reconciliation.py diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index 73d7608240..576921a530 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -23,6 +23,9 @@ from utilities.transaction_base import TransactionBase class AccountsController(TransactionBase): def get_gl_dict(self, args, cancel=None): """this method populates the common properties of a gl entry record""" + if cancel is None: + cancel = (self.doc.docstatus == 2) + gl_dict = { 'company': self.doc.company, 'posting_date': self.doc.posting_date, @@ -30,7 +33,7 @@ class AccountsController(TransactionBase): 'voucher_no': self.doc.name, 'aging_date': self.doc.fields.get("aging_date") or self.doc.posting_date, 'remarks': self.doc.remarks, - 'is_cancelled': self.doc.docstatus == 2 and "Yes" or "No", + 'is_cancelled': cancel and "Yes" or "No", 'fiscal_year': self.doc.fiscal_year, 'debit': 0, 'credit': 0, diff --git a/patches/march_2013/p05_payment_reconciliation.py b/patches/march_2013/p05_payment_reconciliation.py new file mode 100644 index 0000000000..f2f03064d6 --- /dev/null +++ b/patches/march_2013/p05_payment_reconciliation.py @@ -0,0 +1,30 @@ +import webnotes + +def execute(): + # delete wrong gle entries created due to a bug in make_gl_entries of Account Controller + # when using payment reconciliation + res = webnotes.conn.sql_list("""select distinct gl1.voucher_no + from `tabGL Entry` gl1, `tabGL Entry` gl2 + where + (date(gl1.modified) between "2013-03-11" and "2013-03-15") + and date(gl1.modified) = date(gl2.modified) + and gl1.voucher_no = gl2.voucher_no + and gl1.voucher_type = "Journal Voucher" + and gl1.voucher_type = gl2.voucher_type + and gl1.posting_date = gl2.posting_date + and gl1.account = gl2.account + and ifnull(gl1.cost_center, "") = ifnull(gl2.cost_center, "") + and ifnull(gl1.is_cancelled, 'No') = 'No' and ifnull(gl2.is_cancelled, 'No') = 'No' + and ifnull(gl1.against_voucher, '') = ifnull(gl2.against_voucher, '') + and ifnull(gl1.against_voucher_type, '') = ifnull(gl2.against_voucher_type, '') + and gl1.remarks = gl2.remarks + and ifnull(gl1.debit, 0) = ifnull(gl2.credit, 0) + and ifnull(gl1.credit, 0) = ifnull(gl2.debit, 0) + and gl1.name > gl2.name""") + + for r in res: + webnotes.conn.sql("""update `tabGL Entry` set `is_cancelled`='Yes' + where voucher_type='Journal Voucher' and voucher_no=%s""", r) + jv = webnotes.bean("Journal Voucher", r) + jv.run_method("make_gl_entries") + \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index bc68ea15c2..f5e3f40916 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -211,4 +211,5 @@ patch_list = [ "patches.march_2013.p02_get_global_default", "patches.march_2013.p03_rename_blog_to_blog_post", "execute:webnotes.reload_doc('hr', 'search_criteria', 'monthly_attendance_details')", + "patches.march_2013.p05_payment_reconciliation", ] \ No newline at end of file