From 3af321fa59afc0d37335b6f785f295737e1e039c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Oct 2012 14:41:36 +0530 Subject: [PATCH 1/5] find wrong vouchers --- patches/october_2012/find_wrong_voucher.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/patches/october_2012/find_wrong_voucher.py b/patches/october_2012/find_wrong_voucher.py index 8acc278dae6..ed9ce9c644b 100644 --- a/patches/october_2012/find_wrong_voucher.py +++ b/patches/october_2012/find_wrong_voucher.py @@ -1,9 +1,15 @@ def execute(): import webnotes vouchers = webnotes.conn.sql(""" - select parent, parenttype, modified from `tabPurchase Taxes and Charges` + select parent, parenttype, modified, sum(tax_amount) as tax from `tabPurchase Taxes and Charges` where modified >= '2012-07-12' - and category = 'Valuation' and tax_amount != 0 + and category in ('Total', 'Valuation and Total') and parenttype != 'Purchase Taxes and Charges Master' + group by parenttype, parent """) - print vouchers \ No newline at end of file + + for d in vouchers: + total_tax = webnotes.conn.sql("""select tax_amount from `tab%s` where name = %s""" % + (d[1], '%s'), d[0]) + if flt(total_tax[0][0]) != flt(d[3]): + print d \ No newline at end of file From f3a7f347c2998e3692911c1938d9e3bc8e7a471d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Oct 2012 14:45:45 +0530 Subject: [PATCH 2/5] find wrong vouchers --- patches/october_2012/find_wrong_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/october_2012/find_wrong_voucher.py b/patches/october_2012/find_wrong_voucher.py index ed9ce9c644b..d2374adb21a 100644 --- a/patches/october_2012/find_wrong_voucher.py +++ b/patches/october_2012/find_wrong_voucher.py @@ -9,7 +9,7 @@ def execute(): """) for d in vouchers: - total_tax = webnotes.conn.sql("""select tax_amount from `tab%s` where name = %s""" % + total_tax = webnotes.conn.sql("""select total_tax from `tab%s` where name = %s""" % (d[1], '%s'), d[0]) if flt(total_tax[0][0]) != flt(d[3]): print d \ No newline at end of file From 1f33e46e344b90cde620a72978934cafed9d6b43 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Oct 2012 14:47:41 +0530 Subject: [PATCH 3/5] find wrong vouchers --- patches/october_2012/find_wrong_voucher.py | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/october_2012/find_wrong_voucher.py b/patches/october_2012/find_wrong_voucher.py index d2374adb21a..ca612f3256c 100644 --- a/patches/october_2012/find_wrong_voucher.py +++ b/patches/october_2012/find_wrong_voucher.py @@ -1,5 +1,6 @@ def execute(): import webnotes + from webnotes.utils import flt vouchers = webnotes.conn.sql(""" select parent, parenttype, modified, sum(tax_amount) as tax from `tabPurchase Taxes and Charges` where modified >= '2012-07-12' From f84237642e2595b62c9646916bcf31d799a70e68 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Oct 2012 14:51:42 +0530 Subject: [PATCH 4/5] find wrong vouchers --- patches/october_2012/find_wrong_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/october_2012/find_wrong_voucher.py b/patches/october_2012/find_wrong_voucher.py index ca612f3256c..189f2b6984a 100644 --- a/patches/october_2012/find_wrong_voucher.py +++ b/patches/october_2012/find_wrong_voucher.py @@ -2,7 +2,7 @@ def execute(): import webnotes from webnotes.utils import flt vouchers = webnotes.conn.sql(""" - select parent, parenttype, modified, sum(tax_amount) as tax from `tabPurchase Taxes and Charges` + select parent, parenttype, modified, sum(if(add_deduct_tax='Add', tax_amount, -tax_amount)) as tax from `tabPurchase Taxes and Charges` where modified >= '2012-07-12' and category in ('Total', 'Valuation and Total') and parenttype != 'Purchase Taxes and Charges Master' From 92e72428081510eb59b3120758d99e734f36e25c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Oct 2012 14:53:08 +0530 Subject: [PATCH 5/5] find wrong vouchers --- patches/october_2012/find_wrong_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/october_2012/find_wrong_voucher.py b/patches/october_2012/find_wrong_voucher.py index 189f2b6984a..637ed1d70eb 100644 --- a/patches/october_2012/find_wrong_voucher.py +++ b/patches/october_2012/find_wrong_voucher.py @@ -12,5 +12,5 @@ def execute(): for d in vouchers: total_tax = webnotes.conn.sql("""select total_tax from `tab%s` where name = %s""" % (d[1], '%s'), d[0]) - if flt(total_tax[0][0]) != flt(d[3]): + if total_tax and flt(total_tax[0][0]) != flt(d[3]): print d \ No newline at end of file