mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 22:19:18 +00:00
fix(patch): do not append taxes to template if account name is not set (#20310)
This commit is contained in:
@@ -49,10 +49,11 @@ def execute():
|
|||||||
item_tax_template_name = get_item_tax_template(item_tax_templates, item_tax_map, item_code)
|
item_tax_template_name = get_item_tax_template(item_tax_templates, item_tax_map, item_code)
|
||||||
|
|
||||||
# update the item tax table
|
# update the item tax table
|
||||||
|
frappe.db.sql("delete from `tabItem Tax` where parent=%s and parenttype='Item'", item_code)
|
||||||
|
if item_tax_template_name:
|
||||||
item = frappe.get_doc("Item", item_code)
|
item = frappe.get_doc("Item", item_code)
|
||||||
item.set("taxes", [])
|
item.set("taxes", [])
|
||||||
item.append("taxes", {"item_tax_template": item_tax_template_name, "tax_category": ""})
|
item.append("taxes", {"item_tax_template": item_tax_template_name, "tax_category": ""})
|
||||||
frappe.db.sql("delete from `tabItem Tax` where parent=%s and parenttype='Item'", item_code)
|
|
||||||
for d in item.taxes:
|
for d in item.taxes:
|
||||||
d.db_insert()
|
d.db_insert()
|
||||||
|
|
||||||
@@ -95,6 +96,9 @@ def get_item_tax_template(item_tax_templates, item_tax_map, item_code, parenttyp
|
|||||||
else:
|
else:
|
||||||
parts = tax_type.strip().split(" - ")
|
parts = tax_type.strip().split(" - ")
|
||||||
account_name = " - ".join(parts[:-1])
|
account_name = " - ".join(parts[:-1])
|
||||||
|
if not account_name:
|
||||||
|
tax_type = None
|
||||||
|
else:
|
||||||
company = get_company(parts[-1], parenttype, parent)
|
company = get_company(parts[-1], parenttype, parent)
|
||||||
parent_account = frappe.db.get_value("Account",
|
parent_account = frappe.db.get_value("Account",
|
||||||
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company}, fieldname="parent_account")
|
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company}, fieldname="parent_account")
|
||||||
@@ -114,9 +118,11 @@ def get_item_tax_template(item_tax_templates, item_tax_map, item_code, parenttyp
|
|||||||
account.insert()
|
account.insert()
|
||||||
tax_type = account.name
|
tax_type = account.name
|
||||||
|
|
||||||
|
if tax_type:
|
||||||
item_tax_template.append("taxes", {"tax_type": tax_type, "tax_rate": tax_rate})
|
item_tax_template.append("taxes", {"tax_type": tax_type, "tax_rate": tax_rate})
|
||||||
item_tax_templates.setdefault(item_tax_template.title, {})
|
item_tax_templates.setdefault(item_tax_template.title, {})
|
||||||
item_tax_templates[item_tax_template.title][tax_type] = tax_rate
|
item_tax_templates[item_tax_template.title][tax_type] = tax_rate
|
||||||
|
if item_tax_template.get("taxes"):
|
||||||
item_tax_template.save()
|
item_tax_template.save()
|
||||||
return item_tax_template.name
|
return item_tax_template.name
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user