Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/patches/october_2012/find_wrong_voucher.py b/patches/october_2012/find_wrong_voucher.py
index 8acc278..637ed1d 100644
--- a/patches/october_2012/find_wrong_voucher.py
+++ b/patches/october_2012/find_wrong_voucher.py
@@ -1,9 +1,16 @@
def execute():
import webnotes
+ from webnotes.utils import flt
vouchers = webnotes.conn.sql("""
- select parent, parenttype, modified 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 = '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 total_tax from `tab%s` where name = %s""" %
+ (d[1], '%s'), d[0])
+ if total_tax and flt(total_tax[0][0]) != flt(d[3]):
+ print d
\ No newline at end of file