diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.js b/erpnext/accounts/report/budget_variance_report/budget_variance_report.js index c74450191aa..1bb9abd8c92 100644 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.js +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.js @@ -38,6 +38,14 @@ function get_filters() { let budget_against_options = get_dimensions(); let filters = [ + { + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, + }, { fieldname: "from_fiscal_year", label: __("From Fiscal Year"), @@ -67,14 +75,6 @@ function get_filters() { default: "Yearly", reqd: 1, }, - { - fieldname: "company", - label: __("Company"), - fieldtype: "Link", - options: "Company", - default: frappe.defaults.get_user_default("Company"), - reqd: 1, - }, { fieldname: "budget_against", label: __("Budget Against"), @@ -96,9 +96,12 @@ function get_filters() { if (!frappe.query_report.filters) return; let budget_against = frappe.query_report.get_filter_value("budget_against"); + let company = frappe.query_report.get_filter_value("company"); if (!budget_against) return; - return frappe.db.get_link_options(budget_against, txt); + const filters = budget_against !== "Branch" && company ? { company: company } : {}; + + return frappe.db.get_link_options(budget_against, txt, filters); }, }, {