chore: fix linting issues

This commit is contained in:
Deepesh Garg 2023-07-15 18:03:16 +05:30
parent 924cdef6d9
commit 3fa2a8c2d8
18 changed files with 42 additions and 275 deletions

View File

@ -264,11 +264,11 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
}
if(jvd.party_type && jvd.party) {
var party_field = "";
let party_field = "";
if(jvd.reference_type.indexOf("Sales")===0) {
var party_field = "customer";
party_field = "customer";
} else if (jvd.reference_type.indexOf("Purchase")===0) {
var party_field = "supplier";
party_field = "supplier";
}
if (party_field) {
@ -368,7 +368,7 @@ cur_frm.cscript.update_totals = function(doc) {
td += flt(accounts[i].debit, precision("debit", accounts[i]));
tc += flt(accounts[i].credit, precision("credit", accounts[i]));
}
var doc = locals[doc.doctype][doc.name];
doc = locals[doc.doctype][doc.name];
doc.total_debit = td;
doc.total_credit = tc;
doc.difference = flt((td - tc), precision("difference"));

View File

@ -124,7 +124,7 @@ frappe.ui.form.on('Payment Order', {
return frappe.call({
method: "erpnext.accounts.doctype.payment_order.payment_order.make_payment_records",
args: {
"name": me.frm.doc.name,
"name": frm.doc.name,
"supplier": args.supplier,
"mode_of_payment": args.mode_of_payment
},

View File

@ -29,7 +29,6 @@ frappe.query_reports["Sales Payment Summary"] = {
"label": __("Owner"),
"fieldtype": "Link",
"options": "User",
"defaults": user
},
{
"fieldname":"is_pos",

View File

@ -473,7 +473,7 @@ frappe.ui.form.on('Asset', {
}
const item = purchase_doc.items.find(item => item.item_code === frm.doc.item_code);
if (!item) {
doctype_field = frappe.scrub(doctype)
let doctype_field = frappe.scrub(doctype)
frm.set_value(doctype_field, '');
frappe.msgprint({
title: __('Invalid {0}', [__(doctype)]),

View File

@ -1,9 +1,6 @@
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* global frappe */
frappe.ui.form.on("Supplier Scorecard Period", {
onload: function(frm) {
let criteria_grid = frm.get_field("criteria").grid;

View File

@ -1,7 +1,6 @@
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* global frappe */
frappe.ui.form.on("Supplier Scorecard Standing", {
refresh: function() {

View File

@ -1,8 +1,6 @@
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* global frappe */
frappe.ui.form.on("Supplier Scorecard Variable", {
refresh: function() {

View File

@ -54,6 +54,7 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
}
add_lead_to_prospect () {
let me = this;
frappe.prompt([
{
fieldname: 'prospect',
@ -67,12 +68,12 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
frappe.call({
method: 'erpnext.crm.doctype.lead.lead.add_lead_to_prospect',
args: {
'lead': cur_frm.doc.name,
'lead': me.frm.doc.name,
'prospect': data.prospect
},
callback: function(r) {
if (!r.exc) {
frm.reload_doc();
me.frm.reload_doc();
}
},
freeze: true,

View File

@ -624,7 +624,7 @@ erpnext.work_order = {
if ((flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing))) {
frm.has_finish_btn = true;
var finish_btn = frm.add_custom_button(__('Finish'), function() {
let finish_btn = frm.add_custom_button(__('Finish'), function() {
erpnext.work_order.make_se(frm, 'Manufacture');
});
@ -648,7 +648,7 @@ erpnext.work_order = {
}
} else {
if ((flt(doc.produced_qty) < flt(doc.qty))) {
var finish_btn = frm.add_custom_button(__('Finish'), function() {
let finish_btn = frm.add_custom_button(__('Finish'), function() {
erpnext.work_order.make_se(frm, 'Manufacture');
});
finish_btn.addClass('btn-primary');
@ -756,13 +756,14 @@ erpnext.work_order = {
},
make_consumption_se: function(frm, backflush_raw_materials_based_on) {
let max = 0;
if(!frm.doc.skip_transfer){
var max = (backflush_raw_materials_based_on === "Material Transferred for Manufacture") ?
max = (backflush_raw_materials_based_on === "Material Transferred for Manufacture") ?
flt(frm.doc.material_transferred_for_manufacturing) - flt(frm.doc.produced_qty) :
flt(frm.doc.qty) - flt(frm.doc.produced_qty);
// flt(frm.doc.qty) - flt(frm.doc.material_transferred_for_manufacturing);
} else {
var max = flt(frm.doc.qty) - flt(frm.doc.produced_qty);
max = flt(frm.doc.qty) - flt(frm.doc.produced_qty);
}
frappe.call({

View File

@ -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();
}
};

View File

@ -125,6 +125,7 @@ erpnext.StockAnalytics = class StockAnalytics extends erpnext.StockGridReport {
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 @@ erpnext.StockAnalytics = class StockAnalytics extends erpnext.StockGridReport {
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;
}
}

View File

@ -12,10 +12,12 @@ erpnext.StockGridReport = class StockGridReport extends frappe.views.TreeGridRep
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 @@ erpnext.StockGridReport = class StockGridReport extends frappe.views.TreeGridRep
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 @@ erpnext.StockGridReport = class StockGridReport extends frappe.views.TreeGridRep
// 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;
}
}

View File

@ -945,7 +945,7 @@ erpnext.PointOfSale.ItemCart = class {
`<div class="no-transactions-placeholder">No recent transactions found</div>`
)
return;
};
}
const elapsed_time = moment(res[0].posting_date+" "+res[0].posting_time).fromNow();
this.$customer_section.find('.customer-desc').html(`Last transacted ${elapsed_time}`);

View File

@ -9,6 +9,6 @@ frappe.listview_settings['Batch'] = {
return [__("Expired"), "red", "expiry_date,not in,|expiry_date,<=,Today|batch_qty,>,0|disabled,=,0"]
} else {
return [__("Active"), "green", "batch_qty,>,0|disabled,=,0"];
};
}
}
};

View File

@ -92,7 +92,7 @@ frappe.ui.form.on('Delivery Trip', {
frm.set_value("driver_email", data.message.email);
}
});
};
}
},
optimize_route: function (frm) {

View File

@ -67,6 +67,7 @@ frappe.ui.form.on("Stock Reconciliation", {
},
company: function(frm) {
frm.trigger("toggle_display_account_head");
erpnext.accounts.dimensions.update_dimension(frm, frm.doctype);
},
@ -221,9 +222,6 @@ frappe.ui.form.on("Stock Reconciliation", {
frappe.model.set_value(cdt, cdn, "amount_difference", flt(d.amount) - flt(d.current_amount));
}
},
company: function(frm) {
frm.trigger("toggle_display_account_head");
},
toggle_display_account_head: function(frm) {
frm.toggle_display(['expense_account', 'cost_center'],
erpnext.is_perpetual_inventory_enabled(frm.doc.company));

View File

@ -27,10 +27,10 @@ window.get_product_list = function() {
}
window.render_product_list = function(data) {
var table = $("#search-list .table");
let table = $("#search-list .table");
if(data.length) {
if(!table.length)
var table = $("<table class='table'>").appendTo("#search-list");
table = $("<table class='table'>").appendTo("#search-list");
$.each(data, function(i, d) {
$(d).appendTo(table);
@ -38,11 +38,13 @@ window.render_product_list = function(data) {
}
if(data.length < 10) {
if(!table) {
let message = __("No products found.");
$(".more-btn")
.replaceWith("<div class='alert alert-warning'>{{ _("No products found.") }}</div>");
.replaceWith(`<div class='alert alert-warning'>{{ ${message} }}</div>`);
} else {
let message = __("Nothing more to show.");
$(".more-btn")
.replaceWith("<div class='text-muted'>{{ _("Nothing more to show.") }}</div>");
.replaceWith(`<div class='text-muted'>{{ ${message} }}</div>`);
}
} else {
$(".more-btn").toggle(true)

View File

@ -72,7 +72,7 @@ frappe.ready(function() {
var more_items = function(item, item_status){
if(item_status) {
var item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-completed-'+ item)
item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-completed-'+ item)
? 'completed' : 'open';
}
$.ajax({