From 88eb32862234540a715116ea311275265a3b6ac7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 26 Mar 2013 17:44:00 +0530 Subject: [PATCH] fixes: show deducted tax in purchase register --- .../purchase_register/purchase_register.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/accounts/search_criteria/purchase_register/purchase_register.py b/accounts/search_criteria/purchase_register/purchase_register.py index 93fc32393e3..82ab047e3bb 100644 --- a/accounts/search_criteria/purchase_register/purchase_register.py +++ b/accounts/search_criteria/purchase_register/purchase_register.py @@ -77,14 +77,10 @@ for r in res: r.append(net_total) #Get tax for account heads - acc_head_tax = sql("""select account_head, sum(tax_amount) - from `tabPurchase Taxes and Charges` - where parent = '%s' - and parenttype = 'Purchase Invoice' - and add_deduct_tax = 'Add' - and category in ('Total', 'Valuation and Total') - group by account_head - """ %(r[col_idx['ID']],)) + acc_head_tax = sql("""select account_head, + sum(if(add_deduct_tax='Add', tax_amount, -tax_amount)) + from `tabPurchase Taxes and Charges` where parent = %s and parenttype = 'Purchase Invoice' + and category in ('Total', 'Valuation and Total') group by account_head""", r[col_idx['ID']]) #Convert the result to dictionary for easy retrieval acc_head_tax_dict = {}