mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-12 06:48:31 +00:00
Merge pull request #30455 from frappe/mergify/bp/version-13-hotfix/pr-30419
fix: move item tax to item tax template patch (backport #30419)
This commit is contained in:
@@ -113,6 +113,7 @@ def get_item_tax_template(
|
||||
# if no item tax template found, create one
|
||||
item_tax_template = frappe.new_doc("Item Tax Template")
|
||||
item_tax_template.title = make_autoname("Item Tax Template-.####")
|
||||
item_tax_template_name = item_tax_template.title
|
||||
|
||||
for tax_type, tax_rate in iteritems(item_tax_map):
|
||||
account_details = frappe.db.get_value(
|
||||
@@ -120,6 +121,10 @@ def get_item_tax_template(
|
||||
)
|
||||
if account_details:
|
||||
item_tax_template.company = account_details.company
|
||||
if not item_tax_template_name:
|
||||
# set name once company is set as name is generated from company & title
|
||||
# setting name is required to update `item_tax_templates` dict
|
||||
item_tax_template_name = item_tax_template.set_new_name()
|
||||
if account_details.account_type not in (
|
||||
"Tax",
|
||||
"Chargeable",
|
||||
@@ -179,8 +184,9 @@ def get_item_tax_template(
|
||||
if tax_type not in tax_types:
|
||||
item_tax_template.append("taxes", {"tax_type": tax_type, "tax_rate": tax_rate})
|
||||
tax_types.append(tax_type)
|
||||
item_tax_templates.setdefault(item_tax_template.title, {})
|
||||
item_tax_templates[item_tax_template.title][tax_type] = tax_rate
|
||||
item_tax_templates.setdefault(item_tax_template_name, {})
|
||||
item_tax_templates[item_tax_template_name][tax_type] = tax_rate
|
||||
|
||||
if item_tax_template.get("taxes"):
|
||||
item_tax_template.save()
|
||||
return item_tax_template.name
|
||||
|
||||
Reference in New Issue
Block a user