fix wrong vouchers due to Valuation charges

This commit is contained in:
Nabin Hait 2012-10-03 16:34:53 +05:30
parent 1e79441457
commit c09de35ba5

View File

@ -5,11 +5,11 @@ def execute():
vouchers = webnotes.conn.sql(""" vouchers = webnotes.conn.sql("""
select select
parent, parenttype, modified, parent, parenttype, modified, docstatus,
sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Add', sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Add',
tax_amount, 0)) as tax_added, tax_amount, 0)) as tax_added,
sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Deduct', 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 from
`tabPurchase Taxes and Charges` `tabPurchase Taxes and Charges`
where where
@ -46,11 +46,12 @@ def execute():
(correct_total_tax, d['tax_added'], d['tax_ded'], d['parent'])) (correct_total_tax, d['tax_added'], d['tax_ded'], d['parent']))
# post gl entry # post gl entry
webnotes.conn.sql("""update `tabGL Entry` set is_cancelled = 'No' if d['docstatus'] == 1:
where voucher_type = %s and voucher_no = %s""", webnotes.conn.sql("""update `tabGL Entry` set is_cancelled = 'No'
(d['parenttype'], d['parent'])) where voucher_type = %s and voucher_no = %s""",
obj = get_obj(d['parenttype'], d['parent'], with_children=1) (d['parenttype'], d['parent']))
obj.make_gl_entries() obj = get_obj(d['parenttype'], d['parent'], with_children=1)
obj.make_gl_entries()
else: else:
webnotes.conn.sql(""" webnotes.conn.sql("""