fix: Linting and other fixes

This commit is contained in:
Deepesh Garg
2021-05-20 17:08:57 +05:30
parent c9da1fc568
commit b07f7d1b70
6 changed files with 66 additions and 52 deletions

View File

@@ -16,12 +16,11 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.select_text();
},
select_text: function() {
var me = this;
select_text() {
$(this.$body).find('.form-control').click(function() {
$(this).select();
})
},
});
}
set_payment_primary_action: function() {
var me = this;
@@ -62,8 +61,8 @@ erpnext.payments = erpnext.stock.StockController.extend({
show_payment_details: function() {
var me = this;
var multimode_payments = $(this.$body).find('.multimode-payments').empty();
if(this.frm.doc.payments.length){
$.each(this.frm.doc.payments, function(index, data){
if (this.frm.doc.payments.length) {
$.each(this.frm.doc.payments, function(index, data) {
$(frappe.render_template('payment_details', {
mode_of_payment: data.mode_of_payment,
amount: data.amount,
@@ -88,12 +87,12 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.selected_mode = $(this.$body).find(repl("input[idx='%(idx)s']",{'idx': this.idx}));
this.highlight_selected_row()
this.payment_val = 0.0
if(this.frm.doc.outstanding_amount > 0 && flt(this.selected_mode.val()) == 0.0){
if (this.frm.doc.outstanding_amount > 0 && flt(this.selected_mode.val()) == 0.0) {
//When user first time click on row
this.payment_val = flt(this.frm.doc.outstanding_amount / this.frm.doc.conversion_rate, precision("outstanding_amount"))
this.selected_mode.val(format_currency(this.payment_val, this.frm.doc.currency));
this.update_payment_amount()
}else if(flt(this.selected_mode.val()) > 0){
this.update_payment_amount();
} else if (flt(this.selected_mode.val()) > 0) {
//If user click on existing row which has value
this.payment_val = flt(this.selected_mode.val());
}
@@ -101,8 +100,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.bind_amount_change_event();
},
bind_keyboard_event: function() {
var me = this;
bind_keyboard_event() {
this.payment_val = '';
this.bind_form_control_event();
this.bind_numeric_keys_event();
@@ -130,8 +128,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
});
},
highlight_selected_row: function() {
var me = this;
highlight_selected_row() {
var selected_row = $(this.$body).find(repl(".pos-payment-row[idx='%(idx)s']", {'idx': this.idx}));
$(this.$body).find('.pos-payment-row').removeClass('selected-payment-mode');
selected_row.addClass('selected-payment-mode');
@@ -157,7 +154,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
},
bind_amount_change_event: function() {
bind_amount_change_event() {
var me = this;
this.selected_mode.change(function() {
me.payment_val = flt($(this).val()) || 0.0;
@@ -180,9 +177,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
});
},
write_off_amount: function(write_off_amount) {
var me = this;
write_off_amount(write_off_amount) {
this.frm.doc.write_off_amount = flt(write_off_amount, precision("write_off_amount"));
this.frm.doc.base_write_off_amount = flt(this.frm.doc.write_off_amount * this.frm.doc.conversion_rate,
precision("base_write_off_amount"));
@@ -204,7 +199,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
var value = me.selected_mode.val();
if (me.idx == 'change_amount') {
me.change_amount(value);
} else{
} else {
if(flt(value) == 0 && update_write_off && me.frm.doc.outstanding_amount > 0) {
value = flt(me.frm.doc.outstanding_amount / me.frm.doc.conversion_rate, precision(me.idx));
}
@@ -219,7 +214,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
var me = this;
$.each(this.frm.doc.payments, function(index, data) {
if(cint(me.idx) == cint(data.idx)){
if (cint(me.idx) == cint(data.idx)) {
data.amount = flt(me.selected_mode.val(), 2);
}
})