diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.json b/erpnext/accounts/doctype/bank_transaction/bank_transaction.json index b9cef288fb3..39937bb3645 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.json +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.json @@ -121,7 +121,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "Settled", + "default": "Pending", "fetch_if_empty": 0, "fieldname": "status", "fieldtype": "Select", @@ -755,7 +755,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2019-04-26 14:32:16.437813", + "modified": "2019-05-11 05:27:55.244721", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Transaction", diff --git a/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py index e9093847644..bc642212793 100644 --- a/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py @@ -58,7 +58,11 @@ def get_linked_payments(bank_transaction): return check_amount_vs_description(amount_matching, description_matching) elif description_matching: - return sorted(description_matching, key = lambda x: x["posting_date"], reverse=True) + description_matching = filter(lambda x: not x.get('clearance_date'), description_matching) + if not description_matching: + return [] + + return sorted(list(description_matching), key = lambda x: x["posting_date"], reverse=True) else: return [] @@ -99,7 +103,8 @@ def check_matching_amount(bank_account, company, 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, jea.credit_in_account_currency as paid_amount + jea.account_currency as currency, je.pay_to_recd_from as party, je.cheque_date as reference_date, + jea.credit_in_account_currency as paid_amount FROM `tabJournal Entry Account` as jea JOIN @@ -109,12 +114,17 @@ def check_matching_amount(bank_account, company, transaction): WHERE (je.clearance_date is null or je.clearance_date='0000-00-00') AND - jea.account = %s + jea.account = %(bank_account)s AND - jea.credit_in_account_currency like %s + jea.credit_in_account_currency like %(txt)s AND je.docstatus = 1 - """, (bank_account, amount), as_dict=True) + """, { + 'bank_account': bank_account, + 'txt': '%%%s%%' % amount + }, as_dict=True, debug=1) + + frappe.errprint(journal_entries) if transaction.credit > 0: sales_invoices = frappe.db.sql(""" @@ -215,9 +225,14 @@ def get_matching_descriptions_data(company, transaction): company_currency = get_company_currency(company) for key, value in iteritems(links): if key == "Payment Entry": - data.extend(frappe.get_all("Payment Entry", filters=[["name", "in", value]], fields=["'Payment Entry' as doctype", "posting_date", "party", "reference_no", "reference_date", "paid_amount", "paid_to_account_currency as currency"])) + data.extend(frappe.get_all("Payment Entry", filters=[["name", "in", value]], + fields=["'Payment Entry' as doctype", "posting_date", "party", "reference_no", + "reference_date", "paid_amount", "paid_to_account_currency as currency", "clearance_date"])) if key == "Journal Entry": - journal_entries = frappe.get_all("Journal Entry", filters=[["name", "in", value]], fields=["name", "'Journal Entry' as doctype", "posting_date", "pay_to_recd_from as party", "cheque_no as reference_no", "cheque_date as reference_date", "total_credit as paid_amount"]) + journal_entries = frappe.get_all("Journal Entry", filters=[["name", "in", value]], + fields=["name", "'Journal Entry' as doctype", "posting_date", + "pay_to_recd_from as party", "cheque_no as reference_no", "cheque_date as reference_date", + "total_credit as paid_amount", "clearance_date"]) for journal_entry in journal_entries: journal_entry_accounts = frappe.get_all("Journal Entry Account", filters={"parenttype": journal_entry["doctype"], "parent": journal_entry["name"]}, fields=["account_currency"]) journal_entry["currency"] = journal_entry_accounts[0]["account_currency"] if journal_entry_accounts else company_currency @@ -238,6 +253,9 @@ def check_amount_vs_description(amount_matching, description_matching): if description_matching: for am_match in amount_matching: for des_match in description_matching: + if des_match.get("clearance_date"): + continue + if am_match["party"] == des_match["party"]: if am_match not in result: result.append(am_match)