refactor(analytics report): linting
diff --git a/erpnext/buying/report/purchase_analytics/purchase_analytics.js b/erpnext/buying/report/purchase_analytics/purchase_analytics.js
index 7ee9f2c..ba8535a 100644
--- a/erpnext/buying/report/purchase_analytics/purchase_analytics.js
+++ b/erpnext/buying/report/purchase_analytics/purchase_analytics.js
@@ -87,12 +87,18 @@
row_name = data[2].content;
length = data.length;
- if (tree_type == "Supplier" || tree_type == "Item") {
+ if (tree_type == "Supplier") {
row_values = data
.slice(4, length - 1)
.map(function (column) {
return column.content;
});
+ } else if (tree_type == "Item") {
+ row_values = data
+ .slice(5, length - 1)
+ .map(function (column) {
+ return column.content;
+ });
} else {
row_values = data
.slice(3, length - 1)
@@ -109,17 +115,15 @@
let raw_data = frappe.query_report.chart.data;
let new_datasets = raw_data.datasets;
- let found = false;
-
- for (let i = 0; i < new_datasets.length; i++) {
- if (new_datasets[i].name == row_name) {
- found = true;
- new_datasets.splice(i, 1);
- break;
+ let element_found = new_datasets.some((element, index, array)=>{
+ if(element.name == row_name){
+ array.splice(index, 1)
+ return true
}
- }
+ return false
+ })
- if (!found) {
+ if (!element_found) {
new_datasets.push(entry);
}
let new_data = {
diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.js b/erpnext/selling/report/sales_analytics/sales_analytics.js
index aad6bfd..9089b53 100644
--- a/erpnext/selling/report/sales_analytics/sales_analytics.js
+++ b/erpnext/selling/report/sales_analytics/sales_analytics.js
@@ -76,7 +76,6 @@
events: {
onCheckRow: function (data) {
if (!data) return;
-
const data_doctype = $(
data[2].html
)[0].attributes.getNamedItem("data-doctype").value;
@@ -114,17 +113,15 @@
let raw_data = frappe.query_report.chart.data;
let new_datasets = raw_data.datasets;
- let found = false;
-
- for (let i = 0; i < new_datasets.length; i++) {
- if (new_datasets[i].name == row_name) {
- found = true;
- new_datasets.splice(i, 1);
- break;
+ let element_found = new_datasets.some((element, index, array)=>{
+ if(element.name == row_name){
+ array.splice(index, 1)
+ return true
}
- }
+ return false
+ })
- if (!found) {
+ if (!element_found) {
new_datasets.push(entry);
}