Codacy corrections

This commit is contained in:
Charles-Henri Decultot
2018-12-13 08:19:50 +00:00
parent cbe63ec418
commit e8f3050e27

View File

@@ -114,7 +114,7 @@ def check_matching_amount(bank_account, transaction):
["docstatus", "=", "1"], ["payment_type", "=", payment_type], ["ifnull(clearance_date, '')", "=", ""], ["{0}".format(account_from_to), "=", "{0}".format(bank_account)]]) ["docstatus", "=", "1"], ["payment_type", "=", payment_type], ["ifnull(clearance_date, '')", "=", ""], ["{0}".format(account_from_to), "=", "{0}".format(bank_account)]])
payment_field = "jea.debit_in_account_currency" if transaction.credit > 0 else "jea.credit_in_account_currency" payment_field = "jea.debit_in_account_currency" if transaction.credit > 0 else "jea.credit_in_account_currency"
journal_entries = frappe.db.sql(""" query = """
SELECT SELECT
'Journal Entry' as doctype, je.name, je.posting_date, je.cheque_no as reference_no, '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, {0} as paid_amount je.pay_to_recd_from as party, je.cheque_date as reference_date, {0} as paid_amount
@@ -132,7 +132,8 @@ def check_matching_amount(bank_account, transaction):
{0} like %s {0} like %s
AND AND
je.docstatus = 1 je.docstatus = 1
""".format(payment_field), (bank_account, amount), as_dict=True) """.format(payment_field)
journal_entries = frappe.db.sql(query, (bank_account, amount), as_dict=True)
sales_invoices = frappe.db.sql(""" sales_invoices = frappe.db.sql("""
SELECT SELECT
@@ -249,8 +250,7 @@ def get_matching_transactions_payments(description_matching):
def journal_entry_query(doctype, txt, searchfield, start, page_len, filters): def journal_entry_query(doctype, txt, searchfield, start, page_len, filters):
account = frappe.db.get_value("Bank Account", filters.get("bank_account"), "account") account = frappe.db.get_value("Bank Account", filters.get("bank_account"), "account")
query = """
return frappe.db.sql("""
SELECT SELECT
jea.parent, je.pay_to_recd_from, jea.parent, je.pay_to_recd_from,
if(jea.debit_in_account_currency > 0, jea.debit_in_account_currency, jea.credit_in_account_currency) if(jea.debit_in_account_currency > 0, jea.debit_in_account_currency, jea.credit_in_account_currency)
@@ -274,7 +274,10 @@ def journal_entry_query(doctype, txt, searchfield, start, page_len, filters):
LIMIT LIMIT
%(start)s, %(page_len)s""".format(**{ %(start)s, %(page_len)s""".format(**{
'key': searchfield, 'key': searchfield,
}), { })
return frappe.db.sql(query,
{
'txt': "%%%s%%" % txt, 'txt': "%%%s%%" % txt,
'_txt': txt.replace("%", ""), '_txt': txt.replace("%", ""),
'start': start, 'start': start,
@@ -284,7 +287,7 @@ def journal_entry_query(doctype, txt, searchfield, start, page_len, filters):
) )
def sales_invoices_query(doctype, txt, searchfield, start, page_len, filters): def sales_invoices_query(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(""" query = """
SELECT SELECT
sip.parent, si.customer, sip.amount, sip.mode_of_payment sip.parent, si.customer, sip.amount, sip.mode_of_payment
FROM FROM
@@ -303,7 +306,10 @@ def sales_invoices_query(doctype, txt, searchfield, start, page_len, filters):
LIMIT LIMIT
%(start)s, %(page_len)s""".format(**{ %(start)s, %(page_len)s""".format(**{
'key': searchfield, 'key': searchfield,
}), { })
return frappe.db.sql(query,
{
'txt': "%%%s%%" % txt, 'txt': "%%%s%%" % txt,
'_txt': txt.replace("%", ""), '_txt': txt.replace("%", ""),
'start': start, 'start': start,