From 690a0805f6c9b5f25e6bc5d69cffc6d8cc07e85b Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 6 Jun 2016 16:50:20 +0530 Subject: [PATCH] [Fixes] Purchase register, showing wrong value for total amount if tax has deducted. --- .../accounts/report/purchase_register/purchase_register.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py index 9a90f2f235..4bba066f44 100644 --- a/erpnext/accounts/report/purchase_register/purchase_register.py +++ b/erpnext/accounts/report/purchase_register/purchase_register.py @@ -147,10 +147,11 @@ def get_invoice_expense_map(invoice_list): def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts): tax_details = frappe.db.sql(""" - select parent, account_head, sum(base_tax_amount_after_discount_amount) as tax_amount + select parent, account_head, case add_deduct_tax when "Add" then sum(base_tax_amount_after_discount_amount) + else sum(base_tax_amount_after_discount_amount) * -1 end as tax_amount from `tabPurchase Taxes and Charges` where parent in (%s) and category in ('Total', 'Valuation and Total') - group by parent, account_head + group by parent, account_head, add_deduct_tax """ % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) invoice_tax_map = {}