From d743c41b54c6ff72eb5dd6f0386bfc1f37e4d288 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sun, 12 Sep 2021 16:38:18 +0530 Subject: [PATCH] fix(ux): apply proper filtering in stock reports (#27411) * fix(ux): apply proper filtering in stock reports Stock Balance: apply company filter to warehouse field Stock Ageing: apply company filter to warehouse field * fix: unnecessary parens Co-authored-by: Alan <2.alan.tom@gmail.com> --- erpnext/stock/report/stock_ageing/stock_ageing.js | 10 +++++++++- .../stock/report/stock_balance/stock_balance.js | 15 ++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.js b/erpnext/stock/report/stock_ageing/stock_ageing.js index b22788f7a2..db463b7ca0 100644 --- a/erpnext/stock/report/stock_ageing/stock_ageing.js +++ b/erpnext/stock/report/stock_ageing/stock_ageing.js @@ -22,7 +22,15 @@ frappe.query_reports["Stock Ageing"] = { "fieldname":"warehouse", "label": __("Warehouse"), "fieldtype": "Link", - "options": "Warehouse" + "options": "Warehouse", + get_query: () => { + const company = frappe.query_report.get_filter_value("company"); + return { + filters: { + ...company && {company}, + } + }; + } }, { "fieldname":"item_code", diff --git a/erpnext/stock/report/stock_balance/stock_balance.js b/erpnext/stock/report/stock_balance/stock_balance.js index 7d22823eb8..ce6ffa0b91 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.js +++ b/erpnext/stock/report/stock_balance/stock_balance.js @@ -53,13 +53,14 @@ frappe.query_reports["Stock Balance"] = { "width": "80", "options": "Warehouse", get_query: () => { - var warehouse_type = frappe.query_report.get_filter_value('warehouse_type'); - if(warehouse_type){ - return { - filters: { - 'warehouse_type': warehouse_type - } - }; + let warehouse_type = frappe.query_report.get_filter_value("warehouse_type"); + let company = frappe.query_report.get_filter_value("company"); + + return { + filters: { + ...warehouse_type && {warehouse_type}, + ...company && {company} + } } } },