Codacy corrections + sql queries
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class AccountSubtype(Document):
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
class TestAccountSubtype(unittest.TestCase):
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class AccountType(Document):
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
class TestAccountType(unittest.TestCase):
|
||||
|
||||
@@ -12,19 +12,19 @@ frappe.ui.form.on('Bank', {
|
||||
|
||||
|
||||
let add_fields_to_mapping_table = function (frm) {
|
||||
let options = []
|
||||
let options = [];
|
||||
|
||||
frappe.model.with_doctype("Bank Transaction", function() {
|
||||
let meta = frappe.get_meta("Bank Transaction")
|
||||
let meta = frappe.get_meta("Bank Transaction");
|
||||
meta.fields.forEach(value => {
|
||||
if (!["Section Break", "Column Break"].includes(value.fieldtype)) {
|
||||
options.push(value.fieldname);
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
frappe.meta.get_docfield("Bank Transaction Mapping", "bank_transaction_field",
|
||||
frm.doc.name).options = options;
|
||||
|
||||
frm.fields_dict.bank_transaction_mapping.grid.refresh();
|
||||
}
|
||||
};
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
frappe.ui.form.on('Bank Transaction', {
|
||||
onload: function(frm) {
|
||||
frm.set_query('payment_document', 'payment_entries', function(doc, cdt, cdn) {
|
||||
frm.set_query('payment_document', 'payment_entries', function() {
|
||||
return {
|
||||
"filters": {
|
||||
"name": ["in", ["Payment Entry", "Journal Entry", "Sales Invoice", "Purchase Invoice", "Expense Claim"]]
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import flt
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ frappe.listview_settings['Bank Transaction'] = {
|
||||
add_fields: ["unallocated_amount"],
|
||||
get_indicator: function(doc) {
|
||||
if(flt(doc.unallocated_amount)>0) {
|
||||
return [__("Unreconciled"), "orange", "unallocated_amount,>,0"]
|
||||
return [__("Unreconciled"), "orange", "unallocated_amount,>,0"];
|
||||
} else if(flt(doc.unallocated_amount)==0) {
|
||||
return [__("Reconciled"), "green", "unallocated_amount,=,0"];
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class BankTransactionMapping(Document):
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class BankTransactionPayments(Document):
|
||||
|
||||
@@ -6,7 +6,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
import difflib
|
||||
from operator import itemgetter
|
||||
from frappe.utils import flt
|
||||
from six import iteritems
|
||||
|
||||
@@ -49,12 +48,12 @@ def clear_payment_entry(transaction, payment_entry, gl_entry):
|
||||
LEFT JOIN
|
||||
`tabBank Transaction` as bt on btp.parent=bt.name
|
||||
WHERE
|
||||
btp.payment_document = '%s'
|
||||
btp.payment_document = %s
|
||||
AND
|
||||
btp.payment_entry = '%s'
|
||||
btp.payment_entry = %s
|
||||
AND
|
||||
bt.docstatus = 1
|
||||
""" % (payment_entry.doctype, payment_entry.name), as_dict=True)
|
||||
""", (payment_entry.doctype, payment_entry.name), as_dict=True)
|
||||
|
||||
amount_cleared = (flt(linked_bank_transactions[0].credit) - flt(linked_bank_transactions[0].debit))
|
||||
amount_to_be_cleared = (flt(gl_entry.debit) - flt(gl_entry.credit))
|
||||
@@ -118,7 +117,7 @@ def check_matching_amount(bank_account, transaction):
|
||||
journal_entries = frappe.db.sql("""
|
||||
SELECT
|
||||
'Journal Entry' as doctype, je.name, je.posting_date, je.cheque_no as reference_no,
|
||||
je.pay_to_recd_from as party, je.cheque_date as reference_date, %s as paid_amount
|
||||
je.pay_to_recd_from as party, je.cheque_date as reference_date, {0} as paid_amount
|
||||
FROM
|
||||
`tabJournal Entry Account` as jea
|
||||
JOIN
|
||||
@@ -128,12 +127,12 @@ def check_matching_amount(bank_account, transaction):
|
||||
WHERE
|
||||
(je.clearance_date is null or je.clearance_date='0000-00-00')
|
||||
AND
|
||||
jea.account = '%s'
|
||||
jea.account = %s
|
||||
AND
|
||||
%s like '%s'
|
||||
{0} like %s
|
||||
AND
|
||||
je.docstatus = 1
|
||||
""" % (payment_field, bank_account, payment_field, amount), as_dict=True)
|
||||
""".format(payment_field), (bank_account, amount), as_dict=True)
|
||||
|
||||
sales_invoices = frappe.db.sql("""
|
||||
SELECT
|
||||
@@ -148,12 +147,12 @@ def check_matching_amount(bank_account, transaction):
|
||||
WHERE
|
||||
(sip.clearance_date is null or sip.clearance_date='0000-00-00')
|
||||
AND
|
||||
sip.account = '%s'
|
||||
sip.account = %s
|
||||
AND
|
||||
sip.amount like '%s'
|
||||
sip.amount like %s
|
||||
AND
|
||||
si.docstatus = 1
|
||||
""" % (bank_account, amount), as_dict=True)
|
||||
""", (bank_account, amount), as_dict=True)
|
||||
|
||||
for data in [payment_entries, journal_entries, sales_invoices]:
|
||||
if data:
|
||||
@@ -162,6 +161,9 @@ def check_matching_amount(bank_account, transaction):
|
||||
return payments
|
||||
|
||||
def get_matching_descriptions_data(bank_account, transaction):
|
||||
if not transaction.description :
|
||||
return []
|
||||
|
||||
bank_transactions = frappe.db.sql("""
|
||||
SELECT
|
||||
bt.name, bt.description, bt.date, btp.payment_document, btp.payment_entry
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
import json
|
||||
import requests
|
||||
from plaid import Client
|
||||
from plaid.errors import APIError, ItemError
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Plaid Settings', {
|
||||
refresh: function(frm) {
|
||||
|
||||
},
|
||||
|
||||
connect_btn: function(frm) {
|
||||
connect_btn: function() {
|
||||
frappe.set_route('bank-reconciliation');
|
||||
}
|
||||
});
|
||||
@@ -83,7 +83,7 @@ def add_bank_accounts(response, bank, company):
|
||||
|
||||
result.append(new_account.name)
|
||||
|
||||
except frappe.UniqueValidationError as e:
|
||||
except frappe.UniqueValidationError:
|
||||
frappe.msgprint(_("Bank account {0} already exists and could not be created again").format(new_account.account_name))
|
||||
except Exception:
|
||||
frappe.throw(frappe.get_traceback())
|
||||
@@ -99,7 +99,7 @@ def add_account_type(account_type):
|
||||
"doctype": "Account Type",
|
||||
"account_type": account_type
|
||||
}).insert()
|
||||
except:
|
||||
except Exception:
|
||||
frappe.throw(frappe.get_traceback())
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
class TestPlaidSettings(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user