[Fix] Deducted tax amount adding up in the total amount in the GST Itemised Purchase Register report (#14994)
This commit is contained in:
parent
1f4c263a63
commit
20d3bef3c3
@ -157,6 +157,9 @@ def get_delivery_notes_against_sales_order(item_list):
|
|||||||
|
|
||||||
return so_dn_map
|
return so_dn_map
|
||||||
|
|
||||||
|
def get_deducted_taxes():
|
||||||
|
return frappe.db.sql_list("select name from `tabPurchase Taxes and Charges` where add_deduct_tax = 'Deduct'")
|
||||||
|
|
||||||
def get_tax_accounts(item_list, columns, company_currency,
|
def get_tax_accounts(item_list, columns, company_currency,
|
||||||
doctype="Sales Invoice", tax_doctype="Sales Taxes and Charges"):
|
doctype="Sales Invoice", tax_doctype="Sales Taxes and Charges"):
|
||||||
import json
|
import json
|
||||||
@ -176,9 +179,10 @@ def get_tax_accounts(item_list, columns, company_currency,
|
|||||||
if doctype == "Purchase Invoice":
|
if doctype == "Purchase Invoice":
|
||||||
conditions = " and category in ('Total', 'Valuation and Total') and base_tax_amount_after_discount_amount != 0"
|
conditions = " and category in ('Total', 'Valuation and Total') and base_tax_amount_after_discount_amount != 0"
|
||||||
|
|
||||||
|
deducted_tax = get_deducted_taxes()
|
||||||
tax_details = frappe.db.sql("""
|
tax_details = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
parent, description, item_wise_tax_detail,
|
name, parent, description, item_wise_tax_detail,
|
||||||
charge_type, base_tax_amount_after_discount_amount
|
charge_type, base_tax_amount_after_discount_amount
|
||||||
from `tab%s`
|
from `tab%s`
|
||||||
where
|
where
|
||||||
@ -190,7 +194,7 @@ def get_tax_accounts(item_list, columns, company_currency,
|
|||||||
""" % (tax_doctype, '%s', ', '.join(['%s']*len(invoice_item_row)), conditions),
|
""" % (tax_doctype, '%s', ', '.join(['%s']*len(invoice_item_row)), conditions),
|
||||||
tuple([doctype] + invoice_item_row.keys()))
|
tuple([doctype] + invoice_item_row.keys()))
|
||||||
|
|
||||||
for parent, description, item_wise_tax_detail, charge_type, tax_amount in tax_details:
|
for name, parent, description, item_wise_tax_detail, charge_type, tax_amount in tax_details:
|
||||||
description = handle_html(description)
|
description = handle_html(description)
|
||||||
if description not in tax_columns and tax_amount:
|
if description not in tax_columns and tax_amount:
|
||||||
# as description is text editor earlier and markup can break the column convention in reports
|
# as description is text editor earlier and markup can break the column convention in reports
|
||||||
@ -219,9 +223,13 @@ def get_tax_accounts(item_list, columns, company_currency,
|
|||||||
item_tax_amount = flt((tax_amount * d.base_net_amount) / item_net_amount) \
|
item_tax_amount = flt((tax_amount * d.base_net_amount) / item_net_amount) \
|
||||||
if item_net_amount else 0
|
if item_net_amount else 0
|
||||||
if item_tax_amount:
|
if item_tax_amount:
|
||||||
|
tax_amount = flt(item_tax_amount, tax_amount_precision)
|
||||||
|
tax_amount = (tax_amount * -1
|
||||||
|
if (doctype == 'Purchase Invoice' and name in deducted_tax) else tax_amount)
|
||||||
|
|
||||||
itemised_tax.setdefault(d.name, {})[description] = frappe._dict({
|
itemised_tax.setdefault(d.name, {})[description] = frappe._dict({
|
||||||
"tax_rate": tax_rate,
|
"tax_rate": tax_rate,
|
||||||
"tax_amount": flt(item_tax_amount, tax_amount_precision)
|
"tax_amount": tax_amount
|
||||||
})
|
})
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user