Merge pull request #21940 from deepeshgarg007/acc_dim_report_filter

fix: Do not add filters in report on accounting dimension creation if it already exists
This commit is contained in:
Deepesh Garg 2020-05-26 19:30:43 +05:30 committed by GitHub
commit 3a723dd815
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 32 additions and 74 deletions

View File

@ -135,12 +135,5 @@ frappe.query_reports["Accounts Payable"] = {
}
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Accounts Payable"].filters.splice(9, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('Accounts Payable', 9);

View File

@ -104,12 +104,5 @@ frappe.query_reports["Accounts Payable Summary"] = {
}
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Accounts Payable Summary"].filters.splice(9, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('Accounts Payable Summary', 9);

View File

@ -199,12 +199,5 @@ frappe.query_reports["Accounts Receivable"] = {
}
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Accounts Receivable"].filters.splice(9, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('Accounts Receivable', 9);

View File

@ -122,11 +122,4 @@ frappe.query_reports["Accounts Receivable Summary"] = {
}
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Accounts Receivable Summary"].filters.splice(9, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('Accounts Receivable Summary', 9);

View File

@ -4,6 +4,8 @@
frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Balance Sheet"] = $.extend({}, erpnext.financial_statements);
erpnext.utils.add_dimensions('Balance Sheet', 10);
frappe.query_reports["Balance Sheet"]["filters"].push({
"fieldname": "accumulated_values",
"label": __("Accumulated Values"),

View File

@ -5,6 +5,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Cash Flow"] = $.extend({},
erpnext.financial_statements);
erpnext.utils.add_dimensions('Cash Flow', 10);
// The last item in the array is the definition for Presentation Currency
// filter. It won't be used in cash flow for now so we pop it. Please take
// of this if you are working here.

View File

@ -164,12 +164,5 @@ frappe.query_reports["General Ledger"] = {
]
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["General Ledger"].filters.splice(15, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('General Ledger', 15)

View File

@ -6,6 +6,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Profit and Loss Statement"] = $.extend({},
erpnext.financial_statements);
erpnext.utils.add_dimensions('Profit and Loss Statement', 10);
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
{
"fieldname": "project",

View File

@ -56,11 +56,4 @@ frappe.query_reports["Purchase Register"] = {
]
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Purchase Register"].filters.splice(7, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('Purchase Register', 7);

View File

@ -68,12 +68,5 @@ frappe.query_reports["Sales Register"] = {
]
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Sales Register"].filters.splice(7, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('Sales Register', 7);

View File

@ -102,14 +102,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"initial_depth": 3
}
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Trial Balance"].filters.splice(6, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions('Trial Balance', 6);
});

View File

@ -62,7 +62,7 @@ erpnext.financial_statements = {
}
};
function get_filters(){
function get_filters() {
let filters = [
{
"fieldname":"company",
@ -162,15 +162,6 @@ function get_filters(){
}
]
erpnext.dimension_filters.forEach((dimension) => {
filters.push({
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
return filters;
}

View File

@ -191,6 +191,23 @@ $.extend(erpnext.utils, {
})
},
add_dimensions: function(report_name, index) {
let filters = frappe.query_reports[report_name].filters;
erpnext.dimension_filters.forEach((dimension) => {
let found = filters.some(el => el.fieldname === dimension['fieldname']);
if (!found) {
filters.splice(index, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
}
});
},
make_subscription: function(doctype, docname) {
frappe.call({
method: "frappe.automation.doctype.auto_repeat.auto_repeat.make_auto_repeat",