From c09de35ba551cbb1e19fbf7c56392f421801963c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Oct 2012 16:34:53 +0530 Subject: [PATCH] fix wrong vouchers due to Valuation charges --- patches/october_2012/fix_wrong_vouchers.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/patches/october_2012/fix_wrong_vouchers.py b/patches/october_2012/fix_wrong_vouchers.py index f7ff2b416b..62188614d5 100644 --- a/patches/october_2012/fix_wrong_vouchers.py +++ b/patches/october_2012/fix_wrong_vouchers.py @@ -5,11 +5,11 @@ def execute(): vouchers = webnotes.conn.sql(""" select - parent, parenttype, modified, + parent, parenttype, modified, docstatus, sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Add', tax_amount, 0)) as tax_added, sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Deduct', - tax_amount, 0)) as tax_ded + tax_amount, 0)) as tax_ded from `tabPurchase Taxes and Charges` where @@ -46,11 +46,12 @@ def execute(): (correct_total_tax, d['tax_added'], d['tax_ded'], d['parent'])) # post gl entry - webnotes.conn.sql("""update `tabGL Entry` set is_cancelled = 'No' - where voucher_type = %s and voucher_no = %s""", - (d['parenttype'], d['parent'])) - obj = get_obj(d['parenttype'], d['parent'], with_children=1) - obj.make_gl_entries() + if d['docstatus'] == 1: + webnotes.conn.sql("""update `tabGL Entry` set is_cancelled = 'No' + where voucher_type = %s and voucher_no = %s""", + (d['parenttype'], d['parent'])) + obj = get_obj(d['parenttype'], d['parent'], with_children=1) + obj.make_gl_entries() else: webnotes.conn.sql("""