[fix] Wrong company's default tax fetch (#11927)
This commit is contained in:
committed by
Nabin Hait
parent
3fe59b4443
commit
505661b5c0
@@ -233,9 +233,10 @@ class AccountsController(TransactionBase):
|
||||
tax_master_doctype = self.meta.get_field("taxes_and_charges").options
|
||||
|
||||
if self.is_new() and not self.get("taxes"):
|
||||
if not self.get("taxes_and_charges"):
|
||||
if self.company and not self.get("taxes_and_charges"):
|
||||
# get the default tax master
|
||||
self.taxes_and_charges = frappe.db.get_value(tax_master_doctype, {"is_default": 1})
|
||||
self.taxes_and_charges = frappe.db.get_value(tax_master_doctype,
|
||||
{"is_default": 1, 'company': self.company})
|
||||
|
||||
self.append_taxes_from_master(tax_master_doctype)
|
||||
|
||||
@@ -717,8 +718,12 @@ def get_tax_rate(account_head):
|
||||
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_default_taxes_and_charges(master_doctype):
|
||||
default_tax = frappe.db.get_value(master_doctype, {"is_default": 1})
|
||||
def get_default_taxes_and_charges(master_doctype, company=None):
|
||||
if not company: return {}
|
||||
|
||||
default_tax = frappe.db.get_value(master_doctype,
|
||||
{"is_default": 1, "company": company})
|
||||
|
||||
return {
|
||||
'taxes_and_charges': default_tax,
|
||||
'taxes': get_taxes_and_charges(master_doctype, default_tax)
|
||||
|
||||
Reference in New Issue
Block a user