chore: fix linting issues
diff --git a/erpnext/public/js/agriculture/ternary_plot.js b/erpnext/public/js/agriculture/ternary_plot.js
deleted file mode 100644
index b06a1fd..0000000
--- a/erpnext/public/js/agriculture/ternary_plot.js
+++ /dev/null
@@ -1,232 +0,0 @@
-frappe.provide('agriculture');
-
-agriculture.TernaryPlot = class TernaryPlot {
- constructor(opts) {
- Object.assign(this, opts);
-
- frappe.require('assets/frappe/js/lib/snap.svg-min.js', () => {
- this.make_svg();
- this.init_snap();
- this.init_config();
- this.make_plot();
- this.make_plot_marking();
- this.make_legend();
- this.mark_blip();
- });
- }
-
- make_svg() {
- this.$svg = $('<svg height="350" width="400">');
- $(this.parent).append(this.$svg);
- }
-
- init_snap() {
- this.paper = new Snap(this.$svg.get(0));
- }
-
- init_config() {
- this.config = {
- triangle_side: 300,
- spacing: 50,
- strokeWidth: 1,
- stroke: frappe.ui.color.get('black')
- };
- this.config.scaling_factor = this.config.triangle_side / 100;
- let { triangle_side: t, spacing: s, scaling_factor: p } = this.config;
-
- this.coords = {
- sand: {
- points: [
- s + t * Snap.cos(60), s,
- s, s + t * Snap.cos(30),
- s + t, s + t * Snap.cos(30)
- ],
- color: frappe.ui.color.get('peach')
- },
- loamy_sand: {
- points: [
- s + 15 * p * Snap.cos(60), s + (100 - 15) * p * Snap.cos(30),
- s + 10 * p * Snap.cos(60), s + (100 - 10) * p * Snap.cos(30),
- s + (100 - 85) * p, s + t * Snap.cos(30),
- s + (100 - 70) * p, s + t * Snap.cos(30)
- ],
- color: frappe.ui.color.get('pink')
- },
- sandy_loam: {
- points: [
- s + 20 * p * Snap.cos(60) + 27.5 * p, s + (100 - 20) * p * Snap.cos(30),
- s + 20 * p * Snap.cos(60), s + (100 - 20) * p * Snap.cos(30),
- s + 15 * p * Snap.cos(60), s + (100 - 15) * p * Snap.cos(30),
- s + (100 - 75) * p, s + t * Snap.cos(30),
- s + (100 - 50) * p, s + t * Snap.cos(30),
- s + (100 - 50) * p + 7.5 * p * Snap.cos(60), s + t * Snap.cos(30) - 7.5 * p * Snap.cos(30),
- s + (100 - 50) * p + 7.5 * p * Snap.cos(60) - 10 * p, s + t * Snap.cos(30) - 7.5 * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('pink', 'light')
- },
- loam: {
- points: [
- s + (100 - 50) * p + 27.5 * p * Snap.cos(60), s + t * Snap.cos(30) - 27.5 * p * Snap.cos(30),
- s + (100 - 50) * p + 27.5 * p * Snap.cos(60) - 22.5 * p, s + t * Snap.cos(30) - 27.5 * p * Snap.cos(30),
- s + 20 * p * Snap.cos(60) + 27.5 * p, s + (100 - 20) * p * Snap.cos(30),
- s + (100 - 50) * p + 7.5 * p * Snap.cos(60) - 10 * p, s + t * Snap.cos(30) - 7.5 * p * Snap.cos(30),
- s + (100 - 50) * p + 7.5 * p * Snap.cos(60), s + t * Snap.cos(30) - 7.5 * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('brown')
- },
- silt_loam: {
- points: [
- s + t - 27.5 * p * Snap.cos(60), s + 72.5 * p * Snap.cos(30),
- s + (100 - 50) * p + 27.5 * p * Snap.cos(60), s + t * Snap.cos(30) - 27.5 * p * Snap.cos(30),
- s + (100 - 50) * p, s + t * Snap.cos(30),
- s + (100 - 20) * p, s + t * Snap.cos(30),
- s + (100 - 20) * p + 12.5 * p * Snap.cos(60), s + 90 * p * Snap.cos(30),
- s + t - 12.5 * p * Snap.cos(60), s + (100 - 12.5) * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('green', 'dark')
- },
- silt: {
- points: [
- s + t - 12.5 * p * Snap.cos(60), s + (100 - 12.5) * p * Snap.cos(30),
- s + (100 - 20) * p + 12.5 * p * Snap.cos(60), s + 90 * p * Snap.cos(30),
- s + (100 - 20) * p, s + t * Snap.cos(30),
- s + t, s + t * Snap.cos(30)
- ],
- color: frappe.ui.color.get('green')
- },
- silty_clay_loam: {
- points: [
- s + t - 40 * p * Snap.cos(60), s + 60 * p * Snap.cos(30),
- s + t - 40 * p * Snap.cos(60) - 20 * p, s + 60 * p * Snap.cos(30),
- s + t - 27.5 * p * Snap.cos(60) - 20 * p, s + 72.5 * p * Snap.cos(30),
- s + t - 27.5 * p * Snap.cos(60), s + 72.5 * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('cyan', 'dark')
- },
- silty_clay: {
- points: [
- s + t - 60 * p * Snap.cos(60), s + 40 * p * Snap.cos(30),
- s + t - 40 * p * Snap.cos(60) - 20 * p, s + 60 * p * Snap.cos(30),
- s + t - 40 * p * Snap.cos(60), s + 60 * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('cyan')
- },
- clay_loam: {
- points: [
- s + t - 40 * p * Snap.cos(60) - 20 * p, s + 60 * p * Snap.cos(30),
- s + t - 40 * p * Snap.cos(60) - 45 * p, s + 60 * p * Snap.cos(30),
- s + t - 27.5 * p * Snap.cos(60) - 45 * p, s + 72.5 * p * Snap.cos(30),
- s + t - 27.5 * p * Snap.cos(60) - 20 * p, s + 72.5 * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('green', 'light')
- },
- sandy_clay_loam: {
- points: [
- s + 35 * p * Snap.cos(60) + 20 * p, s + (100 - 35) * p * Snap.cos(30),
- s + 35 * p * Snap.cos(60), s + (100 - 35) * p * Snap.cos(30),
- s + 20 * p * Snap.cos(60), s + (100 - 20) * p * Snap.cos(30),
- s + 20 * p * Snap.cos(60) + 27.5 * p, s + (100 - 20) * p * Snap.cos(30),
- s + t - 27.5 * p * Snap.cos(60) - 45 * p, s + 72.5 * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('pink', 'dark')
- },
- sandy_clay: {
- points: [
- s + 55 * p * Snap.cos(60), s + (100 - 55) * p * Snap.cos(30),
- s + 35 * p * Snap.cos(60), s + (100 - 35) * p * Snap.cos(30),
- s + 35 * p * Snap.cos(60) + 20 * p, s + (100 - 35) * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('red')
- },
- clay: {
- points: [
- s + t * Snap.cos(60), s,
- s + 55 * p * Snap.cos(60), s + (100 - 55) * p * Snap.cos(30),
- s + t - 40 * p * Snap.cos(60) - 45 * p, s + 60 * p * Snap.cos(30),
- s + t - 40 * p * Snap.cos(60) - 20 * p, s + 60 * p * Snap.cos(30),
- s + t - 60 * p * Snap.cos(60), s + 40 * p * Snap.cos(30)
- ],
- color: frappe.ui.color.get('yellow')
- },
- };
- }
-
- get_coords(soil_type) {
- return this.coords[soil_type].points;
- }
-
- get_color(soil_type) {
- return this.coords[soil_type].color;
- }
-
- make_plot() {
- for (let soil_type in this.coords) {
- this.paper.polygon(this.get_coords(soil_type)).attr({
- fill: this.get_color(soil_type),
- stroke: this.config.stroke,
- strokeWidth: this.config.strokeWidth
- });
- }
- }
-
- make_plot_marking() {
- let { triangle_side: t, spacing: s, scaling_factor: p } = this.config;
-
- let clay = this.paper.text(t * Snap.cos(60) / 2, s + t * Snap.cos(30) / 2, __("Clay")).attr({
- fill: frappe.ui.color.get('black')
- });
- clay.transform("r300");
-
- let silt = this.paper.text(t, s + t * Snap.cos(30) / 2, __("Silt")).attr({
- fill: frappe.ui.color.get('black')
- });
- silt.transform("r60");
-
- let sand = this.paper.text(35 + t * Snap.cos(60), 90 + t * Snap.cos(30), __("Sand")).attr({
- fill: frappe.ui.color.get('black')
- });
- sand.transform("r0");
- }
-
- make_legend() {
- // let side = len(this.coords)/2;
- let index = 1;
- let offset = 0;
- let exec_once = true;
- for (let soil_type in this.coords) {
- if (index > 6 && exec_once){
- offset = 300;
- index = 1;
- exec_once = false;
- }
- let rect = this.paper.rect(0+offset, 0+index*20, 100, 19, 5, 5).attr({
- fill: this.get_color(soil_type),
- stroke: frappe.ui.color.get('black')
- });
- let text = this.paper.text(5+offset, 16+index*20, soil_type).attr({
- fill: frappe.ui.color.get('black'),
- 'font-size': 12
- });
- index++;
- }
- }
-
- mark_blip({clay, sand, silt} = this) {
- if (clay + sand + silt != 0){
- let { triangle_side: t, spacing: s, scaling_factor: p } = this.config;
-
- let x_blip = s + clay * p * Snap.cos(60) + silt * p;
- let y_blip = s + silt * p * Snap.cos(30) + sand * p * Snap.sin(60);
- this.blip = this.paper.circle(x_blip, y_blip, 4).attr({
- fill: frappe.ui.color.get("orange"),
- stroke: frappe.ui.color.get("orange"),
- strokeWidth: 2
- });
- }
- }
-
- remove_blip() {
- if (typeof this.blip !== 'undefined')
- this.blip.remove();
- }
-};
diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js
index a343c34..98e7f78 100644
--- a/erpnext/public/js/stock_analytics.js
+++ b/erpnext/public/js/stock_analytics.js
@@ -125,6 +125,7 @@
this.serialized_buying_rates = this.get_serialized_buying_rates();
for(var i=0, j=data.length; i<j; i++) {
+ let diff = 0;
var sl = data[i];
sl.posting_datetime = sl.posting_date + " " + sl.posting_time;
var posting_datetime = frappe.datetime.str_to_obj(sl.posting_datetime);
@@ -140,18 +141,18 @@
var is_fifo = valuation_method == "FIFO";
if(sl.voucher_type=="Stock Reconciliation") {
- var diff = (sl.qty_after_transaction * sl.valuation_rate) - item.closing_qty_value;
+ diff = (sl.qty_after_transaction * sl.valuation_rate) - item.closing_qty_value;
wh.fifo_stack = [[sl.qty_after_transaction, sl.valuation_rate, sl.posting_date]];
wh.balance_qty = sl.qty_after_transaction;
wh.balance_value = sl.valuation_rate * sl.qty_after_transaction;
} else {
- var diff = me.get_value_diff(wh, sl, is_fifo);
+ diff = me.get_value_diff(wh, sl, is_fifo);
}
} else {
if(sl.voucher_type=="Stock Reconciliation") {
- var diff = sl.qty_after_transaction - item.closing_qty_value;
+ diff = sl.qty_after_transaction - item.closing_qty_value;
} else {
- var diff = sl.qty;
+ diff = sl.qty;
}
}
diff --git a/erpnext/public/js/stock_grid_report.js b/erpnext/public/js/stock_grid_report.js
index 752fafd..c7867d0 100644
--- a/erpnext/public/js/stock_grid_report.js
+++ b/erpnext/public/js/stock_grid_report.js
@@ -12,10 +12,12 @@
get_value_diff(wh, sl, is_fifo) {
// value
+ let value_diff = 0;
+
if(sl.qty > 0) {
// incoming - rate is given
- var rate = sl.incoming_rate;
- var add_qty = sl.qty;
+ let rate = sl.incoming_rate;
+ let add_qty = sl.qty;
if(wh.balance_qty < 0) {
// negative valuation
// only add value of quantity if
@@ -25,10 +27,11 @@
add_qty = 0;
}
}
+
if(sl.serial_no) {
- var value_diff = this.get_serialized_value_diff(sl);
+ value_diff = this.get_serialized_value_diff(sl);
} else {
- var value_diff = (rate * add_qty);
+ value_diff = (rate * add_qty);
}
if(add_qty)
@@ -39,19 +42,19 @@
// outgoing
if(sl.serial_no) {
- var value_diff = -1 * this.get_serialized_value_diff(sl);
+ value_diff = -1 * this.get_serialized_value_diff(sl);
} else if(is_fifo) {
- var value_diff = fifo_value_diff;
+ value_diff = fifo_value_diff;
} else {
// average rate for weighted average
- var rate = (wh.balance_qty.toFixed(2) == 0.00 ? 0 :
+ let rate = (wh.balance_qty.toFixed(2) == 0.00 ? 0 :
flt(wh.balance_value) / flt(wh.balance_qty));
// no change in value if negative qty
if((wh.balance_qty + sl.qty).toFixed(2) >= 0.00)
- var value_diff = (rate * sl.qty);
+ value_diff = (rate * sl.qty);
else
- var value_diff = -wh.balance_value;
+ value_diff = -wh.balance_value;
}
}