fix: Linting errors

This commit is contained in:
Deepesh Garg 2021-05-13 14:04:51 +05:30
parent a87e3fcb7c
commit fd380d34f9
6 changed files with 52 additions and 53 deletions

View File

@ -516,13 +516,13 @@ class PaymentEntry(AccountsController):
if self.payment_type == "Receive" \
and self.base_total_allocated_amount < self.base_received_amount_after_tax + total_deductions \
and self.total_allocated_amount < self.paid_amount_after_tax + (total_deductions / self.source_exchange_rate):
self.unallocated_amount = (self.received_amount_after_tax + total_deductions -
self.base_total_allocated_amount) / self.source_exchange_rate
self.unallocated_amount = (self.received_amount_after_tax + total_deductions -
self.base_total_allocated_amount) / self.source_exchange_rate
elif self.payment_type == "Pay" \
and self.base_total_allocated_amount < (self.base_paid_amount_after_tax - total_deductions) \
and self.total_allocated_amount < self.received_amount_after_tax + (total_deductions / self.target_exchange_rate):
self.unallocated_amount = (self.base_paid_amount_after_tax - (total_deductions +
self.base_total_allocated_amount)) / self.target_exchange_rate
self.unallocated_amount = (self.base_paid_amount_after_tax - (total_deductions +
self.base_total_allocated_amount)) / self.target_exchange_rate
def set_difference_amount(self):
base_unallocated_amount = flt(self.unallocated_amount) * (flt(self.source_exchange_rate)
@ -719,8 +719,8 @@ class PaymentEntry(AccountsController):
"account": d.account_head,
"against": self.party if self.payment_type=="Receive" else self.paid_from,
dr_or_cr: d.base_tax_amount,
dr_or_cr + "_in_account_currency": d.base_tax_amount \
if account_currency==self.company_currency \
dr_or_cr + "_in_account_currency": d.base_tax_amount
if account_currency==self.company_currency
else d.tax_amount,
"cost_center": d.cost_center
}, account_currency, item=d))
@ -730,8 +730,8 @@ class PaymentEntry(AccountsController):
"account": self.advance_tax_account,
"against": self.party if self.payment_type=="Receive" else self.paid_from,
rev_dr_cr: d.base_tax_amount,
rev_dr_cr + "_in_account_currency": d.base_tax_amount \
if account_currency==self.company_currency \
rev_dr_cr + "_in_account_currency": d.base_tax_amount
if account_currency==self.company_currency
else d.tax_amount,
"cost_center": d.cost_center or self.cost_center
}, account_currency, item=d))
@ -806,7 +806,6 @@ class PaymentEntry(AccountsController):
for i, tax in enumerate(self.taxes):
tax_rate = tax.rate
current_tax_rate = 0.0
# To set row_id by default as previous row.
if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"]:

View File

@ -921,8 +921,8 @@ class PurchaseInvoice(BuyingController):
"account": tax.account_head,
"against": self.supplier,
dr_or_cr: unallocated_amount,
dr_or_cr + "_in_account_currency": unallocated_amount \
if account_currency==self.company_currency \
dr_or_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center
}, account_currency, item=tax))
@ -932,8 +932,8 @@ class PurchaseInvoice(BuyingController):
"account": pe.advance_tax_account,
"against": self.supplier,
rev_dr_cr: unallocated_amount,
rev_dr_cr + "_in_account_currency": unallocated_amount \
if account_currency==self.company_currency \
rev_dr_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center or self.cost_center
}, account_currency, item=tax))

View File

@ -933,8 +933,8 @@ class SalesInvoice(SellingController):
"account": tax.account_head,
"against": self.customer,
dr_or_cr: unallocated_amount,
dr_or_cr + "_in_account_currency": unallocated_amount \
if account_currency==self.company_currency \
dr_or_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center
}, account_currency, item=tax))
@ -944,8 +944,8 @@ class SalesInvoice(SellingController):
"account": pe.advance_tax_account,
"against": self.customer,
rev_dr_cr: unallocated_amount,
rev_dr_cr + "_in_account_currency": unallocated_amount \
if account_currency==self.company_currency \
rev_dr_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center
}, account_currency, item=tax))

View File

@ -136,7 +136,7 @@ def get_gle_map(filters, documents):
# create gle_map of the form
# {"purchase_invoice": list of dict of all gle created for this invoice}
gle_map = {}
filter_obj = {}
gle = frappe.db.get_all('GL Entry',
{
"voucher_no": ["in", documents],
@ -242,7 +242,7 @@ def get_payment_entires(filters):
if filters.get('purchase_invoice') or filters.get('purchase_order'):
parent = frappe.db.get_all('Payment Entry Reference',
{ 'reference_name': ('in', [d.get('name') for d in filters.get('invoices')])}, ['parent'])
{'reference_name': ('in', [d.get('name') for d in filters.get('invoices')])}, ['parent'])
filter_dict.update({'name': ('in', [d.get('parent') for d in parent])})

View File

@ -156,31 +156,31 @@ cur_frm.cscript.validate_taxes_and_charges = function(cdt, cdn) {
var d = locals[cdt][cdn];
var msg = "";
if(d.account_head && !d.description) {
if (d.account_head && !d.description) {
// set description from account head
d.description = d.account_head.split(' - ').slice(0, -1).join(' - ');
}
if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) {
if (!d.charge_type && (d.row_id || d.rate || d.tax_amount)) {
msg = __("Please select Charge Type first");
d.row_id = "";
d.rate = d.tax_amount = 0.0;
} else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total' || d.charge_type == 'On Paid Amount') && d.row_id) {
} else if ((d.charge_type == 'Actual' || d.charge_type == 'On Net Total' || d.charge_type == 'On Paid Amount') && d.row_id) {
msg = __("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'");
d.row_id = "";
} else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) {
} else if ((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) {
if (d.idx == 1) {
msg = __("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
d.charge_type = '';
} else if (!d.row_id) {
msg = __("Please specify a valid Row ID for row {0} in table {1}", [d.idx, __(d.doctype)]);
d.row_id = "";
} else if(d.row_id && d.row_id >= d.idx) {
} else if (d.row_id && d.row_id >= d.idx) {
msg = __("Cannot refer row number greater than or equal to current row number for this Charge type");
d.row_id = "";
}
}
if(msg) {
if (msg) {
frappe.validated = false;
refresh_field("taxes");
frappe.throw(msg);

View File

@ -16,14 +16,14 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.select_text()
},
select_text: function(){
select_text: function() {
var me = this;
$(this.$body).find('.form-control').click(function(){
$(this.$body).find('.form-control').click(function() {
$(this).select();
})
},
set_payment_primary_action: function(){
set_payment_primary_action: function() {
var me = this;
this.dialog.set_primary_action(__("Submit"), function() {
@ -38,7 +38,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
})
},
make_keyboard: function(){
make_keyboard: function() {
var me = this;
$(this.$body).empty();
$(this.$body).html(frappe.render_template('pos_payment', this.frm.doc))
@ -47,10 +47,10 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.clear_amount()
},
make_multimode_payment: function(){
make_multimode_payment: function() {
var me = this;
if(this.frm.doc.change_amount > 0){
if(this.frm.doc.change_amount > 0) {
me.payment_val = me.doc.outstanding_amount
}
@ -59,7 +59,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.payments.amount = flt(this.payment_val);
},
show_payment_details: function(){
show_payment_details: function() {
var me = this;
var multimode_payments = $(this.$body).find('.multimode-payments').empty();
if(this.frm.doc.payments.length){
@ -84,7 +84,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
}
},
set_outstanding_amount: function(){
set_outstanding_amount: function() {
this.selected_mode = $(this.$body).find(repl("input[idx='%(idx)s']",{'idx': this.idx}));
this.highlight_selected_row()
this.payment_val = 0.0
@ -101,45 +101,45 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.bind_amount_change_event();
},
bind_keyboard_event: function(){
bind_keyboard_event: function() {
var me = this;
this.payment_val = '';
this.bind_form_control_event();
this.bind_numeric_keys_event();
},
bind_form_control_event: function(){
bind_form_control_event: function() {
var me = this;
$(this.$body).find('.pos-payment-row').click(function(){
$(this.$body).find('.pos-payment-row').click(function() {
me.idx = $(this).attr("idx");
me.set_outstanding_amount()
})
});
$(this.$body).find('.form-control').click(function(){
$(this.$body).find('.form-control').click(function() {
me.idx = $(this).attr("idx");
me.set_outstanding_amount();
me.update_paid_amount(true);
})
});
$(this.$body).find('.write_off_amount').change(function(){
$(this.$body).find('.write_off_amount').change(function() {
me.write_off_amount(flt($(this).val()), precision("write_off_amount"));
})
});
$(this.$body).find('.change_amount').change(function(){
$(this.$body).find('.change_amount').change(function() {
me.change_amount(flt($(this).val()), precision("change_amount"));
})
});
},
highlight_selected_row: function(){
highlight_selected_row: function() {
var me = this;
var selected_row = $(this.$body).find(repl(".pos-payment-row[idx='%(idx)s']",{'idx': this.idx}));
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')
$(this.$body).find('.amount').attr('disabled', true);
this.selected_mode.attr('disabled', false);
},
bind_numeric_keys_event: function(){
bind_numeric_keys_event: function() {
var me = this;
$(this.$body).find('.pos-keyboard-key').click(function(){
me.payment_val += $(this).text();
@ -148,7 +148,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
me.update_paid_amount()
})
$(this.$body).find('.delete-btn').click(function(){
$(this.$body).find('.delete-btn').click(function() {
me.payment_val = cstr(flt(me.selected_mode.val())).slice(0, -1);
me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency));
me.idx = me.selected_mode.attr("idx")
@ -157,9 +157,9 @@ erpnext.payments = erpnext.stock.StockController.extend({
},
bind_amount_change_event: function(){
bind_amount_change_event: function() {
var me = this;
this.selected_mode.change(function(){
this.selected_mode.change(function() {
me.payment_val = flt($(this).val()) || 0.0;
me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency))
me.idx = me.selected_mode.attr("idx")
@ -169,7 +169,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
clear_amount: function() {
var me = this;
$(this.$body).find('.clr').click(function(e){
$(this.$body).find('.clr').click(function(e) {
e.stopPropagation();
me.idx = $(this).attr("idx");
me.selected_mode = $(me.$body).find(repl("input[idx='%(idx)s']",{'idx': me.idx}));
@ -215,10 +215,10 @@ erpnext.payments = erpnext.stock.StockController.extend({
}
},
update_payment_amount: function(){
update_payment_amount: function() {
var me = this;
$.each(this.frm.doc.payments, function(index, data){
$.each(this.frm.doc.payments, function(index, data) {
if(cint(me.idx) == cint(data.idx)){
data.amount = flt(me.selected_mode.val(), 2)
}
@ -228,7 +228,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
this.show_amounts();
},
show_amounts: function(){
show_amounts: function() {
var me = this;
$(this.$body).find(".write_off_amount").val(format_currency(this.frm.doc.write_off_amount, this.frm.doc.currency));
$(this.$body).find('.paid_amount').text(format_currency(this.frm.doc.paid_amount, this.frm.doc.currency));