fix: Bank Reconciliation Bank Account and Bank Account No field names
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js
index 7c94455..19fadbf 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js
@@ -3,16 +3,16 @@
frappe.ui.form.on("Bank Reconciliation", {
setup: function(frm) {
- frm.add_fetch("bank_account", "account_currency", "account_currency");
+ frm.add_fetch("account", "account_currency", "account_currency");
},
onload: function(frm) {
let default_bank_account = frappe.defaults.get_user_default("Company")?
locals[":Company"][frappe.defaults.get_user_default("Company")]["default_bank_account"]: "";
- frm.set_value("bank_account", default_bank_account);
+ frm.set_value("account", default_bank_account);
- frm.set_query("bank_account", function() {
+ frm.set_query("account", function() {
return {
"filters": {
"account_type": ["in",["Bank","Cash"]],
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json
index e2f967d..b85ef3e 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json
@@ -19,10 +19,9 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "description": "Select account head of the bank where cheque was deposited.",
- "fetch_from": "bank_account_no.account",
+ "fetch_from": "bank_account.account",
"fetch_if_empty": 1,
- "fieldname": "bank_account",
+ "fieldname": "account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -31,7 +30,7 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
- "label": "Bank Account",
+ "label": "Account",
"length": 0,
"no_copy": 0,
"options": "Account",
@@ -164,7 +163,6 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -183,8 +181,9 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "description": "Select the Bank Account to reconcile.",
"fetch_if_empty": 0,
- "fieldname": "bank_account_no",
+ "fieldname": "bank_account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -193,12 +192,11 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Bank Account No",
+ "label": "Bank Account",
"length": 0,
"no_copy": 0,
"options": "Bank Account",
"permlevel": 0,
- "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -450,7 +448,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2019-04-09 18:41:06.110453",
+ "modified": "2020-01-22 00:00:00.000000",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bank Reconciliation",
@@ -483,4 +481,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
index d5ba49a..804bcd8 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
@@ -30,15 +30,12 @@
from
`tabJournal Entry` t1, `tabJournal Entry Account` t2
where
- t2.parent = t1.name and t2.account = %s and t1.docstatus=1
- and t1.posting_date >= %s and t1.posting_date <= %s
- and ifnull(t1.is_opening, 'No') = 'No' {0}
+ t2.parent = t1.name and t2.account = %(account)s and t1.docstatus=1
+ and t1.posting_date >= %(from)s and t1.posting_date <= %(to)s
+ and ifnull(t1.is_opening, 'No') = 'No' %(condition)s
group by t2.account, t1.name
order by t1.posting_date ASC, t1.name DESC
- """.format(condition), (self.bank_account, self.from_date, self.to_date), as_dict=1)
-
- if self.bank_account_no:
- condition = " and bank_account = %(bank_account_no)s"
+ """, {"condition":condition, "account":self.account, "from":self.from_date, "to":self.to_date}, as_dict=1)
payment_entries = frappe.db.sql("""
select
@@ -51,12 +48,12 @@
from `tabPayment Entry`
where
(paid_from=%(account)s or paid_to=%(account)s) and docstatus=1
- and posting_date >= %(from)s and posting_date <= %(to)s {0}
+ and posting_date >= %(from)s and posting_date <= %(to)s
+ and bank_account = %(bank_account)s
order by
posting_date ASC, name DESC
- """.format(condition),
- {"account":self.bank_account, "from":self.from_date,
- "to":self.to_date, "bank_account_no": self.bank_account_no}, as_dict=1)
+ """, {"account":self.account, "from":self.from_date,
+ "to":self.to_date, "bank_account": self.bank_account}, as_dict=1)
pos_entries = []
if self.include_pos_transactions:
@@ -71,7 +68,7 @@
and account.name = sip.account and si.posting_date >= %(from)s and si.posting_date <= %(to)s
order by
si.posting_date ASC, si.name DESC
- """, {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1)
+ """, {"account":self.account, "from":self.from_date, "to":self.to_date}, as_dict=1)
entries = sorted(list(payment_entries)+list(journal_entries+list(pos_entries)),
key=lambda k: k['posting_date'] or getdate(nowdate()))
diff --git a/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py
new file mode 100644
index 0000000..8918b9d
--- /dev/null
+++ b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py
@@ -0,0 +1,16 @@
+import frappe
+
+def _rename_single_field(**kwargs):
+ count = frappe.db.sql("SELECT COUNT(*) FROM tabSingles WHERE doctype='{doctype}' AND field='{new_name}';".format(**kwargs))[0][0]
+ if count == 0:
+ frappe.db.sql("UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';".format(**kwargs))
+
+def execute():
+ BR = "Bank Reconciliation"
+ AC = "account"
+ BA = "bank_account"
+ BAN = "bank_account_no"
+
+ _rename_single_field(doctype = BR, old_name = BA , new_name = AC)
+ _rename_single_field(doctype = BR, old_name = BAN, new_name = BA)
+ frappe.reload_doc("Accounts", "doctype", BR)