Merge pull request #24735 from FHenry/fix_create_item_tax_with_salespurchasetax
fix: add item taxes at the same times as sales and purchase taxes
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index 36033d9..c041d26 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -140,7 +140,7 @@
doc: frm.doc,
freeze: true,
callback: function() {
- frappe.msgprint(__("Default tax templates for sales and purchase are created."));
+ frappe.msgprint(__("Default tax templates for sales, purchase and items are created."));
}
})
},
diff --git a/erpnext/setup/setup_wizard/operations/taxes_setup.py b/erpnext/setup/setup_wizard/operations/taxes_setup.py
index e66fa76..c3c1593 100644
--- a/erpnext/setup/setup_wizard/operations/taxes_setup.py
+++ b/erpnext/setup/setup_wizard/operations/taxes_setup.py
@@ -29,6 +29,7 @@
try:
if accounts:
make_sales_and_purchase_tax_templates(accounts, template_name)
+ make_item_tax_templates(accounts, template_name)
except frappe.NameError:
if frappe.message_log: frappe.message_log.pop()
except RootNotEditable:
@@ -84,6 +85,27 @@
doc = frappe.get_doc(purchase_tax_template)
doc.insert(ignore_permissions=True)
+def make_item_tax_templates(accounts, template_name=None):
+ if not template_name:
+ template_name = accounts[0].name
+
+ item_tax_template = {
+ "doctype": "Item Tax Template",
+ "title": template_name,
+ "company": accounts[0].company,
+ 'taxes': []
+ }
+
+
+ for account in accounts:
+ item_tax_template['taxes'].append({
+ "tax_type": account.name,
+ "tax_rate": account.tax_rate
+ })
+
+ # Items
+ frappe.get_doc(copy.deepcopy(item_tax_template)).insert(ignore_permissions=True)
+
def get_tax_account_group(company):
tax_group = frappe.db.get_value("Account",
{"account_name": "Duties and Taxes", "is_group": 1, "company": company})