fix: Bank Reconciliation Bank Account and Bank Account No field names

This commit is contained in:
racitup 2020-01-22 04:32:15 +00:00 committed by Deepesh Garg
parent 3c5bb80b5a
commit 719678957a
4 changed files with 36 additions and 25 deletions

View File

@ -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"]],

View File

@ -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
}
}

View File

@ -30,15 +30,12 @@ class BankReconciliation(Document):
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 @@ class BankReconciliation(Document):
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 @@ class BankReconciliation(Document):
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()))

View File

@ -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)