fix: Ignore validations for Tax Setup
This commit is contained in:
parent
66a71bdd1a
commit
204ea1027f
@ -25,6 +25,7 @@ def setup_company_independent_fixtures(patch=False):
|
|||||||
frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
|
frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
|
||||||
create_gratuity_rule()
|
create_gratuity_rule()
|
||||||
add_print_formats()
|
add_print_formats()
|
||||||
|
update_accounts_settings_for_taxes()
|
||||||
|
|
||||||
def add_hsn_sac_codes():
|
def add_hsn_sac_codes():
|
||||||
# HSN codes
|
# HSN codes
|
||||||
@ -698,6 +699,7 @@ def set_tax_withholding_category(company):
|
|||||||
for d in docs:
|
for d in docs:
|
||||||
if not frappe.db.exists("Tax Withholding Category", d.get("name")):
|
if not frappe.db.exists("Tax Withholding Category", d.get("name")):
|
||||||
doc = frappe.get_doc(d)
|
doc = frappe.get_doc(d)
|
||||||
|
doc.flags.ignore_validate = True
|
||||||
doc.flags.ignore_permissions = True
|
doc.flags.ignore_permissions = True
|
||||||
doc.flags.ignore_mandatory = True
|
doc.flags.ignore_mandatory = True
|
||||||
doc.insert()
|
doc.insert()
|
||||||
@ -714,11 +716,12 @@ def set_tax_withholding_category(company):
|
|||||||
doc.append("rates", d.get('rates')[0])
|
doc.append("rates", d.get('rates')[0])
|
||||||
|
|
||||||
doc.flags.ignore_permissions = True
|
doc.flags.ignore_permissions = True
|
||||||
|
doc.flags.ignore_validdate = True
|
||||||
doc.flags.ignore_mandatory = True
|
doc.flags.ignore_mandatory = True
|
||||||
|
doc.flags.ignore_links = True
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|
||||||
def set_tds_account(docs, company):
|
def set_tds_account(docs, company):
|
||||||
abbr = frappe.get_value("Company", company, "abbr")
|
|
||||||
parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
|
parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
|
||||||
if parent_account:
|
if parent_account:
|
||||||
docs.extend([
|
docs.extend([
|
||||||
@ -877,7 +880,6 @@ def get_tds_details(accounts, fiscal_year):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def create_gratuity_rule():
|
def create_gratuity_rule():
|
||||||
|
|
||||||
# Standard Indain Gratuity Rule
|
# Standard Indain Gratuity Rule
|
||||||
if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
|
if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
|
||||||
rule = frappe.new_doc("Gratuity Rule")
|
rule = frappe.new_doc("Gratuity Rule")
|
||||||
@ -895,3 +897,7 @@ def create_gratuity_rule():
|
|||||||
|
|
||||||
rule.flags.ignore_mandatory = True
|
rule.flags.ignore_mandatory = True
|
||||||
rule.save()
|
rule.save()
|
||||||
|
|
||||||
|
def update_accounts_settings_for_taxes():
|
||||||
|
if frappe.db.count('Company') == 1:
|
||||||
|
frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)
|
@ -110,7 +110,7 @@ class Company(NestedSet):
|
|||||||
self.create_default_warehouses()
|
self.create_default_warehouses()
|
||||||
|
|
||||||
if frappe.flags.country_change:
|
if frappe.flags.country_change:
|
||||||
install_country_fixtures(self.name)
|
install_country_fixtures(self.name, self.country)
|
||||||
self.create_default_tax_template()
|
self.create_default_tax_template()
|
||||||
|
|
||||||
if not frappe.db.get_value("Department", {"company": self.name}):
|
if not frappe.db.get_value("Department", {"company": self.name}):
|
||||||
|
@ -123,8 +123,11 @@ def make_taxes_and_charges_template(company_name, doctype, template):
|
|||||||
if fieldname not in tax_row:
|
if fieldname not in tax_row:
|
||||||
tax_row[fieldname] = default_value
|
tax_row[fieldname] = default_value
|
||||||
|
|
||||||
return frappe.get_doc(template).insert(ignore_permissions=True)
|
doc = frappe.get_doc(template)
|
||||||
|
doc.flags.ignore_links = True
|
||||||
|
doc.flags.ignore_validate = True
|
||||||
|
doc.insert(ignore_permissions=True)
|
||||||
|
return doc
|
||||||
|
|
||||||
def make_item_tax_template(company_name, template):
|
def make_item_tax_template(company_name, template):
|
||||||
"""Create an Item Tax Template.
|
"""Create an Item Tax Template.
|
||||||
@ -149,14 +152,21 @@ def make_item_tax_template(company_name, template):
|
|||||||
if 'tax_rate' not in tax_row:
|
if 'tax_rate' not in tax_row:
|
||||||
tax_row['tax_rate'] = account_data.get('tax_rate')
|
tax_row['tax_rate'] = account_data.get('tax_rate')
|
||||||
|
|
||||||
return frappe.get_doc(template).insert(ignore_permissions=True)
|
doc = frappe.get_doc(template)
|
||||||
|
doc.flags.ignore_links = True
|
||||||
|
doc.flags.ignore_validate = True
|
||||||
|
doc.insert(ignore_permissions=True)
|
||||||
|
return doc
|
||||||
|
|
||||||
def make_tax_category(tax_category):
|
def make_tax_category(tax_category):
|
||||||
""" Make tax category based on title if not already created """
|
""" Make tax category based on title if not already created """
|
||||||
doctype = 'Tax Category'
|
doctype = 'Tax Category'
|
||||||
if not frappe.db.exists(doctype, tax_category):
|
if not frappe.db.exists(doctype, tax_category):
|
||||||
tax_category['doctype'] = doctype
|
tax_category['doctype'] = doctype
|
||||||
frappe.get_doc(tax_category).insert(ignore_permissions=True)
|
doc = frappe.get_doc(tax_category)
|
||||||
|
doc.flags.ignore_links = True
|
||||||
|
doc.flags.ignore_validate = True
|
||||||
|
doc.insert(ignore_permissions=True)
|
||||||
|
|
||||||
def get_or_create_account(company_name, account):
|
def get_or_create_account(company_name, account):
|
||||||
"""
|
"""
|
||||||
@ -169,7 +179,8 @@ def get_or_create_account(company_name, account):
|
|||||||
existing_accounts = frappe.get_list('Account',
|
existing_accounts = frappe.get_list('Account',
|
||||||
filters={
|
filters={
|
||||||
'account_name': account.get('account_name'),
|
'account_name': account.get('account_name'),
|
||||||
'account_number': account.get('account_number', '')
|
'account_number': account.get('account_number', ''),
|
||||||
|
'company': company_name
|
||||||
},
|
},
|
||||||
or_filters={
|
or_filters={
|
||||||
'company': company_name,
|
'company': company_name,
|
||||||
@ -191,8 +202,11 @@ def get_or_create_account(company_name, account):
|
|||||||
account['root_type'] = root_type
|
account['root_type'] = root_type
|
||||||
account['is_group'] = 0
|
account['is_group'] = 0
|
||||||
|
|
||||||
return frappe.get_doc(account).insert(ignore_permissions=True, ignore_mandatory=True)
|
doc = frappe.get_doc(account)
|
||||||
|
doc.flags.ignore_links = True
|
||||||
|
doc.flags.ignore_validate = True
|
||||||
|
doc.insert(ignore_permissions=True, ignore_mandatory=True)
|
||||||
|
return doc
|
||||||
|
|
||||||
def get_or_create_tax_group(company_name, root_type):
|
def get_or_create_tax_group(company_name, root_type):
|
||||||
# Look for a group account of type 'Tax'
|
# Look for a group account of type 'Tax'
|
||||||
@ -237,7 +251,11 @@ def get_or_create_tax_group(company_name, root_type):
|
|||||||
'account_type': 'Tax',
|
'account_type': 'Tax',
|
||||||
'account_name': account_name,
|
'account_name': account_name,
|
||||||
'parent_account': root_account.name
|
'parent_account': root_account.name
|
||||||
}).insert(ignore_permissions=True)
|
})
|
||||||
|
|
||||||
|
tax_group_account.flags.ignore_links = True
|
||||||
|
tax_group_account.flags.ignore_validate = True
|
||||||
|
tax_group_account.insert(ignore_permissions=True)
|
||||||
|
|
||||||
tax_group_name = tax_group_account.name
|
tax_group_name = tax_group_account.name
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user