[fix] Wrong company's default tax fetch (#11927)
This commit is contained in:
parent
3fe59b4443
commit
505661b5c0
@ -233,9 +233,10 @@ class AccountsController(TransactionBase):
|
|||||||
tax_master_doctype = self.meta.get_field("taxes_and_charges").options
|
tax_master_doctype = self.meta.get_field("taxes_and_charges").options
|
||||||
|
|
||||||
if self.is_new() and not self.get("taxes"):
|
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
|
# 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)
|
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)
|
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_default_taxes_and_charges(master_doctype):
|
def get_default_taxes_and_charges(master_doctype, company=None):
|
||||||
default_tax = frappe.db.get_value(master_doctype, {"is_default": 1})
|
if not company: return {}
|
||||||
|
|
||||||
|
default_tax = frappe.db.get_value(master_doctype,
|
||||||
|
{"is_default": 1, "company": company})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'taxes_and_charges': default_tax,
|
'taxes_and_charges': default_tax,
|
||||||
'taxes': get_taxes_and_charges(master_doctype, default_tax)
|
'taxes': get_taxes_and_charges(master_doctype, default_tax)
|
||||||
|
@ -232,7 +232,7 @@ def make_quotation(source_name, target_doc=None):
|
|||||||
quotation.conversion_rate = exchange_rate
|
quotation.conversion_rate = exchange_rate
|
||||||
|
|
||||||
# get default taxes
|
# get default taxes
|
||||||
taxes = get_default_taxes_and_charges("Sales Taxes and Charges Template")
|
taxes = get_default_taxes_and_charges("Sales Taxes and Charges Template", quotation.company)
|
||||||
if taxes.get('taxes'):
|
if taxes.get('taxes'):
|
||||||
quotation.update(taxes)
|
quotation.update(taxes)
|
||||||
|
|
||||||
|
@ -235,7 +235,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "erpnext.controllers.accounts_controller.get_default_taxes_and_charges",
|
method: "erpnext.controllers.accounts_controller.get_default_taxes_and_charges",
|
||||||
args: {
|
args: {
|
||||||
"master_doctype": taxes_and_charges_field.options
|
"master_doctype": taxes_and_charges_field.options,
|
||||||
|
"company": me.frm.doc.company
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
@ -420,8 +421,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
me.frm.set_value("tc_name", company_doc.default_terms);
|
me.frm.set_value("tc_name", company_doc.default_terms);
|
||||||
}
|
}
|
||||||
|
|
||||||
me.frm.script_manager.trigger("currency");
|
frappe.run_serially([
|
||||||
me.apply_pricing_rule();
|
() => me.frm.script_manager.trigger("currency"),
|
||||||
|
() => me.apply_default_taxes(),
|
||||||
|
() => me.apply_pricing_rule()
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user