Merge pull request #39067 from ruthra-kumar/fix_undefined_error_in_budget_variance_report
fix: undefined error in Budget Variance and Profitability report
This commit is contained in:
commit
d048644327
@ -2,7 +2,44 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.query_reports["Budget Variance Report"] = {
|
frappe.query_reports["Budget Variance Report"] = {
|
||||||
"filters": [
|
"filters": get_filters(),
|
||||||
|
"formatter": function (value, row, column, data, default_formatter) {
|
||||||
|
value = default_formatter(value, row, column, data);
|
||||||
|
|
||||||
|
if (column.fieldname.includes(__("variance"))) {
|
||||||
|
|
||||||
|
if (data[column.fieldname] < 0) {
|
||||||
|
value = "<span style='color:red'>" + value + "</span>";
|
||||||
|
}
|
||||||
|
else if (data[column.fieldname] > 0) {
|
||||||
|
value = "<span style='color:green'>" + value + "</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function get_filters() {
|
||||||
|
function get_dimensions() {
|
||||||
|
let result = [];
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.accounts.doctype.accounting_dimension.accounting_dimension.get_dimensions",
|
||||||
|
args: {
|
||||||
|
'with_cost_center_and_project': true
|
||||||
|
},
|
||||||
|
async: false,
|
||||||
|
callback: function(r) {
|
||||||
|
if(!r.exc) {
|
||||||
|
result = r.message[0].map(elem => elem.document_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
let budget_against_options = get_dimensions();
|
||||||
|
|
||||||
|
let filters = [
|
||||||
{
|
{
|
||||||
fieldname: "from_fiscal_year",
|
fieldname: "from_fiscal_year",
|
||||||
label: __("From Fiscal Year"),
|
label: __("From Fiscal Year"),
|
||||||
@ -44,9 +81,13 @@ frappe.query_reports["Budget Variance Report"] = {
|
|||||||
fieldname: "budget_against",
|
fieldname: "budget_against",
|
||||||
label: __("Budget Against"),
|
label: __("Budget Against"),
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
options: ["Cost Center", "Project"],
|
options: budget_against_options,
|
||||||
default: "Cost Center",
|
default: "Cost Center",
|
||||||
reqd: 1,
|
reqd: 1,
|
||||||
|
get_data: function() {
|
||||||
|
console.log(this.options);
|
||||||
|
return ["Emacs", "Rocks"];
|
||||||
|
},
|
||||||
on_change: function() {
|
on_change: function() {
|
||||||
frappe.query_report.set_filter_value("budget_against_filter", []);
|
frappe.query_report.set_filter_value("budget_against_filter", []);
|
||||||
frappe.query_report.refresh();
|
frappe.query_report.refresh();
|
||||||
@ -71,24 +112,8 @@ frappe.query_reports["Budget Variance Report"] = {
|
|||||||
fieldtype: "Check",
|
fieldtype: "Check",
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
"formatter": function (value, row, column, data, default_formatter) {
|
|
||||||
value = default_formatter(value, row, column, data);
|
|
||||||
|
|
||||||
if (column.fieldname.includes(__("variance"))) {
|
return filters;
|
||||||
|
|
||||||
if (data[column.fieldname] < 0) {
|
|
||||||
value = "<span style='color:red'>" + value + "</span>";
|
|
||||||
}
|
|
||||||
else if (data[column.fieldname] > 0) {
|
|
||||||
value = "<span style='color:green'>" + value + "</span>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.dimension_filters.forEach((dimension) => {
|
|
||||||
frappe.query_reports["Budget Variance Report"].filters[4].options.push(dimension["document_type"]);
|
|
||||||
});
|
|
||||||
|
|||||||
@ -117,8 +117,3 @@ frappe.query_reports["Profitability Analysis"] = {
|
|||||||
"parent_field": "parent_account",
|
"parent_field": "parent_account",
|
||||||
"initial_depth": 3
|
"initial_depth": 3
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.dimension_filters.forEach((dimension) => {
|
|
||||||
frappe.query_reports["Profitability Analysis"].filters[1].options.push(dimension["document_type"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user