fix: add item taxes at the same times as sales and purchase taxes
This commit is contained in:
parent
684fc4e27b
commit
e11ce57f3c
@ -140,7 +140,7 @@ frappe.ui.form.on("Company", {
|
|||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
freeze: true,
|
freeze: true,
|
||||||
callback: function() {
|
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."));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -29,6 +29,7 @@ def make_tax_account_and_template(company, account_name, tax_rate, template_name
|
|||||||
try:
|
try:
|
||||||
if accounts:
|
if accounts:
|
||||||
make_sales_and_purchase_tax_templates(accounts, template_name)
|
make_sales_and_purchase_tax_templates(accounts, template_name)
|
||||||
|
make_item_tax_templates(accounts, template_name)
|
||||||
except frappe.NameError:
|
except frappe.NameError:
|
||||||
if frappe.message_log: frappe.message_log.pop()
|
if frappe.message_log: frappe.message_log.pop()
|
||||||
except RootNotEditable:
|
except RootNotEditable:
|
||||||
@ -84,6 +85,27 @@ def make_sales_and_purchase_tax_templates(accounts, template_name=None):
|
|||||||
doc = frappe.get_doc(purchase_tax_template)
|
doc = frappe.get_doc(purchase_tax_template)
|
||||||
doc.insert(ignore_permissions=True)
|
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):
|
def get_tax_account_group(company):
|
||||||
tax_group = frappe.db.get_value("Account",
|
tax_group = frappe.db.get_value("Account",
|
||||||
{"account_name": "Duties and Taxes", "is_group": 1, "company": company})
|
{"account_name": "Duties and Taxes", "is_group": 1, "company": company})
|
||||||
|
Loading…
Reference in New Issue
Block a user