mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 19:19:17 +00:00
refactor: not warn when filter field is missing in FS reports
This commit is contained in:
@@ -1,12 +1,17 @@
|
|||||||
frappe.provide("erpnext.financial_statements");
|
frappe.provide("erpnext.financial_statements");
|
||||||
|
|
||||||
|
function get_filter_value(filter_name) {
|
||||||
|
// not warn when the filter is missing
|
||||||
|
return frappe.query_report.get_filter_value(filter_name, false);
|
||||||
|
}
|
||||||
|
|
||||||
erpnext.financial_statements = {
|
erpnext.financial_statements = {
|
||||||
filters: get_filters(),
|
filters: get_filters(),
|
||||||
baseData: null,
|
baseData: null,
|
||||||
|
|
||||||
get_pdf_format: function (report, custom_format) {
|
get_pdf_format: function (report, custom_format) {
|
||||||
// If report template is selected, use default pdf formatting
|
// If report template is selected, use default pdf formatting
|
||||||
return report.get_filter_value("report_template") ? null : custom_format;
|
return get_filter_value("report_template") ? null : custom_format;
|
||||||
},
|
},
|
||||||
|
|
||||||
formatter: function (value, row, column, data, default_formatter, filter) {
|
formatter: function (value, row, column, data, default_formatter, filter) {
|
||||||
@@ -15,14 +20,14 @@ erpnext.financial_statements = {
|
|||||||
if (erpnext.financial_statements._is_special_view(column, data))
|
if (erpnext.financial_statements._is_special_view(column, data))
|
||||||
return erpnext.financial_statements._format_special_view(...report_params);
|
return erpnext.financial_statements._format_special_view(...report_params);
|
||||||
|
|
||||||
if (frappe.query_report.get_filter_value("report_template"))
|
if (get_filter_value("report_template"))
|
||||||
return erpnext.financial_statements._format_custom_report(...report_params);
|
return erpnext.financial_statements._format_custom_report(...report_params);
|
||||||
else return erpnext.financial_statements._format_standard_report(...report_params);
|
else return erpnext.financial_statements._format_standard_report(...report_params);
|
||||||
},
|
},
|
||||||
|
|
||||||
_is_special_view: function (column, data) {
|
_is_special_view: function (column, data) {
|
||||||
if (!data) return false;
|
if (!data) return false;
|
||||||
const view = frappe.query_report.get_filter_value("selected_view");
|
const view = get_filter_value("selected_view");
|
||||||
return (view === "Growth" && column.colIndex >= 3) || (view === "Margin" && column.colIndex >= 2);
|
return (view === "Growth" && column.colIndex >= 3) || (view === "Margin" && column.colIndex >= 2);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -100,7 +105,7 @@ erpnext.financial_statements = {
|
|||||||
from_date: formatting.from_date || formatting.period_start_date,
|
from_date: formatting.from_date || formatting.period_start_date,
|
||||||
to_date: formatting.to_date || formatting.period_end_date,
|
to_date: formatting.to_date || formatting.period_end_date,
|
||||||
account_type: formatting.account_type,
|
account_type: formatting.account_type,
|
||||||
company: frappe.query_report.get_filter_value("company"),
|
company: get_filter_value("company"),
|
||||||
};
|
};
|
||||||
|
|
||||||
column.link_onclick =
|
column.link_onclick =
|
||||||
@@ -177,7 +182,7 @@ erpnext.financial_statements = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_format_special_view: function (value, row, column, data, default_formatter) {
|
_format_special_view: function (value, row, column, data, default_formatter) {
|
||||||
const selectedView = frappe.query_report.get_filter_value("selected_view");
|
const selectedView = get_filter_value("selected_view");
|
||||||
|
|
||||||
if (selectedView === "Growth") {
|
if (selectedView === "Growth") {
|
||||||
const growthPercent = data[column.fieldname];
|
const growthPercent = data[column.fieldname];
|
||||||
@@ -252,7 +257,7 @@ erpnext.financial_statements = {
|
|||||||
|
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
account: data.account || data.accounts,
|
account: data.account || data.accounts,
|
||||||
company: frappe.query_report.get_filter_value("company"),
|
company: get_filter_value("company"),
|
||||||
from_date: data.from_date || data.year_start_date,
|
from_date: data.from_date || data.year_start_date,
|
||||||
to_date: data.to_date || data.year_end_date,
|
to_date: data.to_date || data.year_end_date,
|
||||||
project: project && project.length > 0 ? project[0].get_value() : "",
|
project: project && project.length > 0 ? project[0].get_value() : "",
|
||||||
@@ -345,7 +350,7 @@ function get_filters() {
|
|||||||
default: ["Fiscal Year"],
|
default: ["Fiscal Year"],
|
||||||
reqd: 1,
|
reqd: 1,
|
||||||
on_change: function () {
|
on_change: function () {
|
||||||
let filter_based_on = frappe.query_report.get_filter_value("filter_based_on");
|
let filter_based_on = get_filter_value("filter_based_on");
|
||||||
frappe.query_report.toggle_filter_display(
|
frappe.query_report.toggle_filter_display(
|
||||||
"from_fiscal_year",
|
"from_fiscal_year",
|
||||||
filter_based_on === "Date Range"
|
filter_based_on === "Date Range"
|
||||||
@@ -422,7 +427,7 @@ function get_filters() {
|
|||||||
fieldtype: "MultiSelectList",
|
fieldtype: "MultiSelectList",
|
||||||
get_data: function (txt) {
|
get_data: function (txt) {
|
||||||
return frappe.db.get_link_options("Cost Center", txt, {
|
return frappe.db.get_link_options("Cost Center", txt, {
|
||||||
company: frappe.query_report.get_filter_value("company"),
|
company: get_filter_value("company"),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
options: "Cost Center",
|
options: "Cost Center",
|
||||||
@@ -433,7 +438,7 @@ function get_filters() {
|
|||||||
fieldtype: "MultiSelectList",
|
fieldtype: "MultiSelectList",
|
||||||
get_data: function (txt) {
|
get_data: function (txt) {
|
||||||
return frappe.db.get_link_options("Project", txt, {
|
return frappe.db.get_link_options("Project", txt, {
|
||||||
company: frappe.query_report.get_filter_value("company"),
|
company: get_filter_value("company"),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
options: "Project",
|
options: "Project",
|
||||||
|
|||||||
Reference in New Issue
Block a user